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

Localpayment enables you to modify existing subscriptions to accommodate changes in customer needs, such as upgrading or downgrading plans, updating billing information, or changing subscription frequencies. This guide details the process for updating a subscription through Localpayment's API.

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

To modify an existing subscription, send a `PATCH` request to the [Update a Subscription](https://docs.localpayment.com/reference/create-a-subscription.md) endpoint.

### Key Request Parameters

The request requires several key parameters:

| Parameter | Description |
| - | - |
| `amount` | New subscription amount |
| `card` | Card object with updated payment details |
| `autoRecurring` | Billing frequency and repetition settings |
| `discount` | Discount configuration to apply to subscription |
| `retry` | Payment retry configuration for failed charges |
| `dateToUpdate` | Specific date when changes should take effect |
| `suspension` | Subscription suspension settings |
| `status` | Subscription status change (e.g., pause/resume) |

### 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/payin/subscriptions/{externalId} \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
    "dateToUpdate": "2025-10-28",
    "amount": 1600.00,

   "autoRecurring": {
        "repetitions": "2",
        "type": "hour"
    },

   "retry": {
    "repetitions": 2,
    "intervalUnit": "day",
    "intervalValue": 1
  }
}
'

```

See all [available parameters](https://docs.localpayment.com/docs/update-a-subscription.md) in the request.

***

## Step 2: Handle the Response

### Successful Response

A successful update returns the modified subscription details:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "564b161a-76ba-4a84-b5cf-583f2df8c377",
  "internalId": "52425bbd-b68b-4abc-9480-5ae88d53adb3",
  "status": {
    "code": "107",
    "description": "APPROVED",
    "detail": "Update subscription success"
  },
  "errors": []
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `status.code` | Current subscription status code. | Status monitoring. |

### Error Response

When a request fails, you'll receive detailed error information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "status": {
    "code": "400",
    "description": "ERROR",
    "detail": "Invalid operation"
  }
}
```

***

## Step 3: Track Transaction Status

After updating a subscription, 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

The Localpayment API provides various status codes to indicate the progress and outcome of the payment in the response.

| Code | Status | Description |
| :- | :- | :- |
| `107` | `APPROVED` | Update was approved and applied. |
| `400` | `ERROR` | Subscription update was rejected. |

> [!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 Upgrade**: Increasing subscription tier or amount.
2. **Successful Plan Downgrade**: Decreasing subscription tier or amount.
3. **Payment Method Update**: Changing card details.
4. **Customer Information Update**: Modifying customer details.
5. **Validation Errors**: Invalid amounts, missing required fields.
6. **Status Updates**: Webhook handling and status polling

***

## Next Steps

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

> [card] [Cancel subscription](https://docs.localpayment.com/docs/cancel-a-subscription.md)
>
> Terminate active subscriptions when updates aren't sufficient.

> [card] [Handle subscription webhooks](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up webhooks to receive notifications for subscription update events.

> [card] [Create subscription plans](https://docs.localpayment.com/docs/create-a-subscription-plan.md)
>
> Create new plans that can be used when updating subscriptions.


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