# Allocate credit to a subscription `POST /api/v1/subscriptions/{id}/allocate-credit` Applies available credit from a paid payment for the same athlete to the subscription balance. ## Permissions Send your API key in `X-API-Key`. Required permissions are **Subscriptions → Write**. ## Headers - `X-Sport-Id` (integer, required) — The sport ID from [List sports](/api/sports/list.md). Use the sport the record belongs to. ## Path parameters - `id` (integer, required) — ID of the subscription. ## Body parameters - `payment_id` (integer, required) — ID of the incoming athlete credit payment. - `amount` (integer, required) — Positive allocation in minor units. It cannot exceed the available credit or subscription balance. - `notes` (string) — Optional notes about the allocation. ## Request Set ASDINCLOUD_API_KEY and any variables named in the example before running it. ```sh curl --request POST \ --url "https://api.asdincloud.com/api/v1/subscriptions/${ID:?Set ID}/allocate-credit" \ --header "X-API-Key: $ASDINCLOUD_API_KEY" \ --header "X-Sport-Id: ${SPORT_ID:?Set SPORT_ID}" \ --header "Content-Type: application/json" \ --data '{"payment_id":19,"amount":2500,"notes":"Apply club credit"}' ``` ## Response **201 Created** Returns the new credit allocation in `data`. Example with fictional data and selected fields. ```json { "status": "success", "data": { "id": 12, "subscription_id": 53, "payment_id": 19, "athlete_id": 42, "amount": 2500, "notes": "Apply club credit", "metadata": { "source": "credit_allocation" } } } ``` ## Errors - `401` — The API key is missing or invalid. - `403` — The API key lacks the required permission. - `400` — The payment, amount, or available balance is invalid. - `404` — The requested record was not found.