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

# Cancel a Delivery

> Cancel before pickup, with the fee stated up front



## OpenAPI

````yaml platforms/api-reference/openapi.json POST /deliveries/{uid}/cancel
openapi: 3.1.0
info:
  title: UniHop Platform API
  description: >-
    Book and track UniHop last-mile deliveries on behalf of the merchants on
    your platform. Your platform identifier lives in the URL; the merchant's own
    API key authenticates the request.
  version: 1.0.0
servers:
  - url: https://backend.unihop.app/api/v1/{platform}
    description: Production
    variables:
      platform:
        default: your_platform
        description: The platform identifier UniHop issued you at onboarding.
security:
  - apiKeyAuth: []
paths:
  /deliveries/{uid}/cancel:
    post:
      summary: Cancel a delivery
      description: >-
        Cancels a delivery that has not been picked up yet. `GET
        /deliveries/{uid}` returns `expected_cancellation_fee` beforehand.
      parameters:
        - name: uid
          in: path
          description: The delivery `uid` returned when it was created.
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: The delivery was canceled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeliveryCanceled'
        '401':
          description: The API key is missing, invalid, or not valid for this platform.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No delivery with that uid belongs to your platform.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            The delivery has already been picked up and can no longer be
            canceled (`not_cancelable`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    DeliveryCanceled:
      type: object
      description: Returned when a delivery has been canceled.
      properties:
        message:
          type: string
          example: Delivery canceled successfully.
        uid:
          type: string
          example: 9f8e7d6c-1b2a-4c3d-8e9f-0a1b2c3d4e5f
        data:
          type: object
          properties:
            status:
              type: string
              example: Canceled
            cancellation_fee:
              $ref: '#/components/schemas/CancellationFee'
          required:
            - status
            - cancellation_fee
      required:
        - message
        - uid
        - data
    Error:
      type: object
      properties:
        code:
          type: string
          description: >-
            Machine-readable error code, e.g. `not_found`, `not_cancelable`,
            `invalid_api_key`.
        message:
          type: string
          description: A human-readable description of what went wrong.
      required:
        - code
        - message
    CancellationFee:
      type: object
      description: >-
        What canceling costs. Free before the cutoff. After it, the fee scales
        with vehicle size.
      properties:
        amount:
          type: string
          description: Decimal string.
          example: '0.00'
        currency:
          type: string
          example: USD
      required:
        - amount
        - currency
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        The merchant's UniHop API key, sent as `Authorization: Bearer <key>`. It
        identifies the merchant and is what their deliveries are billed against.

````