curl --request PUT \
--url https://go.affixo.dev/v1/campaigns/{id}/commission-rule \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"library_reward_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "percent",
"reward_type": "cash",
"unit": "credits",
"duration": "lifetime",
"length_months": 2,
"product_ids": [
"<string>"
]
}
'import requests
url = "https://go.affixo.dev/v1/campaigns/{id}/commission-rule"
payload = {
"amount": 123,
"library_reward_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "percent",
"reward_type": "cash",
"unit": "credits",
"duration": "lifetime",
"length_months": 2,
"product_ids": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 123,
library_reward_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
type: 'percent',
reward_type: 'cash',
unit: 'credits',
duration: 'lifetime',
length_months: 2,
product_ids: ['<string>']
})
};
fetch('https://go.affixo.dev/v1/campaigns/{id}/commission-rule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://go.affixo.dev/v1/campaigns/{id}/commission-rule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'library_reward_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'type' => 'percent',
'reward_type' => 'cash',
'unit' => 'credits',
'duration' => 'lifetime',
'length_months' => 2,
'product_ids' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://go.affixo.dev/v1/campaigns/{id}/commission-rule"
payload := strings.NewReader("{\n \"amount\": 123,\n \"library_reward_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"percent\",\n \"reward_type\": \"cash\",\n \"unit\": \"credits\",\n \"duration\": \"lifetime\",\n \"length_months\": 2,\n \"product_ids\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://go.affixo.dev/v1/campaigns/{id}/commission-rule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"library_reward_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"percent\",\n \"reward_type\": \"cash\",\n \"unit\": \"credits\",\n \"duration\": \"lifetime\",\n \"length_months\": 2,\n \"product_ids\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://go.affixo.dev/v1/campaigns/{id}/commission-rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"library_reward_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"percent\",\n \"reward_type\": \"cash\",\n \"unit\": \"credits\",\n \"duration\": \"lifetime\",\n \"length_months\": 2,\n \"product_ids\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "commission_rule",
"campaign": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Default commission",
"kind": "monetary",
"amount": 123,
"is_flat": true,
"length_type": "lifetime",
"length_months": 123,
"applies_to_interval": "one_time",
"product_ids": [
"<string>"
]
},
"imported_products": [
"<string>"
]
}{
"object": "commission_rule",
"campaign": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Default commission",
"kind": "monetary",
"amount": 123,
"is_flat": true,
"length_type": "lifetime",
"length_months": 123,
"applies_to_interval": "one_time",
"product_ids": [
"<string>"
]
},
"imported_products": [
"<string>"
]
}{
"error": "invalid_json"
}{
"error": "unauthorized"
}{
"error": "insufficient_scope",
"need": "write"
}{
"error": "link_not_found"
}Set a campaign's commission rule
A campaign carries multiple rules. With no scope this creates/updates the
campaign’s catch-all rule; product_ids scopes the rule to those
Stripe products; billing_interval scopes it to a billing cadence (one
scope type per rule). Conversion-time precedence: product → interval →
catch-all → nothing.
amount is a percentage (0–100) unless type is flat. duration
controls recurrence: lifetime pays every renewal, first_order pays
only the first payment, capped pays for length_months periods.
Set reward_type to non_cash (with a unit, e.g. credits) to pay a
non-cash reward (credits, points or free months delivered via the
fulfilment webhook, never cash) at any scope; amount is then the
count of units and type is ignored. Requires write (or *) scope.
Configuration only. It never moves money.
A prod_… id in product_ids that isn’t in the catalog yet is looked
up in the workspace’s connected Stripe account and imported (the same
row Re-sync would write), then the rule is set; the response lists
those ids in imported_products. If the product can’t be imported the
response says why: 404 product_not_found with reason missing,
other_mode (it belongs to the other Stripe mode) or no_connection;
409 product_not_importable with reason archived or no_price;
502 stripe_lookup_failed when Stripe couldn’t be read.
curl --request PUT \
--url https://go.affixo.dev/v1/campaigns/{id}/commission-rule \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"library_reward_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "percent",
"reward_type": "cash",
"unit": "credits",
"duration": "lifetime",
"length_months": 2,
"product_ids": [
"<string>"
]
}
'import requests
url = "https://go.affixo.dev/v1/campaigns/{id}/commission-rule"
payload = {
"amount": 123,
"library_reward_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "percent",
"reward_type": "cash",
"unit": "credits",
"duration": "lifetime",
"length_months": 2,
"product_ids": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 123,
library_reward_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
type: 'percent',
reward_type: 'cash',
unit: 'credits',
duration: 'lifetime',
length_months: 2,
product_ids: ['<string>']
})
};
fetch('https://go.affixo.dev/v1/campaigns/{id}/commission-rule', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://go.affixo.dev/v1/campaigns/{id}/commission-rule",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 123,
'library_reward_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'type' => 'percent',
'reward_type' => 'cash',
'unit' => 'credits',
'duration' => 'lifetime',
'length_months' => 2,
'product_ids' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://go.affixo.dev/v1/campaigns/{id}/commission-rule"
payload := strings.NewReader("{\n \"amount\": 123,\n \"library_reward_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"percent\",\n \"reward_type\": \"cash\",\n \"unit\": \"credits\",\n \"duration\": \"lifetime\",\n \"length_months\": 2,\n \"product_ids\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://go.affixo.dev/v1/campaigns/{id}/commission-rule")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 123,\n \"library_reward_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"percent\",\n \"reward_type\": \"cash\",\n \"unit\": \"credits\",\n \"duration\": \"lifetime\",\n \"length_months\": 2,\n \"product_ids\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://go.affixo.dev/v1/campaigns/{id}/commission-rule")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 123,\n \"library_reward_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"type\": \"percent\",\n \"reward_type\": \"cash\",\n \"unit\": \"credits\",\n \"duration\": \"lifetime\",\n \"length_months\": 2,\n \"product_ids\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"object": "commission_rule",
"campaign": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Default commission",
"kind": "monetary",
"amount": 123,
"is_flat": true,
"length_type": "lifetime",
"length_months": 123,
"applies_to_interval": "one_time",
"product_ids": [
"<string>"
]
},
"imported_products": [
"<string>"
]
}{
"object": "commission_rule",
"campaign": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Default commission",
"kind": "monetary",
"amount": 123,
"is_flat": true,
"length_type": "lifetime",
"length_months": 123,
"applies_to_interval": "one_time",
"product_ids": [
"<string>"
]
},
"imported_products": [
"<string>"
]
}{
"error": "invalid_json"
}{
"error": "unauthorized"
}{
"error": "insufficient_scope",
"need": "write"
}{
"error": "link_not_found"
}Authorizations
Body
Response
Updated commission rule