Article

Automating conversion tracking via API

The Affilae API lets you create, accept, refuse or adjust your conversions from your own system, without opening the interface. It is the answer when your order volume makes manual validation too heavy.

This page describes the useful endpoints and the order in which to call them. The full technical reference is published on rest.affilae.com/reference.

Prerequisites: your advertiser API key, which acts as the authentication token, the API base URL https://rest.affilae.com, and the required access rights on your program.

Rules that apply to every call

  • Every request must include the header Authorization: Bearer {YOUR_TOKEN}
  • Conversion amounts, sent or received, are expressed in cents. So 100 means 1.00 EUR.
  • All timestamps are in UTC.

Creating a conversion (Server-to-Server)

With Server-to-Server, you can send each order through the API instead of the postback URL. Call POST /advertiser/conversions.add with kind = tracking and the click IDs you kept.

FIELD REQUIRED VALUE
kind Yes tracking: the conversion is linked to the clicks or promo code sent.
program Yes Program ID.
rule Yes Rule ID, the first part of the rule key.
externalId Yes Order number, unique per rule: a second call with the same number returns “Conversion already exists”.
ip Yes The buyer’s IP v4 or v6 address.
cids Recommended Click IDs (24 characters) received in aecid, as an array. A click older than the rule’s Tracking duration (in days), or later than the conversion date, is not taken into account.
amount Yes for a sale Amount excluding tax in cents, after discounts and without shipping costs: 8990 means 89.90.
currency No ISO 4217 code, for example EUR. It must be one of the Rule Currencies, otherwise the call returns “Currency not defined on …”.
date No Order date (ISO 8601, UTC). Defaults to the time of the call.
voucher No Promo code used, written exactly as it was created in Affilae.
customerId No Your customer ID. Required when the rule enables Revenue Sharing.
subId No Free reference of your choice, reported with the conversion.
paymentMethod No Payment method stored with the conversion, for example online.
notify No true by default: the affiliate is notified, postback included. false to skip the notification.

Example:

curl -X POST https://rest.affilae.com/advertiser/conversions.add \
  -H "Authorization: Bearer {YOUR_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"kind": "tracking", "program": "5e336e000000000000000000", "rule": "5e336e000000000000000001",
       "externalId": "CMD-10245", "amount": 8990, "currency": "EUR",
       "cids": ["603ed1800000000000000000"], "ip": "185.179.113.132"}'

Responses:

  • 201: the conversion is created and returned in conversion.data.
  • 202 “No contributions found”: no click and no promo code can be linked, no conversion is created.
  • 400: the request is refused, the message says why, for example “Conversion already exists” or “Invalid clickIDs”.

Retrieving a conversion ID

Before accepting, refusing or updating a conversion, you must know its internal Affilae ID. There are two ways to get it.

1. List your conversions

Call GET /advertiser/conversions.list to retrieve the list of your conversions.

You can filter by:

  • status, with pending, accepted or refused;
  • date range, with from and to;
  • customer identifier, with customerId;
  • external identifier, with externalId.

2. Get the details of a conversion

Call GET /advertiser/conversions.info if you already know the external ID or the customer. This endpoint returns all information about the conversion, including its internal Affilae ID. The program parameter, the program ID, is required.

Accepting or refusing a conversion

Once you have the ID, you can automate your validation decisions. A locked conversion can no longer be accepted or refused.

Accept

Call POST /advertiser/conversions.accept. The conversion is validated and marked as accepted.

Required fields:

  • program, the advertiser program ID;
  • id, the internal conversion ID.

Refuse

Call POST /advertiser/conversions.refuse, for example for a product return, fraud or a test order.

Required fields:

  • program, the program ID;
  • id, the internal conversion ID;
  • reason, the reason for refusal.

Adjusting a conversion amount

If a customer returns part of an order, or a cart adjustment is needed, you can modify the amount of a conversion. Call POST /advertiser/conversions.update.

Conditions:

  • the conversion must not be refused, locked or included in a payment;
  • the adjusted amount must not exceed the initial amount;
  • the amount must not have been modified already.

Required fields:

  • id, the internal conversion ID;
  • amount, the new amount in cents;
  • reason, the reason for the adjustment, for example a partial cart return.

API endpoint summary

ACTION METHOD ENDPOINT
List conversions GET /advertiser/conversions.list
Get conversion info GET /advertiser/conversions.info
Create a conversion POST /advertiser/conversions.add
Accept a conversion POST /advertiser/conversions.accept
Refuse a conversion POST /advertiser/conversions.refuse
Adjust an amount POST /advertiser/conversions.update

Best practices

Tip: run your tests on a small volume of conversions before deploying your script on all your traffic. A status mistake made at scale is hard to undo.
  • Maintain the mapping between your own orders, the externalId, and the Affilae IDs, to prevent duplicates.
  • Store your API key securely, never share it and never include it in client-side code.
  • The API enforces rate limits. Make sure your scripts handle them gracefully.
  • Keep logs of your API calls, they simplify troubleshooting and support.

Need help

Our support team is available from your advertiser interface for any technical assistance.

Related articles

Frequently asked
questions

See more questions

Yes. Call POST /advertiser/conversions.add with kind = tracking, the Program ID, the Rule ID, the order number (externalId), the buyer’s IP address and the click IDs received in aecid (cids). The amount is sent in cents.

Conversion amounts are in cents. An amount of 100 therefore means 1.00 EUR. This applies both to the amounts you send and to the ones you receive.

Every request must include the header Authorization: Bearer {YOUR_TOKEN}, where the token is your advertiser API key. The base URL is https://rest.affilae.com.

Two ways. GET /advertiser/conversions.list returns the list of your conversions, filterable by status, date range, customerId or externalId. GET /advertiser/conversions.info returns the details of one conversion if you already know the external ID or the customer.

Three fields are required: program, the program ID, id, the internal conversion ID, and reason, the reason for refusal. The reason is mandatory, unlike acceptance which does not ask for one.

No. The adjustment is meant for product returns and reduced carts: the adjusted amount must not exceed the initial amount. The conversion must also not be refused, locked or included in a payment, and must not have been modified already.

No. A conversion whose amount has already been modified is no longer eligible for a new adjustment. Double-check your amount before the call.

Yes, the API enforces rate limits. Handle them in your scripts, with a retry when a call is rejected, and keep logs of your calls to make support easier.

In UTC. Convert your dates before filtering on the from and to parameters, otherwise you risk missing the conversions at the edges of the period.

Need help?

Stay up to date with the latest trends in affiliate marketing and never miss any of our articles.

Contact Us