Credits

Create Credit Grant

Grant credits to a customer based on a credit definition. The grant tracks the initial amount, remaining amount, and expiry.

POST
/credits/grants

Authorization

bearerAuth
AuthorizationBearer <token>

Use your secret API key as the bearer token

In: header

Request Body

application/json

customerId*string

Customer to grant credits to

Length1 <= length
creditDefinitionId*string

Credit definition to use

Length1 <= length
initialAmount?integer

Override the default amount from definition

Range1 <= value
source*string

Source of the grant

Value in"subscription" | "manual" | "topup" | "promotion" | "refund"
startDate?string
Formatdate-time
expiryDate?string
Formatdate-time
priority?integer
referenceCode?string

External reference code

notes?string

Response Body

application/json

application/json

application/json

curl -X POST "https://api.getlumen.dev/v1/credits/grants" \  -H "Content-Type: application/json" \  -d '{    "customerId": "cus_Lo4xGg1Yk9pB2eWv3sNtA",    "creditDefinitionId": "cred_def_abc123def456ghi789",    "initialAmount": 10000,    "source": "subscription",    "notes": "Monthly API call allowance"  }'
{
  "grant": {
    "id": "string",
    "merchantId": "string",
    "customerId": "string",
    "creditDefinitionId": "string",
    "applicationType": "usage",
    "initialAmount": 0,
    "remainingAmount": 0,
    "status": "ACTIVE",
    "source": "subscription",
    "featureId": "string",
    "featureSlug": "string",
    "priceId": "string",
    "priceComponentId": "string",
    "currency": "string",
    "startDate": "2019-08-24T14:15:22Z",
    "expiryDate": "2019-08-24T14:15:22Z",
    "referenceCode": "string",
    "notes": "string",
    "priority": 0,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "deletedAt": "2019-08-24T14:15:22Z"
  }
}
{
  "error": "Customer ID is required"
}
{
  "error": "Failed to create credit grant"
}