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

# Create a Subscription Plan

Localpayment enables you to create fixed subscription plans for standardized recurring billing scenarios. This guide details how to set up subscription plans through Localpayment's API, which can then be associated with customer subscriptions for consistent, automated billing.

## Before You Begin

Ensure you have:

> [card] [API Credentials](https://docs.localpayment.com/docs/api-keys-and-environments.md)
>
> Valid API credentials and access token for authentication.

> [card] [Account Setup](https://docs.localpayment.com/docs/make-your-first-test-payment.md)
>
> Proper account setup for your target country and business verification.

> [card] [IP Whitelisting](https://docs.localpayment.com/docs/dashboard-whitelist-your-ips.md)
>
> Whitelist your server IP addresses for API access.

> [card] [Webhook Endpoint](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up a webhook URL to receive payment notifications.

***

## Step 1: Create a Subscription Plan

To create a new subscription plan, send a `POST` request to the [Create Subscription Plan](https://docs.localpayment.com/reference/create-subscription-plan) endpoint.

### Key Request Parameters

The request requires several key objects:

| Parameter | Description | Required |
| - | - | - |
| `name` | Descriptive name for the subscription plan | ✅ |
| `description` | Detailed explanation of plan features and benefits | ❌ |
| `country` | Country code where the plan will be available | ✅ |
| `amount` | Fixed billing amount | ✅ |
| `currency` | Currency code for billing | ✅ |
| `accountNumber` | Your merchant account number | ✅ |
| `autoRecurring.repetitions` | Number of billing cycles (use `0` for recurrence on demand) | ✅ |
| `autoRecurring.type` | Billing frequency unit (use `custom`for recurrence on demand) | |

### Supported Billing Frequencies

> [card] Daily
>
> Bill customers every day. Ideal for services with daily usage or short-term
> subscriptions.
>
> Send the`autoRecurring.type` property with value: `day`

> [card] Monthly
>
> Monthly recurring billing for most SaaS products, membership services, and
> subscription boxes.
>
> Send the`autoRecurring.type` property with value: `month`

> [card] Custom (On-demand)
>
> On-demand billing for variable usage scenarios. Perfect for pay-as-you-go or
> usage-based services.
>
> Send the`autoRecurring.type` property with value: `custom`

### Example Request

Below is an example using `curl`:

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
  --url https://api.stage.localpayment.com/api/subscriptions/plan \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <your_access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Plan Básico Mensual",
    "description": "Acceso básico a contenido exclusivo",
    "country": "MEX",
    "amount": 50,
    "currency": "MXN",
    "accountNumber": "{{accountNumber}}",
    "autoRecurring": {
      "repetitions": 1,
      "type": "hour"
    }
  }'
```

See all [available parameters](https://docs.localpayment.com/reference/create-subscription-plan) in the request.

***

## Step 2: Handle the Response

### Successful Response

A successfully created subscription plan returns complete plan details:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "internalId": "70af52e2-ea99-46a8-a931-65f15f6a3c20",
    "name": "Plan Básico Mensual",
    "description": "Acceso básico a contenido exclusivo",
    "amount": 50,
    "country": "MEX",
    "currency": "MXN",
    "accountNumber": "{{accountNumber}}",
    "autoRecurring": {
        "repetitions": 1,
        "type": "hour"
    },
    "status": {
        "code": "100",
        "description": "ACTIVE",
        "detail": "Subscription plan is active"
    }
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `internalId` | Localpayment's unique plan identifier. | Use as `planId` when creating subscriptions |
| `status.code` | Current plan status code. | Status monitoring. |
| `autoRecurring.type` | Confirmed billing frequency. | Billing cycle verification. |
| `autoRecurring.repetitions` | Confirmed number of billing cycles. | Plan duration tracking. |

### Error Response

When subscription plan creation fails, you'll receive detailed error information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "status": {
        "code": "400",
        "description": "REJECTED",
        "detail": "autoRecurring.type is required"
    }
}
```

***

## Step 3: Track Transaction Status

After creating a subscription plan, monitor its status through these methods:

> [card] [Webhooks (Recommended)](https://docs.localpayment.com/docs/webhooks.md)
>
> Receive real-time notifications when transaction status changes. Most efficient for production environments.

> [card] [Status API Endpoint](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.

> [card] [Business Portal View](https://docs.localpayment.com/docs/dashboard-overview.md)
>
> Visual interface for monitoring transactions. Great for manual oversight and detailed transaction analysis.

### Common Status Codes

| Code | Status | Description |
| :- | :- | :- |
| `100` | `ACTIVE` | Plan is active and available for subscription associations. |
| `400` | `REJECTED` | Plan creation failed due to validation errors or invalid parameters. |

> [!NOTE]
>
> **Complete Reference**
>
> View all status codes in our [Transaction Status Documentation](https://docs.localpayment.com/reference/transaction-status-error-codes).

***

## Testing Your Integration

### Test Scenarios

Verify your integration handles these scenarios:

1. **Successful Plan Creation**: Standard plan creation with valid parameters.
2. **Tiered Pricing Structure**: Creating multiple plans at different price points.
3. **Various Billing Frequencies**: Testing daily, monthly, and custom on-demand plans.
4. **Validation Errors**: Missing required fields, invalid amounts, unsupported countries.
5. **Subscription Association**: Testing that plans can be successfully linked to subscriptions

***

## Next Steps

After creating a subscription plan, you may need to perform additional actions::

> [card] [Create subscription with plan](https://docs.localpayment.com/docs/create-a-subscription.md)
>
> Use the plan internalId as planId parameter to create customer subscriptions
> with your new plan.

> [card] [Update subscription plan](https://docs.localpayment.com/docs/update-a-subscription-plan.md)
>
> Modify existing plan details while maintaining associations with active
> subscriptions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.