PlandalfDocsSign inStart free trial

Affiliates

Track sales from any platform

If customers pay somewhere Plandalf can't see, your server tells Plandalf about each sale. Plandalf matches it to the partner, works out the commission and handles it like any other sale.

How it works

  1. Create an API key

    Go to Settings → API Keys and create a key. Keep it on your server, never in the browser. See Host and API keys.

  2. Keep the referral with each order

    The Plandalf script on your site saves the partner a visitor came from in a cookie called pf_rt. Its value starts with rt_. Read it when the customer checks out and store it with the order. If you only have the partner's code, send that as code instead.

  3. Send each paid sale

    When a payment succeeds, post it to Plandalf (below).

  4. Send refunds

    When you refund, post that too, and the partner's commission goes down to match.

The same steps are in the app: Affiliates → Settings → General → Track sales from your own server → How to track sales.

Send a sale

curl -X POST https://admin.plandalf.dev/api/v1/affiliate/sales \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source": "my-billing",
    "external_id": "inv_1001",
    "currency": "USD",
    "amount_cents": 4900,
    "referral_token": "rt_FROM_THE_PF_RT_COOKIE",
    "customer": { "email": "buyer@example.com" }
  }'
  • source names where the sale came from. Use the same value every time.
  • external_id is your ID for the payment. Sending the same one twice is safe; Plandalf counts it once.
  • amount_cents is the amount paid, in cents.
  • For subscriptions, add subscription_id, and "billing_reason": "renewal" on renewals, so your renewal rules apply.
  • Add "test": true while you try it out. Test sales stay out of real payouts.

Plandalf answers 201 for a new sale and 200 for one it already had.

Send a refund

curl -X POST https://admin.plandalf.dev/api/v1/affiliate/refunds \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source": "my-billing",
    "sale_external_id": "inv_1001",
    "external_id": "refund_77",
    "amount_cents": 4900
  }'

sale_external_id is the external_id of the original sale.

Credits and disputes

The API also takes credit notes and disputes, so commissions follow what happened to the payment. An open dispute holds the commission; a lost one reverses it.

EndpointSend it when
POST /api/v1/affiliate/salesA payment succeeds
POST /api/v1/affiliate/refundsYou refund a payment
POST /api/v1/affiliate/creditsYou issue a credit note
POST /api/v1/affiliate/disputesA customer disputes a payment
POST /api/v1/affiliate/disputes/{external_id}/won, /lost, /warning_closedThe dispute is settled

Every field, response and error is in the Affiliate sales API reference. Send an Idempotency-Key header to make retries safe. occurred_at must be within the last 30 days.

Check it works

Open your test link from Affiliates → Setup in a private window, read the pf_rt cookie, and send a sale with that token and "test": true. Turn on Test mode in the Affiliates header and look for it under Sales.