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

# Change order status

> Moves the order through its lifecycle. Only these transitions are allowed, and anything else is a 400:

- `DRAFT` -> `PENDING`, `CANCELLED`
- `PENDING` -> `CANCELLED`, `DRAFT`
- `PAID` -> `CANCELLED`
- `CANCELLED` -> nothing. Cancellation is terminal; a cancelled order cannot be revived, so issue a new one instead.

`PAID` cannot be requested: an order becomes PAID when its ledger covers its total (`POST /projects/{projectId}/orders/{orderId}/transactions` for cash, external or comp; the payment-intent flow for cards). Asking for it is a 409 `ORDER_NOT_SETTLED` — record the payment instead of retrying.

Pass `cancellationReason` when moving to `CANCELLED` — it is recorded with the caller as `cancelledBy` and ignored for every other target status. A 409 `VERSION_CONFLICT` means the order changed underneath you.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/projects/{projectId}/orders/{orderId}/status
openapi: 3.0.0
info:
  title: MarketBox 2.0 Open API
  version: 1.0.0
  description: >-
    The MarketBox public API for building booking experiences. Core model:
    create an order, then draw its order items down into bookings. Single
    bookings reference an order item per service line; package bookings draw one
    PACKAGE item down across N sessions. To schedule a package, build a slate
    (POST /availability/package-slate) and book it by slateId (POST
    /orders/{orderId}/package-bookings). See the guides for end-to-end
    walkthroughs.
  contact:
    name: MarketBox support
servers:
  - url: https://apiv2.gomarketbox.com
    description: MarketBox Open API
security:
  - ApiKeyAuth: []
paths:
  /v1/projects/{projectId}/orders/{orderId}/status:
    post:
      tags:
        - Orders
      summary: Change order status
      description: >-
        Moves the order through its lifecycle. Only these transitions are
        allowed, and anything else is a 400:


        - `DRAFT` -> `PENDING`, `CANCELLED`

        - `PENDING` -> `CANCELLED`, `DRAFT`

        - `PAID` -> `CANCELLED`

        - `CANCELLED` -> nothing. Cancellation is terminal; a cancelled order
        cannot be revived, so issue a new one instead.


        `PAID` cannot be requested: an order becomes PAID when its ledger covers
        its total (`POST /projects/{projectId}/orders/{orderId}/transactions`
        for cash, external or comp; the payment-intent flow for cards). Asking
        for it is a 409 `ORDER_NOT_SETTLED` — record the payment instead of
        retrying.


        Pass `cancellationReason` when moving to `CANCELLED` — it is recorded
        with the caller as `cancelledBy` and ignored for every other target
        status. A 409 `VERSION_CONFLICT` means the order changed underneath you.
      parameters:
        - schema:
            type: string
            minLength: 1
            description: >-
              The project (tenant) that owns the resource. Every resource in
              this API is scoped to a project, and your API key is restricted to
              the projects it was issued for — a project outside that scope
              returns 403.
            example: prj_01kv60qgnef2kt3pvqgwmkbzfr
          required: true
          description: >-
            The project (tenant) that owns the resource. Every resource in this
            API is scoped to a project, and your API key is restricted to the
            projects it was issued for — a project outside that scope returns
            403.
          name: projectId
          in: path
        - schema:
            type: string
            minLength: 1
            description: >-
              The order — the commercial record. Order items are drawn down into
              bookings.
            example: ord_01kv8m92p4jcrywn14znp8cym0
          required: true
          description: >-
            The order — the commercial record. Order items are drawn down into
            bookings.
          name: orderId
          in: path
      requestBody:
        description: Status change
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  enum:
                    - DRAFT
                    - PENDING
                    - PAID
                    - CANCELLED
                cancellationReason:
                  type: string
                  minLength: 1
                  description: >-
                    Required when status is CANCELLED; omitting it then is a
                    400. Why the order was cancelled.
              required:
                - status
      responses:
        '200':
          description: Updated order
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Order'
                required:
                  - data
        '400':
          description: Invalid transition or validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: API key cannot access this project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '404':
          description: Order not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '409':
          description: >-
            Version conflict (VERSION_CONFLICT), or a `PAID` target
            (ORDER_NOT_SETTLED)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
