# User Registration

## Register New User Without Package

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/signup/‎`

This API endpoint add new user into the system.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                            | Type   | Description                                                                                                                                        |
| ----------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| country\_code<mark style="color:red;">\*</mark> | string | <p>country code</p><p><a data-mention href="/pages/-MLubYbkIUjQIB9ta-sz">/pages/-MLubYbkIUjQIB9ta-sz</a></p>                                       |
| first\_name<mark style="color:red;">\*</mark>   | string | first name                                                                                                                                         |
| last\_name<mark style="color:red;">\*</mark>    | string | last name                                                                                                                                          |
| username<mark style="color:red;">\*</mark>      | string | username                                                                                                                                           |
| password<mark style="color:red;">\*</mark>      | string | password                                                                                                                                           |
| agree\_terms<mark style="color:red;">\*</mark>  | string | agree terms - Possible values are 1 or 0                                                                                                           |
| user\_type<mark style="color:red;">\*</mark>    | string | <p>user role - Possible values are customer or member.<br><strong>member role is equivalent to distributor, consultant, or agent.</strong><br></p> |
| email<mark style="color:red;">\*</mark>         | string | email address                                                                                                                                      |
| phone\_number<mark style="color:red;">\*</mark> | string | phone number                                                                                                                                       |
| place\_genealogy                                | string | place\_genealogy - Possible values are 1 or 0                                                                                                      |
| position                                        | string | if place\_geneolgy is 1, choose user position from the following -   HOLDING\_TANK, LEFT, RIGHT                                                    |
| sponsor                                         | string | <p>sponsor username, required when user\_type is member</p><p><a data-mention href="#get-sponsors-list">#get-sponsors-list</a></p>                 |
| subdomain                                       | string | subdomain name, required when user\_type is member                                                                                                 |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "uid": "<Unique user id>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/signup/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'country_code': '<country code>',
    'sponsor': '<sponsor username>',
    'first_name': '<first name>',
    'last_name': '<last name>',
    'username': '<username>',
    'password': '<password>',
    'agree_terms': '<agree terms>',
    'user_type': '<user role>',
    'email': '<email address>',
    'phone_number': '<phone number>',
    'place_genealogy': '<place genealogy>',
    'position' : '<Genealogy position>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/signup/",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => array(
        'country_code' => <country code>,
        'sponsor' => <sponsor username>,
        'first_name' => <first name>,
        'last_name' => <last name>,
        'username' => <username>,
        'password' => <password>,
        'agree_terms' => <agree terms>,
        'user_type' => <user role>,
        'email' => <email address>,
        'phone_number' => <phone number>,
        'place_genealogy' => <place genealogy>,
        'position' => <Genealogy position>
    ),
    CURLOPT_HTTPHEADER => array(
        "apikey: <apikey>"
    )
));

$response = curl_exec($curl);

curl_close($curl);
echo $response; 
```

#### Error Responses

| Status Code | Error Type       | Field         | Description                                                                                                                                                                                                                                                                                    |
| ----------- | ---------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | country\_code | Invalid country code                                                                                                                                                                                                                                                                           |
| 400         | Validation Error | sponsor       | Invalid sponsor name                                                                                                                                                                                                                                                                           |
| 400         | Validation Error | sponsor       | The selected sponsor is not found or is in the inactive state.                                                                                                                                                                                                                                 |
| 400         | Validation Error | first\_name   | The first name should be an alphabet.                                                                                                                                                                                                                                                          |
| 400         | Validation Error | last\_name    | The last name should be an alphabet.                                                                                                                                                                                                                                                           |
| 400         | Validation Error | username      | Username is already taken. Please try another one.                                                                                                                                                                                                                                             |
| 400         | Validation Error | username      | Invalid username. Only contains alphanumeric characters, underscore and dot. \nUnderscore and dot can't be next to each other (e.g user\_.name). \nUnderscore or dot can't be used multiple times in a row (e.g user\_\_name / user..name). The number of characters must be between 5 to 250. |
| 400         | Validation Error | password      | password validation errors                                                                                                                                                                                                                                                                     |
| 400         | Validation Error | phone\_number | Phone number already taken. Please try another one.                                                                                                                                                                                                                                            |
| 400         | Validation Error | email         | There is a user registered with the specified E-Mail address.                                                                                                                                                                                                                                  |
| 400         | Validation Error | position      | Your chosen position is invalid. The default will be the spilling preference of                                                                                                                                                                                                                |
| 400         | Validation Error | subdomain     | <p>Ensure this field has no more than 15 characters.</p><p>Ensure this field has at least 3 characters.</p>                                                                                                                                                                                    |

## Register New User With Package

