Skip to content

Refenue API

Use the REST API to report signups and payments from your own backend, manage partners and commissions, and read payouts. Use webhooks to hear about changes as they happen.

Every example below was run against a test-mode program. Responses are real, with long lists shortened.

Basics

Base URL

https://app.refenue.co/api/v1

Authentication

Create a secret key in Developers > API keys. Send it as a bearer token:

curl https://app.refenue.co/api/v1/partners \
  -H "Authorization: Bearer rfn_test_..."

Keys are shown once, when you create them. Refenue stores only a hash. Keep keys on your server; never put them in a browser or mobile app (the tracking script uses the separate public key pk_...).

A missing, wrong or revoked key gets 401:

{"error":{"code":"unauthorized","message":"Send your secret key as: Authorization: Bearer rfn_test_..."}}

Test and live mode

A key belongs to one mode. rfn_test_... keys see and create test data only, and rfn_live_... keys live data only. Every customer, sale, commission and payout has livemode. Partners belong to the program, so both modes see them.

Money

Amounts are integers in the currency's minor unit: 4900 with "usd" is $49.00. Currencies are lowercase ISO codes; the API accepts either case.

IDs

IDs have a prefix that says what they are: ptn_ partner, cst_ customer, sale_ sale, com_ commission, pay_ payout, run_ payout run, grp_ partner group. An ID from another program, or from the other mode, is 404.

Errors

Errors have an HTTP status and a body with a stable code and a message you can show or log:

{"error":{"code":"invalid_request","message":"amount is required and must be a number."}}
StatuscodeWhen
400invalid_requestA field is missing or wrong, or the change isn't allowed
401unauthorizedMissing, wrong or revoked key
404not_foundNo such object, or no such route
409conflictIt already exists (e.g. the link name is taken)
429rate_limitedToo many requests; wait for Retry-After seconds
500internal_errorOur fault. Retry with the same Idempotency-Key

Pagination

List endpoints return the newest first:

{"object":"list","data":[...],"has_more":true,"next_cursor":"2"}

Pass limit (1 to 100, default 25) and, for the next page, cursor set to the previous next_cursor:

curl "https://app.refenue.co/api/v1/partners?limit=2&cursor=2" \
  -H "Authorization: Bearer rfn_test_..."

Idempotency

Send an Idempotency-Key header on a POST to retry it safely. A repeat within 24 hours returns the first response, with the header Idempotent-Replayed: true, and changes nothing. Keys are per API key; use a UUID or your own record's ID.

curl -X POST https://app.refenue.co/api/v1/partners \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: partner-signup-8812" \
  -d '{"name":"Docs Partner","email":"docs.partner@example.com","link_slug":"docs-partner"}'

Sales are also deduplicated by charge_id, with or without the header.

Rate limits

600 requests a minute per key. Over that you get 429 and a Retry-After header in seconds.

Partners

The partner object

{
  "object": "partner",
  "id": "ptn_jn7fb8199nthpgd3gk04s0dc358jze72",
  "name": "Docs Partner",
  "email": "docs.partner@example.com",
  "status": "active",
  "group_id": "grp_kx72mxfff5phv2cp2np83ztwbx8jxp03",
  "link_slug": "docs-partner",
  "link": "https://example.com/?via=docs-partner",
  "created_at": "2026-11-26T00:54:55.405Z"
}

status is active, pending (applied, not yet approved), paused, banned or declined.

List partners

GET /partners, filtered with status.

curl "https://app.refenue.co/api/v1/partners?status=active" \
  -H "Authorization: Bearer rfn_test_..."

Create a partner

POST /partners

FieldRequired
nameyes
emailyesThey sign in to the partner portal with it
link_slugnoAppears in their link (?via=...). Made from the name if left out
group_idnoDefaults to the program's default group
send_invitenotrue emails them a portal invite. Default false
curl -X POST https://app.refenue.co/api/v1/partners \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -d '{"name":"Docs Partner","email":"docs.partner@example.com","link_slug":"docs-partner"}'

Returns 201 with the partner. A partner who is already in the program is 409.

Get a partner

GET /partners/:id

curl https://app.refenue.co/api/v1/partners/ptn_jn7fb8199nthpgd3gk04s0dc358jze72 \
  -H "Authorization: Bearer rfn_test_..."

Update a partner

PATCH /partners/:id with any of name, status (active, paused or banned) and group_id.

curl -X PATCH https://app.refenue.co/api/v1/partners/ptn_jn7fb8199nthpgd3gk04s0dc358jze72 \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -d '{"name":"Docs Partner Co"}'

Customers and leads

A customer is someone a partner referred. They start as a lead when they sign up and become a customer at their first payment.

The customer object

{
  "object": "customer",
  "id": "cst_jh7dhs59ay9a6m8awcmrnpra998jywr9",
  "email": "buyer.docs@example.com",
  "external_id": "user_123",
  "partner_id": "ptn_jn7fb8199nthpgd3gk04s0dc358jze72",
  "status": "lead",
  "stripe_customer_id": null,
  "polar_customer_id": null,
  "first_sale_at": null,
  "livemode": false,
  "created_at": "2026-11-26T00:54:57.853Z"
}

