Skip to main content
GET
/
v1
/
credit-grants
curl -X GET "https://api.flexprice.io/v1/credit-grants?limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "data": [
    {
      "id": "cg_abc123xyz",
      "name": "Welcome Bonus",
      "scope": "SUBSCRIPTION",
      "subscription_id": "sub_1234",
      "credits": "100.00000000",
      "cadence": "ONETIME",
      "expiration_type": "DURATION",
      "expiration_duration": 30,
      "expiration_duration_unit": "DAYS",
      "start_date": "2024-01-15T00:00:00Z",
      "conversion_rate": "1.00000",
      "priority": 1,
      "metadata": {
        "campaign": "new_user_2024"
      },
      "created_at": "2024-01-15T10:00:00Z",
      "updated_at": "2024-01-15T10:00:00Z"
    },
    {
      "id": "cg_def456uvw",
      "name": "Monthly Plan Credits",
      "scope": "PLAN",
      "plan_id": "plan_enterprise",
      "credits": "500.00000000",
      "cadence": "RECURRING",
      "period": "MONTHLY",
      "period_count": 12,
      "expiration_type": "BILLING_CYCLE",
      "conversion_rate": "1.00000",
      "metadata": {},
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ],
  "total": 2,
  "limit": 20,
  "offset": 0
}

Query Parameters

scope
string
Filter by scopeValues: PLAN, SUBSCRIPTION
plan_id
string
Filter by plan ID (only returns PLAN-scoped grants)
subscription_id
string
Filter by subscription ID (only returns SUBSCRIPTION-scoped grants)
cadence
string
Filter by cadenceValues: ONETIME, RECURRING
expiration_type
string
Filter by expiration typeValues: NEVER, DURATION, BILLING_CYCLE
limit
integer
default:"10"
Number of credit grants to return per page (max 100)
offset
integer
default:"0"
Number of credit grants to skip for pagination
sort_by
string
default:"created_at"
Field to sort byValues: created_at, updated_at, name, credits
sort_order
string
default:"desc"
Sort orderValues: asc, desc

Response

data
array
Array of credit grant objects
total
integer
Total number of credit grants matching the filter criteria
limit
integer
Number of credit grants returned per page
offset
integer
Number of credit grants skipped
curl -X GET "https://api.flexprice.io/v1/credit-grants?limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "data": [
    {
      "id": "cg_abc123xyz",
      "name": "Welcome Bonus",
      "scope": "SUBSCRIPTION",
      "subscription_id": "sub_1234",
      "credits": "100.00000000",
      "cadence": "ONETIME",
      "expiration_type": "DURATION",
      "expiration_duration": 30,
      "expiration_duration_unit": "DAYS",
      "start_date": "2024-01-15T00:00:00Z",
      "conversion_rate": "1.00000",
      "priority": 1,
      "metadata": {
        "campaign": "new_user_2024"
      },
      "created_at": "2024-01-15T10:00:00Z",
      "updated_at": "2024-01-15T10:00:00Z"
    },
    {
      "id": "cg_def456uvw",
      "name": "Monthly Plan Credits",
      "scope": "PLAN",
      "plan_id": "plan_enterprise",
      "credits": "500.00000000",
      "cadence": "RECURRING",
      "period": "MONTHLY",
      "period_count": 12,
      "expiration_type": "BILLING_CYCLE",
      "conversion_rate": "1.00000",
      "metadata": {},
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ],
  "total": 2,
  "limit": 20,
  "offset": 0
}

Common Filtering Patterns

To see all credits available to a customer, you need to query both:
  1. Plan-scoped grants for any active subscriptions
  2. Subscription-scoped grants for their specific subscriptions
# Get customer's subscriptions
subscriptions = client.subscriptions.list(customer_id="cust_123")

# Get subscription-scoped grants
for sub in subscriptions.data:
    grants = client.credit_grants.list(subscription_id=sub.id)
    
# Get plan-scoped grants
for sub in subscriptions.data:
    grants = client.credit_grants.list(
        scope="PLAN",
        plan_id=sub.plan_id
    )
List all recurring credit grants to understand ongoing commitments:
curl -X GET "https://api.flexprice.io/v1/credit-grants?cadence=RECURRING" \
  -H "Authorization: Bearer YOUR_API_KEY"
While the list endpoint doesn’t directly filter by expiration date, you can:
  1. List all grants with expiration_type=DURATION
  2. Filter by application date ranges in your application logic
  3. Use the credit grant applications endpoint for scheduled credits