AffiliateRail Sales API
The Sales API from AffiliateRail — 3 operation(s) for sales.
The Sales API from AffiliateRail — 3 operation(s) for sales.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/affiliaterail-com:affiliaterail-com-sales-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Affiliaterail Com Sales API
version: '2026-08-21'
description: 'Operations tagged Sales across 2 of this provider''s published API definitions: affiliaterail-com-docs-openapi.json, affiliaterail-com-openapi.json. Each path carries the servers of the definition it was published in.'
servers:
- url: https://api.affiliaterail.com
description: Production
tags:
- name: Sales
paths:
/v1/sales:
get:
tags:
- Sales
summary: List sales
description: '**Scope:** `read`'
security:
- bearerAuth: []
parameters:
- schema:
type: string
example: prg_7uSyy9FqVLCFWrdPeZaK
description: Required on every list
required: true
description: Required on every list
name: program_id
in: query
- schema:
type: string
example: '25'
description: 1 to 100, default 25
required: false
description: 1 to 100, default 25
name: limit
in: query
- schema:
type: string
description: Object id; returns the page after it (older)
required: false
description: Object id; returns the page after it (older)
name: starting_after
in: query
- schema:
type: string
description: Object id; returns the page before it (newer)
required: false
description: Object id; returns the page before it (newer)
name: ending_before
in: query
- schema:
anyOf:
- type: string
- type: array
items:
type: string
description: 'Relations to embed: partner, customer'
required: false
description: 'Relations to embed: partner, customer'
name: expand[]
in: query
- schema:
anyOf:
- type: string
- type: array
items:
type: string
description: Nothing to include on this resource
required: false
description: Nothing to include on this resource
name: include[]
in: query
- schema:
type: string
required: false
name: partner_id
in: query
- schema:
type: string
required: false
name: customer_id
in: query
- schema:
type: string
required: false
name: occurred_after
in: query
- schema:
type: string
required: false
name: occurred_before
in: query
- schema:
type: string
enum:
- 'true'
- 'false'
required: false
name: refunded
in: query
responses:
'200':
description: Sales
content:
application/json:
schema:
$ref: '#/components/schemas/SaleList'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Missing or unknown API key
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Key lacks the required scope
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: No such object in your organization
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: The request was understood and refused
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: 'Rate limited: see Retry-After'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
operationId: getV1Sales
x-operation-id-source: derived
post:
tags:
- Sales
summary: Record a sale
description: 'Charge -> sale -> commission -> balance, atomically, through the same writer the processor webhooks use. Idempotent on `external_charge_id`: sending the same charge twice returns the same sale with a 200 instead of a 201. `amount_minor` is gross; tax is subtracted before the rate when the program commissions on net revenue. The response says explicitly whether money followed: `activity_outcome` is `commission_created` or `sale_recorded`, and a sale that paid nobody carries machine-readable `warnings` instead of failing the call. Customer auto-enrol runs on processor webhooks, not on this endpoint. Charge ids are unique per program, so another program using the same id never affects yours. A charge id already recorded in your program in the other mode (a test-mode id sent with a live key, or the reverse) answers 409 `external_charge_id_taken` with no sale fields.
**Scope:** `commissions:write` (or `write`)'
security:
- bearerAuth: []
requestBody:
description: ''
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SaleCreate'
responses:
'200':
description: 'Already recorded: the existing sale'
content:
application/json:
schema:
$ref: '#/components/schemas/SaleWithOutcome'
'201':
description: The new sale
content:
application/json:
schema:
$ref: '#/components/schemas/SaleWithOutcome'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Missing or unknown API key
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Key lacks the required scope
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: No such object in your organization
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: 'external_charge_id_taken: the charge id is recorded in your program in the other mode'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: The request was understood and refused
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: 'Rate limited: see Retry-After'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
operationId: postV1Sales
x-operation-id-source: derived
servers:
- url: https://api.affiliaterail.com
description: Production
/v1/sales/{id}:
get:
tags:
- Sales
summary: Retrieve a sale
description: '**Scope:** `read`'
security:
- bearerAuth: []
parameters:
- schema:
type: string
pattern: ^(sample_)?sale_
example: sale_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`sale_…`)
required: true
description: Prefixed id (`sale_…`)
name: id
in: path
- schema:
anyOf:
- type: string
- type: array
items:
type: string
description: 'Relations to embed: partner, customer'
required: false
description: 'Relations to embed: partner, customer'
name: expand[]
in: query
- schema:
anyOf:
- type: string
- type: array
items:
type: string
description: Nothing to include on this resource
required: false
description: Nothing to include on this resource
name: include[]
in: query
responses:
'200':
description: The sale
content:
application/json:
schema:
$ref: '#/components/schemas/Sale'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Missing or unknown API key
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Key lacks the required scope
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: No such object in your organization
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: The request was understood and refused
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: 'Rate limited: see Retry-After'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
operationId: getV1SalesById
x-operation-id-source: derived
servers:
- url: https://api.affiliaterail.com
description: Production
/v1/sales/{id}/refund:
post:
tags:
- Sales
summary: Refund a sale
description: 'Voids the sale''s unpaid commissions; an already-paid commission becomes a clawback against the partner''s next balance. Replay-safe: refunding twice is a no-op.
**Scope:** `commissions:write` (or `write`)'
security:
- bearerAuth: []
parameters:
- schema:
type: string
pattern: ^(sample_)?sale_
example: sale_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`sale_…`)
required: true
description: Prefixed id (`sale_…`)
name: id
in: path
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
refunded_at:
type: string
format: date-time
reason:
type: string
responses:
'200':
description: What the refund did
content:
application/json:
schema:
$ref: '#/components/schemas/RefundResult'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Missing or unknown API key
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Key lacks the required scope
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: No such object in your organization
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: The request was understood and refused
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: 'Rate limited: see Retry-After'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
operationId: postV1SalesByIdRefund
x-operation-id-source: derived
servers:
- url: https://api.affiliaterail.com
description: Production
components:
schemas:
WriteWarning:
type: object
properties:
code:
type: string
enum:
- no_partner_attributed
- no_commission_from_rules
- fixed_rate_currency_mismatch
message:
type: string
required:
- code
- message
SaleList:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Sale'
has_more:
type: boolean
description: Pass the last object's id as `starting_after` to fetch the next page
total_count:
type: integer
description: Count of every object matching the filters, ignoring the cursor
required:
- data
- has_more
- total_count
Sale:
type: object
properties:
id:
type: string
pattern: ^(sample_)?sale_
example: sale_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`sale_…`)
object:
type: string
enum:
- sale
program_id:
type: string
pattern: ^(sample_)?prg_
example: prg_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`prg_…`)
customer_id:
type: string
pattern: ^(sample_)?cus_
example: cus_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`cus_…`)
partner_id:
type: string
pattern: ^(sample_)?part_
example: part_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`part_…`)
external_charge_id:
type: string
external_payment_intent_id:
type:
- string
- 'null'
processor:
type: string
enum:
- stripe
- paddle
- chargebee
- manual
- api
amount_minor:
type: integer
example: 2500
description: Integer minor units (cents, pence). Never a float, never a string.
tax_minor:
type:
- integer
- 'null'
example: 2500
description: Integer minor units (cents, pence). Never a float, never a string.
currency:
type: string
minLength: 3
maxLength: 3
example: USD
description: ISO-4217
billing_type:
type: string
enum:
- one_time
- subscription
interval:
type:
- string
- 'null'
enum:
- day
- week
- month
- year
- null
product_id:
type:
- string
- 'null'
product_name:
type:
- string
- 'null'
is_first_sale:
type: boolean
occurred_at:
type: string
format: date-time
example: '2026-08-21T10:15:30.000Z'
description: ISO-8601, UTC
refunded_at:
type:
- string
- 'null'
format: date-time
example: '2026-08-21T10:15:30.000Z'
description: ISO-8601, UTC
metadata:
type:
- object
- 'null'
additionalProperties: {}
description: Your own key/value data, stored as given
created_at:
type: string
format: date-time
example: '2026-08-21T10:15:30.000Z'
description: ISO-8601, UTC
updated_at:
type: string
format: date-time
example: '2026-08-21T10:15:30.000Z'
description: ISO-8601, UTC
required:
- id
- object
- program_id
- customer_id
- partner_id
- external_charge_id
- external_payment_intent_id
- processor
- amount_minor
- tax_minor
- currency
- billing_type
- interval
- product_id
- product_name
- is_first_sale
- occurred_at
- refunded_at
- metadata
- created_at
- updated_at
Error:
type: object
properties:
error:
type: object
properties:
type:
type: string
enum:
- authentication_error
- permission_error
- invalid_request_error
- not_found_error
- conflict_error
- rate_limit_error
- plan_error
- not_implemented_error
- api_error
code:
type: string
message:
type: string
param:
type: string
required:
- type
- code
- message
required:
- error
RefundResult:
type: object
properties:
object:
type: string
enum:
- refund
sale_id:
type: string
pattern: ^(sample_)?sale_
example: sale_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`sale_…`)
voided_commissions:
type: integer
clawback_minor:
type: integer
example: 2500
description: Integer minor units (cents, pence). Never a float, never a string.
currency:
type: string
minLength: 3
maxLength: 3
example: USD
description: ISO-4217
refunded_at:
type: string
format: date-time
example: '2026-08-21T10:15:30.000Z'
description: ISO-8601, UTC
required:
- object
- sale_id
- voided_commissions
- clawback_minor
- currency
- refunded_at
SaleCreate:
type: object
properties:
program_id:
type: string
pattern: ^(sample_)?prg_
example: prg_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`prg_…`)
customer_id:
type: string
pattern: ^(sample_)?cus_
example: cus_7uSyy9FqVLCFWrdPeZaK
description: Prefixed id (`cus_…`)
external_charge_id:
type: string
minLength: 1
description: Your charge id. One charge produces at most one sale, forever.
amount_minor:
type: integer
minimum: 0
example: 2500
description: Integer minor units (cents, pence). Never a float, never a string.
tax_minor:
type:
- integer
- 'null'
minimum: 0
default: null
example: 2500
description: Integer minor units (cents, pence). Never a float, never a string.
currency:
type: string
minLength: 3
maxLength: 3
example: USD
description: ISO-4217
billing_type:
type: string
enum:
- one_time
- subscription
default: subscription
interval:
type:
- string
- 'null'
enum:
- day
- week
- month
- year
- null
default: null
product_id:
type:
- string
- 'null'
default: null
product_name:
type:
- string
- 'null'
default: null
occurred_at:
type: string
format: date-time
example: '2026-08-21T10:15:30.000Z'
description: ISO-8601, UTC
metadata:
type:
- object
- 'null'
additionalProperties: {}
description: Your own key/value data, stored as given
required:
- program_id
- customer_id
- external_charge_id
- amount_minor
- currency
SaleWithOutcome:
allOf:
- $ref: '#/components/schemas/Sale'
- type: object
properties:
activity_outcome:
type: string
enum:
- commission_created
- sale_recorded
description: '`commission_created` when the sale produced a commission; `sale_recorded` when we accepted the sale and paid nobody (see `warnings` for why)'
warnings:
type: array
items:
$ref: '#/components/schemas/WriteWarning'
description: Partial-success notes; empty when a commission was created
required:
- activity_outcome
- warnings
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: rail_live_… or rail_test_…
description: Create keys in Settings → API keys. Each key carries scopes; the docs name the scope every route needs.
x-refined-from:
- affiliaterail-com-docs-openapi.json
- affiliaterail-com-openapi.json