> ## 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.

# Update a Subscription Plan

Localpayment allows you to modify existing subscription plans to accommodate changes in your pricing strategy, billing cycles, or service offerings. This guide details how to update a subscription plan through Localpayment's API, ensuring existing subscriptions can continue under the new terms or according to your configured policies.

## 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: Update a Subscription Plan

To modify an existing subscription plan, send a`PATCH` request to the Update Subscription Plan endpoint.

### Key Request Parameters

The request requires several key parameters:

| Parameter | Description | Required |
| - | - | - |
| `amount` | Updated billing amount | ❌ |
| `autoRecurring` | Updated configuration for automatic recurring billing | ❌ |
| `autoRecurring.repetitions` | Updated number of billing cycles (use `0` for recurrence on demand) | ❌ |
| `autoRecurring.type` | Updated billing frequency unit (use `custom`for recurrence on demand) | ❌ |

### Supported Billing Frequencies

> [card] Daily
>
> Update to daily billing. Ideal for services transitioning to daily usage patterns.
>
> Send the`autoRecurring.type` property with value: `day`

> [card] Monthly
>
> Update to monthly billing. Common for standardizing billing cycles across product lines.
>
> Send the`autoRecurring.type` property with value: `month`

> [card] Custom (On-demand)
>
> Update to on-demand billing. Suitable for moving to usage-based pricing models.
>
> 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 PATCH \
  --url 'https://api.stage.localpayment.com/api/subscriptions/plan/{internalId}' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <your_access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "amount": 150,
    "autoRecurring": {
      "repetitions": 1,
      "type": "month"
    }
  }'
```

See all [available parameters](#key-request-parameters) in the request.

***

## Step 2: Handle the Response

### Successful Response

A successfully updated subscription plan returns confirmation with the current status:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "internalId": "106e9aff-96da-42e9-a9e1-4dee207e6073",
    "status": {
        "code": "100",
        "description": "ACTIVE",
        "detail": "Subscription plan was update"
    }
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `internalId` | Localpayment's unique plan identifier. | Verify you've updated the correct plan. |
| `status.code` | Current plan status code. | Confirm the plan remains active after updates. |
| `status.description` | Human-readable status description. | Display status in administrative interfaces. |
| `status.detail` | Detailed status information. | Confirm the update operation was successful. |

### Error Response

When a subscription plan update 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": "amount must be greater than or equal to 1"
  }
}
```

***

## Step 3: Track Transaction Status

After updating 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 update 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 Amount Update**: Modify plan pricing with valid amount values.
2. **Billing Frequency Change**: Update from monthly to daily or custom billing.
3. **Partial Updates**: Modify only specific fields without sending complete payload.
4. **Validation Errors**: Test with invalid amounts, missing required fields, or unsupported frequencies.
5. **Nonexistent Plan**: Attempt to update a plan that doesn't exist.
6. **Authentication Failures**: Test with invalid or expired access tokens.

***

## Next Steps

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

> [card] [Create a new subscription plan](https://docs.localpayment.com/docs/create-a-subscription-plan.md)
>
> Set up additional subscription plans for different pricing tiers or service
> levels.

> [card] [Create subscription with updated plan](https://docs.localpayment.com/docs/create-a-subscription.md)
>
> Create new subscriptions using your updated plan to test the changes.

> [card] [Get subscription plan details](https://docs.localpayment.com/docs/get-subscription-plan.md)
>
> Retrieve the updated plan information to verify all changes were applied
> correctly.


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