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

# Create Checkout Session

> Create a Stripe Checkout session for a subscription.

## Request

<ParamField body="user_id" type="string" required>
  User ID that will own the subscription.
</ParamField>

<ParamField body="email" type="string" required>
  Customer email address.
</ParamField>

<ParamField body="success_url" type="string" required>
  URL Stripe should redirect to after successful checkout.
</ParamField>

<ParamField body="cancel_url" type="string" required>
  URL Stripe should redirect to after cancellation.
</ParamField>

<ParamField body="tier" type="string">
  Subscription tier. Valid values: `starter` or `pro`. Default: `starter`.
</ParamField>

## Response

<ResponseField name="checkout_url" type="string">
  Stripe-hosted checkout URL.
</ResponseField>

## Example

<CodeGroup>
  ```python Python SDK theme={null}
  from entityml import EntityMLClient

  client = EntityMLClient()
  session = client.billing.create_checkout_session(
      user_id="YOUR_USER_ID",
      email="you@example.com",
      success_url="https://entityml.com/dashboard?checkout=success",
      cancel_url="https://entityml.com/subscribe",
      tier="pro",
  )
  print(session["checkout_url"])
  ```

  ```bash CLI theme={null}
  entityml billing checkout \
    --user-id YOUR_USER_ID \
    --email you@example.com \
    --success-url https://entityml.com/dashboard?checkout=success \
    --cancel-url https://entityml.com/subscribe \
    --tier pro
  ```

  ```bash Raw HTTP (cURL) theme={null}
  curl -X POST "https://api.entityml.com/api/v1/subscriptions/checkout" \
    -H "Content-Type: application/json" \
    -d '{
      "user_id": "YOUR_USER_ID",
      "email": "you@example.com",
      "success_url": "https://entityml.com/dashboard?checkout=success",
      "cancel_url": "https://entityml.com/subscribe",
      "tier": "pro"
    }'
  ```
</CodeGroup>

### Example response

```json theme={null}
{
  "checkout_url": "https://checkout.stripe.com/c/pay/cs_test_..."
}
```
