Appearance
Subtract
http
POST https://api.creduse.com/subtractSubtracts credits from a user's balance. This is typically used when a user performs an action that consumes credits.
- If the user does not have enough credits, the request will return an
InsufficientFundserror. - The subtraction follows the FIFO principle: the oldest credits are subtracted first. For more information, see the Credit Subtraction Logic page.
Request body
| Parameter | Type | Description |
|---|---|---|
end_user_id | UUID | Required. The unique identifier of the user. |
amount | integer | Required. The amount of credits to subtract from the user's balance. Positive integers only. |
Example request
curl
curl https://api.creduse.com/subtract \
-H "Authorization : Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"end_user_id": "UUID",
"amount": 100
}' \Python
from creduse import CreduseClient
client = CreduseClient()
client.subtract(
end_user_id=UUID("12345678-1234-5678-1234-567812345678"),
amount=100
)Response
Returns a subtraction object. The response will include the end_user_id and the amount of credits subtracted.
json
{
"end_user_id": "UUID",
"amount": 100
}