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

# Cancel order

> Requests cancellation of an order. A 201 response means the cancellation request was received — not necessarily that the order is cancelled yet.

Check the `cancellationStatus` in the response:

- orders that can be cancelled immediately (for example, those not yet dispatched) come back `canceled` right away
- others come back `pending` and are reviewed asynchronously before being approved or denied

For requests that return `pending`, listen for the `order.cancellationrequest.created` and `order.cancellationrequest.updated` events to learn the outcome — see [Order Cancellation Requests events](https://docs.sibipro.com/events/order.cancellation-requests).



## OpenAPI

````yaml https://api.sibipro.com/orders/openapi.json post /{id}/cancel
openapi: 3.0.0
info:
  title: Orders API
  version: 1.0.0
  description: RESTful API for managing orders
servers:
  - url: https://api.sibipro.com/orders
    description: API endpoint
security:
  - bearerAuth: []
paths:
  /{id}/cancel:
    post:
      summary: Cancel order
      description: >-
        Requests cancellation of an order. A 201 response means the cancellation
        request was received — not necessarily that the order is cancelled yet.


        Check the `cancellationStatus` in the response:


        - orders that can be cancelled immediately (for example, those not yet
        dispatched) come back `canceled` right away

        - others come back `pending` and are reviewed asynchronously before
        being approved or denied


        For requests that return `pending`, listen for the
        `order.cancellationrequest.created` and
        `order.cancellationrequest.updated` events to learn the outcome — see
        [Order Cancellation Requests
        events](https://docs.sibipro.com/events/order.cancellation-requests).
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: The ID of the order to cancel
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelOrderRequest'
      responses:
        '201':
          description: >-
            Cancellation requested. The response reflects the current
            `cancellationStatus`: usually `pending` (queued for asynchronous
            review), but already `canceled` for orders that are cancelled
            immediately.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelationResponse'
        '400':
          description: Bad request - Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validationError:
                  value:
                    code: VALIDATION_ERROR
                    message: Invalid input parameters
        '401':
          description: Unauthorized - Missing or invalid authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  value:
                    code: UNAUTHORIZED
                    message: Missing or invalid authentication token
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                serverError:
                  value:
                    code: INTERNAL_SERVER_ERROR
                    message: An unexpected error occurred
                    details:
                      - field: unknown
                        error: >-
                          Internal server error occurred while processing
                          request
components:
  schemas:
    CancelOrderRequest:
      type: object
      properties:
        reason:
          type: string
          description: Reason for the cancellation
          example: Customer requested a cancellation
      required:
        - reason
    CancelationResponse:
      type: object
      properties:
        cancellationStatus:
          type: string
          enum:
            - approved
            - denied
            - pending
            - canceled
          description: >-
            Status of the cancellation request. `pending`: the request is
            awaiting review. `approved` or `canceled`: the order has been
            cancelled. `denied`: the request was rejected and the order
            continues processing.
          example: pending
        cancellationReason:
          type: string
          description: Reason for the cancellation request
          example: Customer requested a cancellation
        requestedAt:
          type: string
          format: date-time
          description: Timestamp when the cancellation was requested
          example: '2024-01-20T12:00:00Z'
      required:
        - requestedAt
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code indicating the type of error
        message:
          type: string
          description: Human-readable error message explaining what went wrong
          example: The request contains invalid parameters
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
              error:
                type: string
            required:
              - field
              - error
          description: Detailed validation errors when applicable
          example:
            - field: customer.email
              error: Invalid email
            - field: address.postalCode
              error: Invalid
      required:
        - code
        - message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token from the SIBI developer dashboard (developer.sibipro.com),
        sent as `Authorization: Bearer <token>`.

````