<mark style="color:green;">`POST`</mark> `‎‎https://<domain>/<api prefix>/<version>/user/signup-package/`

This API endpoint add new user into the system with an enrollment package.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                                     | Type   | Description                                                                                                                                    |
| -------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| country\_code<mark style="color:red;">\*</mark>          | string | <p>country code</p><p><a data-mention href="/pages/-MLubYbkIUjQIB9ta-sz">/pages/-MLubYbkIUjQIB9ta-sz</a></p>                                   |
| sponsor<mark style="color:red;">\*</mark>                | string | <p>sponsor username</p><p><a data-mention href="#get-sponsors-list">#get-sponsors-list</a></p>                                                 |
| first\_name<mark style="color:red;">\*</mark>            | string | first name                                                                                                                                     |
| last\_name<mark style="color:red;">\*</mark>             | string | last name                                                                                                                                      |
| username<mark style="color:red;">\*</mark>               | string | username                                                                                                                                       |
| password<mark style="color:red;">\*</mark>               | string | password                                                                                                                                       |
| confirm\_password<mark style="color:red;">\*</mark>      | string | confirm password                                                                                                                               |
| agree\_terms<mark style="color:red;">\*</mark>           | string | agree terms - Possible values are 1 or 0                                                                                                       |
| user\_type<mark style="color:red;">\*</mark>             | string | <p>user role - Possible values are customer or member.<br><strong>member role is equivalent to distributor, consultant, or agent.</strong></p> |
| email<mark style="color:red;">\*</mark>                  | string | email address                                                                                                                                  |
| phone\_number<mark style="color:red;">\*</mark>          | string | phone number                                                                                                                                   |
| place\_genealogy                                         | string | place\_genealogy - Possible values are 1 or 0                                                                                                  |
| product\_id<mark style="color:red;">\*</mark>            | string | <p>enrollment package - product id</p><p><a data-mention href="/pages/-MLw05Q_8wzi9FNmKaf4">/pages/-MLw05Q\_8wzi9FNmKaf4</a></p>               |
| address\_first\_name<mark style="color:red;">\*</mark>   | string | address first name                                                                                                                             |
| address\_last\_name<mark style="color:red;">\*</mark>    | string | address last name                                                                                                                              |
| address\_mail\_id<mark style="color:red;">\*</mark>      | string | address E-mail address                                                                                                                         |
| address\_phone\_number<mark style="color:red;">\*</mark> | string | address phone number                                                                                                                           |
| address\_name\_line<mark style="color:red;">\*</mark>    | string | address house number                                                                                                                           |
| address\_premise<mark style="color:red;">\*</mark>       | string | address street                                                                                                                                 |
| address\_locality<mark style="color:red;">\*</mark>      | string | address locality                                                                                                                               |
| address\_postal\_code<mark style="color:red;">\*</mark>  | string | address post code                                                                                                                              |
| address\_country\_code<mark style="color:red;">\*</mark> | string | <p>address country code</p><p><a data-mention href="/pages/-MLubYbkIUjQIB9ta-sz">/pages/-MLubYbkIUjQIB9ta-sz</a></p>                           |
| address\_state\_code<mark style="color:red;">\*</mark>   | string | <p>address state code</p><p><a data-mention href="/pages/-MLucOCnGnt1gwEl_mE1">/pages/-MLucOCnGnt1gwEl\_mE1</a></p>                            |
| subdomain<mark style="color:red;">\*</mark>              | string | subdomain name                                                                                                                                 |
| position                                                 | string | possible values - HOLDING\_TANK, LEFT, RIGHT                                                                                                   |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "uid": "<Unique user id>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/signup-package/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'country_code': '<country code>',
    'sponsor': '<sponsor username>',
    'first_name': '<first name>',
    'last_name': '<last name>',
    'username': '<username>',
    'password': '<password>',
    'confirm_password': '<confirm password>',
    'agree_terms': '<agree terms>',
    'user_type': '<user role>',
    'email': '<email address>',
    'phone_number': '<phone number>',
    'place_genealogy': '<place genealogy>',
    'position' : '<Genealogy position>',
    'product_id': '<product id>',
    'address_first_name': '<address first name>',
    'address_last_name': '<address last name>',
    'address_mail_id': '<address email id>',
    'address_phone_number': '<address phone number>',
    'address_name_line': '<address house number>',
    'address_premise': '<address street>',
    'address_locality': '<address locality>',
    'address_postal_code': '<address post code>',
    'address_country_code': '<address country code>',
    'address_state_code': '<address state code>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/signup-package/",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => array(
        'country_code' => <country code>,
        'sponsor' => <sponsor username>,
        'first_name' => <first name>,
        'last_name' => <last name>,
        'username' => <username>,
        'password' => <password>,
        'confirm_password' => <confirm password>,
        'agree_terms' => <agree terms>,
        'user_type' => <user role>,
        'email' => <email address>,
        'phone_number' => <phone number>,
        'place_genealogy' => <place genealogy>,
        'position' => <genealogy position>,
        'product_id' => <product id>,
        'address_first_name' => <address first name>,
        'address_last_name' => <address last name>,
        'address_mail_id' => <address email id>,
        'address_phone_number' => <address phone number>,
        'address_name_line' => <address house number>,
        'address_premise' => <address street>,
        'address_locality' => <address locality>,
        'address_postal_code' => <address post code>,
        'address_country_code' => <address country code>,
        'address_state_code' => <address state code>
    ),
    CURLOPT_HTTPHEADER => array(
        "apikey: <apikey>"
    )
));
```

#### Error Responses

| Status Code | Error Type       | Field                  | Description                                                                                                                                                                                                                                                                                             |
| ----------- | ---------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | country\_code          | Invalid country code                                                                                                                                                                                                                                                                                    |
| 400         | Validation Error | sponsor                | Invalid sponsor name                                                                                                                                                                                                                                                                                    |
| 400         | Validation Error | sponsor                | The selected sponsor is not found or is in the inactive state.                                                                                                                                                                                                                                          |
| 400         | Validation Error | first\_name            | The first name should be an alphabet.                                                                                                                                                                                                                                                                   |
| 400         | Validation Error | last\_name             | The last name should be an alphabet.                                                                                                                                                                                                                                                                    |
| 400         | Validation Error | username               | Username is already taken. Please try another one.                                                                                                                                                                                                                                                      |
| 400         | Validation Error | username               | username Invalid username. Only contains alphanumeric characters, underscore and dot. \nUnderscore and dot can't be next to each other (e.g user\_.name). \nUnderscore or dot can't be used multiple times in a row (e.g user\_\_name / user..name). The number of characters must be between 5 to 250. |
| 400         | Validation Error | password               | password validation errors                                                                                                                                                                                                                                                                              |
| 400         | Validation Error | confirm\_password      | Confirmed password doesn't match.                                                                                                                                                                                                                                                                       |
| 400         | Validation Error | phone\_number          | Phone number already taken. Please try another one.                                                                                                                                                                                                                                                     |
| 400         | Validation Error | email                  | There is a user registered with the specified E-Mail address.                                                                                                                                                                                                                                           |
| 400         | Validation Error | position               | Your chosen position is invalid. The default will be the spilling preference of                                                                                                                                                                                                                         |
| 400         | Validation Error | address\_postal\_code  | Invalid postcode                                                                                                                                                                                                                                                                                        |
| 400         | Validation Error | address\_state\_code   | Invalid address\_state\_code                                                                                                                                                                                                                                                                            |
| 400         | Validation Error | address\_first\_name   | Invalid address\_first\_name                                                                                                                                                                                                                                                                            |
| 400         | Validation Error | address\_last\_name    | Invalid address\_last\_name                                                                                                                                                                                                                                                                             |
| 400         | Validation Error | address\_country\_code | Invalid address\_country\_code                                                                                                                                                                                                                                                                          |
| 400         | Validation Error | product\_id            | Invalid product\_id                                                                                                                                                                                                                                                                                     |
| 400         | Validation Error | subdomain              | <p>Ensure this field has no more than 15 characters.</p><p>Ensure this field has at least 3 characters.</p>                                                                                                                                                                                             |
| **5**00     | Server Error     |                        | User creation is failed.                                                                                                                                                                                                                                                                                |

## Get Sponsors List

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/get/sponsors/`

This API endpoint will return a list of sponsors.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200: OK " %}

```html
HTTP/1.1 200 OK
Content-Type: application/json
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "username": "<username>",
                "first_name": "<first_name>",
                "last_name": "<last_name>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": "<previous_page_url>",
        "next": "<next_page_url>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/sponsors/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/get/sponsors/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access tooken>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

## Validate Sponsor

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/validate-sponsor/`

This API endpoint will validate a sponsor.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200: OK " %}

```html
HTTP/1.1 200 OK
Content-Type: application/json
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/validate-sponsor/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'sponsor': '<sponsor_user_name>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/validate-sponsor/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('sponsor' => '<sponsor_user_name>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | FIeld   | Description                                                                                                                                 |
| ----------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | sponsor | <p>Invalid sponsor username.</p><p>Sponsor is blocked or inactive.</p><p>The selected sponsor is not found or is in the inactive state.</p> |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.epixelsoftware.help/user-registration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
