openapi: 3.0.3 info: title: Patch Carbon Order Line Items Orders API version: '2' description: 'The Patch API lets developers browse verified carbon projects, generate emissions estimates, and place orders for carbon credits and removals. Reconstructed from the publicly published patch-python, patch-node, and patch-ruby SDKs (auto-generated by openapi-generator from the official Patch OpenAPI document). ' contact: name: Patch Engineering email: engineering@usepatch.com url: https://docs.patch.io/ license: name: Proprietary url: https://www.patch.io/terms servers: - url: https://api.patch.io description: Production API security: - bearerAuth: [] tags: - name: Orders description: Place, retrieve, place, and cancel carbon credit and removal orders. paths: /v1/orders: get: tags: - Orders operationId: retrieveOrders summary: List Orders description: Returns a paginated list of carbon credit and removal orders for the authenticated organization. parameters: - $ref: '#/components/parameters/PageParam' - name: metadata in: query schema: type: object additionalProperties: type: string description: Filter orders by metadata key/value pairs set when the order was created. - name: state in: query schema: type: string enum: - draft - placed - processing - complete - cancelled responses: '200': description: Order list response content: application/json: schema: $ref: '#/components/schemas/OrderListResponse' '401': $ref: '#/components/responses/Unauthorized' post: tags: - Orders operationId: createOrder summary: Create An Order description: Creates a new carbon credit or removal order. Orders may be created in draft and placed later, or placed inline. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateOrderRequest' responses: '200': description: Order response content: application/json: schema: $ref: '#/components/schemas/OrderResponse' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' /v1/orders/{id}: get: tags: - Orders operationId: retrieveOrder summary: Retrieve An Order description: Returns a single carbon credit or removal order by ID. parameters: - name: id in: path required: true schema: type: string responses: '200': description: Order response content: application/json: schema: $ref: '#/components/schemas/OrderResponse' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' /v1/orders/{uid}: delete: tags: - Orders operationId: deleteOrder summary: Delete An Order description: Deletes a draft order. Placed and completed orders cannot be deleted; use the cancel endpoint instead. parameters: - name: uid in: path required: true schema: type: string responses: '200': description: Delete order response content: application/json: schema: $ref: '#/components/schemas/DeleteOrderResponse' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' /v1/orders/{id}/place: patch: tags: - Orders operationId: placeOrder summary: Place An Order description: Transitions a draft order to placed, committing the credits to the buyer. parameters: - name: id in: path required: true schema: type: string responses: '200': description: Order response content: application/json: schema: $ref: '#/components/schemas/OrderResponse' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' /v1/orders/{id}/cancel: patch: tags: - Orders operationId: cancelOrder summary: Cancel An Order description: Cancels a previously placed order where the project allows cancellation. parameters: - name: id in: path required: true schema: type: string responses: '200': description: Order response content: application/json: schema: $ref: '#/components/schemas/OrderResponse' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' components: schemas: Order: type: object properties: id: type: string created_at: type: string format: date-time production: type: boolean state: type: string enum: - draft - placed - processing - complete - cancelled amount: type: integer description: Total mass in grams. unit: type: string example: g price: type: integer description: Subtotal in minor currency units. patch_fee: type: integer currency: type: string example: USD registry_url: type: string format: uri nullable: true metadata: type: object additionalProperties: true line_items: type: array items: $ref: '#/components/schemas/OrderLineItem' issued_to: $ref: '#/components/schemas/OrderIssuedTo' ErrorResponse: type: object properties: success: type: boolean example: false error: type: object properties: code: type: integer message: type: string data: nullable: true meta: type: object properties: patch_version: type: integer DeleteOrderResponse: type: object properties: success: type: boolean error: nullable: true data: nullable: true meta: $ref: '#/components/schemas/Meta' Meta: type: object description: Pagination and response metadata block returned on list endpoints. properties: prev_page: type: integer nullable: true next_page: type: integer nullable: true CreateOrderRequest: type: object properties: project_id: type: string metadata: type: object additionalProperties: true state: type: string enum: - draft - placed vintage_year: type: integer vintage_start_year: type: integer vintage_end_year: type: integer total_price: type: integer currency: type: string example: USD amount: type: integer unit: type: string example: g issued_to: $ref: '#/components/schemas/OrderIssuedTo' OrderLineItemProject: type: object properties: id: type: string name: type: string OrderListResponse: type: object properties: success: type: boolean error: nullable: true data: type: array items: $ref: '#/components/schemas/Order' meta: $ref: '#/components/schemas/Meta' OrderLineItem: type: object properties: id: type: string project: $ref: '#/components/schemas/OrderLineItemProject' vintage_year: type: integer nullable: true vintage_start_year: type: integer nullable: true vintage_end_year: type: integer nullable: true amount: type: integer description: Mass in grams. unit: type: string example: g price: type: integer currency: type: string example: USD OrderIssuedTo: type: object description: End beneficiary that credits should be issued and attributed to. properties: name: type: string email: type: string format: email OrderResponse: type: object properties: success: type: boolean error: nullable: true data: $ref: '#/components/schemas/Order' meta: $ref: '#/components/schemas/Meta' responses: NotFound: description: The requested resource was not found. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' BadRequest: description: Request was malformed or failed validation. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' Unauthorized: description: API key missing, malformed, or invalid. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' parameters: PageParam: name: page in: query schema: type: integer minimum: 1 default: 1 description: 1-indexed page number for paginated responses. securitySchemes: bearerAuth: type: http scheme: bearer description: API key bearer token issued from the Patch dashboard. Sandbox and live keys are separated.