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

# Cancel shipment

> Cancel a shipment.

- **KiriminAja**: requires `awb` on the shipment (already booked). Cancels via `cancelOrderExpress` and sets `shippingStatus: cancelled`.
- **RideBlitz**: requires `awb`. Cancels via the RideBlitz API and sets `shippingStatus: cancelled_by_business`.
- **GoSend**: if `orderNo` exists, calls GoSend cancel API; otherwise just updates the local row. Sets `shippingStatus: cancelled`.
- **custom / jne**: persists the cancellation locally; no outbound call.

Provide a human-readable `reason` to help your team and the carrier understand why.



## OpenAPI

````yaml POST /shipping/shipments/{id}/cancel
openapi: 3.1.0
info:
  title: bitbybit Open API — Shipping
  description: >-
    Programmatic access to bitbybit shipping: store locations, provider
    discovery, coverage lookup, fee quoting, and the full shipment lifecycle
    (create, book, update, cancel, track) across GoSend, KiriminAja, and
    RideBlitz.
  version: 1.0.0
  contact:
    name: bitbybit Support
    url: https://bitbybit.studio
servers:
  - url: https://api.bitbybit.studio/customer/api/open/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Store Locations
    description: >-
      Manage warehouse / pickup origin addresses. Couriers pick up from these
      locations when a shipment is booked.
  - name: Providers
    description: Discover connected carriers and the services each carrier offers.
  - name: Coverage
    description: >-
      Look up the courier-specific province / city / district / sub-district
      dictionaries needed to populate addresses and quote fees.
  - name: Fee Calculation
    description: Quote shipping fees across carriers using one unified request shape.
  - name: Shipments
    description: >-
      Create, update, cancel, and track shipments. A shipment is always attached
      to an Order.
