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

# Subscribe to Plan

> Create a subscription to a plan

Subscribe a user to a specific plan. This creates a Stripe checkout session.

## Path Parameters

<ParamField path="id" type="string" required>
  The plan ID to subscribe to
</ParamField>

## Request Body

<ParamField body="success_url" type="string" required>
  URL to redirect after successful payment
</ParamField>

<ParamField body="cancel_url" type="string" required>
  URL to redirect if payment is cancelled
</ParamField>

<ParamField body="customer_email" type="string">
  Customer email for the checkout
</ParamField>

<ParamField body="user_id" type="string">
  User ID to associate with the subscription
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the checkout session was created
</ResponseField>

<ResponseField name="checkoutUrl" type="string">
  Stripe checkout URL to redirect the user
</ResponseField>

<ResponseField name="sessionId" type="string">
  Stripe session ID
</ResponseField>

<RequestExample>
  ```bash theme={null}
  curl -X POST "https://api.usegately.com/api/v1/plans/plan_123/subscribe" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "success_url": "https://mysite.com/success",
      "cancel_url": "https://mysite.com/pricing",
      "customer_email": "user@example.com",
      "user_id": "user_123"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "checkoutUrl": "https://checkout.stripe.com/c/pay/xxx",
    "sessionId": "cs_xxx"
  }
  ```
</ResponseExample>
