# Create Project Plan - Add New Subscription Tiers via API

> API reference for programmatically creating subscription plans. POST endpoint for developers integrating with BotSubscription.

Source: https://docs.botsubscription.com/api/plans/create/

Add a new subscription tier to your project. Define the plan name, price, currency, and billing duration to offer members different membership options. You can also configure whether the plan supports recurring payments, one-time purchases, or both.

<ApiEndpoint method="POST" endpoint="/v2/projects/{project_id}/plans" />

<ApiAuthorization type="Bearer API Key" />

**API key access:** Unrestricted project API key required. Restricted keys cannot call this endpoint.

<ApiSection title="Path Parameters">
  <ApiParameter name="project_id" type="string" required description="The unique identifier of the project." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="plan_name" type="string" required description="Display name (3–50 characters). Supports letters in any language, numbers, spaces, hyphens, underscores, parentheses, square brackets, dot, comma, percent, plus, supported currency symbols and emojis." />
  <ApiParameter name="plan_price" type="string|number" required description="Nonnegative price within the currency's decimal limit. Prefer a decimal string such as 29.99; JSON numbers must also satisfy the numeric precision limits." />
  <ApiParameter name="plan_currency" type="string" required description="A supported currency code (e.g., USD, EUR)." />
  <ApiParameter name="plan_price_formatted" type="string" required description="Formatted display price, for example $29.99. Required separately from the numeric price." />
  <ApiParameter name="plan_duration" type="string" required description="Duration of the plan (e.g., '1 hour', '1 day', '1 month')." />
  <ApiParameter name="plan_targets" type="array" description="Target selections, for example [{&quot;kind&quot;:&quot;role&quot;,&quot;external_id&quot;:&quot;123456789012345678&quot;}]. Each kind is role, channel or group; external_id is the platform numeric ID as a string." />
  <ApiParameter name="plan_data" type="object" description="Additional plan configuration options." />
  <ApiParameter name="plan_data.plan_recurring" type="boolean" description="Whether the plan supports recurring payments." />
  <ApiParameter name="plan_data.plan_one_time" type="boolean" description="Whether the plan supports one-time payments." />
  <ApiParameter name="plan_data.plan_trial" type="string" description="Trial duration, for example '1 day'. Use a positive relative duration for a trial; do not use an absolute date or the lifetime value '0'. Applies to recurring and nonrecurring trial plans." />
</ApiSection>

To configure a recurring trial, send `plan_data: {"plan_recurring": true, "plan_one_time": false, "plan_trial": "1 day"}` with a positive plan price and a finite `plan_duration`, such as `"1 month"`. For a nonrecurring trial, set `plan_recurring` to `false` and `plan_one_time` to `true`. See [Automatic Trials for Named Members](https://docs.botsubscription.com/api/payment-requests/create/#automatic-trials-for-named-members) for project-key checkout behavior.

Trial eligibility is per customer and plan within the project. A completed checkout on that plan consumes eligibility; terminating its membership does not reset it. Omitted or empty `plan_targets` makes a plan universal across the project's applicable targets.

Prices follow the [decimal input rules](https://docs.botsubscription.com/api/overview/#decimal-amounts) and the selected currency's precision. USD allows 2 decimal places, JPY 0, BTC 8, and ETH 18. Trailing zeroes do not count: `"10.000"` USD is accepted; `"10.006"` USD returns `422 VALIDATION_ERROR` instead of being rounded. The 18-digit input limit still applies to the fractional part of a decimal string.

Recurring plans require a finite duration; lifetime `"0"` is not supported for recurring billing. `plan_price_formatted` is a separate display string; `"1"` is valid without a currency symbol. A display string does not override the numeric price or its precision checks.

A universal plan can return expanded applicable targets with `is_universal: true`; a populated `plan_targets` array does not make it a restricted plan.

## Recover a saved creation

If the response fails, check `Resource-Created` and `Response-Validation-Failed` before repeating the operation. Preserve the original request and retry key. A nonreplayable result can identify the saved resource in `error.details`; retrieve it before considering another create. See [creation outcome recovery](https://docs.botsubscription.com/api/overview/#creation-outcomes-after-a-failed-response).

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X POST "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/plans" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "plan_name": "Pro Plan",
    "plan_price": "29.99",
    "plan_currency": "USD",
    "plan_duration": "1 month",
    "plan_price_formatted": "$29.99"
  }'
```

```javascript
const project_id = 'YOUR_PROJECT_ID';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${project_id}/plans`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    plan_name: 'Pro Plan',
    plan_price: '29.99',
    plan_currency: 'USD',
    plan_duration: '1 month',
    plan_price_formatted: '$29.99'
  })
});
const data = await response.json();
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
response = requests.post(
    f'https://api.botsubscription.com/v2/projects/{project_id}/plans',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    json={
        'plan_name': 'Pro Plan',
        'plan_price': '29.99',
        'plan_currency': 'USD',
        'plan_duration': '1 month',
        'plan_price_formatted': '$29.99'
    }
)
data = response.json()
```

```php
$project_id = 'YOUR_PROJECT_ID';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/plans");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'plan_name' => 'Pro Plan',
    'plan_price' => '29.99',
    'plan_currency' => 'USD',
    'plan_duration' => '1 month',
    'plan_price_formatted' => '$29.99'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={201} description="Plan created">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans",
  "code": 201,
  "message": "Plan created successfully",
  "data": {
    "plan_name": "Pro Plan",
    "plan_price": "29.99",
    "plan_currency": "USD",
    "plan_duration": "1 month",
    "plan_price_formatted": "$29.99",
    "plan_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    "plan_data": {
      "plan_recurring": false,
      "plan_one_time": true
    },
    "plan_targets": [
      {
        "target_name": "Members",
        "platform": "discord",
        "kind": "role",
        "external_id": "123456789012345678",
        "is_enabled": true,
        "target_id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
        "parent_target_id": null,
        "participant_count": 0
      }
    ],
    "is_universal": true
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Missing required fields">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans",
  "code": 422,
  "errors": [
    {
      "message": "body: plan_name is required but was not provided",
      "error_code": "VALIDATION_ERROR"
    },
    {
      "message": "body: plan_price: Option 1: value is required but was not provided",
      "error_code": "VALIDATION_ERROR"
    },
    {
      "message": "body: plan_price: Option 2: value is required but was not provided",
      "error_code": "VALIDATION_ERROR"
    },
    {
      "message": "body: plan_currency is required but was not provided",
      "error_code": "VALIDATION_ERROR"
    },
    {
      "message": "body: plan_duration is required but was not provided",
      "error_code": "VALIDATION_ERROR"
    },
    {
      "message": "body: plan_price_formatted is required but was not provided",
      "error_code": "VALIDATION_ERROR"
    }
  ]
}
```

  </ApiResponse>
  <ApiResponse status={401} description="Invalid or expired API key">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Price exceeds USD precision">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans",
  "code": 422,
  "error": {
    "message": "Plan price has more decimal places than USD allows (2).",
    "error_code": "VALIDATION_ERROR"
  }
}
```

  </ApiResponse>
<ApiResponse status={409} description="Created resource response cannot be replayed">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "POST",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans",
  "code": 409,
  "error": {
    "error_code": "IDEMPOTENCY_RESPONSE_NOT_REPLAYABLE",
    "message": "A request with this Idempotency-Key was already processed, but its response cannot be replayed",
    "details": [
      {
        "resource_type": "plan",
        "resource_id": "33333333-3333-4333-8333-333333333333"
      }
    ]
  }
}
```

</ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