paths:
  /shipping/shipments/{id}/cancel:
    post:
      tags:
        - Shipments
      summary: Cancel shipment
      description: >-
        Cancel a shipment.


        - **KiriminAja**: requires `awb` on the shipment (already booked).
        Cancels via `cancelOrderExpress` and sets `shippingStatus: cancelled`.

        - **RideBlitz**: requires `awb`. Cancels via the RideBlitz API and sets
        `shippingStatus: cancelled_by_business`.

        - **GoSend**: if `orderNo` exists, calls GoSend cancel API; otherwise
        just updates the local row. Sets `shippingStatus: cancelled`.

        - **custom / jne**: persists the cancellation locally; no outbound call.


        Provide a human-readable `reason` to help your team and the carrier
        understand why.
      operationId: cancelShipment
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  maxLength: 500
                  description: Human-readable cancellation reason (max 500 chars).
            example:
              reason: Customer cancelled the order
      responses:
        '200':
          description: Cancelled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Shipment'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    Shipment:
      type: object
      properties:
        id:
          type: string
        orderId:
          type: string
          nullable: true
        provider:
          $ref: '#/components/schemas/ShippingProvider'
        providerLabel:
          type: string
          description: Human-readable provider name (e.g. `KiriminAja`).
        name:
          type: string
          nullable: true
        fee:
          type: number
          format: double
          nullable: true
        currency:
          type: string
          nullable: true
        shippingStatus:
          anyOf:
            - $ref: '#/components/schemas/ShippingStatus'
            - type: 'null'
        serviceType:
          anyOf:
            - $ref: '#/components/schemas/ServiceType'
            - type: 'null'
        serviceName:
          type: string
          nullable: true
        selectedExpedition:
          type: string
          nullable: true
        selectedDelivery:
          type: string
          nullable: true
        courierGroup:
          type: string
          nullable: true
        vehicleType:
          anyOf:
            - $ref: '#/components/schemas/VehicleType'
            - type: 'null'
        bikeFuelType:
          type: string
          nullable: true
        packageHandover:
          anyOf:
            - $ref: '#/components/schemas/PackageHandover'
            - type: 'null'
        pickupSchedule:
          type: string
          format: date-time
          nullable: true
        storeLocationId:
          type: string
          nullable: true
        sender:
          $ref: '#/components/schemas/AddressOutput'
        delivery:
          $ref: '#/components/schemas/AddressOutput'
        package:
          $ref: '#/components/schemas/PackageOutput'
        driver:
          anyOf:
            - type: object
              properties:
                name:
                  type: string
                  nullable: true
                phone:
                  type: string
                  nullable: true
                photo:
                  type: string
                  nullable: true
                licensePlate:
                  type: string
                  nullable: true
            - type: 'null'
        insurance:
          type: boolean
          nullable: true
        insuranceFee:
          type: number
          format: double
          nullable: true
        insuranceAmount:
          type: number
          format: double
          nullable: true
        discountAmount:
          type: number
          format: double
          nullable: true
        discountPercentage:
          type: number
          format: double
          nullable: true
        distance:
          type: number
          format: double
          nullable: true
        trackingUrl:
          type: string
          nullable: true
        awb:
          type: string
          nullable: true
          description: Carrier waybill / tracking number. Populated after booking.
        orderNo:
          type: string
          nullable: true
          description: >-
            Carrier order number (KA `kj_order_id`, GoSend `orderNo`, RB
            merchant order id).
        bookingId:
          type: string
          nullable: true
        pickupNumber:
          type: string
          nullable: true
          description: KiriminAja Express pickup batch number.
        paymentId:
          type: string
          nullable: true
        paymentStatus:
          type: string
          nullable: true
        statusCode:
          type: integer
          nullable: true
          description: Provider-specific status code.
        cancellationReason:
          type: string
          nullable: true
        cancelledBy:
          type: string
          nullable: true
        cancelledSource:
          type: string
          nullable: true
        eventTimestamp:
          type: string
          nullable: true
    ShippingProvider:
      type: string
      enum:
        - gosend
        - kirimin_aja
        - ride_blitz
        - jne
        - custom
      description: >-
        Provider/courier code. `gosend`, `kirimin_aja`, and `ride_blitz` are
        externally integrated; `jne` is a passthrough placeholder; `custom` is
        for merchant-defined methods.
    ShippingStatus:
      type: string
      enum:
        - confirmed
        - allocated
        - out_for_pickup
        - picked
        - out_for_delivery
        - on_hold
        - cancelled
        - delivered
        - rejected
        - no_driver
        - awaiting
        - on_the_way_to_pickup
        - delivering
        - delivery_completed
        - canceled
        - processed_packages
        - shipped_packages
        - canceled_packages
        - finished_packages
        - returned_packages
        - return_finished_packages
        - created
        - midmile_pickup_done
        - midmile_pickup_failed
        - arrived_blitz_hub
        - allocation_failure
        - pickup_started
        - pickup_done
        - pickup_failed
        - pickup_failure
        - dropoff_started
        - dropoff_done
        - dropoff_failed
        - delivery_failure
        - cancelled_by_blitz
        - cancelled_by_business
        - returned_to_business
      description: >-
        Unified shipping status. Some values are provider-specific (e.g.
        `cancelled_by_blitz` is RideBlitz, `midmile_pickup_done` is KiriminAja
        Express).
    ServiceType:
      type: string
      enum:
        - INSTANT
        - EXPRESS
      description: >-
        Service category. `INSTANT` = on-demand intra-city; `EXPRESS` =
        scheduled inter-city.
    VehicleType:
      type: string
      enum:
        - TWO_WHEEL
        - FOUR_WHEEL
      description: >-
        Vehicle requested for the pickup. `TWO_WHEEL` = motorcycle, `FOUR_WHEEL`
        = car.
    PackageHandover:
      type: string
      enum:
        - PICKUP
        - DROPOFF
      description: >-
        How the merchant hands the package to the carrier. `PICKUP` = courier
        picks up from the store, `DROPOFF` = merchant drops off at carrier hub.
    AddressOutput:
      type: object
      properties:
        name:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        address:
          type: string
          nullable: true
        notes:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        province:
          type: string
          nullable: true
        country:
          type: string
          nullable: true
        zip:
          type: string
          nullable: true
        kecamatan:
          type: string
          nullable: true
        kecamatanId:
          type: integer
          nullable: true
        kelurahan:
          type: string
          nullable: true
        kelurahanId:
          type: integer
          nullable: true
        coordinates:
          anyOf:
            - $ref: '#/components/schemas/Coordinates'
            - type: 'null'
    PackageOutput:
      type: object
      properties:
        weight:
          type: number
          format: double
          nullable: true
        length:
          type: number
          format: double
          nullable: true
        width:
          type: number
          format: double
          nullable: true
        height:
          type: number
          format: double
          nullable: true
        itemName:
          type: string
          nullable: true
        itemType:
          type: string
          nullable: true
        itemValue:
          type: number
          format: double
          nullable: true
        itemQty:
          type: integer
          nullable: true
        notes:
          type: string
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                Machine-readable code, e.g. `VALIDATION_ERROR`, `NOT_FOUND`,
                `INTEGRATION_NOT_CONNECTED`, `PROVIDER_ERROR`, `BOOKING_FAILED`.
            message:
              type: string
              description: Human-readable error message.
    Coordinates:
      type: object
      required:
        - lat
        - lng
      properties:
        lat:
          type: number
          format: double
          minimum: -90
          maximum: 90
        lng:
          type: number
          format: double
          minimum: -180
          maximum: 180
  responses:
    ValidationError:
      description: Request validation failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: VALIDATION_ERROR
              message: origin.districtId is required for KiriminAja Express
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHORIZED
              message: Invalid API key
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: NOT_FOUND
              message: Shipment not found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Create one in Settings > Developer. The key
        must have the `BITCRM` product scope and an `orders` resource scope;
        required action depends on the endpoint (`READ`, `WRITE`, or `DELETE`).

````