Create a lead

POST /leads. Use this instead of refenue.signup() in the browser when you record signups on your server. It needs to know who referred them, from one of:

Field
click_idwindow.refenue.referral from the browser, sent to your server with the signup
partner_idWhen you already know the partner (e.g. a coupon code you mapped to them)

and these:

FieldRequired
emailyesUsed to match payments later
external_idnoYour user ID. Lets you report sales by it
curl -X POST https://app.refenue.co/api/v1/leads \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -d '{"email":"buyer.docs@example.com","external_id":"user_123","partner_id":"ptn_jn7fb8199nthpgd3gk04s0dc358jze72"}'

Returns 201 with the customer, or 200 with the existing one if that email was already referred (the first partner keeps the credit).

List customers

GET /customers, filtered with partner_id, email or status (lead or customer).

curl "https://app.refenue.co/api/v1/customers?partner_id=ptn_jn7fb8199nthpgd3gk04s0dc358jze72" \
  -H "Authorization: Bearer rfn_test_..."

Sales and refunds

If you take payments with Stripe and connected it in Developers, Refenue records sales and refunds on its own; you don't need these endpoints. Use them for other billing systems (Paddle, Lemon Squeezy, Polar, invoices, your own).

Report a sale

POST /sales. Identify the referred customer with one of customer_id, email or external_id.

FieldRequired
amountyesWhat they paid, in minor units, after discounts and before tax
currencyyes
charge_idyesYour payment or invoice ID. A repeat is ignored
occurred_atnoISO 8601. Defaults to now
product_idsnoFor product-specific commission rules
curl -X POST https://app.refenue.co/api/v1/sales \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -d '{"email":"buyer.docs@example.com","amount":4900,"currency":"usd","charge_id":"inv_docs_1"}'

Returns 201 with the sale and the commission it earned (null when the rules give none, e.g. after a one-time commission was already paid):

{
  "sale": {
    "object": "sale",
    "id": "sale_k978ad2sh4zvztyegbtag4gn4d8jy8jt",
    "customer_id": "cst_jh7dhs59ay9a6m8awcmrnpra998jywr9",
    "partner_id": "ptn_jn7fb8199nthpgd3gk04s0dc358jze72",
    "provider": "api",
    "charge_id": "inv_docs_1",
    "amount": 4900,
    "refunded_amount": 0,
    "currency": "usd",
    "product_ids": [],
    "livemode": false,
    "occurred_at": "2026-11-26T00:54:58.796Z"
  },
  "commission": {
    "object": "commission",
    "id": "com_kn75mtet3we6zxsm02hmm6w4ys8jyqw8",
    "kind": "sale",
    "amount": 1470,
    "status": "held",
    "payable_at": "2026-12-26T00:54:58.796Z",
    "...": "see the commission object"
  }
}

Sending the same charge_id again returns 200 with the original sale and "commission": null, and creates nothing. A sale for someone who wasn't referred is 404:

{"error":{"code":"not_found","message":"No referred customer matches. Create a lead first; customers who weren't referred aren't attributed."}}

Refund a sale

POST /sales/:id/refund with amount_refunded: the total refunded so far, not the amount of this refund. Sending the same total twice changes nothing.

curl -X POST https://app.refenue.co/api/v1/sales/sale_k9787j8ehxn48cpb2v9mawgzc58jy75r/refund \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -d '{"amount_refunded":4950}'

Returns the sale. Its commission is reduced in step: a full refund reverses a commission that hasn't been paid; a partial refund, or any refund after the commission was paid, adds a negative adjustment commission that comes off the partner's next payout.

Commissions

The commission object

{
  "object": "commission",
  "id": "com_kn7fv6g5r88hg39sspqc11jqes8jzhjw",
  "kind": "adjustment",
  "amount": -1485,
  "currency": "usd",
  "status": "held",
  "partner_id": "ptn_jn7fb8199nthpgd3gk04s0dc358jze72",
  "customer_id": "cst_jh7dhs59ay9a6m8awcmrnpra998jywr9",
  "sale_id": "sale_k9787j8ehxn48cpb2v9mawgzc58jy75r",
  "parent_id": "com_kn7fx2hcst9xzkq3ses6t2rnen8jz3rb",
  "payout_id": null,
  "note": "Partial refund.",
  "livemode": false,
  "payable_at": "2026-12-26T00:56:37.941Z",
  "created_at": "2026-11-26T00:56:38.950Z"
}
kind
saleEarned from a payment
bonusAdded by hand or through the API
adjustmentA correction to parent_id, usually negative after a refund
status
heldFlagged for review (e.g. self-referral). Needs approval
pendingWaiting out the hold period until payable_at
approvedWill be in the next payout run
paidPaid in payout_id
rejectedRejected in review; never paid
reversedUndone by a full refund before it was paid

List commissions

GET /commissions, filtered with status and partner_id.

