# Open a hosted checkout session

`POST /api/v1/checkout-sessions`

Exactly one of `customer_id` / `customer_external_id`. A subscription checkout needs `items` (or `plan_id` / `plan_code` with `seats`).

Needs the `checkout:write` scope, or a full-access key.

## Request body

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "customer_id": {
      "type": "string",
      "format": "uuid",
      "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    },
    "customer_external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "mode": {
      "type": "string",
      "enum": [
        "subscription",
        "setup"
      ]
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "plan_id": {
            "type": "string",
            "format": "uuid",
            "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
          },
          "plan_code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000,
            "description": "Seats / units of a licensed item (default 1)."
          },
          "meter": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Makes this a metered item billing this meter monthly. Never the first item; no quantity."
          }
        },
        "description": "Exactly one of `plan_id` / `plan_code`."
      },
      "minItems": 1,
      "maxItems": 10
    },
    "plan_id": {
      "type": "string",
      "format": "uuid",
      "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    },
    "plan_code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "seats": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100000
    },
    "promotion_code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "allow_promotion_codes": {
      "type": "boolean",
      "description": "Default true."
    },
    "lock_items": {
      "type": "boolean",
      "description": "Default false. True: plan, seats, interval and items are fixed. The page shows them read-only, and the hosted quote and confirm refuse any change (422 `items_locked`)."
    },
    "trial_days": {
      "type": "integer",
      "minimum": 0,
      "maximum": 730
    },
    "success_url": {
      "type": "string",
      "format": "uri"
    },
    "cancel_url": {
      "type": "string",
      "format": "uri"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "maxLength": 500
      },
      "description": "At most 50 keys (each ≤ 40 characters); copied onto the subscription."
    }
  },
  "required": [
    "success_url",
    "cancel_url"
  ]
}
```

## Responses

### 201

The session; send the payer to `url` (valid 24 hours).

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "object": {
          "type": "string",
          "enum": [
            "checkout_session"
          ]
        },
        "mode": {
          "type": "string",
          "enum": [
            "subscription",
            "setup"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "open"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "object",
        "mode",
        "status",
        "url",
        "expires_at"
      ]
    },
    "_agent": {
      "type": "object",
      "properties": {
        "summary": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "ok"
          ]
        },
        "next_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "summary",
        "status",
        "next_actions",
        "warnings"
      ]
    },
    "api_version": {
      "type": "string",
      "example": "2026-07-01"
    }
  },
  "required": [
    "data",
    "_agent",
    "api_version"
  ]
}
```

### 422

`validation_failed`, or `unprocessable` when an item cannot be billed.
