Skip to main content

Referrals API

Referrals endpoints exposed by the Devotel CPaaS API Base path: /api/v1/referrals/programs Endpoint count: 11

List referral programs

GET /api/v1/referrals/programs
List every referral program in your workspace — including disabled ones — with its reward type, reward configs, referral window, and enabled flag. Use this to page through programs before drilling into one by id.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Get a referral program

GET /api/v1/referrals/programs/{id}
Fetch a single referral program by id — its reward type, reward configs, target URL, referral window, and enabled flag. Returns 404 when no program with that id exists in your workspace.
string
required
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

List referral conversions

GET /api/v1/referrals/programs/{id}/conversions
Page through a program’s recorded conversions — the referral of a contact’s signup. Each row carries the referrer and referee contact ids, human-readable identity labels for both sides, the reward status (pending, paid, rejected), and the rejection reason when rejected. Filter by status and page with limit (default 25, max 100) and offset. Returns the rows with the total count, limit, and offset.
string
required
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Get the referral leaderboard

GET /api/v1/referrals/programs/{id}/leaderboard
Return the top referrers of a program as a ranked leaderboard of referral codes — visits, signups, and paid rewards per code, with a human-readable referrer label alongside the contact id. The limit query parameter (default 25, max 100) caps the page size. To aggregate over the whole program rather than the truncated top page, use GET /programs/{id}/totals.
string
required
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Get program-wide referral totals

GET /api/v1/referrals/programs/{id}/totals
Aggregate referral totals over EVERY referral code in a program — distinct referrer count, total signups, and total paid rewards — with no leaderboard page-size limit. Use it for detail-page stat cards where summing the top-N leaderboard would undercount.
string
required
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Count referral programs

GET /api/v1/referrals/programs/count
Return just the total number of referral programs in your workspace ({ total }). Use it for dashboard badges and count cards without downloading the full program list.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Create a referral program

POST /api/v1/referrals/programs
Create a referral program for your workspace’s contacts. A program defines the reward type (credit, discount_code, or custom), the human-readable reward_value label, and the optional per-side reward configs (referrer_reward, referee_reward). A credit reward pays into your wallet balance when a conversion is marked paid; discount and custom rewards go through the shared incentive engine. Optionally set a target_url to send referred visitors to a landing page other than your signup, and a start_at / end_at window to bound when referrals convert. Programs are created enabled unless you pass enabled: false. Returns the created program. Requires the owner, admin, or developer role.
string
Stripe-style idempotency token. Pass a stable, client-generated value (1-255 chars) to dedupe retries on transient timeouts. The same key+credential+path replays the original response for 24h on 2xx (5min on 4xx, 30s on 5xx). Returns 409 if a concurrent request with the same key is already in flight; replayed responses include the Idempotency-Replay: true response header.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Issue a referral code

POST /api/v1/referrals/programs/{id}/codes
Mint a referral code for one of your contacts in the given program — or return the contact’s existing code when one was already issued. Each code tracks its own visits, signups, and paid rewards, and referral links resolve through the public /r/:code redirect. Returns 404 when the program does not exist. Requires the owner, admin, or developer role.
string
required
string
Stripe-style idempotency token. Pass a stable, client-generated value (1-255 chars) to dedupe retries on transient timeouts. The same key+credential+path replays the original response for 24h on 2xx (5min on 4xx, 30s on 5xx). Returns 409 if a concurrent request with the same key is already in flight; replayed responses include the Idempotency-Replay: true response header.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Pay a referral reward

POST /api/v1/referrals/programs/{id}/conversions/{conversionId}/pay
Mark a pending conversion as paid and fulfill its reward. The update is scoped by the program id, so a conversion from another program is never paid through this endpoint — a 404 is returned instead. For credit programs the reward pays into your wallet balance; for discount_code programs a redeemable code is minted and returned; for custom programs a tracked payout is recorded. The returned conversion carries a fulfillments array with each reward’s provider and delivery status. Requires the owner, admin, or developer role.
string
required
string
required
string
Stripe-style idempotency token. Pass a stable, client-generated value (1-255 chars) to dedupe retries on transient timeouts. The same key+credential+path replays the original response for 24h on 2xx (5min on 4xx, 30s on 5xx). Returns 409 if a concurrent request with the same key is already in flight; replayed responses include the Idempotency-Replay: true response header.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Update a referral program

PUT /api/v1/referrals/programs/{id}
Update a referral program by id. The body is a partial program — send only the fields you want to change (name, reward_type, reward_value, per-side reward configs, enabled, target_url, start_at, end_at). Returns the updated program, or 404 when no program with that id exists. Requires the owner, admin, or developer role.
string
required
string
Stripe-style idempotency token. Pass a stable, client-generated value (1-255 chars) to dedupe retries on transient timeouts. The same key+credential+path replays the original response for 24h on 2xx (5min on 4xx, 30s on 5xx). Returns 409 if a concurrent request with the same key is already in flight; replayed responses include the Idempotency-Replay: true response header.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Delete a referral program

DELETE /api/v1/referrals/programs/{id}
Delete a referral program by id, removing its issued referral codes and recorded conversions. Returns 204 on success and 404 when no program with that id exists. Requires the owner, admin, or developer role.
string
required
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.