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

# Get Checkout Session

> Retrieve a specific checkout session by ID

# Get Checkout Session

Retrieves the details of an existing checkout session.

## Request

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

<ParamField path="id" type="string" required>
  The unique identifier of the checkout session (e.g., `sess_abc123`)
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="string">
      Unique session identifier
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status: `pending`, `processing`, `completed`, `failed`,
      `cancelled`, `refunded`
    </ResponseField>

    <ResponseField name="checkoutUrl" type="string">
      The URL where the customer can complete the payment
    </ResponseField>

    <ResponseField name="currency" type="string">
      Three-letter ISO currency code
    </ResponseField>

    <ResponseField name="total" type="integer">
      Total amount in cents
    </ResponseField>

    <ResponseField name="customerEmail" type="string">
      Customer's email address
    </ResponseField>

    <ResponseField name="customerName" type="string">
      Customer's name (if provided)
    </ResponseField>

    <ResponseField name="description" type="string">
      Session description
    </ResponseField>

    <ResponseField name="metadata" type="object">
      Custom key-value pairs
    </ResponseField>

    <ResponseField name="successUrl" type="string">
      Redirect URL after successful payment
    </ResponseField>

    <ResponseField name="cancelUrl" type="string">
      Redirect URL if payment cancelled
    </ResponseField>

    <ResponseField name="failureUrl" type="string">
      Redirect URL if payment failed
    </ResponseField>

    <ResponseField name="completedAt" type="string">
      ISO 8601 completion timestamp (if completed)
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 creation timestamp
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      ISO 8601 last update timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.swiftpay.cx/api/checkout/sessions/sess_abc123 \
    -H "Authorization: Bearer mp_live_your_api_key"
  ```

  ```javascript JavaScript theme={null}
  const sessionId = "sess_abc123";

  const response = await fetch(
     `https://api.swiftpay.cx/api/checkout/sessions/${sessionId}`,
     {
        headers: {
           Authorization: "Bearer mp_live_your_api_key",
        },
     }
  );

  const session = await response.json();

  if (session.data.status === "completed") {
     console.log("Payment successful!");
  }
  ```

  ```python Python theme={null}
  import requests

  session_id = 'sess_abc123'

  response = requests.get(
      f'https://api.swiftpay.cx/api/checkout/sessions/{session_id}',
      headers={'Authorization': 'Bearer mp_live_your_api_key'}
  )

  session = response.json()

  if session['data']['status'] == 'completed':
      print('Payment successful!')
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": {
      "id": "sess_abc123",
      "amountInCents": 2999,
      "currency": "USD",
      "status": "completed",
      "checkoutUrl": "https://checkout.swiftpay.cx/sess_abc123",
      "customerEmail": "customer@example.com",
      "metadata": {
        "orderId": "order_12345",
        "productName": "Premium Plan"
      },
      "successUrl": "https://yoursite.com/success",
      "cancelUrl": "https://yoursite.com/cancel",
      "expiresAt": "2024-01-15T11:30:00Z",
      "completedAt": "2024-01-15T10:35:00Z",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  }
  ```

  ```json 404 theme={null}
  {
     "success": false,
     "error": {
        "type": "not_found",
        "message": "Checkout session not found",
        "requestId": "req_abc123"
     }
  }
  ```
</ResponseExample>

## Session Statuses

| Status       | Description                                |
| ------------ | ------------------------------------------ |
| `pending`    | Session created, awaiting customer payment |
| `processing` | Payment is being processed                 |
| `completed`  | Payment successful                         |
| `expired`    | Session expired before payment             |
| `failed`     | Payment failed                             |

<Note>
  Sessions expire after 1 hour by default. Check `expiresAt` to see when a
  pending session will expire.
</Note>
