> ## 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.

# List Checkout Sessions

> List all checkout sessions with filtering and pagination

# List Checkout Sessions

Returns a paginated list of checkout sessions for your business.

## Request

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

<ParamField query="status" type="string">
  Filter by status: `pending`, `processing`, `completed`, `failed`,
  `cancelled`, `refunded`, or `all`.
</ParamField>

<ParamField query="limit" type="integer" default="20">
  Number of results per page (1-100).
</ParamField>

<ParamField query="page" type="integer" default="1">
  Page number for pagination.
</ParamField>

<ParamField query="search" type="string">
  Search by customer email or description.
</ParamField>

<ParamField query="from" type="string">
  Filter sessions created after this ISO 8601 date.
</ParamField>

<ParamField query="to" type="string">
  Filter sessions created before this ISO 8601 date.
</ParamField>

## Response

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

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="items" type="array">
      Array of checkout session objects

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

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

        <ResponseField name="currency" type="string">
          Currency code
        </ResponseField>

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

        <ResponseField name="checkoutUrl" type="string">
          Payment URL
        </ResponseField>

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

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

    <ResponseField name="meta" type="object">
      <Expandable title="properties">
        <ResponseField name="total" type="integer">
          Total number of matching sessions
        </ResponseField>

        <ResponseField name="page" type="integer">
          Current page number
        </ResponseField>

        <ResponseField name="limit" type="integer">
          Results per page
        </ResponseField>

        <ResponseField name="totalPages" type="integer">
          Total number of pages
        </ResponseField>

        <ResponseField name="hasNextPage" type="boolean">
          Whether a next page exists
        </ResponseField>

        <ResponseField name="hasPreviousPage" type="boolean">
          Whether a previous page exists
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

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

  # Filter by status

  curl "https://api.swiftpay.cx/api/checkout/sessions?status=completed&limit=50" \
   -H "Authorization: Bearer mp_live_your_api_key"

  # With date range

  curl "https://api.swiftpay.cx/api/checkout/sessions?startDate=2024-01-01&endDate=2024-01-31" \
   -H "Authorization: Bearer mp_live_your_api_key"

  ```

  ```javascript JavaScript theme={null}
  // Basic list
  const response = await fetch(
    'https://api.swiftpay.cx/api/checkout/sessions?limit=20',
    {
      headers: {
        'Authorization': 'Bearer mp_live_your_api_key'
      }
    }
  );

  const sessions = await response.json();

  // Paginate through all results
  let cursor = null;
  const allSessions = [];

  do {
    const url = new URL('https://api.swiftpay.cx/api/checkout/sessions');
    url.searchParams.set('limit', '100');
    if (cursor) url.searchParams.set('cursor', cursor);

    const res = await fetch(url, {
      headers: { 'Authorization': 'Bearer mp_live_your_api_key' }
    });
    const data = await res.json();

    allSessions.push(...data.data);
    cursor = data.pagination.nextCursor;
  } while (cursor);
  ```

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

  # Basic list
  response = requests.get(
      'https://api.swiftpay.cx/api/checkout/sessions',
      headers={'Authorization': 'Bearer mp_live_your_api_key'},
      params={'status': 'completed', 'limit': 50}
  )

  sessions = response.json()

  # Paginate through results
  all_sessions = []
  cursor = None

  while True:
      params = {'limit': 100}
      if cursor:
          params['cursor'] = cursor

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

      all_sessions.extend(data['data'])

      if not data['pagination'].get('nextCursor'):
          break
      cursor = data['pagination']['nextCursor']
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": [
      {
        "id": "sess_abc123",
        "amountInCents": 2999,
        "currency": "USD",
        "status": "completed",
        "customerEmail": "customer@example.com",
        "metadata": {
          "orderId": "order_12345"
        },
        "createdAt": "2024-01-15T10:30:00Z"
      },
      {
        "id": "sess_def456",
        "amountInCents": 4999,
        "currency": "USD",
        "status": "pending",
        "customerEmail": "another@example.com",
        "metadata": {},
        "createdAt": "2024-01-15T09:15:00Z"
      }
    ],
    "pagination": {
      "hasMore": true,
      "nextCursor": "cursor_xyz789",
      "total": 150
    }
  }
  ```
</ResponseExample>
