curl --request POST \
--url https://us.api.flexprice.io/v1/creditgrants \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"credits": "<string>",
"name": "<string>",
"addon_id": "<string>",
"conversion_rate": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"expiration_duration": 123,
"metadata": {},
"period_count": 123,
"plan_id": "<string>",
"priority": 123,
"start_date": "2023-11-07T05:31:56Z",
"subscription_id": "<string>",
"topup_conversion_rate": "<string>"
}
'from flexprice import Flexprice
with Flexprice(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.credit_grants.create_credit_grant(cadence="ONETIME", credits="<value>", name="<value>", scope="PLAN")
# Handle response
print(res)import { Flexprice } from "@flexprice/sdk";
const flexprice = new Flexprice({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await flexprice.creditGrants.createCreditGrant({
cadence: "ONETIME",
credits: "<value>",
name: "<value>",
scope: "PLAN",
});
console.log(result);
}
run();package main
import(
"context"
flexprice "github.com/flexprice/go-sdk/v2"
"github.com/flexprice/go-sdk/v2/models/types"
"log"
)
func main() {
ctx := context.Background()
s := flexprice.New(
flexprice.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.CreditGrants.CreateCreditGrant(ctx, types.CreateCreditGrantRequest{
Cadence: types.CreditGrantCadenceOnetime,
Credits: "<value>",
Name: "<value>",
Scope: types.CreditGrantScopePlan,
})
if err != nil {
log.Fatal(err)
}
if res.CreditGrantResponse != nil {
// handle response
}
}{
"addon_id": "<string>",
"cadence": "ONETIME",
"conversion_rate": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"credit_grant_anchor": "2023-11-07T05:31:56Z",
"credits": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"environment_id": "<string>",
"expiration_duration": 123,
"expiration_duration_unit": "DAY",
"expiration_type": "NEVER",
"id": "<string>",
"metadata": {},
"name": "<string>",
"period": "DAILY",
"period_count": 123,
"plan_id": "<string>",
"priority": 123,
"scope": "PLAN",
"start_date": "2023-11-07T05:31:56Z",
"status": "published",
"subscription_id": "<string>",
"tenant_id": "<string>",
"topup_conversion_rate": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Create credit grant
Use when giving a customer or plan credits (e.g. prepaid balance or promotional credits). Scope can be plan or subscription; supports start/end dates.
curl --request POST \
--url https://us.api.flexprice.io/v1/creditgrants \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"credits": "<string>",
"name": "<string>",
"addon_id": "<string>",
"conversion_rate": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"expiration_duration": 123,
"metadata": {},
"period_count": 123,
"plan_id": "<string>",
"priority": 123,
"start_date": "2023-11-07T05:31:56Z",
"subscription_id": "<string>",
"topup_conversion_rate": "<string>"
}
'from flexprice import Flexprice
with Flexprice(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.credit_grants.create_credit_grant(cadence="ONETIME", credits="<value>", name="<value>", scope="PLAN")
# Handle response
print(res)import { Flexprice } from "@flexprice/sdk";
const flexprice = new Flexprice({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await flexprice.creditGrants.createCreditGrant({
cadence: "ONETIME",
credits: "<value>",
name: "<value>",
scope: "PLAN",
});
console.log(result);
}
run();package main
import(
"context"
flexprice "github.com/flexprice/go-sdk/v2"
"github.com/flexprice/go-sdk/v2/models/types"
"log"
)
func main() {
ctx := context.Background()
s := flexprice.New(
flexprice.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.CreditGrants.CreateCreditGrant(ctx, types.CreateCreditGrantRequest{
Cadence: types.CreditGrantCadenceOnetime,
Credits: "<value>",
Name: "<value>",
Scope: types.CreditGrantScopePlan,
})
if err != nil {
log.Fatal(err)
}
if res.CreditGrantResponse != nil {
// handle response
}
}{
"addon_id": "<string>",
"cadence": "ONETIME",
"conversion_rate": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"credit_grant_anchor": "2023-11-07T05:31:56Z",
"credits": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"environment_id": "<string>",
"expiration_duration": 123,
"expiration_duration_unit": "DAY",
"expiration_type": "NEVER",
"id": "<string>",
"metadata": {},
"name": "<string>",
"period": "DAILY",
"period_count": 123,
"plan_id": "<string>",
"priority": 123,
"scope": "PLAN",
"start_date": "2023-11-07T05:31:56Z",
"status": "published",
"subscription_id": "<string>",
"tenant_id": "<string>",
"topup_conversion_rate": "<string>",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Authorizations
Enter your API key in the format x-api-key <api-key>*
Body
Credit Grant configuration
ONETIME, RECURRING PLAN, SUBSCRIPTION, ADDON amount in the currency = number of credits * conversion_rate ex if conversion_rate is 1, then 1 USD = 1 credit ex if conversion_rate is 2, then 1 USD = 0.5 credits ex if conversion_rate is 0.5, then 1 USD = 2 credits
DAY, WEEK, MONTH, YEAR NEVER, DURATION, BILLING_CYCLE Show child attributes
Show child attributes
DAILY, WEEKLY, MONTHLY, ANNUAL, QUARTERLY, HALF_YEARLY create_prorations, none topup_conversion_rate is the conversion rate for the topup to the currency ex if topup_conversion_rate is 1, then 1 USD = 1 credit ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits
Response
Created
ONETIME, RECURRING amount in the currency = number of credits * conversion_rate ex if conversion_rate is 1, then 1 USD = 1 credit ex if conversion_rate is 2, then 1 USD = 0.5 credits ex if conversion_rate is 0.5, then 1 USD = 2 credits
DAY, WEEK, MONTH, YEAR NEVER, DURATION, BILLING_CYCLE Show child attributes
Show child attributes
DAILY, WEEKLY, MONTHLY, ANNUAL, QUARTERLY, HALF_YEARLY PLAN, SUBSCRIPTION, ADDON published, deleted, archived topup_conversion_rate is the conversion rate for the topup to the currency ex if topup_conversion_rate is 1, then 1 USD = 1 credit ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits

