# Update Project Plan - Modify Subscription Settings via API

> Update subscription plan details including name, price, duration, and configuration via the API.

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

Modify an existing subscription plan's settings. Change the name, adjust pricing, update the billing cycle, or toggle payment options. Omitted top-level fields remain unchanged. When supplying `plan_data`, send both billing flags explicitly as described below.

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

<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." />
  <ApiParameter name="plan_id" type="string" required description="The unique identifier of the plan to update." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="expected_revision" type="string" description="Optional opaque revision from authenticated Get Plan or a prior update. Refuses a stale edit without writing." />
  <ApiParameter name="plan_name" type="string" 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" description="Nonnegative price within the resulting currency's decimal limit. Prefer a decimal string such as 1.25; JSON numbers must also satisfy the numeric precision limits." />
  <ApiParameter name="plan_currency" type="string" description="A supported currency code (e.g., USD, EUR)." />
  <ApiParameter name="plan_duration" type="string" description="Duration of the plan (e.g., '1 hour', '1 day', '1 month')." />
  <ApiParameter name="plan_price_formatted" type="string" description="Formatted price display string (e.g., '$10.00')." />
  <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, not an absolute date or lifetime '0'." />
</ApiSection>

All listed top-level fields are optional; unknown top-level fields are rejected. Recognized `plan_data` properties merge with existing properties, but a supplied `plan_data` object defaults omitted `plan_recurring` to `false` and omitted `plan_one_time` to `true`. Include both flags when changing trial configuration.

For example, `{"plan_data":{"plan_recurring":false,"plan_one_time":true,"plan_trial":"1 day"}}` switches the plan to a nonrecurring trial. This changes configuration, not trial history: a customer with a completed checkout on the same plan does not become eligible again. See [Create a Trial Plan](https://docs.botsubscription.com/api/plans/create/) and [Automatic Trial Checkout](https://docs.botsubscription.com/api/payment-requests/create/#automatic-trials-for-named-members).

Prices follow the [decimal input rules](https://docs.botsubscription.com/api/overview/#decimal-amounts) and the resulting currency's precision. USD allows 2 decimal places, JPY 0, BTC 8, and ETH 18; trailing zeroes do not add precision. Changing only `plan_currency` validates the stored price against the new currency. For example, switching a plan priced at `"10.01"` to JPY returns `422 VALIDATION_ERROR`.

An unchanged stored price can be retained even if it exceeds the currency's decimal limit. Unrelated edits do not require a price correction. Resending an unchanged price and currency must still satisfy the input schema. A changed price or currency must satisfy the resulting currency limit.

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 universal plan can return expanded applicable targets with `is_universal: true`; a populated `plan_targets` array does not make it a restricted plan.

## Prevent concurrent plan edits

Read the plan with an unrestricted project API key and save its `revision`. Include that value as `expected_revision` with your changes. The value uses `v1.` followed by 64 lower-case hexadecimal characters; treat it as opaque rather than building it yourself.

A stale revision returns `409 CONFLICT` without writing. Fetch the plan again, reconcile your changes, and submit the new edit with a new `Idempotency-Key`. A timeout or lost response needs the original key and unchanged body instead. Without `expected_revision`, the last arriving write wins.

A successful update returns the new `revision`. A request naming no field to change can return `304` with no body. Malformed revisions return `422 VALIDATION_ERROR`.

## Add or remove this plan's targets

`plan_targets` replaces the plan's explicit target selection. To add a target, send the existing selections plus the new one. To remove a target, send the selections you want to keep. Omitting `plan_targets` leaves the selection unchanged.

For example, this request selects a Telegram channel and group using their platform IDs as strings:

```json
{
  "plan_targets": [
    { "kind": "channel", "external_id": "-1001234567890" },
    { "kind": "group", "external_id": "-1002345678901" }
  ]
}
```

To remove the channel from this plan, send only the group entry. Other plans using that channel keep their selections. Read the plan back to confirm `is_universal: false` and the expanded target objects.

<Warning>
Sending `{"plan_targets":[]}` removes the explicit restriction and makes the plan universal across applicable project targets. It does not disable access. The response uses `is_universal: true` and can contain a populated `plan_targets` array.
</Warning>

Changing a target's name or enabled state uses the separate [target update endpoint](https://docs.botsubscription.com/api/targets/update/) and affects that shared target across plans.

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X PATCH "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/plans/YOUR_PLAN_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "plan_name": "Pro Plan (Updated)",
    "plan_price": "34.99",
    "plan_price_formatted": "$34.99"
  }'
```

```javascript
const project_id = 'YOUR_PROJECT_ID';
const plan_id = 'YOUR_PLAN_ID';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${project_id}/plans/${plan_id}`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    plan_name: 'Pro Plan (Updated)',
    plan_price: '34.99',
    plan_price_formatted: '$34.99'
  })
});
const data = await response.json();
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
plan_id = 'YOUR_PLAN_ID'
response = requests.patch(
    f'https://api.botsubscription.com/v2/projects/{project_id}/plans/{plan_id}',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    json={
        'plan_name': 'Pro Plan (Updated)',
        'plan_price': '34.99',
        'plan_price_formatted': '$34.99'
    }
)
data = response.json()
```

```php
$project_id = 'YOUR_PROJECT_ID';
$plan_id = 'YOUR_PLAN_ID';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/plans/{$plan_id}");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
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 (Updated)',
    'plan_price' => '34.99',
    'plan_price_formatted' => '$34.99'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={200} description="Plan updated">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
  "code": 200,
  "message": "Plan updated successfully",
  "data": {
    "plan_name": "Pro Plan (Updated)",
    "plan_price": "34.99",
    "plan_currency": "USD",
    "plan_duration": "1 month",
    "plan_price_formatted": "$34.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,
    "revision": "v1.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Invalid plan ID">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/not-a-uuid",
  "code": 422,
  "errors": [
    {
      "message": "params: plan_id Invalid UUID",
      "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": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Idempotency key reused with a different request">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
  "code": 422,
  "error": {
    "message": "This Idempotency-Key was already used with a different request",
    "error_code": "IDEMPOTENCY_KEY_MISMATCH"
  }
}
```

  </ApiResponse>
  <ApiResponse status={200} description="Explicit target selection updated">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
  "code": 200,
  "message": "Plan updated successfully",
  "data": {
    "plan_name": "Pro Plan (Updated)",
    "plan_price": "34.99",
    "plan_currency": "USD",
    "plan_duration": "1 month",
    "plan_price_formatted": "$34.99",
    "plan_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
    "plan_data": {
      "plan_recurring": false,
      "plan_one_time": true
    },
    "plan_targets": [
      {
        "target_name": "Example group",
        "platform": "telegram",
        "kind": "group",
        "external_id": "-1002345678901",
        "is_enabled": true,
        "target_id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
        "parent_target_id": null,
        "participant_count": 0
      }
    ],
    "is_universal": false,
    "revision": "v1.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Stored price cannot be represented in the new currency">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/22222222-2222-4222-8222-222222222222",
  "code": 422,
  "error": {
    "message": "Plan price has more decimal places than JPY allows (0).",
    "error_code": "VALIDATION_ERROR"
  }
}
```

  </ApiResponse>
<ApiResponse status={409} description="Stale plan revision">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/plans/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
  "code": 409,
  "error": {
    "error_code": "CONFLICT",
    "message": "The plan changed. Reload and try again."
  }
}
```

</ApiResponse>
<ApiResponse status={304} description="No field to change">

No response body.

</ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
