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

# Cancel Checkout Session

> Abandon an open checkout session

# Cancel Checkout Session

Marks an open session as abandoned.

<Note>
  Requires `checkout: write` and an allowlisted partner key. **No signature is needed** — cancel carries no body. Send `API-Version` as on every other checkout call.
</Note>

Cancel when your buyer walks away, so the session cannot later be paid by a stray retry and your own records show why it ended.

<Note>
  An open session does **not** hold inventory — tickets are only claimed at completion. Cancelling therefore releases nothing and is not required to free stock, but it is still the correct way to close a cart you have abandoned.
</Note>

## Path Parameters

<ParamField path="checkout_session_id" type="string" required>
  The session to cancel.
</ParamField>

## Response

`200` with the session, now `status: "canceled"`.

Cancellation is terminal. A canceled session cannot be updated or completed — both return `409 invalid_session_state`.

## A completed session cannot be canceled

Once tickets are issued, this endpoint is the wrong tool and returns `409 invalid_session_state`. Cancelling a checkout session is not a refund — it only abandons a cart that was never paid.

To refund or cancel a real order, use the organizer's own tools or the [Payments API](/api-reference/payments/list-payments). Refunds follow the organizer's policy, not the agent's.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
    "https://www.gomry.com/api/v1/checkout_sessions/acp_sess_AbCdEfGhIjKlMnOpQrSt/cancel" \
    -H "X-API-KEY: your_api_key" \
    -H "API-Version: 2025-09-12"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch(
    `https://www.gomry.com/api/v1/checkout_sessions/${sessionId}/cancel`,
    {
      method: "POST",
      headers: {
        "X-API-KEY": process.env.GOMRY_API_KEY,
        "API-Version": "2025-09-12",
      },
    }
  );
  const session = await res.json(); // status: "canceled"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "acp_sess_AbCdEfGhIjKlMnOpQrSt",
    "buyer": { "name": "Ada Lovelace", "email": "ada@example.com" },
    "status": "canceled",
    "currency": "usd",
    "line_items": [
      {
        "id": "li_1",
        "item": { "id": "TktAbCdEfGhIjKlMnOpQ", "quantity": 2 },
        "base_amount": 15800,
        "discount": 0,
        "subtotal": 15800,
        "tax": 0,
        "total": 16790
      }
    ],
    "totals": [
      { "type": "total", "display_text": "Total", "amount": 16790 }
    ],
    "messages": []
  }
  ```
</ResponseExample>