components:
  schemas:
    Order:
      type: object
      properties:
        projectId:
          type: string
        tenantId:
          type: string
        orderId:
          type: string
        clientId:
          type: string
        currency:
          type: string
          minLength: 3
          maxLength: 3
        subtotal:
          $ref: '#/components/schemas/Money'
        feeTotal:
          $ref: '#/components/schemas/Money'
        tax:
          $ref: '#/components/schemas/Money'
        total:
          $ref: '#/components/schemas/Money'
        amountPaid:
          $ref: '#/components/schemas/Money'
        amountRefunded:
          $ref: '#/components/schemas/Money'
        status:
          type: string
          enum:
            - DRAFT
            - PENDING
            - PAID
            - CANCELLED
        statusUpdatedAt:
          type: string
          format: date-time
        cancellationReason:
          type: string
          nullable: true
        cancelledBy:
          type: string
          nullable: true
        paymentMethod:
          type: string
          enum:
            - STRIPE
            - CASH
            - EXTERNAL
            - COMP
            - MIXED
            - LEGACY
        settledAt:
          type: string
          format: date-time
        amountComped:
          $ref: '#/components/schemas/Money'
        pricingRegion:
          type: object
          nullable: true
          properties:
            country:
              type: string
              nullable: true
            state:
              type: string
              nullable: true
            postalCode:
              type: string
              nullable: true
        locale:
          type: string
        attribution:
          type: object
          properties:
            searchId:
              type: string
              minLength: 1
              maxLength: 128
              description: >-
                The `searchId` of the MarketBox search response the buyer booked
                from — the `X-MB-Search-Id` header / body field of every search
                route. Stored as given; a value MarketBox never issued is kept
                but not trusted.
              example: srch_01k7q3x9h4e8rb2d6m0z5a7c1n
            sessionKey:
              type: string
              minLength: 1
              maxLength: 64
              description: >-
                The same opaque per-session key you send with site events, at
                most 64 characters. Never an email, IP or user id.
              example: sess-example-01
            surface:
              type: string
              enum:
                - home
                - results
                - listing
                - site_search
                - profile
                - widget
                - assistant
                - other
              description: Where on your site the buyer started the purchase.
              example: results
          additionalProperties: false
          description: >-
            Which search and site session this purchase came from. Optional; set
            once on the order and copied onto every booking it funds. See the
            search-log guide, "Booking attribution".
        deleted:
          type: boolean
        version:
          type: integer
          minimum: 0
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        createdBy:
          type: string
        updatedBy:
          type: string
      required:
        - projectId
        - tenantId
        - orderId
        - clientId
        - currency
        - subtotal
        - tax
        - total
        - amountPaid
        - amountRefunded
        - status
        - statusUpdatedAt
        - deleted
        - version
        - createdAt
        - updatedAt
        - createdBy
        - updatedBy
    ErrorMessage:
      type: object
      properties:
        code:
          type: string
          description: Stable machine-readable error code, e.g. NOT_FOUND.
        message:
          type: string
          description: Human-readable description of what went wrong.
        statusCode:
          type: integer
          description: The HTTP status code of this response.
        requestId:
          type: string
          description: >-
            The id of this request, also returned as the X-Request-Id header.
            Quote it in a support ticket.
      required:
        - code
        - message
        - statusCode
        - requestId
      example:
        code: NOT_FOUND
        message: Booking not found
        statusCode: 404
        requestId: a3f1c2de-9b64-4a2f-8f0e-5c9d1b7a2e10
    Money:
      type: object
      properties:
        amount:
          type: integer
          minimum: 0
        currency:
          type: string
          minLength: 1
          maxLength: 3
      required:
        - amount
        - currency
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key minted in the MarketBox dashboard. Scope is restricted to the
        projects you select at creation time. Every route needs the key's
        standard API access (`*`) except `POST /v1/projects/{projectId}/events`,
        which needs `events:write`; a key without `*` is refused with 403
        `CAPABILITY_NOT_GRANTED`.

````

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