import { Autumn } from 'autumn-js'
const autumn = new Autumn()
const result = await autumn.referrals.createProgram({
id: "refer_a_friend",
rewardId: "beta_credits_grant",
redeemOn: "customer_creation",
receivedBy: "referrer",
maxRedemptions: 10,
planIds: null,
excludeTrial: false,
});from autumn_sdk import Autumn
autumn = Autumn(secret_key="am_sk_test...")
res = autumn.referrals.create_program(
id="refer_a_friend",
reward_id="beta_credits_grant",
redeem_on="customer_creation",
received_by="referrer",
max_redemptions=10,
plan_ids=None,
exclude_trial=False,
)curl --request POST \
--url https://api.useautumn.com/v1/referral_programs.create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-api-version: <x-api-version>' \
--data '
{
"id": "refer_a_friend",
"reward_id": "beta_credits_grant",
"redeem_on": "customer_creation",
"received_by": "referrer",
"max_redemptions": 10,
"plan_ids": null,
"exclude_trial": false,
"created_at": 1718000000000
}
'{
"id": "refer_a_friend",
"reward_id": "beta_credits_grant",
"redeem_on": "customer_creation",
"received_by": "referrer",
"max_redemptions": 10,
"plan_ids": null,
"exclude_trial": false,
"created_at": 1718000000000
}
Create Referral Program
Create a referral program linked to an existing reward.
import { Autumn } from 'autumn-js'
const autumn = new Autumn()
const result = await autumn.referrals.createProgram({
id: "refer_a_friend",
rewardId: "beta_credits_grant",
redeemOn: "customer_creation",
receivedBy: "referrer",
maxRedemptions: 10,
planIds: null,
excludeTrial: false,
});from autumn_sdk import Autumn
autumn = Autumn(secret_key="am_sk_test...")
res = autumn.referrals.create_program(
id="refer_a_friend",
reward_id="beta_credits_grant",
redeem_on="customer_creation",
received_by="referrer",
max_redemptions=10,
plan_ids=None,
exclude_trial=False,
)curl --request POST \
--url https://api.useautumn.com/v1/referral_programs.create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-api-version: <x-api-version>' \
--data '
{
"id": "refer_a_friend",
"reward_id": "beta_credits_grant",
"redeem_on": "customer_creation",
"received_by": "referrer",
"max_redemptions": 10,
"plan_ids": null,
"exclude_trial": false,
"created_at": 1718000000000
}
'{
"id": "refer_a_friend",
"reward_id": "beta_credits_grant",
"redeem_on": "customer_creation",
"received_by": "referrer",
"max_redemptions": 10,
"plan_ids": null,
"exclude_trial": false,
"created_at": 1718000000000
}
Body Parameters
Response
{
"id": "refer_a_friend",
"reward_id": "beta_credits_grant",
"redeem_on": "customer_creation",
"received_by": "referrer",
"max_redemptions": 10,
"plan_ids": null,
"exclude_trial": false,
"created_at": 1718000000000
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Body
11When the reward is granted: on redemption, or when the redeemer checks out.
customer_creation, checkout Who receives the reward: the referrer only, or both parties.
referrer, all A positive redemption limit, or null for unlimited redemptions.
0 < x <= 9007199254740991Required when redeem_on is checkout. Plan IDs must be unique.
1Whether checkouts that start a trial should skip granting the reward.
Address an existing referral program by its stable id. Omit when creating — the server generates one.
1Response
OK
The unique identifier for the referral program.
The ID of the reward granted when a code is redeemed.
When the reward is granted: on redemption, or when the redeemer checks out.
customer_creation, checkout Who receives the reward: the referrer only, or both parties.
referrer, all The Unix timestamp (in milliseconds) when the referral program was created.
The maximum number of times a referral code can be redeemed.
The plans whose checkout triggers the reward. Only used when redeem_on is checkout.
Whether checkouts that start a trial should skip granting the reward.