> ## Documentation Index
> Fetch the complete documentation index at: https://developers.cubbo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel an order

> Cancels one order, identified by its `order_number` within your store, and releases the stock
reserved for it. The cancellation is recorded in the order history with the reason
"Canceled from API"; it is not propagated to the sales channel the order came from.
- An order can be canceled while it is in `initial`, `unpaid`, `empty`, `error`,
  `cancelation_window`, `awaiting_fulfillment_request`, `entirely_dropshipping`, `backorder`,
  `hold`, `pending`, `processing`, `picking` or `packing` (on pick-and-ship stores, only before
  the package is picked up). A `shipped` order can still be canceled while the carrier has not
  collected it (no dispatch yet and shipping status still `created`, `awaiting_collection` or
  undefined), unless it ships on an external label.
- Canceling an order that is already `canceled` or `interrupted` is a no-op and returns `200`.
- Orders already on their way or returned (`returning`, `returned`, `return_arrived`,
  `reentered`, or `shipped` and dispatched) are refused with `422`. Those messages are
  returned in Spanish, exactly as shown in the examples.
- Soft cancel: if Cubbo support has enabled "soft cancel on shipped orders" for your store, a
  cancellation request for an order past the point of cancellation is answered with `200`
  and `{"status": "accepted", "order_id": ...}` instead of `422`. The order is NOT canceled
  and keeps its status; the attempt is recorded in the order history so your team can act on
  it (for example, intercept the shipment or process a return).
- Requires an API user with the "orders update" permission and access to the store;
  otherwise `401`.
- Caution: some failures are answered with HTTP `200` and an `error` body (see the `200`
  examples). Always check for an `error` key in the response, not only the status code.




## OpenAPI

````yaml /openapi.yaml post /orders/cancel
openapi: 3.1.0
info:
  title: Cubbo Clients API
  version: '1.0'
  summary: >-
    Orders, inventory, replenishments, returns, shipping and webhooks for Cubbo
    fulfillment.
  description: >
    The Cubbo Clients API connects your store, ERP or marketplace with Cubbo's
    fulfillment network.

    All endpoints except `POST /auth/token` require a bearer token; see the
    Authentication guide.

    Request and response bodies are JSON. Errors are JSON objects with an
    `error` key.
  contact:
    name: Cubbo integrations
    email: integraciones@cubbo.com
servers:
  - url: https://api.cubbo.com/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Exchange client credentials for a bearer token.
  - name: Orders
    description: Create, update, hold, cancel and read sales orders.
  - name: Shipping labels
    description: Read the shipping labels generated for an order.
  - name: Inventory
    description: Products and stock per store.
  - name: Lots
    description: Lot-level inventory for products with expiration or batch tracking.
  - name: Reports
    description: Bulk reports for reconciliation.
  - name: Replenishments
    description: Inbound shipments to the warehouse.
  - name: Returns
    description: Returns and exchanges.
  - name: Stores
    description: Store provisioning and settings.
  - name: Shipping methods
    description: Available shipping methods, coverage and quotes.
  - name: Click and collect
    description: Pickup points and in-store pickup orders.
paths:
  /orders/cancel:
    post:
      tags:
        - Orders
      summary: Cancel an order
      description: >
        Cancels one order, identified by its `order_number` within your store,
        and releases the stock

        reserved for it. The cancellation is recorded in the order history with
        the reason

        "Canceled from API"; it is not propagated to the sales channel the order
        came from.

        - An order can be canceled while it is in `initial`, `unpaid`, `empty`,
        `error`,
          `cancelation_window`, `awaiting_fulfillment_request`, `entirely_dropshipping`, `backorder`,
          `hold`, `pending`, `processing`, `picking` or `packing` (on pick-and-ship stores, only before
          the package is picked up). A `shipped` order can still be canceled while the carrier has not
          collected it (no dispatch yet and shipping status still `created`, `awaiting_collection` or
          undefined), unless it ships on an external label.
        - Canceling an order that is already `canceled` or `interrupted` is a
        no-op and returns `200`.

        - Orders already on their way or returned (`returning`, `returned`,
        `return_arrived`,
          `reentered`, or `shipped` and dispatched) are refused with `422`. Those messages are
          returned in Spanish, exactly as shown in the examples.
        - Soft cancel: if Cubbo support has enabled "soft cancel on shipped
        orders" for your store, a
          cancellation request for an order past the point of cancellation is answered with `200`
          and `{"status": "accepted", "order_id": ...}` instead of `422`. The order is NOT canceled
          and keeps its status; the attempt is recorded in the order history so your team can act on
          it (for example, intercept the shipment or process a return).
        - Requires an API user with the "orders update" permission and access to
        the store;
          otherwise `401`.
        - Caution: some failures are answered with HTTP `200` and an `error`
        body (see the `200`
          examples). Always check for an `error` key in the response, not only the status code.
      operationId: cancelOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderCancelRequest'
            example:
              store_id: 1234
              order_number: ORD-0001
      responses:
        '200':
          description: >
            The order was canceled (empty object), the cancellation was accepted
            as a soft cancel, or

            the request failed in a way that is reported with an `error` body.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/OrderCancelResult'
                  - $ref: '#/components/schemas/OrderCancelAccepted'
                  - $ref: '#/components/schemas/Error'
              examples:
                canceled:
                  summary: Order canceled (or already canceled)
                  value: {}
                softCancelAccepted:
                  summary: >-
                    Store has soft cancel enabled and the order is past
                    cancellation
                  value:
                    status: accepted
                    order_id: 123456
                notCancellable:
                  summary: Status does not allow cancellation (reported with HTTP 200)
                  value:
                    error: Error, order_id '123456' cannot be cancelled
                missingParam:
                  summary: Missing parameter (reported with HTTP 200)
                  value:
                    error: Error, Parameter order_number is required
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          description: >-
            The order was not found in the store or its business rules forbid
            the cancellation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                orderNotFound:
                  value:
                    error: >-
                      Order with order_number ORD-0001 not found for store id
                      1234
                alreadyShipped:
                  description: >-
                    The order was already shipped, dispatched or returned
                    (message in Spanish).
                  value:
                    error: >-
                      Error al cancelar la orden: 123456, La orden ya fue
                      enviada
                externalLabel:
                  description: >-
                    A shipment on an external carrier label cannot be canceled
                    (message in Spanish).
                  value:
                    error: >-
                      Error al cancelar la orden: 123456, No se puede cancelar
                      un envío con guía externa
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - bearerAuth: []
components:
  schemas:
    OrderCancelRequest:
      type: object
      description: Identifies the single order to cancel.
      required:
        - order_number
        - store_id
      properties:
        order_number:
          type: string
          description: Your order number, unique within the store.
          example: ORD-0001
        store_id:
          type: integer
          description: Id of the store the order belongs to.
          example: 1234
    OrderCancelResult:
      type: object
      description: Empty object returned when the cancellation or deletion succeeded.
      additionalProperties: false
      example: {}
    OrderCancelAccepted:
      type: object
      description: >-
        Returned instead of `422` when the store has soft cancel enabled and the
        order is past the point of cancellation. The order keeps its status; the
        attempt is recorded in its history.
      required:
        - status
        - order_id
      properties:
        status:
          type: string
          description: Always `accepted`.
          enum:
            - accepted
          example: accepted
        order_id:
          type: integer
          description: Cubbo id of the order whose cancellation was recorded.
          example: 123456
    Error:
      type: object
      description: Error body returned by every failed request.
      required:
        - error
      properties:
        error:
          type: string
          description: >-
            Human-readable description of the failure. For `401` responses it is
            always `Unauthorized`.
          example: Parameter store_id is required
        message:
          type: string
          description: >-
            Present on `401` responses only; the reason the request was
            rejected.
          example: invalid token
        code:
          type:
            - string
            - 'null'
          description: >-
            Stable machine-readable code, present on some order, return and
            replenishment errors.
          example: ORDER_ALREADY_EXISTS
        context:
          type:
            - object
            - 'null'
          description: >-
            Extra data about the failure when available, for example the id of
            the conflicting order.
          additionalProperties: true
          example:
            order_id: 987654
  responses:
    Unauthorized:
      description: >-
        Missing or invalid token, wrong credentials, or no access to the
        requested store.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            invalidToken:
              value:
                error: Unauthorized
                message: invalid token
            noHeader:
              value:
                error: Unauthorized
                message: no authorization header found
            storeNotAllowed:
              value:
                error: Unauthorized
                message: not allowed to show? this Store
    InternalServerError:
      description: >-
        Unexpected error. Retry with backoff; if it persists, send the timestamp
        to Cubbo support.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'unexpected error, timestamp: 1760000000'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Token returned by `POST /auth/token`, sent as `Authorization: Bearer
        <token>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.