Integrations

One REST API over the whole program

One REST API over every object in your program, from partners and links to commissions, payouts and webhook endpoints. Whatever the dashboard shows, the API can read, and the daily work can be written. Typed clients are generated from the OpenAPI document. It is on every plan, the trial included.

Published 3 September 2026. Every claim on this page was read off the documentation linked below on 3 September 2026. Written by Jimi Barkway, who built AffiliateRail. Jimi has run affiliate programs from both sides of the link. Corrections go to support@affiliaterail.com.

A request and a responseYour code sends a request with a bearer key. AffiliateRail answers with an integer amount in minor units and the currency beside it. The coin sits where the money is.Your codeGET /v1/commissionsAffiliateRailone contract, every objectBearer rail_live_…amount_minor: 4999, currency: USDAInteger money, a currency in hand, one shape for every list.Never a float, never a string. A build test walks every endpoint.

01 The contract

What can the API do?

Read everything the dashboard shows. Write the daily work: add partners, record sales, approve commissions, mark payouts paid. Keys are minted under Settings, API keys, and carry scopes. A test key sees the same organisation and stamps every response with X-Rail-Livemode: false.

Lists are flat and paged. Money is an integer in minor units with a currency beside it, never a float. An id from another organisation is a 404, never a 403, so ids cannot be probed.

The AffiliateRail dashboard: referrals, commissions and payouts for one program
Whatever the dashboard shows, the API can read.

02 Typed clients

How do I get a typed client?

Generate one from the OpenAPI document the API publishes. The pairing we use ourselves is openapi-typescript for the types and openapi-fetch for the calls: one .d.ts file, no other codegen. Every path, parameter and response is typed from the same document the reference renders, so your compiler and the docs cannot disagree.

Any OpenAPI 3.1 toolchain does the same for other languages. Additive changes never break existing calls.

npm install openapi-fetch
npm install -D openapi-typescript
npx openapi-typescript \
  https://api.affiliaterail.com/v1/openapi.json \
  -o rail-api.d.ts

# then, in TypeScript
const rail = createClient<paths>({
  baseUrl: "https://api.affiliaterail.com",
  headers: { Authorization: `Bearer ${process.env.RAIL_API_KEY}` },
});
const { data } = await rail.GET("/v1/partners", {
  params: { query: { program_id: "prg_...", limit: 5 } },
});
A typed client in three commands. Rerun the third to pick up new endpoints.

03 Safety

What keeps a retry safe?

An Idempotency-Key header on any POST replays the first response for 24 hours. The same key with a different body is a 422. The same key while the first request is still running is a 409 with Retry-After, so a racing retry cannot run the work twice.

Every key may make 25 requests a second, with the limit reported on every response. Errors are one shape, with the parameter named. Every response carries X-Rail-Version, and additive changes never bump it.

Three headers to know

  • Idempotency-Key

    Replays the first response for 24 hours. A different body under the same key is a 422.

  • X-RateLimit-Remaining

    25 a second per key. Past it, a 429 with Retry-After.

  • X-Rail-Version

    A date. Additive changes never bump it.

Step by step

A first call in four steps

API access is part of every plan, the free trial included.

  1. Mint a key

    Settings, API keys. Name it after what will hold it and pick the narrowest scopes. It is shown once.

  2. Make a first call

    List your partners with a bearer header. The response is data, has_more and total_count, flat, every time.

  3. Generate the client

    npx openapi-typescript against the published OpenAPI document. Rerun it whenever you want new endpoints.

  4. Point your assistant at the contract

    llms.txt and llms-full.txt carry every route, parameter and schema as plain text. For your data rather than the API's shape, use the MCP server.

Said plainly

What it does, and does not do

Both lists are read off the same docs pages as everything else here.

It does

  • Covers every object

    Programs, partners, customers, sales, commissions, payouts, flows, webhook endpoints, reports.

  • Returns money as integers

    Minor units in _minor fields with a currency. Rates in basis points. A build test walks every endpoint to keep it so.

  • Tells you what a write did

    POST /v1/sales answers commission_created or sale_recorded, with warnings when nobody was paid.

  • Returns the existing record on a duplicate

    A 409 with the partner you collided with under existing, so you can link records without a second request.

  • Answers comparison periods in one request

    GET /v1/reports returns the previous window and the delta beside the current one.

It does not

  • Expose tax forms

    Status only. The form itself never travels over an API key.

  • Ship a hand-written SDK

    The typed client is generated from the OpenAPI document, so it cannot drift from the running product.

  • Let one organisation see another

    A foreign id is a 404, the same as one that never existed.

  • Bump the version for additive changes

    New fields, endpoints and enum values arrive under the same X-Rail-Version.

Questions

Common questions

Is the API on every plan?

Yes, the free trial included. Keys are minted under Settings, API keys, and carry scopes.

Is there an SDK?

A typed TypeScript client is generated from the OpenAPI document with openapi-typescript and openapi-fetch. Any OpenAPI 3.1 toolchain does the same for other languages.

How is money represented?

As an integer in minor units in a field ending _minor, with a currency beside it. Rates are basis points. Never a float, never a string.

What is the rate limit?

25 requests a second per key, as a token bucket. Past it, a 429 with Retry-After. A busy integration can have a key of its own.

Sources

Where these facts come from

Every claim on this page was read off the product's own documentation on the date shown. The docs change with the product, and then this page is behind until we fix it. Email support@affiliaterail.com and we will correct it and move the date.

Start

Fourteen days to see it work, with nothing on the line

No card. Cancel in one click. Full refund within 30 days of your first payment.