# Set up automatic payment for a service

`POST https://console.advinservers.com/api/v1/client/billing/managed-services/{service}/subscription`

### Overview

Starts automatic payment setup for a service that has no subscription. Unless a saved method is named (below), the customer must finish setup on the page `checkoutUrl` opens before the subscription appears. `environment` says whether that page takes live (`production`) or test (`sandbox`) payments.

Where more than one payment option can renew automatically, send `option` with the `value` of a recurring option from the checkout options list; the first one offered is used otherwise. To charge each renewal to a saved card or PayPal account, send its `uuid` as `payment_card` or `paypal_account`, from the automatic payments list. Automatic payments are then on straight away: `active` is true and `checkoutUrl` is null. With no saved method named, `checkoutUrl` opens a page to add a new card (with the card option) or PayPal account (with the PayPal option) for this service. `resumed` is always false.

Use `chargesNow` to tell the customer whether setup will charge them immediately. A paid service is not charged until its next due date. An overdue service is charged immediately. `firstChargeAt` gives the first payment date.

### Permissions

Requires the account permission `billing.manage` (Manage billing).

## Authorization

Send `Authorization: Bearer <token>` with the request. Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.

## Path parameters

- `service` (string, required): The service ID returned by the billing endpoints.

## Body

Sent as `application/json`.

- `option` (string | null): The value of `option`. One of: `stripe_once`, `stripe_subscription`, `stripe_checkout`, `paypal_once`, `paypal_subscription`, `btcpay_once`, `nowpayments_once`, `null`.
- `paypal_account` (string<uuid> | null): The value of `paypal_account`.
- `payment_card` (string<uuid> | null): The value of `payment_card`.

## Response 200

The record, as a JSON object. There is no envelope.

- `checkoutUrl` (string | null, required): The value of `checkout_url`.
- `environment` (string, required): The value of `environment`.
- `chargesNow` (boolean, required): The value of `charges_now`.
- `firstChargeAt` (string | null, required): The date and time for first charge at, in UTC.
- `resumed` (boolean, required): The value of `resumed`.
- `active` (boolean, required): Autopay is already on, from a saved PayPal account, so there is no page to open.

```json
{
  "checkoutUrl": null,
  "environment": "production",
  "chargesNow": false,
  "firstChargeAt": "2026-10-11",
  "resumed": false,
  "active": true
}
```

## Errors

- `401`: The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- `403`: Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- `404`: The resource was not found in the selected team. Resources in another account or team also return 404.
- `422`: A field is missing or invalid, or the resource cannot accept this change in its current state. Check `message` for details. Field validation also includes an `errors` object keyed by field name.
- `429`: Too many requests. The `Retry-After` header says how many seconds to wait. Limits are per account, so several keys on one account share them.

## Example request

```bash
curl --request POST \
  --url 'https://console.advinservers.com/api/v1/client/billing/managed-services/{service}/subscription' \
  --header 'Authorization: Bearer <token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "option": "stripe_once",
  "paypal_account": "555fcb9c-a003-4fa8-aae6-25d550922b5b",
  "payment_card": "3de21877-5bcc-4e7a-a606-e959e00b5c0a"
}'
```