curl "https://app.refenue.co/api/v1/commissions?partner_id=ptn_jn7fb8199nthpgd3gk04s0dc358jze72" \
  -H "Authorization: Bearer rfn_test_..."

Add a commission

POST /commissions adds a commission that is approved right away: a bonus, or with a negative amount an adjustment that takes money back.

FieldRequired
partner_idyes
amountyesMinor units of the program's currency
noteyesShown to the partner
curl -X POST https://app.refenue.co/api/v1/commissions \
  -H "Authorization: Bearer rfn_test_..." \
  -H "Content-Type: application/json" \
  -d '{"partner_id":"ptn_jn7fb8199nthpgd3gk04s0dc358jze72","amount":2500,"note":"Launch bonus"}'

Approve or reject a held commission

POST /commissions/:id/approve moves a held commission on: to approved, or to pending if its hold period hasn't ended. POST /commissions/:id/reject rejects a held or pending one, along with its adjustments.

curl -X POST https://app.refenue.co/api/v1/commissions/com_kn75mtet3we6zxsm02hmm6w4ys8jyqw8/approve \
  -H "Authorization: Bearer rfn_test_..."

Any other status is 400:

{"error":{"code":"invalid_request","message":"Only held commissions need approval."}}

Payouts

Payouts are created by payout runs in the dashboard. The API reads them.

List payouts

GET /payouts, filtered with status (pending, paid or failed) and partner_id.

curl "https://app.refenue.co/api/v1/payouts?limit=1" \
  -H "Authorization: Bearer rfn_test_..."
{
  "object": "list",
  "data": [
    {
      "object": "payout",
      "id": "pay_md73yna0p5q6d4y7wvtkvpm7658jzkk6",
      "run_id": "run_m97cade8657bp8hnq0vczxtrms8jyxap",
      "partner_id": "ptn_jn72gbjrdaaaj1y4tdcx4acftd8jw2xe",
      "amount": 5250,
      "currency": "usd",
      "method": "paypal",
      "status": "paid",
      "failure_reason": null,
      "livemode": false,
      "paid_at": "2026-11-26T00:24:21.972Z",
      "created_at": "2026-11-26T00:23:51.034Z"
    }
  ],
  "has_more": true,
  "next_cursor": "1"
}

Webhooks

Add endpoints in Developers > Webhooks, separately for test and live mode. Each endpoint gets every event, or only the types you pick.

Events

Typedata is aWhen
partner.createdpartnerA partner is added, or applies
partner.approvedpartnerAn application is approved
lead.createdcustomerA referred visitor signs up
customer.createdcustomerA lead makes their first payment
sale.createdsaleA referred customer pays
sale.refundedsaleA sale is refunded, fully or in part
commission.createdcommissionA commission or adjustment is created
commission.approvedcommissionA commission becomes payable
commission.reversedcommissionA commission is reversed by a refund
payout.paidpayoutA payout run is marked paid

Partners belong to the program, not a mode, so partner events go to both your test and live endpoints. Send test on an endpoint sends a ping event.

Payload

Refenue sends a POST with a JSON body:

{
  "id": "evt_h3589n5xcram4frtz7n11p3i",
  "object": "event",
  "type": "commission.created",
  "livemode": false,
  "created_at": "2026-11-26T00:56:39.908Z",
  "data": {
    "object": "commission",
    "id": "com_kn798wk6yjbvasqp3qjvvb66gx8jyare",
    "kind": "bonus",
    "amount": 2500,
    "status": "approved",
    "...": "the full object, as the API returns it"
  }
}

Headers:

Header
Refenue-Signaturet=<unix seconds>,v1=<signature>
Refenue-Event-IdThe event's id. The same event can arrive more than once; skip IDs you've handled

Respond with any 2xx within 10 seconds. Anything else, or no answer, is retried after 30 seconds, 2 minutes, 10 minutes, 1, 3, 6 and 12 hours, then marked failed. The endpoint's delivery log shows each attempt, and Resend sends one again.

Verify the signature

The signature is a hex HMAC-SHA256 of <t>.<raw body>, keyed with the endpoint's signing secret (rfnwh_..., from Signing secret). Check it against the raw body, before parsing, and reject old timestamps:

import crypto from "node:crypto";

export function verifyRefenue(rawBody, header, secret, toleranceSeconds = 300) {
  const parts = Object.fromEntries(
    (header ?? "").split(",").map((p) => p.split("=", 2)),
  );
  const t = Number(parts.t);
  if (!t || !parts.v1) return false;
  if (Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(parts.v1);
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

// Express: keep the raw body for verification.
app.post("/webhooks/refenue", express.raw({ type: "application/json" }), (req, res) => {
  const raw = req.body.toString("utf8");
  if (!verifyRefenue(raw, req.get("Refenue-Signature"), process.env.REFENUE_WEBHOOK_SECRET)) {
    return res.sendStatus(400);
  }
  const event = JSON.parse(raw);
  // ...handle event.type
  res.sendStatus(200);
});

The format is the same as Stripe's, so a Stripe signature helper works if you point it at the Refenue-Signature header.