cURL
curl --request POST 'https://api.integrateledger.com/v1/referral-programs' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"id":"friends","name":"Refer a friend","referrerRewardId":"welcome","refereeRewardId":"launch20","trigger":"first_payment","maxRewardsPerReferrer":10}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.writeReferralProgram({ body: { id: "friends", name: "Refer a friend", referrerRewardId: "welcome", refereeRewardId: "launch20", trigger: "first_payment", maxRewardsPerReferrer: 10 } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.write_referral_program({"id": "friends", "name": "Refer a friend", "referrerRewardId": "welcome", "refereeRewardId": "launch20", "trigger": "first_payment"}){
"item": {
"id": "<string>",
"name": "<string>",
"referrerRewardId": "<string>",
"refereeRewardId": "<string>",
"trigger": "signup",
"planIds": [
"<string>"
],
"maxRewardsPerReferrer": 123,
"archived": true
},
"changed": true
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "insufficient_permissions",
"requiredScope": "customers:read",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "payload_too_large",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "rate_limited",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}Rewards
Create or update a referral program
Name a reward for the referrer, and one for the new customer.
POST
/
v1
/
referral-programs
cURL
curl --request POST 'https://api.integrateledger.com/v1/referral-programs' \
-H "Authorization: Bearer $LEDGER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"id":"friends","name":"Refer a friend","referrerRewardId":"welcome","refereeRewardId":"launch20","trigger":"first_payment","maxRewardsPerReferrer":10}'import ledger from "integrateledger";
const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });
await client.writeReferralProgram({ body: { id: "friends", name: "Refer a friend", referrerRewardId: "welcome", refereeRewardId: "launch20", trigger: "first_payment", maxRewardsPerReferrer: 10 } });import os
from integrateledger import ledger
client = ledger(api_key=os.environ["LEDGER_API_KEY"])
client.write_referral_program({"id": "friends", "name": "Refer a friend", "referrerRewardId": "welcome", "refereeRewardId": "launch20", "trigger": "first_payment"}){
"item": {
"id": "<string>",
"name": "<string>",
"referrerRewardId": "<string>",
"refereeRewardId": "<string>",
"trigger": "signup",
"planIds": [
"<string>"
],
"maxRewardsPerReferrer": 123,
"archived": true
},
"changed": true
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "<string>",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment.",
"issues": [
{
"path": "<string>",
"message": "<string>"
}
]
}{
"error": "insufficient_permissions",
"requiredScope": "customers:read",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "payload_too_large",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}{
"error": "rate_limited",
"message": "No customer \"user_123\" exists in this environment. Create it with POST /v1/customers, or check that the API key is for the right environment."
}Creates or updates one referral program, in the catalog’s shape. Its rewards must be active rewards of the environment (
unknown_reward). A change applies to referrals from then on; referrals already rewarded keep what they got. The catalog’s referralPrograms writes the same programs. Needs the Catalog permission at Write.Authorizations
Body
application/json