> For the complete documentation index, see [llms.txt](https://help.theaffiliateplatform.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.theaffiliateplatform.com/apis-and-configurations/registration-api.md).

# Registration API

{% hint style="info" %}
This document describes how to build a custom registration page for the affiliates via API.
{% endhint %}

{% hint style="danger" %}
The default API URL is **<https://boapi.smartico.ai/>** but depending on your setup it could be different. Check for the exact URL in the '***Settings***' section. See [API Keys and URL](https://help.theaffiliateplatform.com/apis-and-configurations/api-keys-and-url.md).
{% endhint %}

### Affiliate registration API

An Operator can implement their own affiliate registration page that is using TAP API.

The API is using simple HTTP-POST to the URL <https://boapi.smartico.ai/api/register-aff>

Send the body as JSON, with the header `Content-Type: application/json`. This method does not need an API key: there is no `authorization` header.

POST body is JSON in format

```json
{
	"hostname": "aff.casino.com",
	"first_name": "First-name",
	"last_name": "Last-name",
	"bo_user_email": "user@example.com",
	"phone_number": "44097657269",
	"username": "username123",
	"password": "Q!w2e3r4",
	"skype": "skype",
	"company": "My Company",
	"web_site_url": "https://example.com",
	"country": "BG",
	"comments": "some info",
	"language": "FR",
	"tc": true,
	"token": "token-from-google-recaptcha"
}
```

Notes regarding parameters:

* Password should be at least 6 characters, have one lowercase letter, one uppercase letter, and one number
* The following fields are mandatory: 'first\_name', 'last\_name', 'username', 'password', 'bo\_user\_email', 'tc', 'hostname'. 'token' is mandatory only while reCAPTCHA is turned on (see below). 'country' is optional.
* 'tc' must be `true`: the affiliate accepts the Terms and Conditions
* Hostname should match exactly to the hostname that is configured in TAP BackOffice for the operator: **Configuration → Settings**, **General** tab, field '*Domain for registration page for affiliates*'. Only one hostname is allowed.
* Pass the hostname without `https://` and without a slash at the end, e.g. `aff.casino.com`. The API does not find the operator for `https://aff.casino.com` and returns error -5.
* Username should be 6 characters minimum
* The system is not allowing duplicate usernames and mails
* 'bo\_user\_email' must be a valid email address
* Language parameter should be ISO 2 symbols code of language
* If you are submitting Microsoft Teams contact details, use 'skype' parameter

<figure><img src="https://2789002490-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkbip9hFgRFwIv4mXJPnz%2Fuploads%2FG5u0orijzVIdEFzzknkT%2Fimage.png?alt=media&amp;token=80956061-53a3-450e-87ab-990d83de51ff" alt=""><figcaption><p>Settings,General tab - Domain for registration page for affiliates</p></figcaption></figure>

{% hint style="warning" %}
If your page sends the request from the browser, the API accepts it only from allowed domains. If your domain is not allowed, ask TAP support, or send the request from your server.
{% endhint %}

You can also pass optional parameters

```typescript
// new affiliate will be assigned as a child of specified parent_affiliate_id
// (ignored if your setup has no affiliate with this ID)
parent_affiliate_id: number; 

// affiliate will be assigned to a specific manager
// (ignored if this is not an active manager in your setup)
manager_id: number; 

// Facebook page for contact   
contact_fb: string;

// VK page for contact
contact_vk: string;

// Telegram page for contact
contact_telegram: string;

// Discord contact
contact_discord: string;

// WhatsApp contact
contact_wa: string;

// ID of the Affiliate in the external system.
// Must be unique in your setup: a duplicate fails with error -11
ext_affiliate_id: string;
```

The registration API does not save a payment method. To set 'payment\_method\_id' and 'payment\_method\_details', update the affiliate after the registration, as described in "Update affiliate details" on the [More API methods](https://help.theaffiliateplatform.com/apis-and-configurations/more-api-methods.md) page.

### Response

The API answers with HTTP status 200 also when the registration fails. Check 'err\_code' in the answer: `0` means the affiliate is registered.

```json
{
	"err_code": 0,
	"err_message": "reg_server_ok",
	"affiliate_id": 12345,
	"aff_status_id": 1,
	"frontend_ext_user_id": "bo_user_id:67890",
	"bo_user_id": 67890
}
```

* 'affiliate\_id' is the ID of the new affiliate
* 'aff\_status\_id' is the status of the new affiliate: 1 = Pending, 2 = Approved
* 'bo\_user\_id' is the ID of the affiliate's login user
* 'err\_message' is a translation key (e.g. `reg_server_username_in_user`), not a text to show as is
* For errors -5 and -12, the answer also has 'err\_technical' with a short explanation

The API can return the following error codes

```typescript
enum AffApiErrors {
   OK = 0,
   BOT = -1, // reCAPTCHA check failed, or its score is too low
   FORM_NOT_VALID = -2, // a mandatory field is missing, or 'tc' is not true
   USERNAME_RULE_NOT_VALUD = -3, // Username should be at least 6 symbols
   PASSWORD_RULE_NOT_VALID = -4, // not returned at the moment
   CANNOT_FIND_AFFILIATE_OPERATOR_BY_HOST = -5, // the 'hostname' parameter identifies the operator. System can support multiple operators. See the notes above
   FAIL_IN_REGISTRATION_FLOW = -6, // not returned at the moment
   USERNAME_ALREADY_EXISTS = -7,
   EMAIL_ALREADY_EXISTS = -8,
   PASSWORD_STRENGTH = -9, // Password should be at least 6 symbols, have one lowercase letter, one uppercase letter and one number
   BO_USER_CREATION_FAILED = -10, // the login user of the affiliate could not be created
   GENERAL_AFF_CREATION_FAIL = -11, // the affiliate could not be created, e.g. 'ext_affiliate_id' is already used
   AFF_OPERATOR_IS_DISABLED = -12, // the operator is disabled
   MAIL_IS_NOT_VALID = -13, // 'bo_user_email' is not a valid email address, or the mail check refused it
}
```

### Setting up Google ReCaptcha on the front end.

Add the following script on your front-end

```html
<script src="https://www.google.com/recaptcha/api.js?render=6LeR49UfAAAAAO7J7vKDCD4vM-Lq5ZA_NsquS9J_"></script>

<!-- Obtain the token in the following way -->
<script>
var _reCAPTCHA_site_key_ = '6LeR49UfAAAAAO7J7vKDCD4vM-Lq5ZA_NsquS9J_';
grecaptcha.ready(function() {
   grecaptcha.execute(_reCAPTCHA_site_key_, {action: 'affregistration'}).then(function(token) {
      // pass token to the API call to Affiliate registration API
   });
});
</script>

```

Get a new token for each registration request, right before you send it. The default TAP registration page does the same.

It's also possible to make API calls from the server side (backend) without using re-captcha protection.

To disable re-captcha verification for your setup:

1. Go to **Configuration → Settings**, **General** tab, **Affiliate App Features** section
2. Set 'Enable recaptcha on the registration page and API' to No
3. Click **Save**

This turns reCAPTCHA off for the default TAP registration page too.

<figure><img src="https://2789002490-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fkbip9hFgRFwIv4mXJPnz%2Fuploads%2F1wPfMMgSbsao3LwuZxa9%2Fimage.png?alt=media&amp;token=ec19ecfe-22b8-4d64-ad3f-55a3deae6c25" alt=""><figcaption><p>Settings, Affiliate App Features tab: the field 'Enable recaptcha on the registration page and API'</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.theaffiliateplatform.com/apis-and-configurations/registration-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
