Time to read: 7 min

The article covers the following topics:

General Info

First of all, to get started with API, you need to find your API-key. To do it, just navigate to the 'Users' Tab - > 'Users management' -> 'User edit page'.

Only the General manager has permission to get the 'User edit page'.

❗ Find out more about How to Create New User here, and How to Grant Specific Permissions to the General Manager here, to the Affiliate Manager here and to the Account Manager here.

Next thing you need is API URL, you can find it in Settings tab -> Settings -> Tracking domains -> Default URL's tab.

Find out more about where you can find your/Affiliate's API-key and API URL here.

API Request Structure: GET/POST + api domain + path + ? + api-key=189471975956279174174.

❗ It should be noted that header content-type - application/x-www-form-urlencoded is used on an ongoing basis, and content-type - multipart/form-data is used for uploading files (logo, creative files).

[POST] Add user

To create a new user via API, you need to navigate to the 'User managing (admin methods)' section in the API Doc and choose the 'Add user' method (follow the link):

Here you may see a lot of parameters that can be used to create a new user.

These parameters are required:

  • email - [REQUIRED] User's Email

  • password - [REQUIRED] User's password (Available: at least 6 characters)

  • first_name - [REQUIRED] User's first name

  • last_name - [REQUIRED] User's last name

  • roles[] - [REQUIRED] Array of allowed roles.

The required parameter 'roles[]' includes one of the user types: General manager / Affiliate manager / Sales manager, and may includes section visibility. Some roles include others, e.g:

ROLE_MANAGER_AFFILIATE => 
'ROLE_SECTION_STATS'
'ROLE_SECTION_STATS' => 
'ROLE_SECTION_STATS_COMMON',
'ROLE_SECTION_STATS_CONVERSION',
'ROLE_SECTION_STATS_SUPPLIER',
'ROLE_SECTION_STATS_OFFER',
'ROLE_SECTION_STATS_PARTNER',
'ROLE_SECTION_STATS_COUNTRY',
'ROLE_SECTION_STATS_CITY',
'ROLE_SECTION_STATS_OS',
'ROLE_SECTION_STATS_GOAL',
'ROLE_SECTION_STATS_DEVICE',
'ROLE_SECTION_STATS_LIMITS',
'ROLE_SECTION_STATS_PARTNER_POSTBACK',
'ROLE_SECTION_STATS_SERVER_POSTBACK',
'ROLE_SECTION_STATS_COMPARISON'

❗ If you define both type and roles parameters for the user, keep in mind the following:

  • you can select the common_manager type only for the user with ROLE_ADMIN

  • you can select the affiliate_manager type only for the user with ROLE_MANAGER_AFFILIATE

  • you can select the account_manager type only for the user with ROLE_MANAGER_SALES.

Below you can find an example on how to create a new user via API:

1) First of all, make sure that headers are entered correctly:

2) Enter the required and all needed parameters in the body section:

If everything is entered correctly, you will receive the status '1' response.

Note that assigned roles give Default permissions to the user.

The example of user creation via cURL request:

curl --location --request POST 'http://api-rocketcompany.affise.com/3.0/admin/user' \
--header 'api-key: c057faba8779ef56bdc493' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode '[email protected]' \
--data-urlencode 'password=88888888' \
--data-urlencode 'first_name=Api' \
--data-urlencode 'last_name=User' \
--data-urlencode 'roles[0]=ROLE_MANAGER_AFFILIATE' \
--data-urlencode 'roles[1]=ROLE_SECTION_SUPPLIER' \
--data-urlencode 'roles[2]=ROLE_SECTION_PARTNER' \
--data-urlencode 'skype=api_user' \
--data-urlencode 'work_hours=8-8'

It is possible to upload an image for a user (user logo, user picture, user avatar) via API. To do it you need to use the API request for user editing:

https://api.affise.com/docs3.1/#add-user

❗ Use the parameter 'avatar'. The image should be uploaded in Base64 format. To convert your picture into this format, use third-party services, like this one (free to use).

We support only JPEG format for image addition via API. If you would like to upload the PNG image - do it via UI.

See the GIF:

Then insert the copied code to the software you use (Postman, Insomnia, etc.).


❗ Uploading the image via API doesn't allow cropping the image in the way you want, that's why we recommend using foursquare images with a size of 200x200 pixels approximately - otherwise, the image will be distorted or cropped automatically in a way you don't like.

If you want to delete the picture via API, you need to make absolutely the same request, but without the parameter's value. Don't add the code of the image, but add the parameter 'avatar' itself and then send the request.

The cURL request for logo deleting:

curl --request POST \
--url https://api-rocketcompany.affise.com/3.0/admin/user/5c9b47a5c0417bbb008b4567 \
--header 'Api-key: c057faba8779ef56bdc493c' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data avatar=

[POST] Edit user

To edit the user via API, you need to navigate to the 'User managing (admin methods)' section in the API Doc and choose the 'Edit user' method (follow the link):

