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

# Subscribe to Plan

> Create a new subscription for a customer on a specific plan

## Authentication

This endpoint requires a **Bearer token** in the `Authorization` header.

```
Authorization: Bearer <your_jwt_token>
```

## Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the subscription plan to subscribe to.
</ParamField>

## Body Parameters

<ParamField body="customerEmail" type="string" required>
  The email address of the customer subscribing to the plan. Used for sending receipts and renewal notifications.
</ParamField>

<ParamField body="customerName" type="string" required>
  The full name of the customer.
</ParamField>

<ParamField body="walletAddress" type="string" required>
  The customer's cryptocurrency wallet address. Recurring payments will be collected from this address via the on-chain subscription smart contract.
</ParamField>

## Response

<ResponseField name="id" type="string">
  Unique identifier for the subscription.
</ResponseField>

<ResponseField name="planId" type="string">
  The ID of the subscription plan.
</ResponseField>

<ResponseField name="planName" type="string">
  The name of the subscription plan.
</ResponseField>

<ResponseField name="customerEmail" type="string">
  The subscriber's email address.
</ResponseField>

<ResponseField name="customerName" type="string">
  The subscriber's name.
</ResponseField>

<ResponseField name="walletAddress" type="string">
  The subscriber's wallet address.
</ResponseField>

<ResponseField name="status" type="string">
  The subscription status. Newly created subscriptions start as `active` (or `trialing` if the plan has a trial period).
</ResponseField>

<ResponseField name="currentPeriodStart" type="string">
  ISO 8601 timestamp marking the start of the current billing period.
</ResponseField>

<ResponseField name="currentPeriodEnd" type="string">
  ISO 8601 timestamp marking the end of the current billing period.
</ResponseField>

<ResponseField name="trialEnd" type="string">
  ISO 8601 timestamp marking when the trial period ends, if applicable.
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp of when the subscription was created.
</ResponseField>

<RequestExample>
  ```json Request theme={null}
  {
    "customerEmail": "alice@example.com",
    "customerName": "Alice Johnson",
    "walletAddress": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef12"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "sub_abc123def456",
    "planId": "plan_abc123def456",
    "planName": "Pro Monthly",
    "customerEmail": "alice@example.com",
    "customerName": "Alice Johnson",
    "walletAddress": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef12",
    "status": "trialing",
    "currentPeriodStart": "2026-03-26T14:30:00Z",
    "currentPeriodEnd": "2026-04-26T14:30:00Z",
    "trialEnd": "2026-04-09T14:30:00Z",
    "createdAt": "2026-03-26T14:30:00Z"
  }
  ```
</ResponseExample>
