---
title: "Set reseller subscription expiry"
description: "Set, extend or clear the date until which a reseller can use the panel. Works in both billing modes. Admin keys only, atomic, audited, idempotent."
---

# Set reseller subscription expiry

Every reseller can carry a subscription expiry date: the same **Never Expires** / **Subscription Expires** setting the panel shows in **Edit Reseller**. This endpoint sets that date, pushes it forward by a number of days, or clears it so the account never expires.

It is the tool for billing a reseller a periodic fee for panel access: when the reseller pays, extend the subscription; when the payment is missing, let it lapse or set it to a past date. It works the same for resellers sold by credits and by slots (`credits` and `users` billing modes).

What an expired subscription means:

- The reseller **keeps** its lines, credits, slots and sub-resellers. Nothing is deleted or refunded.
- The reseller **cannot operate** until the subscription is renewed: in the panel it cannot create, edit or renew lines or sub-resellers, and through the API its own key gets `402 billing_expired` on the same operations (creating, editing, renewing and resetting the password of lines, creating sub-resellers and transferring credits). Enabling, disabling and deleting its own lines stay available, as in the panel.
- If the panel administrator turned on **Ban lines when a reseller's subscription expires** (Settings, Resellers), the lines of an expired reseller sold by slots are suspended a few minutes after the expiry. They come back on their own when the subscription is renewed; through this endpoint, right away.

## Endpoint

`POST https://<your-panel-domain>/panel-api/v1/resellers/{id}/billing/expiry`

## Authentication

Send the API key in the `Authorization: Bearer <your-api-key>` header. Only admin keys can call this endpoint. The target must be a reseller: administrator accounts return `422 not_a_reseller`.

## Required scope

`resellers:write`

## Idempotency

Every POST must include an `Idempotency-Key` header. Reusing the same key with the same body replays the cached response without applying the change again; reusing it with a different body returns `409 idempotency_conflict`.

This matters for `extend_days`, which adds time on every call. Derive the key from the payment that triggered it (for example `invoice-1044-renewal`), so a retry after a timeout never extends the subscription twice. See [Rate limits and Idempotency](/docs/?page=panel-api-rate-limits-idempotency).

## Path parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `id` | int | The ID of the reseller. |

## Request body

Send **exactly one** of `billing_expires` or `extend_days`.

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |
| `billing_expires` | int or null | one of the two | Sets the expiry to this Unix timestamp in seconds (UTC), from `1` to `2147483647` (2038-01-19). `null` means the subscription never expires. A timestamp in the past is valid: the subscription is expired at once. `0` is rejected. |
| `extend_days` | int | one of the two | Adds this many days, from `1` to `3650`, to the later of now and the current expiry. An account that never expires, or that has already expired, is extended from now. |
| `reason` | string | no | Free-form label, for example an invoice number. Truncated to 100 characters and shown in the reseller's history in the panel. |

Both numeric fields accept a JSON integer or a string made only of digits (`"30"`). Decimals, negative numbers and booleans are rejected with `422 validation_error`.

Set an exact date:

```json
{
  "billing_expires": 1798761599,
  "reason": "Invoice 1044, paid until 2026-12-31"
}
```

Extend by 30 days:

```json
{
  "extend_days": 30,
  "reason": "Invoice 1045"
}
```

Remove the expiry:

```json
{
  "billing_expires": null
}
```

Two `extend_days` calls for the same reseller that arrive at the same time both apply: the second one adds its days on top of the first.

## Response

The billing snapshot after the change, in the same shape as [`GET /resellers/{id}/billing`](/docs/?page=xai-ref-resellers-billing).

```json
{
  "mode": "credits",
  "credits": 47.5,
  "max_users": null,
  "active_users": null,
  "billing_expires": 1798761599
}
```

For a reseller sold by slots, `max_users` and `active_users` are filled in and `credits` is `null`, exactly as in the billing endpoint.

## Examples

The official SDKs do not wrap this endpoint yet. Call it over HTTP.

### cURL: set an exact date

```bash
curl -X POST https://<your-panel-domain>/panel-api/v1/resellers/42/billing/expiry \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: invoice-1044-renewal" \
  -d '{"billing_expires":1798761599,"reason":"Invoice 1044"}'
```

### cURL: extend by 30 days

```bash
curl -X POST https://<your-panel-domain>/panel-api/v1/resellers/42/billing/expiry \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: invoice-1045-renewal" \
  -d '{"extend_days":30,"reason":"Invoice 1045"}'
```

### cURL: suspend panel access now

```bash
curl -X POST https://<your-panel-domain>/panel-api/v1/resellers/42/billing/expiry \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: invoice-1046-overdue" \
  -d "{\"billing_expires\":$(( $(date +%s) - 60 )),\"reason\":\"Invoice 1046 overdue\"}"
```

### PHP (no SDK)

```php
$ch = curl_init('https://<your-panel-domain>/panel-api/v1/resellers/42/billing/expiry');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer <your-api-key>',
        'Content-Type: application/json',
        'Idempotency-Key: invoice-1045-renewal',
    ],
    CURLOPT_POSTFIELDS     => json_encode(['extend_days' => 30, 'reason' => 'Invoice 1045']),
]);
$billing = json_decode(curl_exec($ch), true);
echo $billing['billing_expires'], PHP_EOL;
```

### Python (no SDK)

```python
import requests

resp = requests.post(
    "https://<your-panel-domain>/panel-api/v1/resellers/42/billing/expiry",
    headers={
        "Authorization": "Bearer <your-api-key>",
        "Idempotency-Key": "invoice-1045-renewal",
    },
    json={"extend_days": 30, "reason": "Invoice 1045"},
    timeout=30,
)
resp.raise_for_status()
print(resp.json()["billing_expires"])
```

## Errors

| HTTP | Error slug | When it happens | How to fix |
| ---- | ---------- | --------------- | ---------- |
| 400 | `missing_idempotency_key` | The `Idempotency-Key` header was not sent. | Add the header on every POST. |
| 400 | `invalid_body` | The body has neither `billing_expires` nor `extend_days`. | Send one of the two. |
| 401 | `invalid_key` | Missing, malformed, or unknown API key. | Send a live key in `Authorization: Bearer <token>`. |
| 403 | `insufficient_scope` | The key does not carry `resellers:write`. Reseller keys never do. | Use an admin key with `resellers:write`. |
| 403 | `admin_only_endpoint` | A reseller key reached this endpoint. | Use an admin key. |
| 404 | `not_found` | No reseller exists with that ID. | Verify the ID with `GET /resellers/{id}` first. |
| 409 | `idempotency_conflict` | The `Idempotency-Key` was reused with a different body. | Generate a new key or resend the original body. |
| 422 | `validation_error` | Both fields were sent, or a value has the wrong type or is out of range (including `billing_expires: 0`). Nothing was changed. | Send exactly one field with a valid value. |
| 422 | `not_a_reseller` | The account is an administrator. Subscription expiry only applies to resellers. | Check the ID. |
| 422 | `expiry_out_of_range` | `extend_days` would move the expiry past 2038-01-19, the latest supported date. Nothing was changed. | Extend by fewer days, or send `billing_expires: null` for an account that should never expire. |
| 429 | `rate_limited` | The per-key request budget for this minute is spent. | Back off and retry after the minute rolls over. |

## See also

- [Get reseller billing](/docs/?page=xai-ref-resellers-billing)
- [Adjust reseller billing](/docs/?page=xai-ref-resellers-billing-adjust)
- [Update a reseller](/docs/?page=xai-ref-resellers-update)
- [Rate limits and Idempotency](/docs/?page=panel-api-rate-limits-idempotency)