Some user data can be changed by this method:

  • email - User's Email

  • password - User's password (Available: at least 6 characters)

  • first_name - User's first name

  • last_name - User's last name

  • roles[] - Array of allowed roles.

  • skype - User's skype

  • work_hours - User's working time

  • type - User type

There is no need to rewrite all parameters, only those parameters that need to be changed.

Below you can find an example on how to edit the user via API:

1) First of all, make sure that headers are entered correctly:

2) Enter the needed parameters in the body section:

If everything is entered correctly, you will receive the status '1' response.

The example of user editing via cURL request:

curl --location --request POST 'http://api-rocketcompany.affise.com/3.0/admin/user/5f17ed6b3e10795af' \
--header 'api-key: c057faba8779ef56bdc493c' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'type=common_manager'

[POST] Update user permissions

To edit user's permissions via API, you need to navigate to the 'User managing (admin methods)' section in the API Doc and choose the 'Update user permissions' method (follow the link):

To edit permissions for a particular user you firstly need to get the full list of his current permissions.

Use this method to do it:

Then copy of the part of the response to this method:

It should start with

{

"permissions": {

And should end with 4 curly brackets:

}
}
}
}

After that you need to create a new request in Insomnia/Postman with the following attributes:

  • POST method

  • JSON format of the body (not Form URL encoded)

  • Content type: application/json

  • Api-key: API key of General manager

Then you need to insert the whole copied block to a body of this request.

❗ If you leave “exceptions” arrays as they are, nothing will change. But if you change the value in the “level” parameter and leave the “exceptions” as they are, relevant permissions will be changed. An example: you had “write” value in the “level” parameter, but changed that to “deny” parameter and left the “exceptions” array as it is (you didn’t delete it). Then the relevant permission will be changed to “deny”.

There is an example of a request in JSON format where some lists of exceptions were added (for “Access to affiliates editing” and “Access to advertisers editing” permissions):

{

"permissions": {

"general": {

"marketplace": {

"level": "read"

},

"settings": {

"level": "write"

}

},

"notificator": {

"client-subscription": {

"level": "deny"

},

"transport-configuration": {

"level": "deny"

},

"user-subscription": {

"level": "deny"

}

},

"stats": {

"affiliate-postback": {

"level": "read"

},

"clicks-list": {

"level": "read"

},

"comparison-report": {

"level": "read"

},

"conversions-export": {

"level": "read"

},

"conversions-import": {

"level": "write"

},

"conversions-list": {

"level": "read"

},

"entity-account-manager": {

"level": "read",

"default_level": "read"

},

"entity-affiliate-manager": {

"level": "deny"

},

"referral": {

"level": "deny"

},

"server-postback": {

"level": "read"

},

"slice-account_manager_id": {

"level": "deny"

},

"slice-advertiser_id": {

"level": "deny"

},

"slice-affiliate_id": {

"level": "read"

},

"slice-affiliate_manager_id": {

"level": "deny"

},

"slice-browser": {

"level": "deny"

},

"slice-city": {

"level": "read"

},

"slice-connection-type": {

"level": "deny"

},

"slice-country": {

"level": "read"

},

"slice-day": {

"level": "read"

},

"slice-device": {

"level": "read"

},

"slice-goal": {

"level": "read"

},

"slice-landing": {

"level": "deny"

},

"slice-mobile-carrier": {

"level": "deny"

},

"slice-offer_id": {

"level": "read"

},

"slice-os": {

"level": "read"

},

"slice-prelanding": {

"level": "deny"

},

"slice-smart_id": {

"level": "deny"

},

"slice-sub1": {

"level": "deny"

},

"slice-sub2": {

"level": "deny"

},

"slice-trafficback_reason": {

"level": "read"

},

"stats-export": {

"level": "read"

},

"view-custom": {

"level": "read"

},

"view-kpi": {

"level": "deny"

},

"view-retention-rate": {

"level": "deny"

}

},

"users": {

"entity-account-manager": {

"level": "deny"

},

"entity-advertiser": {

"level": "write",

"exceptions": {

"strings": {

"deny": [

"5c24b10a43cf7655008b4567",

"5da43e1d10768e44b351c2c5",

"5e2d96491d4b0b0738afb1b2",

"5e3aecd91d4b0b0738afb3d7",

"5cfa86cf43cf7676008b4604",

"5e58e3c6ac611cda7e576a89"

],

"read": [

"5e7dba10c3d9b3f9f5dd31ff"

]

}

}

},

"entity-affiliate": {

"level": "write",

"exceptions": {

"ints": {

"deny": [

2

],

"read": [

5

]

}

}

},

"entity-affiliate-manager": {

"level": "deny"

},

"entity-common-manager": {

"level": "deny"

},

"entity-preset": {

"level": "deny"

},

"view-users": {

"level": "deny"

}

}

}

}

You need to specify ID’s of certain affiliates/advertisers you want to add to a list of exceptions like it was done in the example above.

See the GIF:

You may also find the following articles helpful:


If you have more questions on how to create a new user via API, feel free to contact the Affise Support Team via [email protected] or your Dedicated Account Manager.

Did this answer your question?