Affiliate Program Settings
The two endpoints holding the commission rate, period, delay and payout floor.
Overview
The program settings decide how much commission is given, when and for how long. Two endpoints read and write one structure.
Three settings work together: the rate sets the size of the commission, the period says whether it comes once or on every renewal, and the delay says when the earnings count as payable.
The cookie duration answers a separate question: how many days after a click on the link a visitor can become a customer and still be credited to that partner.
Reference
Reading the Program Settings
Returns every setting of the affiliate program.
onetime or lifetime.curl 'https://panel.example.com/api/v1/admin/affiliates/config' \
-H "Authorization: Bearer $API_KEY"const res = await fetch('https://panel.example.com/api/v1/admin/affiliates/config', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data } = await res.json();
const rate = data.rate;
const floor = data.min_payment.amount;$ch = curl_init('https://panel.example.com/api/v1/admin/affiliates/config');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// Read here BEFORE saving: the save writes a default over any field you leave out.
$cfg = Api::Affiliates()->GetAffiliateConfig()['data'];
$cfg['rate'] = 15;Saving the Program Settings
Writes the whole set of settings and returns where they now stand.
onetime or lifetime.curl -X PUT 'https://panel.example.com/api/v1/admin/affiliates/config' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"enabled":true,"commission_period":"lifetime","commission_delay":30,"rate":10,"cookie_duration":30,"min_payment":{"amount":50,"currency_id":840}}'const read = await fetch('https://panel.example.com/api/v1/admin/affiliates/config', {
headers: { Authorization: `Bearer ${apiKey}` },
});
const { data: cfg } = await read.json();
const res = await fetch('https://panel.example.com/api/v1/admin/affiliates/config', {
method: 'PUT',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ ...cfg, rate: 15 }),
});$cfg = $current; // GET /affiliates/config yaniti
$cfg['rate'] = 15;
$ch = curl_init('https://panel.example.com/api/v1/admin/affiliates/config');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($cfg),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);// A FULL WRITE: every field you leave out returns to its default (texts and payout methods GO EMPTY).
$cfg = Api::Affiliates()->GetAffiliateConfig()['data'];
$cfg['rate'] = 15;
Api::Affiliates()->SaveAffiliateConfig($cfg);Pitfalls
The save endpoint writes every field in the body. A field you leave out is not kept and returns to its default: numbers to zero, texts to empty, the payout methods and program texts to an empty list. To change the rate alone, read first and write over the object that comes back.
The program text is an object with a key per language. The payout methods are a list whose every element holds a name per language of its own. Writing them the same way empties the method list, and partners see no option when asking for a payout.
The period field is cleaned up alone and not checked against the values that are known. A misspelled value saves without a word, no error comes back, and the period does not behave as you expect. Read the value back after saving.
While the program is off a new service assignment is refused, and existing balances and waiting payout requests stay where they are. Turning it off stops new commission from being made rather than freezing what exists.
Related Articles
Thanks for your feedback!
Our support team is here around the clock for anything you can't find above.