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

# Cancel order

> Cancel an order. Allowed up to and including the `in_transit` status.



## OpenAPI

````yaml /api-reference/openapi.json patch /orders/cancel/{orderId}
openapi: 3.1.0
info:
  title: Sparqle API
  version: 1.0.0
  description: >-
    Create deliveries, fetch shipping labels, and track orders with Sparqle.


    This specification is a hand-authored starting point derived from the API
    source. Replace or merge it with the spec exported from your previous docs
    as you refine the reference.
servers:
  - url: https://staging-v2.sparqle.tech
    description: Test
  - url: https://v2.sparqle.com
    description: Live
security:
  - apiKey: []
paths:
  /orders/cancel/{orderId}:
    patch:
      tags:
        - Orders
      summary: Cancel order
      description: Cancel an order. Allowed up to and including the `in_transit` status.
      operationId: cancelOrder
      parameters:
        - name: orderId
          in: path
          required: true
          schema:
            type: string
          example: SPQ-10293
      responses:
        '200':
          description: Order cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    Order:
      type: object
      properties:
        id:
          type: integer
          example: 1
        orderId:
          type: string
          example: SPQ-10293
        orderRef:
          type: string
          example: PADE3JWEA
        status:
          $ref: '#/components/schemas/OrderStatus'
        name:
          type: string
          example: iPod
        barcode:
          type: string
          example: 3STBXX123456789
        trackingUrl:
          type: string
          example: https://tracking.sparqle.com/barcode/3STBXX123456789
        deliveryName:
          type: string
          example: Jane Doe
        deliveryEmail:
          type: string
          example: jane@example.com
        deliveryAddress:
          type: string
          example: Gustav Mahlerlaan 320, 1082 ME Amsterdam
        deliveryEta:
          type: string
          example: 12:40 - 13:00
        deliveryEtaDate:
          type: string
          format: date
          example: '2026-08-13'
        deliveryDate:
          type: string
          example: '2026-08-13'
        locationId:
          type: integer
          example: 1
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    OrderStatus:
      type: string
      enum:
        - draft
        - expected
        - in_transit
        - out_for_delivery
        - awaiting_next_attempt
        - at_pickup_point
        - completed
        - failed
        - in_return_transit
        - returned
        - cancelled
        - rejected
        - address_not_found
        - inactive
        - missing
        - lost
        - error
      example: draft
  responses:
    Unauthorized:
      description: Missing or invalid API key
    NotFound:
      description: Resource not found
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: api-key

````