Documentation sections

Admin API: affiliate networks

Admin API methods for affiliate networks: the template catalog, the list, and creating, editing and deleting a network.

The methods on this page work with the same list as the Networks («Сети») section in the panel: they return the template catalog and create, edit and delete affiliate networks. All methods require a token with Full access («Полный доступ») (full). Authorization is described on the Admin API: overview and authorization page, and the request format and common error codes on the Request, response and error format page.

Network object

The list, create and update methods return a network in the same form.

FieldTypeDescription
idstring, UUIDNetwork ID. The same value goes into the network_id field of an offer
namestringName. Substituted into the {affiliate_network_name} macro
postback_templatestring or nullPostback parameters. Start with ? or &. If null or an empty string, the network's postback address is the same as the general one
template_idstringCatalog template ID. For a network created without a template, an empty string
template_versionintegerVersion of the template the network was created from. For a network created without a template, 0
offer_paramstringParameters for the offer link, for example sub1={subid}. If not set, an empty string

The first character of postback_template determines the network's postback address: a string starting with ? replaces the standard parameters, and a string starting with & is appended to them. Rules and examples are in How the postback URL is built. The methods do not return the ready address: it is shown in the Networks section, in the Postback URL («URL постбэка») column.

In the response body, the & character inside strings is written as \u0026. This is valid JSON notation: after parsing you get &. In requests, write & as is.

Template catalog

Get the network template catalog

http
GET /api/v1/affiliate-network-templates

Returns the catalog of affiliate network templates — 333 entries. No parameters.

Response — code 200 and an object:

FieldTypeDescription
versionintegerCatalog version
itemsarrayTemplates
items[].idstringTemplate ID. Passed in template_id when creating a network
items[].namestringNetwork name
items[].versionintegerTemplate version. Passed in template_version
items[].postback_templatestringPostback parameters
items[].offer_paramstringParameters for the offer link
items[].notestringNote, for example Замените REPLACE перед подключением (“Replace REPLACE before connecting”). May be empty

The catalog contents and notes are covered on the Catalog of source and network templates page.

Network list

Get the list of networks

http
GET /api/v1/affiliate-networks

Returns all of the team's networks. No parameters, no pagination. Sorted by creation date, newest first.

Response — code 200 and an array of network objects. If there are no networks, [].

There is no method to read a single network: find it in the list by id.

Creating a network

Create a network

http
POST /api/v1/affiliate-networks

Creates a network from a catalog template or with your own postback parameters.

FieldTypeRequiredDescription
namestringyesName, up to 200 bytes: that is 200 Latin characters or 100 Cyrillic ones. A string of spaces only is not accepted
template_idstringnoCatalog template ID. If set, postback_template and offer_param are taken from the template, and the values in the request are ignored
template_versionintegerwith template_idCatalog template version. Must match the current one
postback_templatestring or nullnoPostback parameters for a network without a template. First character ? or &, length up to 16,000 bytes, no line breaks. An empty string is allowed
offer_paramstringnoParameters for the offer link for a network without a template, up to 4096 bytes

The name is not taken from the template: pass name for a catalog network too.

Response — code 201 and a network object.

Example: a network from a template. Take the ID and version from the catalog.

bash
curl -X POST https://panel.example.com/api/v1/affiliate-networks \
  -H "Api-Key: <token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Example Network","template_id":"kt-50e6398b4494","template_version":1}'
json
{
  "template_id": "kt-50e6398b4494",
  "template_version": 1,
  "offer_param": "sub1={subid}",
  "id": "7b0d2c3e-5a41-4f8e-9c1d-2e6f8a9b0c1d",
  "name": "Example Network",
  "postback_template": "?payout={money}&status={action}&lead_status=0&sale_status=subscribe,rebill&ignore_status=unsubscribe&subid={sub1}"
}

Example: a network with your own parameters.

bash
curl -X POST https://panel.example.com/api/v1/affiliate-networks \
  -H "Api-Key: <token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"My Network","postback_template":"?subid={sub1}&status={status}&payout={amount}","offer_param":"sub1={subid}"}'

Errors — code 422, code = validation:

MessageCause
name is requiredThe name field is missing or empty, or the body was not parsed: it is not a JSON object, it is larger than 1 MiB, or a field has the wrong type, for example template_version passed as a string
Шаблон сети не найден или устарел (network template not found or outdated)The catalog has no template with this template_id and this template_version, or template_version was not passed. Request the catalog again
Некорректное название или параметры сети (invalid network name or parameters)name is longer than 200 bytes or consists of spaces only, or offer_param is longer than 4096 bytes
Постбек должен содержать параметры после ? или & (postback must contain parameters after ? or &)postback_template starts with a different character, is longer than 16,000 bytes or contains a line break
Некорректные параметры постбека (invalid postback parameters)postback_template contains a ; character or a % character not followed by two hexadecimal digits

Editing a network

Edit a network

http
PUT /api/v1/affiliate-networks/{id}

Changes the network's name and postback parameters. A network cannot be edited in the panel: this method is the only way to change it.

Path parameter id — network ID, UUID.

FieldTypeRequiredDescription
namestringyesNew name. Same limits as on creation
postback_templatestring or nullnoNew postback parameters. Same rules as on creation

The method writes both fields on every request. To change only the name, take the current postback_template from the network list and pass it together with the new name.

Warning.

A request without postback_template erases the saved postback parameters: the field becomes null, and the network's postback address becomes the general one.

This method does not change the template_id, template_version and offer_param fields: the response returns the values set on creation. A catalog template is not applied to an existing network. This way, for a catalog network you can put your own values in place of REPLACE in the postback parameters, and the parameters for the offer link are kept.

Response — code 200 and a network object. The new name is substituted into the {affiliate_network_name} macro of this network's offers.

bash
curl -X PUT https://panel.example.com/api/v1/affiliate-networks/7b0d2c3e-5a41-4f8e-9c1d-2e6f8a9b0c1d \
  -H "Api-Key: <token>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Example Network CPA","postback_template":"?payout={money}&status={action}&lead_status=0&sale_status=subscribe,rebill&subid={sub1}"}'

After postback_template changes, the network's postback address in the Networks section changes. In the affiliate network's account the address stays the same until you replace it yourself — see Pasting the address into the network's account.

Errors:

CodecodeWhen
400bad_requestid is not a UUID
404not_foundThere is no network with this id
422validationThe same messages as on creation, except the template message

Deleting a network

Delete a network

http
DELETE /api/v1/affiliate-networks/{id}

Deletes a network. Path parameter id — network ID, UUID. No request body. The network is deleted immediately and does not go to the trash.

Response — code 204 with no body. Offers in which the network was selected stay and keep receiving traffic: their network_id field becomes null, and the {affiliate_network_name} macro becomes empty. The tracker keeps accepting postbacks sent to the address already entered in the network's account.

Errors:

CodecodeWhen
400bad_requestid is not a UUID
404not_foundThere is no network with this id

You choose a network in an offer with the network_id field — see Admin API: offers.

Updated Need help? ↗