# Introduction

Epixel MLM Commission Engine API Integration

## **Purpose**

This document aims to describe how external client applications can integrate with the [Epixel MLM software](https://www.epixelmlmsoftware.com/) API system.&#x20;

## **What is an API?**

API is the acronym for the term Application Programming Interface. API defines how an application implements the interface for external applications to communicate with it and use it’s functionalities exposed to the outside world. It specifies the technical language to be used for this communication.&#x20;

The client application “calls” an API implemented by a system to fetch a resource it’s looking for or get some action done. This is known as a “request” to which the host system responds by sending back a “response”, which could be a representation of a resource or the acknowledgement of an action taken. The responses are usually sent back in JSON(Javascript Object Notation) format.

A client application can be of any of the following types -&#x20;

Web Server App - An app’s backend server calls the API,&#x20;

Mobile App - End-user’s mobile device directly calls the API.&#x20;

Single-page App - A web-browser based app calls the API(eg. React/Angular app)&#x20;

### **API Basics**&#x20;

The Epixel [MLM software](https://www.epixelmlmsoftware.com/) implements an API over the HTTP protocol. This means that the clients must communicate with it via standard http calls like GET, POST, PUT and DELETE etc.&#x20;

An HTTP API request usually has the following format -&#x20;

*METHOD <https://www.api.hostname/endpoint?parm1=value1\\&parm2=value2>*

&#x20;This request consists of the following parts -&#x20;

**Method** - This specifies the action to be taken. HEAD, GET, POST, PUT, DELETE are some of the common HTTP methods used in API calls.

Commonly used HTTP methods -&#x20;

GET - Used to fetch data from the server. Should not affect the data.

HEAD - Same as GET, but transfers the status line and header section only. Used to check the availability of a resource.

POST - Used to send data to the server, such as file upload or for submitting user information through forms

PUT - Replaces the current representations of the target resource with the uploaded content.

DELETE - Removes all current representations of the target resource given by a URI.

**Endpoint** - The endpoint usually represents a resource (eg.- the profile page of a user)  or some action (eg.- logging in a user)  at the host system. It consists of the hostname part followed by the endpoint identifier. The endpoints of an API represent the resources of the system exposed to the outside world and also the various actions that one can make on those resources. An endpoint is also called a URL (Universal Resource Locator) or URI (Universal Resource Identifier).

**Query parameters** - These are the additional arguments that are required to be passed along with the endpoint name. Eg - The username name of a user.

Following would be a simple example of an API call in the format discussed above -&#x20;

GET [`https://epixelmlmsystem/afl/api/v1/user/get/profile?uid=123`](/user-profile#get-profile-details)

&#x20;This call gets the profile details of the user from [https://epixelmlmsystem](https://epixelmlmsystem/profile?) through the endpoint *profile.* (This assumes that the user has already been authenticated in the system)  &#x20;

### **Integrating Client Applications with Epixel MLM API System.**

For external client applications to use the Epixel MLM API system, they have to be integrated with it first.

This process starts with the MLM system admin registering the external application in its API system. On registering the application the system generates an application token which will be JSON(Javascript Object Notation) encoded as a Base64URL string.\
Follow the steps for successful integration of the application with epixelmlmsoftware,

* Log in as system super admin,
* Find **API** Menu from top menubar - **Administartion > API** **> Applications**

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FelyoIrtud1dlwKnnkuFt%2FScreenshot%20from%202021-11-11%2016-40-29.png?alt=media\&token=29b2c9fe-bf8b-4874-b990-ab24208e2a0b)

* Register Client Application - by clicking the add button

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2Fp9ZPa0BrWaMWoyImcz8O%2FScreenshot%20from%202021-11-11%2016-40-53.png?alt=media\&token=56a52769-b67f-4fed-a755-b5f4424ccdcf)

The client application must furnish the following details during the app registration -&#x20;

* Project/Application name
* API Version&#x20;
* Client type - Mobile, Web backend, or Browser-based application.

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FypXg5nW08aLjwDCIMc5j%2FScreenshot%20from%202021-11-11%2016-41-07.png?alt=media\&token=3ae563b7-4319-436a-b8dc-a60627039458)

* Generate apikey (app token)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FlIv3mqtFZQdxGQLXcs4n%2FScreenshot.png?alt=media\&token=01e5fd9a-baf2-44a0-ac88-e1e6d903b24b)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FyjTpkfnBdQAuzFPtfgL6%2FScreenshot%20from%202021-11-11%2016-41-39.png?alt=media\&token=c39a3e51-e33a-4179-9fb1-351691f0e42b)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FQ5he5dBmWcjqFPdsX5jy%2FScreenshot%20from%202021-11-11%2016-42-00.png?alt=media\&token=130f94a4-1fcb-4cd6-8590-abd64a46441a)

Choose the created application and click save to generate apikey for your application.

The registration step will generate the app token with the following details encoded -&#x20;

{

&#x20;       **typ**: Application type - server, web, or mobile

&#x20;       **aud**: audience - the application id

&#x20;       **iss**: authentication server identifier

&#x20;      **iat**: issued-at timestamp

}

A token in this format is known as JSON Web Token (JWT). These key-value pairs are known as claims of the token.<br>

* Register or add an API admin user - an admin gets permission for all endpoints and manages user data.

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2Fr8DiHthEr5CpikQYFy20%2FScreenshot1.png?alt=media\&token=6baf5760-4217-4eb9-9570-626b783978e8)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FCMR8Kfiy8vL0IbzbgIGe%2FScreenshot%20from%202021-11-11%2016-42-18.png?alt=media\&token=63341078-2210-430a-bb32-d1fca868b864)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FesZyLciqZT2Nh2GGpOl8%2FScreenshot%20from%202021-11-11%2016-42-37.png?alt=media\&token=85962ef6-563e-46b4-8ee3-c3e9826b40be)

* Add outgoing configuration for your application to use webhook and SSO services.

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FddmUB1Dw0rm96t8sPqAH%2FScreenshot3.png?alt=media\&token=8e1d4dbc-3ce8-4512-9cb2-9c2d0da196f8)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FIxz3erM71bp39EPOyJbH%2FScreenshot%20from%202021-11-11%2016-43-18.png?alt=media\&token=6a6828fa-241b-41a0-9c0a-220f1e4ae57e)

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FCyb1xstgNj7g9bmjjGdk%2FScreenshot%20from%202021-11-11%2016-43-25.png?alt=media\&token=8cbfabb4-5316-4f7a-9ec4-58a3de82c1d8)

Choose application, platform, domain details, and authentication details.

* Get Encryption keys, first go to application edit option -&#x20;

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FOr2MZJIfWFoNTcRzsjOK%2FScreenshot%20from%202021-11-11%2016-43-59.png?alt=media\&token=a354d6ad-a738-4fe4-a35f-7dd93b20b189)

collect encryption codes from the bottom of the edit form.&#x20;

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MLpzmoWKiz7pzro4aHn%2Fuploads%2FvkWh09BFq6sCn3FVOX3i%2FScreenshot%20from%202021-11-11%2016-44-14.png?alt=media\&token=1da282f9-e355-462e-a415-cde24ce1cde4)

#### **Client authentication for public access**

When there is no user login involved, the authentication flow will be as follows -&#x20;

All the API requests from the application are supposed to carry the application token to be considered valid in the MLM API system. The information presented by the token claims will be validated by the API server during the authentication of the API requests.&#x20;

Any request that doesn't carry the application token will be rejected by the API as having inadequate permission. So the client application must store this token securely in its database and include it in all the API requests that it makes to the MLM API. The token represents the client's identity to the API and hence must not be shared with any third party.&#x20;

\
The following example depicts a sample API request using the CURL (Command URL) utility.

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLpzmoWKiz7pzro4aHn%2F-MLq6KaUPzBq0ZnodI0Y%2F-MLqCCVyKi9NKi8K-pAd%2F1-2.png?alt=media\&token=59f5f4e9-de40-4d64-ace0-cb9afcd8fa31)

This API request is trying to register a user at the /api/register endpoint. The user details are passed as input in JSON format. The application token is included in the header as "apikey: {app token value}"

#### **Client authentication for logged-in user**

The authentication flow for client API requests involving a user who needs extra authentication is different from the flow for public access described in the previous section. In addition to the application token, the requests need to carry an access token for the user. To obtain the access token the user needs to login providing his/her login credentials to the API server. &#x20;

Sample request to the /token endpoint -

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLpzmoWKiz7pzro4aHn%2F-MLq6KaUPzBq0ZnodI0Y%2F-MLqCZCGkztdd6P5md3t%2F2.png?alt=media\&token=e17a14ee-5707-4fb0-869d-bf4c91373c90)

Sample response with access and refresh tokens in JSON -

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLpzmoWKiz7pzro4aHn%2F-MLq6KaUPzBq0ZnodI0Y%2F-MLqCnLL9bonoD_Qkb11%2F3.png?alt=media\&token=11400f9e-5ca1-4b8f-a8ce-9eaf8828ed10)

The response contains a refresh token in addition to the access token. This is to be used whenever an access token expires. Presenting the refresh token at the /token endpoint will give the client a new access token.&#x20;

Once the client gets the access token for a user, every API request on behalf of that user is supposed to carry the access token. The MLM API expects this access token to be sent in a cookie. &#x20;

A sample request passing the access token -

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLpzmoWKiz7pzro4aHn%2F-MLq6KaUPzBq0ZnodI0Y%2F-MLqDCDKfDR0SlZWQJCy%2F4.png?alt=media\&token=7d973420-5ce1-4bfe-af05-2c252952be40)

The request above tries to fetch the profile of the user "johnsamuels". The access token obtained in the previous step is passed as a cookie named access\_token.  &#x20;

Once the access token gets expired, the client requests the /token endpoint of the API for a new access token, sending the refresh token as input.

Sample API request for requesting a new access token -

![](https://540057697-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLpzmoWKiz7pzro4aHn%2F-MLq6KaUPzBq0ZnodI0Y%2F-MLqDPMAm6hzSPCayo34%2F5.png?alt=media\&token=0cd414ff-f3fe-4f24-ba33-e57f895c47fd)

{% hint style="info" %}
During Integration of Client Application with Epixel MLM API, Must register an API Admin&#x20;

user for access non-user API endpoints such as [‎Countries](/countries) [States](/states) etc.

An API Admin can access all endpoints and manage users' data using uid in request query params.&#x20;

Also, collect encryption keys on the basis of the client platform.
{% endhint %}

### &#x20;**HTTP Standard status codes**

| **Error Code**     | Description                                                                                                                      |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| 1xx: Informational | Communicates transfer protocol-level information.                                                                                |
| 200                | OK, Successful                                                                                                                   |
| 201                | Created, Resource creation is successful.                                                                                        |
| 204                | No Content                                                                                                                       |
| 400                | Bad Request, Bad input parameter. Error messages should indicate which one and why.                                              |
| 401                | Unauthorized, The client passed in the invalid Auth token. The client should refresh the token and then try again.               |
| 403                | Forbidden, Authentication failed due to invalid authentication permissions.                                                      |
| 404                | Not Found, Resource not found.                                                                                                   |
| 405                | Method Not Allowed, The resource doesn't support the specified HTTP verb.                                                        |
| 409                | Conflict. The request could not be completed due to a conflict with the current state of the target resource.                    |
| 500                | Internal Server Error, Servers are not working as expected. The request is probably valid but needs to be requested again later. |
| 503                | Service Unavailable.                                                                                                             |

### Error Response Structure

Basic error structure

```markup
{
    "status_code": <HTTP response status code>,
    "errors": {
        "type": "<Error name>",
        "detail": [
            {
                "message": "<Detailed error description>"
            }
        ]
    }
}
```

Validation error structure

```markup
{
    "status_code": 400,
    "errors": {
        "type": "Validation Error",
        "detail": [
            {
                "attribute": "<Field Name>",
                "message": <Array of messages>
            }
        ]
    }
}
```

| Paramater    | Data Type | Description                                                                                                                                         |
| ------------ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| status\_code | Int       | <p>Http reponse status code</p><p>Example : 500,403,400</p>                                                                                         |
| type         | String    | Short name for the error.                                                                                                                           |
| message      | Sting     | <p>Long description about the error.</p><p>Example:</p><p>"detail": \[ { "message": "Something went wrong. Couldn't process the     request.} ]</p> |

### Common Error Responses

| Status Code | Error Type           | Description                                                                      |
| ----------- | -------------------- | -------------------------------------------------------------------------------- |
| 500         | Server Error         | Something went wrong. Couldn't process the request.                              |
| 401         | Request Failed       | Something went wrong couldn't validate request through APIKEY.                   |
| 400         | Bad Request          | Missing required header APIKEY                                                   |
| 400         | Inactive APIKEY      | APIKEY is in an inactive state. Please contact the developer or try again later. |
| 400         | Under Maintenance    | APIKEY is in maintanance mode. Please contact the developer or try again later.  |
| 403         | Host Blocked         | Your Host address is blocked.                                                    |
| 403         | Host Not Whitelisted | Your Host address is not whitelisted.                                            |
| 403         | IP Blocked           | Your Ip address is blocked.                                                      |
| 403         | IP Not Whitelisted   | Your IP adrdess is not whitelisted.                                              |


# Authentication

### Getting apikey/apptoken

To acquire an apikey for your application, you must register your application with Epixel MLM software. Then you will get a unique apikey based on your application type.

You will use this apikey in your request's header. Here is an example:

`apikey: {apikey}`

This will necessary for your every use cases, that means every request's to Epixel MLM API must require have apikey.

### Access and Refresh token

The Epixel MLM API uses JSON Web Tokens (JWT) to authenticate user-level access. These tokens offer a method to establish secure server-to-server authentication by transferring a compact JSON object with a signed payload of your account’s details.

When authenticating to the Epixel MLM API, there are two JWT's (refresh and access token) should be generated uniquely by a server-side application and included access token as a Bearer Token in the header of each request.

Access token has only a limited time validity. After that you need to request for new access token using the refresh token.

To get access and refresh token you must request to login endpoint with apikey in header also username and password in the request body. After successfull authentication you will get the access and refresh token for that specific user.

### API Authentication

For accessing each endpoint users should have an access token. To receive this, users should authenticate by the username and password provided with the API key. By using this access token users can connect to the API end-points.

### Login

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

This API endpoint will return an access and refresh token for the user.

#### Headers

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

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| username<mark style="color:red;">\*</mark> | string |             |
| password<mark style="color:red;">\*</mark> | string |             |

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

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

Body:
{
    "refresh": <refresh token>,
    "access": <access token>
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': '‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/user/login/',
  'headers': {
    'apikey': '<apikey>',
  },
  formData: {
    'username': '<username>',
    'password': '<password>'
  }
};
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/login/",
  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('username' => '<username>','password' => '<password>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>"
  ),
));

$response = curl_exec($curl);

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

**Error** **Reponses**

| Status | Code Error            | Type Description                                                                                |
| ------ | --------------------- | ----------------------------------------------------------------------------------------------- |
| 401    | Authentication failed | The supplied authentication credentials are invalid.                                            |
| 401    | **I**nactive Account  | No active account found with the given credentials.                                             |
| 401    | Access Blocked        | Your account is blocked due to too many failed log-in attempts. Please try again in 10 minutes. |

### Token Refresh

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

This API endpoint will return a new access token for the user.

#### Headers

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

#### Request Body

| Name                                      | Type   | Description    |
| ----------------------------------------- | ------ | -------------- |
| refresh<mark style="color:red;">\*</mark> | string | R‎efresh Token |

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

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

Body:
{
    "access": <access token>
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': '‎https://<domain>/<api prefix>/<version>/user/token/refresh/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'refresh': '<refresh token>'
  }
};
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/token/refresh/",
  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('refresh' => '<refresh token>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <spaikey>"
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field   | Description                                          |
| ----------- | ---------------- | ------- | ---------------------------------------------------- |
| 400         | Validation Error | refresh | The supplied authentication credentials are invalid. |
| 400         | Validation Error | refresh | No active account found with the given credentials.  |

### Logout

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

This API endpoint will blacklist the refresh token generated for the user.

#### Headers

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

#### Request Body

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

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

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

Body:
{
    "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/logout/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'refresh': '<refresh token>'
  }
};
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/logout/",
  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('refresh' => '<refresh token>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access token>"
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

Same error reponses of token refresh endpoint

### Common Authentication Error Responses

| Status Code | Error Type               | Description                                                   |
| ----------- | ------------------------ | ------------------------------------------------------------- |
| 401         | Bad Authorization Header | Missing required authorization header.                        |
| 401         | Bad Authorization Header | Authorization header must contain two space-delimited values. |
| 401         | Invalid Access Token     | The supplied access token is invalid or expired.              |


# 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="/countries">/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="/countries">/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="/enrollment-packages">/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="/countries">/pages/-MLubYbkIUjQIB9ta-sz</a></p>                                            |
| address\_state\_code<mark style="color:red;">\*</mark>   | string | <p>address state code</p><p><a data-mention href="/states">/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> |


# Single Sign-On

Single Sign-on (SSO) occurs when a user logs in to one application and is then signed in to other applications automatically, regardless of the platform, technology, or domain the user is using. The user signs in only one time, hence the name of the feature (Single Sign-on).

For example, if you log in to a Google service such as Gmail, you are automatically authenticated to YouTube, Google Drive, Google Analytics, and other Google apps. Likewise, if you log out of your Gmail or other Google apps, you are automatically logged out of all the apps; this is known as Single Logout.

## How it works with Epixel MLM Software

For the implementation of SSO service, the services connected to our system are considered as two types of services. ie; host and client services.

The service in which the user logs directly is called host service and the services which are logged from this host service is called the client service.

Workflow:-

* **Login**

1. user logs in to a service by using login credentials (host).
2. an API session-id is created in the host service.
3. when the user requests another service, a request is sent to the particular login endpoint of the requested service with a single time token.
4. then using the received single time token and an apikey a request is sent to the host service to validate the request. after validating the request an API session-id and an access token are returned.
5. in the client service using the access token user is authenticated. and an acknowledgment is sent to the host service. Logout

* **Logout**

if a user requests log out from any of the services it will automatically log out the user from all services.

1. Log out from the host service
   * a request with API session-id is sent to the logout end point of all the services which are logged in using the host service.
   * then the client service will destroy the session related to the API session-id.
2. Log out from the client service

   * The API session id is passed to the host service.
   * then the host service will destroy all the sessions related to the API session-id.

## Single Sign-On Service Request

<mark style="color:orange;">`PUT`</mark> `‎https://<domain>/<sso prefix>/<version>/service-request/`

This endpoint will return a unique login URL of the requested service. Normally this is an in-site ajax request.

#### Request Body

| Name                                      | Type   | Description  |
| ----------------------------------------- | ------ | ------------ |
| service<mark style="color:red;">\*</mark> | string | service slug |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "url": "<unique user login url>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Error Responses

| Status Code | Error Type        | Field   | Description                                   |
| ----------- | ----------------- | ------- | --------------------------------------------- |
| 400         | Validation Error  | service | This field is required.                       |
| 400         | Validation Error  | service | This field may not be blank.                  |
| 403         | Permission Denied |         | Please login first to continue.               |
| 500         | Server Error      |         | Service request failed.                       |
| 500         | Server Error      |         | No Service user found. Please contact admin.  |
| 500         | Server Error      |         | Service not registered. Please contact admin. |

## Single Sign-On External Service Request

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/sso/service-request/`

Requesting unique login url for another service from host service\
This API endpoint will return unique login url for the requested service

#### Headers

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

#### Request Body

| Name                                       | Type   | Description    |
| ------------------------------------------ | ------ | -------------- |
| service<mark style="color:red;">\*</mark>  | string | service slug   |
| api\_sid<mark style="color:red;">\*</mark> | string | api session id |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "url": "<unique user login url>"
    }

}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/sso/service-request/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'service': '<service slug>',
    'api_sid': '<api session id>'
  }
};
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>/sso/service-request/",
  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('service' => '<service slug>','api_sid' => '<api session id>'),
  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 | service  | This field is required.                        |
| 400         | Validation Error | api\_sid | This field is required.                        |
| 400         | Validation Error | service  | This field may not be blank.                   |
| 400         | Validation Error | api\_sid | This field may not be blank.                   |
| 404         | No Session Found |          | No Logged-in session found with this api\_sid. |
| 500         | No Service Found |          | Service not registered. Please contact admin.  |

## Single Sign-On URL Token Verify

<mark style="color:green;">`POST`</mark> `‎‎https://<domain>/<api prefix>/<version>/sso/token-verify/`

This endpoint will return an API session-id and an access token.

#### Headers

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

#### Request Body

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

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "api_sid": "<api session id>",
        "auth_token": "<access token>"
     }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/sso/token-verify/',
  'headers': {
    'apikey': '<api key>'
  },
  formData: {
    'token': '<url token>'
  }
};
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>/sso/token-verify/",
  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('token' => '<url token>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <api key>"
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field | Description                  |
| ----------- | ---------------- | ----- | ---------------------------- |
| 400         | Validation Error | token | This field is required       |
| 400         | Validation Error | token | This field may not be blank. |
| 400         | Validation Error | token | Invalid token.               |
| 500         | Server Error     |       | Token generation failed      |

## Single Sign-On Login Acknowledgment

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/sso/login-acknowledgement/`

This endpoint will acknowledge the host service.

#### Path Parameters

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

#### Request Body

| Name                                       | Type   | Description    |
| ------------------------------------------ | ------ | -------------- |
| api\_sid<mark style="color:red;">\*</mark> | string | api session id |
| service<mark style="color:red;">\*</mark>  | string | service slug   |

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

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

Body:
{
    "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>/sso/login-acknowledgement/',
  'headers': {
    'apikey': '<api key>'
  },
  formData: {
    'service': '<service slug>',
    'api_sid': '<api session id>'
  }
};
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>/sso/login-acknowledgement/",
  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('service' => '<service slug>','api_sid' => '<api session id>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <api key>"
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field    | Description                   |
| ----------- | ---------------- | -------- | ----------------------------- |
| 400         | Validation Error | service  | This field is required        |
| 400         | Validation Error | service  | This field may not be blank.  |
| 400         | Validation Error | api\_sid | This field is required        |
| 400         | Validation Error | api\_sid | This field may not be blank.  |
| 401         | Request Failed   |          | Invalid service with api\_id. |

## Single Sign-On User Logout

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

This API endpoint will destroy all sessions based on the api\_sid.

#### Headers

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

#### Request Body

| Name                                       | Type   | Description    |
| ------------------------------------------ | ------ | -------------- |
| api\_sid<mark style="color:red;">\*</mark> | string | api session id |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/sso/logout/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'api_sid': '<api session id>'
  }
};
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>/sso/logout/",
  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_POSTFIELDS => array('api_sid' => '<api session id>'),
  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 | api\_sid | This field is required       |
| 400         | Validation Error | api\_sid | This field may not be blank. |
| 400         | Validation Error | api\_sid | Invalid api\_sid.            |


# User Profile

Get user profile details and update profile details.

## **Get** Profile Details

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

This API endpoint will give you the user profile details.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "UserProfile": [
            {
                "username": "<username>",
                "first_name": "<first name>",
                "last_name": "<last name>",
                "email": "<email>",
                "phone_code": "<phone code>",
                "phone_number": "<phone number>",
                "country_code": "<country code>"
            }
        ]
        "ProfileImage": "<image_path>",
        "UserLocInfo":{
            "lan": "<language_key>",
            "tz": "<timezone>",
            "currency": "<currency_code>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/profile/',
  '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/profile/",
  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-token>"
  ),
));

$response = curl_exec($curl);

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

## **Update Profile Details**

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

This API endpoint will update user profile details.

If the email address is changed, need to add token checksum field and token field for verification.

#### 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                                                                                                                                          |
| --------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| first\_name                             | string | first name                                                                                                                                           |
| last\_name                              | string | last name                                                                                                                                            |
| email<mark style="color:red;">\*</mark> | string | email address                                                                                                                                        |
| phone\_number                           | string | phone number                                                                                                                                         |
| languages                               | string | <p>language code</p><p><a data-mention href="#get-local-info">#get-local-info</a></p>                                                                |
| currencies                              | string | <p>currency code</p><p><a data-mention href="#get-local-info">#get-local-info</a></p>                                                                |
| timezones                               | string | <p>timezone</p><p><a data-mention href="#get-local-info">#get-local-info</a></p>                                                                     |
| token\_field                            | string | <p>Required when user update mail id,</p><p><a data-mention href="/payout#get-checksum-token">/pages/-MR9vtlqUQUP9DtaZfXW#get-checksum-token</a></p> |
| token\_checksum\_field                  | string | <p>Required when user update mail id,</p><p><a data-mention href="/payout#get-checksum-token">/pages/-MR9vtlqUQUP9DtaZfXW#get-checksum-token</a></p> |

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

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

Body:
{
    "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/update/profile/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'first_name': '<first_name>',
    'last_name': '<last_name>',
    'email': '<email>',
    'phone_number': '<phone_number>'
  }
};
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/update/profile/",
  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('first_name' => '<first_name>','last_name' => '<last_name>','email' => '<email>','phone_number' => '<phone_number>'),
  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 | email                  | <p>Enter a valid email address.</p><p>This field is required.</p>                 |
| 400         | Validation Error | phone\_number          | Phone number must be entered in the format: '999999999'. Up to 15 digits allowed. |
| 400         | Validation Error | first\_name            | Ensure this field has no more than 255 characters.                                |
| 400         | Validation Error | last\_name             | Ensure this field has no more than 255 characters.                                |
| 400         | Validation Error | token\_checksum\_field | This field is required.                                                           |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>Token is not matching.</p>                       |

## Upload profile image

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

This API endpoint is for uploading a user profile image

#### 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           |
| ------------------------------------------------ | ------ | --------------------- |
| image<mark style="color:red;">\*</mark>          | object | image file(Type file) |
| cropped\_image<mark style="color:red;">\*</mark> | object | image file(Type file) |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "image_url": "<image_url>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/profile/profile-image/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'image': {
      'value': <image uri>,
      'options': {
        'filename': '<image name>',
        'contentType': null
      },
    'cropped_image': {
      'value': <cropped_image uri>,
      'options': {
        'filename': '<cropped_image name>',
        'contentType': null
    }
  }
};
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/profile/profile-image/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('<image root path>'), 'cropped_image'=> new CURLFILE('<cropped_image root path>')),
  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 | image          | Upload a valid image. The file you uploaded was either not an image or a corrupted image.               |
| 400         | Validation Error | cropped\_image | Upload a valid image. The file you uploaded was either not an image or a corrupted image.               |
| 429         | Throttled        |                | Your daily profile update limit exceeded. Expected available in \<HH> hours \<M minutes and ss seconds. |

## Get Local Info

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

This API endpoint will return list site-local info such as currency list, language list, and timezones list.

#### 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": {
        "languages": [
            {
                "key": "<language_key>",
                "name": "<language_name>"
            },
            ...
        ],
        "currencies": [
            {
                "key": "<currency_code>",
                "name": "<currency_name>"
            },
            ...
        ],
        "timezones": [
            {
                "key": "<timezone_key>",
                "name": "<timezone_name>"
            },
        ]
    }
}
        
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/local-info/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/get/local-info/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```


# User Address

Get user address details and update address

## Get Address Details

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

This API endpoint will give you the user address details.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "UserAddress": {
            "address": "<address>",
            "city": "<city>",
            "postcode": "<postcode>",
            "phone": "<phone_number>",
            "state": {
                "id": <state_id>,
                "name": <state_name>
            },
            "country": {
                "id": <country_id>,
                "name": <country_name>,
                "sortname": <country_short_name_code>
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
​var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/address/',
  '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/address/",
  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-token>"
  ),
));

$response = curl_exec($curl);

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

## Update Address Details

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

This API endpoint will update user address details.

#### 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<mark style="color:red;">\*</mark>  | string | <p>country id</p><p><a data-mention href="/countries">/pages/-MLubYbkIUjQIB9ta-sz</a></p> |
| address<mark style="color:red;">\*</mark>  | string | address                                                                                   |
| city<mark style="color:red;">\*</mark>     | string | city                                                                                      |
| postcode<mark style="color:red;">\*</mark> | string | postcode                                                                                  |
| phone<mark style="color:red;">\*</mark>    | string | phone number                                                                              |
| state<mark style="color:red;">\*</mark>    | string | <p> state id</p><p><a data-mention href="/states">/pages/-MLucOCnGnt1gwEl\_mE1</a></p>    |

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

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

Body:
{
    "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/manage/address/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'address': '<address>',
    'city': '<city>',
    'phone': '<phone>',
    'postcode': '<postcode>'
    'state': '<state_id>',
    'country': '<country_id>',
  }
};
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/manage/address/",
  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('address' => '<address>','city' => '<city>','phone' => '<phone>','postcode' => '<postcode>','state' => '<state_id>','country' => '<country_id>',)
  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 | phone                          | Phone number must be entered in the formate: '99999999'. Up to 15 digits allowed. |
| 400         | Validation Error | postcode                       | The postcode is not valid for \<country\_name>.                                   |
| 400         | Validation Error | country, state                 | A valid integer is required.                                                      |
| 400         | Validation Error | address, phone, city, postcode | This field may not be blank.                                                      |


# About User

Get and Update User Additional Details.

## Get User Additional Details

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

This API endpoint will give you the user additional information details.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "AdditionalInfo": {
            "about": "<about>",
            "linkedin": "<linkedin-id>",
            "facebook": "<facebook-id>",
            "instagram": "<instagram-id>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/additional-info/',
  '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/additional-info/",
  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-token>",
  ),
));

$response = curl_exec($curl);

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

## ‎‎‎‎‎Update User Additional Details

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

This API endpoint will update user additional details.

#### 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  |
| --------- | ------ | ------------ |
| about     | string | user about   |
| facebook  | string | facebook-id  |
| instagram | string | instagram-id |
| linkedin  | string | linkedin-id  |

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

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

Body:
{
    "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>/manage/additional-info/',
  'headers': {
    'apikey': 'apikey',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'linkedin': '<linkedin-id>',
    'facebook': '<facebook-id>',
    'instagram': '<instagram-id>',
    'about': '<about>'
  }
};
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/manage/additional-info/",
  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('linkedin' => '<linkedin-id>','facebook' => '<facebook-id >','instagram' => '<instagram-id>','about' => '<about>'),
  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 | about, facebook, instagram, linkedin | Ensure this field has no more than 500 characters. |


# User Password

Change password and reset password.

## Change password

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

This API endpoint is for changing user password

#### 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      |
| --------------------------------------------------- | ------ | ---------------- |
| old\_password<mark style="color:red;">\*</mark>     | string | old password     |
| new\_password<mark style="color:red;">\*</mark>     | string | new password     |
| confirm\_password<mark style="color:red;">\*</mark> | string | confirm password |

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

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

Body:
{
    "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/profile/change-password/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'old_password': '<old_password>',
    'new_password': '<new_password>',
    'confirm_password': '<confirm_password>',
  }
};
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/profile/change-password/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('old_password' => '<old_password>','new_password' => '<new_password>','confirm_password' => '<confirm_password>'),
  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                                                                                                                                                                                                                                                                                                                                           |
| ----------- | -------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Authentication Error |                   | Your old password was entered incorrectly. Please enter it again.                                                                                                                                                                                                                                                                                     |
| 400         | Validation Error     | confirm\_password | The two password fields didn't match.                                                                                                                                                                                                                                                                                                                 |
| 400         | Validation Error     | password          | <p>Your password can't be too similar to your other personal information.</p><p>Your password must contain at least 8 characters.</p><p>Your password can't be a commonly used password.</p><p>Your password can't be entirely numeric.</p><p>Your password must contain at least one capital letter, small letter, number and special character.</p> |

## Forgot password request

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

This API endpoint is to reset the user password. Users can request with the registered email or username. Users will get a link with token and user key in an email. This token, user key, and a new password can send to the forget password submit API endpoint to change the current password or directly use the link to change the password.

#### Headers

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

#### Request Body

| Name                                    | Type   | Description       |
| --------------------------------------- | ------ | ----------------- |
| email<mark style="color:red;">\*</mark> | string | email or username |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
ar request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/forgot-password/',
  'headers': {
    'apikey': '<apikey>',
  },
  formData: {
    'email': '<email or username>'
  }
};
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/forgot-password/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('email' => '<email or username>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>"
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type           | Description                                                                                        |
| ----------- | -------------------- | -------------------------------------------------------------------------------------------------- |
| 40**1**     | Authentication Error | There is multiple users are registered with the specified E-Mail address.Please enter the username |
| 401         | Authentication Error | This username or email does not exist in the system.                                               |

## Forgot password submit

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

This endpoint is to reset the user password. User will get a link with token and user key in an email after success response from forgot password request API endpoint. Once use the link to change the password else send the token, user key, and a new password to this API endpoint to change the current user password.

#### Headers

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

#### Request Body

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| user<mark style="color:red;">\*</mark>          | string | user key from link |
| token<mark style="color:red;">\*</mark>         | string | token from link    |
| new\_password<mark style="color:red;">\*</mark> | string | new password       |

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

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

Body:
{
    "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/forgot-password-submit/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'token': '<token_from_link>',
    'new_password': '<new_password>',
    'user': '<user_key_from_link>'
  }
};
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/forgot-password-submit/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('user' => '<user_key_from_link>','token' => '<token>','new_password' => '<new_password>'),
  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 | token    | The token is invalid. Enter the correct token that send to your email.                                                                                                                                                                                                                                                                                |
| 400         | Validation Error | password | <p>Your password can't be too similar to your other personal information.</p><p>Your password must contain at least 8 characters.</p><p>Your password can't be a commonly used password.</p><p>Your password can't be entirely numeric.</p><p>Your password must contain at least one capital letter, small letter, number and special character.</p> |
| 400         | Validation Error | user     | This field is required.                                                                                                                                                                                                                                                                                                                               |


# User Roles

Manage User Roles

## Get User Roles

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

This API endpoint will give you the user roles details.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "UserRoles": [
            {
                "id": <role-id>,
                "name": "<role-name>"
            },
            ...
        ],
        "AllGroups": [
            {
                "<role-id>": "<role-name>"
            },
            ...
        ],
        "g_placed": <geneology_placed_or_not>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/roles/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  }
};
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/roles/",
  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-token>",
  ),
));

$response = curl_exec($curl);

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

## Upgrade User Role

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

This API endpooint will upgrade a user role from customer to preferred customer or to member.           &#x20;

#### 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                                                                                                                                                                                                                                                                               |
| --------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| unique\_id<mark style="color:red;">\*</mark>  | string | User unique id.                                                                                                                                                                                                                                                                           |
| upgrade\_to<mark style="color:red;">\*</mark> | string | <p>Upgrade options, possible values are:<br><strong>Member</strong> - Upgrade user role from customer to member.<br><strong>Preferred Customer</strong> - Upgrade user role from customer to preferred customer.</p>                                                                      |
| api\_place\_genealogy                         | string | <p>api\_place\_genealogy is required when upgrading the role from customer to preferred customer.<br>Possible values are:<br><strong>True</strong> - Place the user in genealogy when upgrading to preferred customer<br><strong>False</strong> - Do not place the user in genealogy.</p> |

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

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

Body:
{
    "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>/upgrade/user-role/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>' 
  },
  formData: {
    'unique_id': '<user_unique_id>',
    'upgrade_to': '<upgrade_option>',
    'api_place_genealogy': '<True_or_False>'
  }
};
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>/upgrade/user-role/',
  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('unique_id' => '<user_unique_id>','upgrade_to' => '<upgrade_option>','api_place_genealogy' => '<True_or_False>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access-token>'
  ),
));

$response = curl_exec($curl);

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

| Status Code | Error Type       | Field                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------- | ---------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | unique\_id            | <p>This field is required and its may not be blank.</p><p>User not exist or invalid unique id.</p><p>Ensure this field has no more than 255 characters.</p>                                                                                                                                                                                                                                                                           |
| 400         | Validation Error | upgrade\_to           | <p>This field is required and its may not be blank.</p><p>Invalid upgrade option, Choose a valid one.</p>                                                                                                                                                                                                                                                                                                                             |
| 400         | Validation Erorr | api\_place\_genealogy | <p>This field is required and its may not be blank.</p><p>Choose a valid option.</p>                                                                                                                                                                                                                                                                                                                                                  |
| 403         | Request Failed   |                       | <p>User role is already upgraded.</p><p>User already have a member role.</p><p>User already have a preferred customer role.</p><p>Free user place genealogy disabled, can't upgrade user role.</p><p>Free package for user role upgrade is not created.</p><p>User role upgrade option not found.</p><p>Created free package is not a customer privilaged package.</p><p>Created free package is not a member privilaged package.</p> |

## Downgrade User Role

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

This API endpoint will downgrade a user role from member to preferred customer or to customer.

#### 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                                                                                                                                                                                                                |
| -------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| unique\_id<mark style="color:red;">\*</mark>       | string | user unique id                                                                                                                                                                                                             |
| downgrade\_to<mark style="color:red;">\*</mark>    | string | <p>Downgrade options, possible values are: <br><strong>Customer</strong> - Downgrade user role from member to customer.<br><strong>Preferred Customer</strong> - Downgrade user role from member to preferred customer</p> |
| api\_block\_user<mark style="color:red;">\*</mark> | string | <p>Block the user with role downgrade, Possible values are:<br><strong>True</strong> - Block user account.<br><strong>False</strong> - Do not block.</p>                                                                   |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/downgrade/user-role/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  },
  formData: {
    'unique_id': '<user_unique_id>',
    'downgrade_to': '<downgrade_option>'
  }
};
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>/downgrade/user-role/',
  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('unique_id' => '<user_unique_id>','downgrade_to' => '<downgrade_option>'),
  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 | unique\_id       | <p>This field is required and its may not be blank.</p><p>User not exist or invalid unique id.</p><p>Ensure this field has no more than 255 characters.</p>        |
| 400         | Validation Error | downgrade\_to    | <p>This field is required and its may not be blank.</p><p>Invalid downgrade option, Choose a valid one.</p>                                                        |
| 400         | Validation Erorr | api\_block\_user | Choose a valid option.                                                                                                                                             |
| 403         | Request Failed   |                  | <p>User already have a downgraded role.</p><p>User already have a customer role.</p><p>User already have a preferred customer role.</p><p>Somthing went wrong.</p> |


# Manage User

Block and Unblock User

## Block User

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

This API endpoint will block a user account.

#### 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         |
| -------------------------------------------- | ------ | ------------------- |
| unique\_id<mark style="color:red;">\*</mark> | string | Unique key of user. |

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

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

Body:
{
    "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>/block/user/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Beare <access-token>'
  },
  formData: {
    'unique_id': '<user_unique_id>'
  }
};
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>/block/user/',
  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('unique_id' => '<user_unique_id>'),
  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 | unique\_id | <p>This field is required and its may not be blank.</p><p>User not exist or invalid unique id.</p><p>Ensure this field has no more than 255 characters.</p> |

## Unblock User

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

This API endpoint will unblock a user.

#### 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         |
| -------------------------------------------- | ------ | ------------------- |
| unique\_id<mark style="color:red;">\*</mark> | string | Unique key of user. |

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

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

Body:
{
    "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>/unblock/user/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Beare <access-token>'
  },
  formData: {
    'unique_id': '<user_unique_id>'
  }
};
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>/unblock/user/',
  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('unique_id' => '<user_unique_id>'),
  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 | unique\_id | <p>This field is required and its may not be blank.</p><p>User not exist or invalid unique id.</p><p>Ensure this field has no more than 255 characters.</p> |


# ‎Countries

Get List of Countries

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

This API endpoint returns all countries list with phone code.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "countries": [
            {
                "id": <country_id>,
                "code": <country_short_name_code>,
                "name": <country_name>,
                "phonecode": <country_phone_code>
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/countries/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/get/countries/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# States

Get List of States

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

This API endpoint returns all states list based on the country short code specified in the url. Replace  in the url to country short code and it must be a valide (country code)  string value.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "countries": [
            {
                "id": <state_id>,
                "code": <state_short_name_code>,
                "name": <state_name>
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/states/<country_short_code>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/get/states/<country_short_code>/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# Ewallet

Ewallet endpointes

## Ewallet List

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

This API endpoint will return a list of enabled wallets.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "<wallet_key>": {
            "name": "<wallet_name>"
        },
       "<wallet_key>": {
            "name": "<wallet_name>"
        },
        ...
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/wallet-list/',
  '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>/get/wallet-list/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# Support Ticket

## Support Ticket Category List

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/support/get/category-list/`

This API endpoint will give a list of Category which was chosen when creating a support ticket.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "CategoryList": [
            {
                "id": <Category-id>,
                "category": "<Category-name>",
                "description": "<Description>"
            },
           ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/support/get/category-list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  }
};
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>/support/get/category-list/",
  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-token>",
  ),
));

$response = curl_exec($curl);

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

## Create Support Ticket

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/support/create/ticket/`

This API endpoint will create a support ticket.

#### 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                                                                                                                                                                                                |
| ----------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| subject<mark style="color:red;">\*</mark> | string | ticket subject                                                                                                                                                                                             |
| priority                                  | string | priority id - Possible values are 1(Low), 2(Medium),or 3(High)                                                                                                                                             |
| comment<mark style="color:red;">\*</mark> | string | ticket comment                                                                                                                                                                                             |
| category                                  | string | <p>category  id - Get possible values through <strong>Support Ticket Category List</strong> API endpoint.</p><p><a data-mention href="#support-ticket-category-list">#support-ticket-category-list</a></p> |
| attachment                                | object | attachment file - Upload a attachment file (maximum size 2Mib).                                                                                                                                            |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/creat/support/ticket/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'subject': '<subject>',
    'priority': '<priority-id>',
    'comment': '<comment>',
    'category': '<category-id>',
    'attachment': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>',
        'contentType': null
      }
    }
  }
};
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>/creat/support/ticket/",
  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('subject' => '<subject>','priority' => '<priority-id>','comment' => '<comment>','category' => '<category>','attachment'=> new CURLFILE('<file_path>')),
  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 | subject, comment | This field is required.                            |
| 400         | Validation Error | subject          | Ensure this field has no more than 500 characters. |
| 400         | Validation Error | priority         | "\\"priority\\" is not a valid choice.             |
| 400         | Validation Error | category         | Invalid pk"\\"category\\" - object does not exist. |
| 400         | Validation Error | attachment       | File is too big. Max filesize: 2MiB.               |
| 401         | Request Failed   |                  | Currenly Open Ticket Limit Exceed.                 |

## Support Ticket History

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

This API endpoint will provide a history of support tickets. A request without query params provides details of last created 50 tickets.\
To get a range of ticket history provide offset and limit values in query params.\
Also provides filtered details of ticket history when a request with a possible query params. Ticket subject, ticket category, and ticket status are the possible query params.

#### Query Parameters

| Name     | Type   | Description                                                                              |
| -------- | ------ | ---------------------------------------------------------------------------------------- |
| offset   | string | offset value                                                                             |
| limit    | string | limit value                                                                              |
| subject  | string | ticket subject                                                                           |
| category | string | category id - Get possible values through **Support Ticket Category List** API endpoint. |
| status   | string | status id - Possible values are 1(Open), 2(Processing),or 3(Closed)                      |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "TicketList": [
            {
                "id": <ticket_id>,
                "subject": "<ticket_subject>",
                "priority": "<ticket_priority_id>",
                "category": <ticket_category_id>,
                "category_title": "<ticket_category_title>",
                "comment": "<ticket_comment>",
                "status": "<ticket_status_id>"
            }
            ...
        ]
    }
}


------------------------

priority_options = (
    ('1', 'Low'),
    ('2', 'Medium'),
    ('3', 'High'),
)
status_options = (
    ('1', 'Open'),
    ('2', 'Processing'),
    ('3', 'Closed'),
)
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/ticket/history/',
  '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>/get/ticket/history/",
  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-token>"
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field    | Description                      |
| ----------- | ---------------- | -------- | -------------------------------- |
| 400         | Validation Error | category | Catogory id is not valid numeric |
| 400         | Validation Error | status   | Status id is not valid numeric   |

## Support Ticket Tag List

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

This API endpoint will give a list of Tags which was chosen when updating a support ticket.

#### Headers

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

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

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "TicketTagList": [
            {
                "id": <tag_id>,
                "tag": "<tag_name>",
                "keyword": "<tag_keyword>"
            },
           ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/ticket/tags/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  }
};
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>/get/ticket/tags/",
  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-token>"
  ),
));
$response = curl_exec($curl);

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

## Update Support Ticket

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/support/update/ticket/`

This API endpoint will update a support ticket.

#### 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                                                                                                                                                                           |
| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ticket\_id<mark style="color:red;">\*</mark> | string | Id of ticket which wants to update                                                                                                                                                    |
| priority                                     | string | priority id - Possible values are 1(Low), 2(Medium),or 3(High)                                                                                                                        |
| tags<mark style="color:red;">\*</mark>       | string | <p>tag id - Get possible values through <strong>Support Ticket Tag List</strong> API endpoint.</p><p><a data-mention href="#support-ticket-tag-list">#support-ticket-tag-list</a></p> |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/update/support/ticket/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  },
  formData: {
    'ticket_id': '<ticket id>',
    'priority': '<priority id>',
    'tags': '<tag id>'
  }
};
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>/update/support/ticket/",
  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('ticket_id' => '<ticket id>','priority' => '<ticket id>','tags' => '<tag id>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <accsess-token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | Field    | Description                                                                                                                                |
| ----------- | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| 400         | Invalid Input    | ticket   | <p>You are not the owner of the requested ticket,</p><p>Ticket id is not valid,</p><p>Ticket id is required and this may not be blank.</p> |
| 400         | Validation Error | priority | "\\"priority\\" is not a valid choice.                                                                                                     |
| 400         | Validation Error | tags     | <p>This list may not be empty.</p><p>Incorrect type. Expected pk value, received str.</p><p>Invalid pk "tags" - object does not exist.</p> |

## Get Ticket Detailed View

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/support/ticket/detailed-view/`

This API endpoint will provide a detailed view of support ticket.

#### 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 |
| -------------------------------------------- | ------ | ----------- |
| ticket\_id<mark style="color:red;">\*</mark> | string | ticket id   |

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

```html
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "ticket": {
            "id": <ticket id>,
            "subject": "<subject>",
            "priority": "<priority_id>",
            "category": <category_id>,
            "comment": "<comment>",
            "status": "<status_id>",
            "tags": [
                tag id
            ]
        },
        "author": "<author_email>",
        "conversations": [            
            {
                "id": <conversations_id>,
                "ticket": <ticket_id>,
                "comment": "<comment>",
                "author":"<conversation_author_email>"
            },
            ...
        ],
        "attachments": [
            {
                "id": <attachments id>,
                "conversation_id": <conversation id>
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/support/ticket/detailed-view/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
 formData: {
  'ticket_id': '<ticket id>'
  }
};
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 => "",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "https://<domain>/<api prefix>/<version>/support/ticket/detailed-view/",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => array('ticket_id' => '<ticket id>'),
  CURLOPT_HTTPHEADER => arra(
    "apikey: <apikey>",
    "Authorization: Bearer <access token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


```

#### Error Responses

| Status Code | Error Type    | Field  | Description                                                                                                                                |
| ----------- | ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| 400         | Invalid Input | ticket | <p>You are not the owner of the requested ticket,</p><p>Ticket id is not valid.</p><p>Ticket id is required and this may not be blank.</p> |

## Get Attachment

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/support/ticket/download/<attachment_id>/`

This API endpoint will return an HTTP Response of the attachment file.

#### 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 " %}

```
Get HTTP Response of attachment file.
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/support/ticket/download/<attachment_id>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/support/ticket/download/<attachment_id>/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Ticket Add Conversation

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/support/ticket/conversation/`

This API endpoint will add a conversation to support ticket.

#### 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                                   |
| ----------------------------------------- | ------ | --------------------------------------------- |
| ticket<mark style="color:red;">\*</mark>  | string | ticket id                                     |
| comment<mark style="color:red;">\*</mark> | string | conversation comment                          |
| attachment                                | string | Upload a attachment file (maximum size 2Mib). |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/support/ticket/conversation/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'ticket': '<ticket id>',
    'comment': '<comment>',
    'attachment': {
      'value': fs.createReadStream('file path'),
      'options': {
        'filename': '<filename>',
        'contentType': null
      }
    }
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**&#x20;

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/support/ticket/conversation/",
  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('ticket' => '<ticket id>','comment' => '<comment>','attachment'=> new CURLFILE('file path')),
  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 | ticket     | <p>This field is required.</p><p>You are not the owner of the requested ticket.</p><p>Incorrect type. Expected pk value, received str.</p><p>Invalid pk "ticket" - object does not exist.</p><p>This field may not be null.</p> |
| 400         | Validation Error | comment    | <p>This field is required.</p><p>This field may not be blank.</p>                                                                                                                                                               |
| 400         | Validation Error | attachment | File is too big. Max filesize: 2MiB.                                                                                                                                                                                            |

## Change Ticket Status

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/‎support/ticket/status/`

This API endpoint will change status of support ticket.

#### 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                                                |
| ---------------------------------------- | ------ | ---------------------------------------------------------- |
| ticket<mark style="color:red;">\*</mark> | string | ticket id                                                  |
| status<mark style="color:red;">\*</mark> | string | status id - Possible values are 2(to open) and 3(to close) |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/‎support/ticket/status/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'ticket': '<ticket id>',
    'status': '<status id>'
  }
};
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>/‎support/ticket/status/",
  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('ticket' => '<ticket id>','status' => '<status id>'),
  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 | ticket | <p>You Can't open or close this Ticket,</p><p>Ticket id is not valid</p><p>Ticket is  already closed,</p><p>Ticket is already processing,<br>Ticket is already open,</p><p>Ticket id is required and this may not be blank.</p> |
| 400         | Validation Error | status | <p>""status" is not a valid choice.</p><p>Status id is required and this may not be blank.</p>                                                                                                                                  |


# List Banners

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/banners/`

This API endpoint will give you the available banner images.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "banners": [
            {
                "image": "<image_path>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/banners/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    }
};
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>/commerce/banners/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# Enrollment Packages

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/enrollment-packages/`

This API endpoint will return a list of all active enrollment packages.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "products": [
             {
                "name": "<package_name>",
                "price": "<price>",
                "images": "<images>",
                "description": "<description>",
                "short_desciption": "<short_desciption>",
                "product_id": "<product_id>",
                "bundle_id": "<bundle_id>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/enrollment-packages/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/enrollment-packages/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# Group Attributes

Manage Group Attributes Filter

## **List attributes group**

<mark style="color:blue;">`GET`</mark> `‎‎ https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/`

This API endpoint will give you the list of attributes group.

#### Query Parameters

| Name        | Type   | Description                                                                                                             |
| ----------- | ------ | ----------------------------------------------------------------------------------------------------------------------- |
| offset      | string | numeric - The offset indicates the starting position of the query in relation to the complete set of unpaginated items. |
| limit       | string | The limit indicates the maximum number of items to return, default maximum number is 50, and maximum limit is 100.      |
| group\_name | string | Attribute group name.                                                                                                   |
| attr\_name  | string | Attribute name.                                                                                                         |

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <attribute_group_id>,
                "name": "<attribute_group_name>",
                "attribute_id": [
                    {
                        "id": <attribute_id>,
                        "machine_code": "<attribute_machine_code>",
                        "name": "<attribute_name>",
                        "description": "<attribute_description>",
                        "widget": "<attribute_widget_type>",
                        "attribute_for": "<attribute_for>",
                        "is_unique": <is_unique_boolean>,
                        "is_required": <is_required_boolean>,
                        "is_display": <is_display_boolean>,
                        "options": [
                            {
                                "label": "<option_label>",
                                "value": "<option_value>",
                                "status": <option_status_boolean>,
                                "weight": <option_weight>
                            },
                            ...
                        ],
                        "data_type": "<attribute_data_type>",
                        "status": <attribute_status>,
                        "created": "<created_date_time>"
                    },
                    ...
                ],
                "status": <attribute_group_status>,
                "created": "<created_date_time>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <link_for_previous_page_list>,
        "next": <link_for_next_page_list>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': '‎https://<domain>/<api prefix>/<version>/commerce/product/list/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/list/attribute-groups/",
  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 token>",
  ),
));

$response = curl_exec($curl);

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

## Create attributes group

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/create/attribute-groups/`

This API endpoint will create an attributes group.

#### 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                                                                                                                                                                                                   |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>          | string | Name of attribute                                                                                                                                                                                             |
| attribute\_id<mark style="color:red;">\*</mark> | array  | <p>Attribute id - require an array of attribute ids containing at least one attribute id.</p><p><a data-mention href="/product-attribute#list-attributes">/pages/-MMGTZ7ncCPxGvDbrBEn#list-attributes</a></p> |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/commerce/product/create/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"name":"<name>","attribute_id":["<attribute_id>","<attribute_id>",...]})

};
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>/commerce/product/create/attribute-groups/',
  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 =>'{
    "name":"<name>",
    "attribute_id": ["<attribute_id>","<attribute_id>"]
}',
  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 | name          | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 20 characters.</p>           |
| 400         | Validation Error | attribute\_id | <p>Attribute id is required.</p><p>attribute\_id is not valid or This field may not be blank.</p><p>attribute\_id is not exist.</p> |

## Update attributes group

<mark style="color:green;">`POST`</mark> `‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute-groups/`

This API endpoint will update an attributes groups.

#### 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                                                                            |
| ----------------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
| attrgroup\_id<mark style="color:red;">\*</mark> | string | Id of an attributes group that wants to update.                                        |
| name<mark style="color:red;">\*</mark>          | string | Give a new name if u want to update the name of the group else give the existing name. |
| remove\_attr                                    | array  | An array of attribute ids that wants to remove from the attributes group.              |
| add\_attr                                       | array  | An array of attribute ids that wants to add to the attributes group.                   |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/commerce/product/update/attribute-groups/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"attrgroup_id":"<attrgroup_id>","name":"<name>","add_attr":["<attr_id>","<attr_id>",...],"remove_attr":["<attr_id>","<attr_id>",...]})

};
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>/commerce/product/update/attribute-groups/',
  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 =>'{
    "attrgroup_id":"<attrgroup_id>",
    "name":"<name>",
    "add_attr": ["<attr_id>","<attr_id>",...],
    "remove_attr": ["<attr_id>","<attr_id>",...]
}',
  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         | Invalid Input    | attrgroup\_id | <p>This field is required.</p><p>attrgroup\_id is not valid or This field may not be blank</p>                                                                |
| 400         | Validation Error | name          | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 20 characters.</p>                                     |
| 400         | Validation Error | attribute\_id | <p>\<attribute\_id>  is not valid or This field may not be blank.</p><p>\<attribute\_id>  is not exist.</p><p>\<attribute\_id> is already exist in group.</p> |


# Product Attribute

Manage product attributes

### Create attribute

<mark style="color:green;">`POST`</mark> `‎‎ https://<domain>/<api prefix>/<version>/commerce/product/create/attribute/`

This endpoint will help to create a new attribute to 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                                                                                                                                        |
| --------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>        | dict    | Attribute name, eg: {"en":"\<name>"}                                                                                                               |
| description<mark style="color:red;">\*</mark> | dict    | Attribute description, eg:{"en":"\<description>"}                                                                                                  |
| data\_type<mark style="color:red;">\*</mark>  | string  | Data type, possible values are **String, Integer, Float, and Boolean.**                                                                            |
| widget<mark style="color:red;">\*</mark>      | string  | Supported widgets are **select\_box, radio\_button, color\_box, textfield, textarea, and datepicker**.                                             |
| options<mark style="color:red;">\*</mark>     | array   | <p>contains at least one dict with the following keys</p><p>{"status": \<boolean>,"label":"\<string>","value":"\<string>","weight":\<integer>}</p> |
| is\_unique                                    | boolean |                                                                                                                                                    |
| is\_display                                   | boolean |                                                                                                                                                    |
| is\_required                                  | boolean |                                                                                                                                                    |
| attribute\_for                                | string  | general or varients                                                                                                                                |

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

```
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**&#x20;

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': '‎ https://<domain>/<api prefix>/<version>/commerce/product/create/attribute/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  body: JSON.stringify({"name":{"en":"<name in english>","de":"<name in german>"},"data_type":"<attribute data type>","attribute_for":"<attribute for>","widget":"<widget type>","description":{"en":"<description in english>","de":"<description in german>"},"is_unique":"<is unique value>","is_required":"<is required>","is_display":"<need to display>","options":[{"status":"<attribute option status>","label":"<attribute option label>","value":"<attirbute option value>","weight":"<attirbute option weight>"},{"status":"<attribute option status>","label":"<attribute option label>","value":"<attirbute option value>","weight":"<attirbute option weight>"}]})

};
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>/commerce/product/create/attribute/",
  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 =>"{\"name\":{\"en\":\"<name in english>\",\"de\":\"<name in german>\"},\"data_type\":\"<attribute data type>\",\"attribute_for\":\"<attribute for>\",\"widget\":\"<widget type>\",\"description\":{\"en\":\"<description in english>\",\"de\":\"<description in german>\"},\"is_unique\":\"<is unique value>\",\"is_required\":\"<is required>\",\"is_display\":\"<need to display>\",\"options\":[{\"status\":\"<attribute option status>\",\"label\":\"<attribute option label>\",\"value\":\"<attirbute option value>\",\"weight\":\"<attirbute option weight>\"},{\"status\":\"<attribute option status\",\"label\":\"<attribute option label>\",\"value\":\"<attirbute option value>\",\"weight\":\"<attirbute option weight>\"}]}",
  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 | name        | Name for {language code}  language is required.                                                                |
| 400         | Validation Error | description | <p>Description for {language code} langauge is required.</p><p></p>                                            |
| 400         | Validation Error | widget      | {widget name} is not a valid choice. Supported widgets are {widgets}.                                          |
| 400         | Validation Error | widget      | {widget name} is not a valid choice. Supported widgets for data type {data type} is/are {widget/widgets}.      |
| 400         | Validation Error | data\_type  | {data\_type} is not a valid choice. Supported data types are {data}.                                           |
| 400         | Validation Error | widget      | {widget} widget can't be selected for an {data\_type} data type.                                               |
| 400         | Validation Error | options     | The selected widget-data\_type attribute doesn't support any options. leave it as empty or no need to mention. |
| 400         | Validation Error | options     | This field is required.                                                                                        |
| 400         | Validation Error | name        | All languages of names must have a description of the corresponding language.                                  |

### List Attributes

<mark style="color:blue;">`GET`</mark> `‎‎ https://<domain>/<api prefix>/<version>/commerce/product/list/attributes/`

This endpoint will return list of available product attributes

#### Query Parameters

| Name     | Type   | Description  |
| -------- | ------ | ------------ |
| en\_name | string | English name |

#### 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 " %}

```html
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <id>,
                "name": {
                    "en": "<name in english>",
                    "de": "<name in german>"
                },
                "description": {
                    "en": "<description in english>",
                    "de": "<description in german>"
                },
                "widget": "<widget type>",
                "attribute_for": "<attribute for>",
                "is_unique": <is unique value>,
                "is_required": <is required>,
                "is_display": <need to display>,
                "options": [
                    {
                        "label": "<attribute option label>",
                        "value": "<attirbute option value>",
                        "status": <attribute option status>,
                        "weight": <attirbute option weight>
                    },
                    {
                        "label": "<attribute option label>",
                        "value": "<attirbute option value>",
                        "status": <attribute option status>,
                        "weight": <attirbute option weight>
                    }
                ],
                "data_type": "<attribute data type>",
                "status": 1
            }
        ],
        "count": <total attibutes count>,
        "previous": <previous url>,
        "next": <next url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Node

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': '‎ https://<domain>/<api prefix>/<version>/commerce/product/list/attributes/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/list/attributes/",
  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 token>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

### Get A Attribute

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/get/attribute/<attribute id>/`

This endpoint will return a single attribute details

#### Headers

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

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

```html
{
    "status_code": 200,
    "errors": {},
    "data": {
        "id": <id>,
        "name": {
            "en": "<name in english>",
            "de": "<name in german>"
        },
        "description": {
            "en": "<description in english>",
            "de": "<description in german>"
        },
        "widget": "<widget type>",
        "attribute_for": "<attribute for>",
        "is_unique": <is unique value>,
        "is_required": <is required>,
        "is_display": <need to display>,
        "options": [
            {
                "label": "<attribute option label>",
                "value": "<attirbute option value>",
                "status": <attribute option status>,
                "weight": <attirbute option weight>
            },
            {
                "label": "<attribute option label>",
                "value": "<attirbute option value>",
                "status": <attribute option status>,
                "weight": <attirbute option weight>
            }
        ],
        "data_type": "<attribute data type>",
        "status": 1
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': '‎https://<domain>/<api prefix>/<version>/commerce/product/get/attribute/<attribute id>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/get/attribute/<attribute_id>/",
  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 token"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

### Delete Attribute

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/delete/attribute/<attribute id>/`

This endpoint will help to delete a product attribute from the system.

#### 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 " %}

```
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/attribute/<attribute_id>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/delete/attribute/<attribute_id>/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

### Update Attribute

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/update/attribute/<attribute id>/`

This endpoint will help to edit a product attribute details.

#### 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              |
| ---- | ------ | ------------------------ |
|      | String | Same as create attribute |

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

```
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/update/attribute/<attribute_id>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  body: JSON.stringify({"name":{"en":"<name in english>","de":"<name in german>"},"data_type":"<attribute data type>","attribute_for":"<attribute for>","widget":"<widget type>","description":{"en":"<description in english>","de":"<description in german>"},"is_unique":"<is unique value>","is_required":"<is required>","is_display":"<need to display>","options":[{"status":"<attribute option status>","label":"<attribute option label>","value":"<attirbute option value>","weight":"<attirbute option weight>"},{"status":"<attribute option status>","label":"<attribute option label>","value":"<attirbute option value>","weight":"<attirbute option weight>"}]})

};
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>/commerce/product/update/attribute/<attribute_id>/",
  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 =>'{
    "name":{"en":"<name>"},
    "description":{"en":"<description>"},
    "data_type":"<data_type>",
    "widget":"<widget>",
    "options":[{"status": <status>,"label":"<attribute_option_label>","value":"<value>","weight":<weight>}]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

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


# Product Catalogue

Manage product catalogue

## **List catalogues**

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/list/catalogue/`

This API endpoint will return a list of product catalogue&#x20;

#### Query Parameters

| Name   | Type   | Description                                                                                                        |
| ------ | ------ | ------------------------------------------------------------------------------------------------------------------ |
| offset | string | The offset indicates the starting position of the query in relation to the complete set of unpaginated items.      |
| limit  | string | The limit indicates the maximum number of items to return, default maximum number is 50, and maximum limit is 100. |

#### 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 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <catalogue_id>,
                "name": "<catalogue_name>",
                "parent_id": <parent_id>,
                "image": "<image_path>",
                "parent": {
                    "id": <parent_id>,
                    "name": "<parent_name>"
                },
                "translation": [
                    {
                        "name": "<catalogue_name>",
                        "language_code": "<language_code>",
                        "entity_id": <entity_id>
                    }
                    ...
                ]
            },
            ...
        ],
        "count": <list_count>,
        "previous": "<link_for_previous_page_list>",
        "next": "<link_for_next_page_list>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/catalogue/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/list/catalogue/",
  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 token>",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## Create C**atalogue**

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/create/catalogue/`

This API endpoint will create a product catalogue

#### Headers

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

#### Request Body

| Name                                         | Type   | Description            |
| -------------------------------------------- | ------ | ---------------------- |
| name<mark style="color:red;">\*</mark>       | string | Name of catalogue      |
| parent\_id<mark style="color:red;">\*</mark> | string | Parent id of catalogue |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/commerce/product/create/catalogue/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'name ': '<catalogue_name>',
    'parent_id': '<parent_id>'
  }
};
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>/commerce/product/create/catalogue/",
  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('name ' => '<catalogue_name>','parent_id' => '<parent_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 | name       | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 200 characters.</p><p>""Catalogue name already selected. Please choose different name !"</p> |
| 400         | Validation Error | parent\_id | <p>Parent id is required</p><p>This field may not be blank</p><p>Incorrect type. Expected pk value, received str.</p><p>Invalid pk "parent\_id" - object does not exist.</p>                        |

## Update Catalogue

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/update/catalogue/`

This API endpoint will update a product catalogue.

#### 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                             |
| -------------------------------------------- | ------ | --------------------------------------- |
| id<mark style="color:red;">\*</mark>         | string | Catalogue id                            |
| name<mark style="color:red;">\*</mark>       | string | New name or existing name of catalogue. |
| parent\_id<mark style="color:red;">\*</mark> | string | Parent id                               |

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

```
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/commerce/product/update/catalogue/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'id': '<catalogue_id>',
    'name': '<name>',
    'parent_id': '<parent_catalogue_id>'
  }
};
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>/commerce/product/update/catalogue/",
  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('id' => '<catalogue_id>','name' => '<name>','parent_id' => '<parent_catalogue_id>'),
  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                                            | Invalid Input | id    | <p>Catalogue id is required.</p><p>This field may not be blank.</p><p>Catalogue id is not valid.</p><p>Catalogue does not exist.</p> |
| All other error responses of create catalogue. |               |       |                                                                                                                                      |

## Delete Catalogue

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/delete/catalogue/?id=<id>`

This API endpoint will delete a product catalogue.

#### Query Parameters

| Name                                 | Type   | Description  |
| ------------------------------------ | ------ | ------------ |
| id<mark style="color:red;">\*</mark> | string | Catalogue id |

#### 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 " %}

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/catalogue/?id=<id>',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/delete/catalogue/?id=<id>",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  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                                                                                                                   |
| ----------- | -------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed |       | Catalogue can't delete or remove                                                                                              |
| 400         | Invalid Input  | id    | <p>Catalogue id is not valid.</p><p>Catalogue does not exist.<br>This field may not be blank<br>Catalogue id is required.</p> |


# Product Details

get complete details of a product

## Get Product Details

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/product-details/`

This API endpoint will return details of the product.

#### Query Parameters

| Name                                         | Type   | Description          |
| -------------------------------------------- | ------ | -------------------- |
| bundle\_id<mark style="color:red;">\*</mark> | number | bundle id(unique id) |

#### 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 " %}

```html
HTTP/1.1 200 OK
Content-Type: application/json
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "displaydata": [
            {
                "attributes": {
                    "<machine_code>": {
                        "attr_id": <attribute_id>,
                        "language": "<language>",
                        "attr_name": "<attr_name>",
                        "attr_type": "<attr_type>",
                        "attr_value": "<attr_value>",
                        "machine_code": "<machine_code>"
                    },
                    ...
                },
                "extra_discount": "<extra_discount>",
                "additional_data": "<additional_data>",
                "varient_attributes": {
                    "541": {
                        "sku": "<sku>",
                        "<machine_code>": {
                            "attr_id": <attr_id>,
                            "language": "<language>",
                            "attr_name": "<attr_name>",
                            "attr_type": "<attr_type>",
                            "is_unique": <is_unique>,
                            "attr_value": "<attr_value>",
                            "is_display": <is_display>,
                            "attr_widget": "<attr_widget>",
                            "is_required": <is_required>,
                            "machine_code": "<machine_code>"
                        },
                        ...
                    }
                },
                "description": "<description>",
                "short_description": "<short_description>",
                "currency": "<currency>",
                "images": [
                    "<images>"
                ]
            }
        ],
        "rating": {
            "total_rating": <total_rating>,
            "rating": []
        },
        "media_path": "<media_path>",
        "reserve": <reserve>,
        "similar_products": []
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/product-details/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/product-details/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | Field      | Description                                                |
| ----------- | ---------------- | ---------- | ---------------------------------------------------------- |
| 400         | Validation Error | bundle\_id | <p>Bundle id is required.</p><p>Bundle does not exist.</p> |


# Product Review

get each products review and write review for a product

## Write a review

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/product-review/`

Using this API users can write a review for a previously purchased product.

#### Headers

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

#### Request Body

| Name                                      | Type   | Description                   |
| ----------------------------------------- | ------ | ----------------------------- |
| comment<mark style="color:red;">\*</mark> | string | review comment                |
| bundle<mark style="color:red;">\*</mark>  | number | product bundle id (unique id) |
| stars<mark style="color:red;">\*</mark>   | number | no. of stars given            |

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

```
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/commerce/product/product-review/',
  'headers': {
    'apikey': '<api key>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'comment': '<comment>',
    'stars': '<star count>',
    'bundle': '<bundle id>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```typescript
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
  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('bundle' => '<bundle_id>','comment' => '<>comment','stars' => '<stars_count>'),
  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 | bundle  | <p>Bundle id is required.</p><p>This field may not be blank.</p><p>Product with bundle id not exist.</p> |
| 400         | Validation Error | comment | comment is required                                                                                      |
| 400         | Validation Error | stars   | stars count is required                                                                                  |

## Get Review Status

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/product-review/`

This endpoint will return how many times the user purchased this product previously.

#### Query Parameters

| Name       | Type   | Description |
| ---------- | ------ | ----------- |
| bundle\_id | string |             |

#### 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 " %}

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

{% endtab %}
{% endtabs %}

#### Note:

All Reviews from different users of a product are fetched in product details api.

#### Sample Code

#### **Node**

```typescript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/product-review/',
  'headers': {
    'apikey': '<api key>',
    'Authorization': 'Bearer <access token>',
    'Cookie': 'defult_store_slug=admin_store; store_user=admin_store'
  },
  formData: {

  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

#### PHP

```typescript
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://<domain>/<api prefix>/<version>/commerce/product/product-review/');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'apikey' => '<api key>',
  'Authorization' => 'Bearer <access token>',
  'Cookie' => 'defult_store_slug=admin_store; store_user=admin_store'
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

#### Error Responses

| Status Code | Error Type       | Field      | Description                                                                                              |
| ----------- | ---------------- | ---------- | -------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | bundle\_id | <p>Bundle id is required.</p><p>This field may not be blank.</p><p>Product with bundle id not exist.</p> |


# Product Category

Manage product category

## List Product Categories

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/list/categories/`

This API endpoint will return a list of the product category (product-type)

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| offset | string |             |
| limit  | string |             |

#### 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 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <category_id>,
                "name": "<category_name>",
                "status": <status>,
                "has_inventory": <has_inventory_boolean>,
                "has_recurring": <has_recurring_boolean>,
                "has_variants": <has_variants_boolean>,
                "has_shippable": <has_shippable_boolean>,
                "has_discount": <has_discount_boolean>,
                "created": "<created_date>",
                "modified": "<modified_date>",
                "data": {
                    "tax": {
                        "method": "<method_name>",
                        "method_status": <status>
                    },
                    "afl_fees": {
                        "method": "<method_name>",
                        "method_status": <status>
                    },
                    ...
                },
                "slug": "<slug>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_link>,
        "next": "<next_page_link>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/categories/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/list/categories/",
  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 token>",
  ),
));

$response = curl_exec($curl);

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

## Create Product Category

Create a Product category (Product - Type).

* First, Get the list of enabled product type method configuration through the below-provided endpoint.
* Then Create product type through the post method.

### Active Product Type Method Configurations

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/`

This API endpoint will return  enabled product type method configurations

#### 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 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "EnabledProductTypeMethodConf": [
            {
                "method": "<method_name>",
                "weight": <weight>,
                "title": "<method_title>",
                "description": "<method_description>",
                "attr_slug": [],
                "disabled_status": <status>
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/get/producttype/methodconf/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/get/producttype/methodconf/',
  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 token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

### Create Product Type

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/create/category/`

This API endpoint will create a product type.

#### 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                                                                                                                                                                                                                    |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| name<mark style="color:red;">\*</mark>           | string | Method name                                                                                                                                                                                                                    |
| translations<mark style="color:red;">\*</mark>   | object | name translations for name                                                                                                                                                                                                     |
| method<mark style="color:red;">\*</mark>         | array  | <p>An array of the string contains method names</p><p><a data-mention href="#active-product-type-method-configurations">#active-product-type-method-configurations</a></p>                                                     |
| catalogue\_ids<mark style="color:red;">\*</mark> | array  | <p>An array of integer contains catalogue ids</p><p><a data-mention href="/product-catalogue#list-catalogues">/pages/-MMYxeDt21MtgYbSzJLX#list-catalogues</a></p>                                                              |
| attr\_grp\_ids<mark style="color:red;">\*</mark> | array  | <p>An array of integerS contains product attribute group ids,<br>Require at least  one group id</p><p><a data-mention href="/group-attributes#list-attributes-group">/pages/-MM3zChhwWl38L3-GwL2#list-attributes-group</a></p> |

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

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

{% endtab %}
{% endtabs %}

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

```php
{
    "name": "<product-type-name>",
    "translations": {
        "<language_code>": "<name>",
        "<language_code>": "<name>",
        ...
    },
    "method": [
        "<method_name>",
        "<method_name>",
        ...
    ],
    "catalogue_ids": [
        <catalogue_id>,
        <catalogue_id>,
        ...
    ],
    "attr_grp_ids": [
        <attr_grp_ids>,
        <attr_grp_ids>,
        ...
    ]
}
```

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/category/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"name":"<method-name>","translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>],"attr_grp_ids":[<id>,<id>]})
};
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>/commerce/product/create/category/',
  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 =>'{
    "name": "<method_name>",
    "translations": {
        "<language_code>": "<name>",
        "<language_code>": "<name>"
    },
    "method": [
        "<method_name>",
        "<method_name>"
    ],
    "catalogue_ids": [
        <id>,
        <id>
    ],
    "attr_grp_ids": [
        <id>,
        <id>
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld          | Description                                                                                                                              |
| ----------- | ---------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | name           | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 250 characters.</p>               |
| 400         | Validation Error | catalogue\_ids | <p>Provided \<catalogue\_ids> is not a valid catalogue id</p><p>Provided \<catalogue\_ids> does not exist</p>                            |
| 400         | Validation Error | attr\_grp\_ids | <p>Provide at least one group</p><p>Provided \<attr\_grp\_id> is not a valid group id</p><p>Provided \<attr\_grp\_id> does not exist</p> |

## Update Product Category

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/update/category/`

This API endpoint will update a product category.

#### 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                                                                                                   |
| ------------------------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------- |
| ptype<mark style="color:red;">\*</mark>          | integer | Product type id                                                                                               |
| name<mark style="color:red;">\*</mark>           | string  | New or existing name of the product type                                                                      |
| attr\_grp\_ids<mark style="color:red;">\*</mark> | array   | <p>Replace with a new array of integer or existing group ids,<br>Require at least one attribute group id.</p> |
| translations<mark style="color:red;">\*</mark>   | object  | name translations for name                                                                                    |
| method<mark style="color:red;">\*</mark>         | array   | An array of the string contains method names                                                                  |
| catalogue\_ids<mark style="color:red;">\*</mark> | array   | An array of integer contains catalogue ids                                                                    |

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

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

{% endtab %}
{% endtabs %}

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

```php
{    
    "ptype":<product_typ>,
    "name": "<product-type-name>",
    "translations": {
        "<language_code>": "<name>",
        "<language_code>": "<name>",
        ...
    },
    "method": [
        "<method_name>",
        "<method_name>",
        ...
    ],
    "catalogue_ids": [
        <catalogue_id>,
        <catalogue_id>,
        ...
    ],
    "attr_grp_ids": [
        <attr_grp_ids>,
        <attr_grp_ids>,
        ...
    ]
}
```

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/update/category/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"ptype":<product_type_id>,"name":"<name>","attr_grp_ids":[<id>,<id>],"translations":{"<language_code>":"<name>","<language_code>":"<name>"},"method":["<method_name>","<method_name>"],"catalogue_ids":[<id>,<id>]})

};
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>/commerce/product/update/category/',
  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 =>'{
    "ptype":<product_type_id>,
    "name":"<name>",
    "attr_grp_ids":[
        <id>,
        <id>
    ],
    "translations": {
        "<language_code>":"<name>",
        "<language_code>":"<name>"
    },
    "method": [
        <method_name>",
        <method_name>"
    ],
     "catalogue_ids": [
        <id>,
        <id>         
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | FIeld          | Description                                                                                                                             |
| ----------- | ---------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | ptype          | <p>Product Type id is required.</p><p>This field may not be blank.</p><p>Product Type does not exist.</p>                               |
| 400         | Validation Error | name           | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 250 characters.</p>              |
| 400         | Validation Error | catalogue\_ids | <p>Provided \<catalogue\_ids> is not a valid catalogue id</p><p>Provided \<catalogue\_ids> does not exist</p>                           |
| 400         | Validation Error | attr\_grp\_ids | <p>Provide at least one group</p><p>Provided \<attr\_grp\_id> is not a valid group id</p><p>Provided \<attr\_grp\_id> does not exis</p> |

## Delete Product Category

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>`

This API endpoint will delete a product category

#### Query Parameters

| Name                                 | Type   | Description         |
| ------------------------------------ | ------ | ------------------- |
| id<mark style="color:red;">\*</mark> | string | Product category id |

#### Headers

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

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/category/?id=<category_id>',
  '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>/commerce/product/delete/category/?id=<category_id>",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  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         | Invalid Input  | id    | <p>Category id is not valid.</p><p>Category does not exist.<br>This field may not be blank<br>Category id is required.</p> |
| 401         | Request Failed |       | <p>There are products in this category.you can't delete it</p><p>Category can't delete or remove</p>                       |


# Product

Manage Product

## Create Product

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/create/`

This API endpoint will create a product under an external-api-product type.

#### 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                                                                                                                                                                                                                                               |
| ------------------------------------------------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bundle\_id<mark style="color:red;">\*</mark>                       | string | Bundle id(bundle unique id)                                                                                                                                                                                                                               |
| name<mark style="color:red;">\*</mark>                             | string | Product bundle name                                                                                                                                                                                                                                       |
| bundle\_name\_translations<mark style="color:red;">\*</mark>       | string | <p>Translations for a product bundle.<br>A Bundle name in English is required.</p>                                                                                                                                                                        |
| description\_translations<mark style="color:red;">\*</mark>        | string | <p>Product description,<br>Description in English is required.</p>                                                                                                                                                                                        |
| short\_description\_translations<mark style="color:red;">\*</mark> | string | <p>Product short description,<br>A short description in English is required.</p>                                                                                                                                                                          |
| varients<mark style="color:red;">\*</mark>                         | string | <p>At least one varient is required.<br>Varient must contain price, product-name, and whole-sale-price. and ensure that the selected product type only contains these three varients. <br>Additionally, add a key product-sku (product unique sku).  </p> |
| attributes<mark style="color:red;">\*</mark>                       | string | The attribute must contain business-volume, points,  and, cumulative-volume.                                                                                                                                                                              |

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

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

{% endtab %}
{% endtabs %}

**Note**:-

By using this API endpoint you can create a product under product type external-api-product.

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

```markup
{
    "bundle_id":"<bundle_id>",
    "name":"<bundle_name>",
    "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
    "description_translations":{"en": "<description_en>","de": "<description_dn>"},
    "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
    "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
    "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
}
```

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/create/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "bundle_id":"<bundle_id>",
    "name":"<bundle_name>",
    "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
    "description_translations":{"en": "<description_en>","de": "<description_dn>"},
    "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
    "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
    "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
  })

};
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>/commerce/product/create/',
  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 =>'{
    "bundle_id":"<bundle_id>",
    "name":"<bundle_name>",
    "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
    "description_translations":{"en": "<description_en>","de": "<description_dn>"},
    "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
    "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
    "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------- | ---------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |                                  | Required product type for creating product using api is not created.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| 400         | Validation Error | bundle\_id                       | <p>Bundle id is required.</p><p>This field may not be blank.</p><p>Produt with same bundle id is already exist.</p>                                                                                                                                                                                                                                                                                                                                                                                 |
| 400         | Validation Error | name                             | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 200 characters.</p>                                                                                                                                                                                                                                                                                                                                                                          |
| 400         | Validation Error | bundle\_name\_translations       | <p>This field is required.</p><p>Bundle Name for en language is required.</p>                                                                                                                                                                                                                                                                                                                                                                                                                       |
| 400         | Validation Error | description\_translations        | <p>This field is required.</p><p>Description of en language is required.</p>                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 400         | Validation Error | short\_description\_translations | <p>This field is required.</p><p>A short description of en language is required.</p>                                                                                                                                                                                                                                                                                                                                                                                                                |
| 400         | Validation Error | varients                         | <p>This field is required.</p><p>You can't possible add a product under the requested product type. Select a product type have only Price, Whole sale price and Product name as varients.</p><p>One of the varient object is not valid, check each varient objects contains price,product-name,whole-sale-price and product-sku.</p><p>At least one varient is required.</p><p>Product id should be a unique value.</p><p>Product id may not be a null value. Same product id's recieved.</p>       |
| 400         | Validation Error | attributes                       | <p>This field is required.</p><p>You cant possible to add product under the requested product type. Select a product type have only Business-volume, Pointes and Cumulative-volume as attributes.</p><p>Attribute should contains Business-volume, Points and Cumulative-volume, not include another attributes.</p><p>Business-volume is required.</p><p>Points is required.</p><p>Cumulative-volume is required.</p><p>Attribute must contains Business-volume, Points and Cumulative-volume.</p> |

## Update Product

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/update/`

This API endpoint will update a product bundle if it's an external-api-product type .

#### Headers

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

#### Request Body

| Name                                                               | Type   | Description                                                                                                                                                                                                                   |
| ------------------------------------------------------------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bundle\_id<mark style="color:red;">\*</mark>                       | string | Product bundle unique id                                                                                                                                                                                                      |
| name<mark style="color:red;">\*</mark>                             | string | New name or existing name for bundle.                                                                                                                                                                                         |
| bundle\_name\_translations<mark style="color:red;">\*</mark>       | string | Existing  or New Translations for a product bundle.                                                                                                                                                                           |
| description\_translations<mark style="color:red;">\*</mark>        | string | Existing or New Translations for Product description                                                                                                                                                                          |
| short\_description\_translations<mark style="color:red;">\*</mark> | string | Existing or New Translations for Product short description,                                                                                                                                                                   |
| varients<mark style="color:red;">\*</mark>                         | string | Varient must contain price, product-name, and whole-sale-price. Additionally, add a key product-sku with aexisting sku as a value if u want to update existing variant or give new sku as a value to add new product varient. |
| attributes<mark style="color:red;">\*</mark>                       | string | The attribute must contain business-volume, points, and, cumulative-volume.                                                                                                                                                   |

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

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

{% endtab %}
{% endtabs %}

**Note**:-

By using this API endpoint you can update a product that is under external-api-product.

Additionally, add a key  product-sku with a existing id as a value if you want to update the existing varien&#x74;*.* Give new id as a value of product-sku for adding a new product varient.&#x20;

Body Parameters are JSON.stringify, Refer below block for the body parameter structure, and also refer sample code.

```markup
{
    "bundle_id":"<bundle_id>",
    "name":"<bundle_name>",
    "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
    "description_translations":{"en": "<description_en>","de": "<description_dn>"},
    "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
    "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":<product_sku>},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":<product_sku>}],
    "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
}
```

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/update/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "bundle_id":"<bundle_id>",
    "name":"<bundle_name>",
    "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
    "description_translations":{"en": "<description_en>","de": "<description_dn>"},
    "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
    "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":<product_sku>},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":<product_sku>}],
    "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
})

};
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>/commerce/product/update/',
  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 =>'{
    "bundle_id":"<bundle_id>",
    "name":"<bundle_name>",
    "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
    "description_translations":{"en": "<description_en>","de": "<description_dn>"},
    "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
    "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":<product_sku>},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":<product_sku>}],
    "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
}',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------- | ---------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Invalid Input    | bundle\_id                       | <p>Bundle id is required.</p><p>This field may not be blank.</p><p>Bundle does not exist.</p><p>Requested bundle is not under the external api product category.</p>                                                                                                                                                                                                                                                                                                  |
| 400         | Validation Error | name                             | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 200 characters.</p>                                                                                                                                                                                                                                                                                                                                            |
| 400         | Validation Error | description\_translations        | <p>This field is required.</p><p>Description of en language is required.</p>                                                                                                                                                                                                                                                                                                                                                                                          |
| 400         | Validation Error | short\_description\_translations | <p>This field is required.</p><p>A short description of en language is required.</p>                                                                                                                                                                                                                                                                                                                                                                                  |
| 400         | Validation Error | varients                         | <p>You can't possible add a product under the requested product type. Select a product type have only Price, Whole sale price and Product name as varients.</p><p>One of the varient object is not valid, check each varient objects contains price,product-name,whole-sale-price and product-sku.</p><p>At least one varient is required.</p><p>Product sku should be a unique value. Product sku may not be a null value. Same product sku's recieved.</p>          |
| 400         | Validation Error | attributes                       | <p>You cant possible to add product under the requested product type. Select a product type have only Business-volume, Pointes and Cumulative-volume as attributes.</p><p>Attribute should contains Business-volume, Points and Cumulative-volume, not include another attributes.</p><p>Business-volume is required.</p><p>Points is required.</p><p>Cumulative-volume is required.</p><p>Attribute must contains Business-volume, Points and Cumulative-volume.</p> |

## Delete Product Bundle

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/delete/`

This API endpoint will delete a product bundle if it's an external-api-product type.

#### Query Parameters

| Name                                         | Type   | Description |
| -------------------------------------------- | ------ | ----------- |
| bundle\_id<mark style="color:red;">\*</mark> | string | Bundle id   |

#### 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 " %}

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/?bundle_id=<bundle_id>',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/delete/?bundle_id=<bundle_id>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  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         | Invalid Input  | bundle\_id | <p>Bundle id is required.</p><p>This field may not be blank.</p><p>Product Bundle does not exist.</p><p>Product Bundle is not a external-api-product type.</p> |
| 401         | Request Failed |            | <p>The product contains in a order that is not completed yet.</p><p>The package purchased by some users.</p>                                                   |

## Delete Product Varient

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/delete/product-varient/`

This API endpoint will delete a varient (product) from the product bundle if it's an external-api-product type.&#x20;

#### Query Parameters

| Name                                           | Type   | Description  |
| ---------------------------------------------- | ------ | ------------ |
| bundle\_id<mark style="color:red;">\*</mark>   | string | Bundle id    |
| product\_sku<mark style="color:red;">\*</mark> | string | Product sku. |

#### 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 " %}

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

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/delete/product-varient/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/delete/product-varient/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  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 | product\_sku | <p>This field is required.</p><p>This field may not be blank.</p><p>Product sku is not valid.</p><p>Product does not exist.</p>                                                                                                         |
| 400         | Validation Error | bundle\_id   | <p>This field is required.</p><p>This field may not be blank.</p>                                                                                                                                                                       |
| 401         | Request Failed   |              | <p>Only one varient left under the product bundle, can't delete it.</p><p>You can delete a product under the external-api-product not athor category product.</p><p>Only one varient left under the prouct bundle, can't delete it.</p> |

## List Products

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/list/`

This API endpoint List product bundle with product details.

#### Query Parameters

| Name     | Type   | Description         |
| -------- | ------ | ------------------- |
| offset   | string |                     |
| limit    | string |                     |
| name     | string | Product Bundle name |
| category | string | Product type        |

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
             {
                "name": "<bundli_name>",
                "product_type": "<product_type>",
                "status": <status>,
                "products": [
                    {
                        "product_id": "<product_id>",
                        "name": "<product_name>",
                        "product_type": "<product_type_name>",
                        "base_price": "<product_price>",
                        "status": <status>,
                        "image": "<image>"
                    }
                ],
                "bundle_id": "<bundle_id>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/commerce/product/list/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

## Create Bulk Products

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/bulk/create/`

This API endpoint will create bulk product.

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "Product_creation_failed": {
            "same_bundle_id": [<return if already exist product with same bundle id.>],
            "bundle_id_null": [<return if bunle is a null value.>],
            "bundle_id_not_found": [<return if bundle id is not given.>]
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Body params :- JSON.stringify

```php
[
    {
        "bundle_id":"<bundle_id>",
        "name":"<bundle_name>",
        "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
        "description_translations":{"en": "<description_en>","de": "<description_dn>"},
        "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
        "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sk>"}],
        "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
    },
    {
        "bundle_id":"<bundle_id>",
        "name":"<bundle_name>",
        "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
        "description_translations":{"en": "<description_en>","de": "<description_dn>"},
        "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
        "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sju>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
        "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
    },
    ...
]
```

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/bulk/create/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify([{
        "bundle_id":"<bundle_id>",
        "name":"<bundle_name>",
        "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
        "description_translations":{"en": "<description_en>","de": "<description_dn>"},
        "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
        "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
        "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
     },
     {
        "bundle_id":"<bundle_id>",
        "name":"<bundle_name>",
        "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
        "description_translations":{"en": "<description_en>","de": "<description_dn>"},
        "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
        "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
        "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
     },
    ...
    ])

};
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>/commerce/product/bulk/create/',
  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 =>'[
   {
        "bundle_id":"<bundle_id>",
        "name":"<bundle_name>",
        "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
        "description_translations":{"en": "<description_en>","de": "<description_dn>"},
        "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
        "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
        "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
   },
   {
        "bundle_id":"<bundle_id>",
        "name":"<bundle_name>",
        "bundle_name_translations":{"en": "<bundle_name_en>","de": "<bundle_name_de>"},
        "description_translations":{"en": "<description_en>","de": "<description_dn>"},
        "short_description_translations":{"en": "<short_description_en>","de": "<short_description_de>"},
        "varients":[{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"},{"price":<product_price>,"product-name":"<product_name>","whole-sale-price":<whole_sale_price>,"product-sku":"<product_sku>"}],
        "attributes":{"business-volume":<business-volume>, "points":<reward_point>, "cumulative-volume":<cumulative_volume>}
   },
    ...
  ]',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type     | FIeld | Description                                                                                                                |
| ----------- | -------------- | ----- | -------------------------------------------------------------------------------------------------------------------------- |
| 400         | Request Failed |       | <p>Required product type for creating product using api is not created.</p><p>Maximum bulk create product count is 50.</p> |

Check error responses of the create product endpoint.

## List API Product

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/product/list/api-products/`

This API endpoint will return a list of products that are created by api.

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "bundle_id": "<bundle_id>",
                "bundle_name": "<bundle_name>",
                "products": [
                    {
                        "product_id": "<product_id>",
                        "name": "<product_name1>",
                        "base_price": <base_price>,
                        "status": <status>
                    },
                    ...
                ]
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/product/list/api-products/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/commerce/product/list/api-products/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# Order

## **Create Order**

<mark style="color:green;">`POST`</mark> `https://<domain>/<api prefix>/<version>/commerce/create-order/`&#x20;

This API Endpoint will create an order.

#### 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                                                                                                                                                                                                                                                                                     |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| uid<mark style="color:red;">\*</mark>           | string | user id                                                                                                                                                                                                                                                                                         |
| total\_amount<mark style="color:red;">\*</mark> | number | Order total amount                                                                                                                                                                                                                                                                              |
| address<mark style="color:red;">\*</mark>       | object | <p>Is an object for address details, the object should contain address\_first\_name, address\_last\_name, address\_mail\_id, address\_phone\_number, address\_name\_line, address\_premise, address\_locality,  address\_postal\_code, address\_country\_code, and address\_state\_code<br></p> |
| products<mark style="color:red;">\*</mark>      | array  | <p>Must be an array of products,<br>product object should contain product\_id, quantity, unit\_price, discount, and total\_amount.</p>                                                                                                                                                          |

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

```
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/commerce/create-order/',
  'headers': {
    'apikey': '<apikey>'
  },
  body: JSON.stringify(
    {
        "products": [
            {
                "product_id": <product id>,
                "quantity":<product quantity>,
                "unit_price":<product unit price>,
                "discount":<product total dicount>,
                "total_amount":<lineitem total amount>
            }
        ],
        "address": {
            "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>"
        },
        "total_amount":<total order amount>,
        "uid":"<user id>"
    }
  )

};
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>/commerce/create-order/',
  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 =>'{
    "products": [
        {
            "product_id":<product id>,
            "quantity":<product quantity>,
            "unit_price":<product unit price>,
            "discount":<product total dicount>,
            "total_amount":<lineitem total amount>
        }
    ],
    "address":{
        "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>"
    },
    "total_amount":<total order amount>,
    "uid":"<user id>"
}',
  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 | products               | This field is required. Must have one product.                                               |
| 400         | Validation Error | product\_id            | Invalid product\_id \<product id>                                                            |
| 400         | Validation Error | quantity               | Invalid quantity. Quantity must be greater than 1.                                           |
| 400         | Validation Error | address\_state\_code   | Invalid address\_state\_code                                                                 |
| 400         | Validation Error | address\_country\_code | Invalid address\_country\_code                                                               |
| 400         | Validation Error | uid                    | Invalid user id                                                                              |
| 400         | Validation Error | total\_amount          | Invalid order total\_amount. Order total\_amount must be the sum of line item total\_amount. |

## **Renewal or Upgrade**

<mark style="color:green;">`POST`</mark> `https://<domain>/<api prefix>/<version>/commerce/upgrade-renewal-package/`&#x20;

This API Endpoint will help to package upgrade or renewal

#### 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                         |
| -------------------------------------------------------- | ------ | ----------------------------------- |
| order\_type<mark style="color:red;">\*</mark>            | string | Possible values are upgrade,renewal |
| uid<mark style="color:red;">\*</mark>                    | string | user id                             |
| order\_total<mark style="color:red;">\*</mark>           | number | Order tatal amount                  |
| address\_state\_code<mark style="color:red;">\*</mark>   | string | Adress state code                   |
| address\_country\_code<mark style="color:red;">\*</mark> | string | Adresss county code                 |
| address\_postal\_code<mark style="color:red;">\*</mark>  | string | Adress postal code                  |
| address\_locality<mark style="color:red;">\*</mark>      | string | Address locality                    |
| address\_premise<mark style="color:red;">\*</mark>       | string | Address street                      |
| address\_name\_line<mark style="color:red;">\*</mark>    | string | Address house number                |
| address\_phone\_number<mark style="color:red;">\*</mark> | string | Address phone number                |
| address\_mail\_id<mark style="color:red;">\*</mark>      | string | Address E-mail ID                   |
| address\_last\_name<mark style="color:red;">\*</mark>    | string | Address last name                   |
| address\_first\_name<mark style="color:red;">\*</mark>   | string | Address first name                  |
| discount<mark style="color:red;">\*</mark>               | number | Total discount                      |
| unit\_price<mark style="color:red;">\*</mark>            | number | unit price of the product           |
| product\_id<mark style="color:red;">\*</mark>            | number | product id                          |

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

```
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/upgrade-renewal-package/',
  'headers': {
    'apikey': '<apikey>'
  },
  body: JSON.stringify(
    {        
        "product_id": <product id>,
        "unit_price": <product unit price>,
        "discount": <total discount amount>,
        "order_total": <order total amount>          
        "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>"
        "uid":"<user id>",
        "order_type":"<order type>"
    }
  )

};
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>/commerce/create-order/',
  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 =>'{
    "product_id": <product id>,
    "unit_price": <product unit price>,
    "discount": <total discount amount>,
    "order_total": <order total amount>          
    "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>"
    "uid":"<user id>",
    "order_type":"<order type>"
}',
  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 | product\_id            | Invalid product\_id \<product id>                                                                                         |
| 400         | Validation Error | address\_postcode      | 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 | uid                    | Invalid user id                                                                                                           |
| 400         | Validation Error | product\_id            | Couldn't process your request. Renewal package not same as the existing package. Please check your package and try again. |
| 400         | Validation Error | product\_id            | Couldn't process your request. May be you reached maximum upgrade or invalid package id.                                  |
| 400         | Validation Error | order\_total           | Discount must be less than unit\_price.                                                                                   |
| 400         | Validation Error | order\_total           | Order total must be difference of unit\_price and discount.                                                               |
| 400         | Validation Error | uid                    | You are not placed into the genealogy yet. Please wait until the placement completes.                                     |
| 400         | Validation Error | uid                    | There exists a package upgrade in processing. Please wait until the process complete or contact the site administrator.   |
| 400         | Validation Error | uid                    | System initiated package auto upgrade. Please wait until the process complete.                                            |
| 400         | Validation Error | uid                    | Payment for previous purchase is not completed yet. Please wait until the payment complete or cancel that payment.        |
| 400         | Validation Error | uid                    | There exists a package upgrade in processing. Please wait until the process complete or contact the site administrator.   |
| 400         | Validation Error | uid                    | You cannot perform package upgrade because you have an active refund request.                                             |
| 400         | Validation Error | product\_id            | The supplied package same as the existing package. Please change your package and try again.                              |
| 400         | Validation Error | order\_type            | Invalid order\_type. Supported values are upgrade,renewal                                                                 |
| 400         | Validation Error | product\_id            | You already have an active package.                                                                                       |

## List Orders

<mark style="color:blue;">`GET`</mark> `https://<domain>/<api prefix>/<version>/commerce/all-orders/`

get the list of orders

#### Query Parameters

| Name         | Type   | Description  |
| ------------ | ------ | ------------ |
| order number | string | order number |
| period       | string | period       |
| category     | string | category     |
| limit        | string | limit        |

#### 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 " %}

```
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "orders": [
            {
                "id": <id>,
                "uid": <uid>,
                "order_number": <order number>,
                "data": <data>,
                "order_total": <order_total>,
                "currency_symbol": <currency_symbol>,
                "currency_code": <currency_code>,
                "order_type": <order_type>,
                "status": <status>,
                "created": <created>,
                "modified": <modified>,
                "shipping_id": <shipping_id>,
                "billing_id": <billing_id>
            }
        ],
        "filter_data": <filter data>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require("request");

var options = { method: 'GET',
  url: 'https://<domain>/<api prefix>/<version>/commerce/all-orders/',
  headers: 
   { authorization: 'Bearer <access-token>',
     apikey: '<apikey>',
     'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' }
   } 
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/all-orders/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"product_id\"\r\n\r\n46363\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "authorization: Bearer <access-token>",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

## Order Details

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/order-details/`

get details of order using order\_number

#### 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  |
| ----------------------------------------------- | ------ | ------------ |
| order\_number<mark style="color:red;">\*</mark> | number | order number |

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

```html
{
    "status_code": 200,
    "errors": {},
    "data": [
        {
            "id": <id>,
            "product_id": <product_id>,
            "bundle_id": <bundle_id>,
            "line_item_label": "<line_item_label>",
            "quantity": <quantity>,
            "price": "<price>",
            "data": {
                "price": {
                    "data": [],
                    "items": {
                        "base_price": {
                            "data": [],
                            "title": "<title>",
                            "total": <total>,
                            "included": <included>,
                            "quantity": <quantity>,
                            "description": "<description>",
                            "currency_code": "<currency_code>"
                        }
                    },
                    "title": "<title>",
                    "total": <total>,
                    "quantity": <quantity>,
                    "description": "<description>",
                    "currency_code": "<currency_code>",
                    "revenue_total": <revenue_total>
                },
                "modules": {},
                "product": {
                    "sku": "<sku>",
                    "product_type": "<product_type>",
                    "product_type_code": "<product_type_code>"
                },
                "item_display": {
                    "items": {
                        "varient_attributes": {
                            "title": "<title>",
                            "params": {
                                "price": {
                                    "value": "<value>"
                                },
                                "images": {
                                    "value": "<images>"
                                },
                                "product-name": {
                                    "value": "<product-name>"
                                },
                                "whole-sale-price": {
                                    "value": <whole-sale-price>
                                }
                            },
                            "display": {},
                            "description": "<description>"
                        }
                    }
                }
            },
            "order_id": <order_id>,
            "currency_code": "<currency_code>",
            "order_id_id": <order_id_id>,
            "status": "<status>",
            "image_path": "<image_path>"
        },
        ....
    ]
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/order-details/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'order_number': 'order_number'
  }
};
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>/commerce/order-details/?order_number=<order_number>',
  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_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

<table data-header-hidden><thead><tr><th>status code</th><th width="200">error type</th><th>field</th><th>description</th></tr></thead><tbody><tr><td>status code</td><td>error type</td><td>field</td><td>description</td></tr><tr><td>400</td><td>Validation Error</td><td>order_number</td><td><p>Order Number maynot be blank.</p><p>Order Number is required.</p><p>Invalid order number.</p></td></tr></tbody></table>


# Place Genealogy

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

This endpoint will place the user to genealogy

#### 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 |
| ------------------------------------- | ------ | ----------- |
| uid<mark style="color:red;">\*</mark> | string | user id     |

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

```
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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/place-user-genealogy/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'uid': '<user id>'
  }
};
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/place-user-genealogy/',
  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('uid' => '<user id>'),
  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 | uid   | This field is required.           |
| 400         | Validation Error | uid   | User already placed in genealogy. |
| 400         | Validation Error | uid   | Invalid uid. Please check again.  |


# Rank Details

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

This endpoint will return the rank details of the user

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "rank": {
            "uid": "<user_id>",
            "title": "<rank_title>",
            "image": "<rank_image>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/rank-details/?uid=<user id>',
  'headers': {
    'apikey': '<apikey>',
    'Authorization':'Bearer <access token>'
  }
};
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/rank-details/?uid=<user id>',
  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 token>'
  ),
));

$response = curl_exec($curl);

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


# Dashboard Data

User dashboard widget datas.

## Multi wallet Summery

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

This API endpoint will return the multi-wallet summary.

#### Query Parameters

| Name           | Type   | Description   |
| -------------- | ------ | ------------- |
| currency\_code | string | currency code |

#### Headers

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

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "multi_wallet_balances": [
            {
                "key": "<wallet_key>",
                "name": "<wallet_name>",
                "balance": "<wallet_balance>"
            },
            ...
        ],
        "membership_point_wallet_overview": [
            {
                "amount": "<amount>",
                "category": "<category_title>",
                "short_name": "<short_code>"
            },
            {
                "amount": "<amount>",
                "category": "<category_title>",
                "short_name": "<short_code>"
            },
            {
                "amount": "<amount>",
                "category": "<category_title>",
                "short_name": "<short_code>"
            }
            ...
        ],
        "total_earnings": "<amount>",
        "total_invest": "<amount>",
        "multi_wallet_payout": {
            "Membership points wallet": "<amount>",
            "Bonus coins wallet": "<amount>",
            "Membership coins wallet": "<amount>"
        },
        "total_payout": "<amount>",
        "profit_generated": <percentage>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/walletdata/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  }
};
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/walletdata/',
  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_POSTFIELDS => array('currency_code' => 'inr'),
  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 | currency\_code | Invalid Currency Code. |

## Team Sales

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

This API endpoint will return team sales widget data.

#### Query Parameters

| Name        | Type   | Description                                                             |
| ----------- | ------ | ----------------------------------------------------------------------- |
| filter\_val | string | Posible value are: overall, today, this\_week, this\_month, this\_year. |

#### 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 " %}

```markup
If the MLM plantype is unilevel or matrix

HTTP/1.1 200 OK
Content-Type: application/json
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "left_sales": "<left_sales>",
        "right_sales": "<right_sales>",
        "total_team_sales": "<total_team_sales>",
        "total_personal_sales": "<total_personal_sales>",
        "direct_referred_members": <direct_referred_members>,
        "active_referred_members": <active_referred_members>
    }
}

If plantype is binary

HTTP/1.1 200 OK
Content-Type: application/json
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "left_sales": "<left_sales>",
        "right_sales": "<right_sales>",
        "total_team_sales": "<total_team_sales>",
        "left_carry_forward": "<left_carry_forward>",
        "right_carry_forward": "<right_carry_forward>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/teamsales/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  }
};
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/teamsales/',
  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-token>'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Response

| Status Code | Error Type       | FIeld       | Description           |
| ----------- | ---------------- | ----------- | --------------------- |
| 400         | Validation Error | filter\_val | Invalid filter value. |

## Team Performance

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

This API endpoint will return user team performance widget data.&#x20;

#### Query Parameters

| Name        | Type   | Description                                                             |
| ----------- | ------ | ----------------------------------------------------------------------- |
| filter\_val | string | Posible value are: overall, today, this\_week, this\_month, this\_year. |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "Rank Overview": [
            {
                "Rank": "<rank_name>",
                "Rank Image": "<rank_image>",
                "Count": <achieved_users_count>
            },
            ...
        ],
        "Package Overview": [
            {
                "Package": "<package_name>",
                "Package Image": [
                    <package_image>,
                ],
                "Count": <user_count>
            },
            ...
        ],
        "Top Earners": [
            {
                "Uid": <uid>,
                "Name": "<fiirst_name_last_name>",
                "Username": "<user_name>",
                "Email": "<email>",
                "Amount": <earnigs>,
                "Earnings": "<earnigs_with_currency>",
                "Profile Image": "<profile_image>"
            }
            ....
        ],
        "Recent Joinings": [
            {
                "Uid": <uid>,
                "Name": "<fiirst_name_last_name>",
                "Username": "<user_name>",
                "Email": "<email>",
                "Created": "<joining_date>",
                "Profile Image": "<profile_image>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/teamperformance/',
  '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/teamperformance/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld       | Description           |
| ----------- | ---------------- | ----------- | --------------------- |
| 400         | Validation Error | filter\_val | Invalid filter value. |

## Rank Analysis

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

This API endpoint will return user rank analysis widget data.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "Current Rank": {
            "id": <rank_id>,
            "title": "<rank_name>",
            "image": "<rank_image>",
            "weight": <rank_weight>
        },
        "Next Rank": {
            "id": <rank_id>,
            "title": "<rank_name>",
            "image": "<rank_image>",
            "weight": <rank_weight>
        },
        "Rank Conditions": [
            {
                "required": <required_value>,
                "achieved": <achieved_value>,
                "name": "<name>",
                "title": "<rank_title>",
                "current_rank_name": "<rank_name>",
                "satisfied": <satisfied>,
                "satisfied_percent": <satisfied_percent>
            }
            ...
        ],
        "Current Package": {
            "title": "<package_name>",
            "description": "<Current_Package>",
            "bundle": <bundl_id>,
            "image": [
                "<image>"
            ],
            "base_price": <base_price>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/rankanalysis/',
  '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/rankanalysis/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

## Commision Data

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

This API endpoint will return user commision data.

#### Query Parameters

| Name           | Type   | Description                                                             |
| -------------- | ------ | ----------------------------------------------------------------------- |
| currency\_code | string | currency code                                                           |
| wallet\_name   | string | wallet name eg: wallet1,wallet2 etc                                     |
| filter\_val    | string | Posible value are: overall, today, this\_week, this\_month, this\_year. |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "Earnings": [
            {
                "amount": "<amount>",
                "category": "<incom_category>",
                "currency_code": "<currency_code>"
            },
            ...
        ],
        "Expenses": [
            {
                "amount": "<amount>",
                "category": "<charges_tds_category>",
                "currency_code": "<currency_code>"
            },
            ...
        ],
        "Withdrawal": [
            {
                "amount": "<amount>",
                "category": "<payout_category>",
                "currency_code": "<currency_code>",
                "payout_method": "<payout_method>",
                "payout_status": <payout_status>
            }
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/commisiondata/',
  '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/commisiondata/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | FIeld          | Description            |
| ----------- | ---------------- | -------------- | ---------------------- |
| 400         | Validation Error | filter\_val    | Invalid filter value.  |
| 400         | Validation Error | wallet\_name   | Invalid wallet name    |
| 400         | Validation Error | currency\_code | Invalid Currency Code. |

## User Dashboard

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

This API endpoint will return the whole dashboard data of the user.

#### Query Parameters

| Name           | Type   | Description                                                             |
| -------------- | ------ | ----------------------------------------------------------------------- |
| currency\_code | string | currency code                                                           |
| wallet\_name   | string | wallet name eg: wallet1,wallet2 etc                                     |
| filter\_val    | string | Posible value are: overall, today, this\_week, this\_month, this\_year. |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "WalletData":  {
         "multi_wallet_balances": [
            {
                "key": "<wallet_key>",
                "name": "<wallet_name>",
                "balance": "<wallet_balance>"
            },
            ...
        ],
        "membership_point_wallet_overview": [
            {
                "amount": "<amount>",
                "category": "<category_title>",
                "short_name": "<short_code>"
            },
            ...
        ],
        "total_earnings": "<amount>",
        "total_invest": "<amount>",
        "multi_wallet_payout": {
            "Membership points wallet": "<amount>",
            "Bonus coins wallet": "<amount>",
            "Membership coins wallet": "<amount>"
        },
        "total_payout": "<amount>",
        "profit_generated": <percentage>
        },
        "TeamSales": {
            "left_sales": "<left_sales>",
            "right_sales": "<right_sales>",
            "total_team_sales": "<total_team_sales>",
            "total_personal_sales": "<total_personal_sales>",
            "direct_referred_members": <direct_referred_members>,
            "active_referred_members": <active_referred_members>,
            "left_carry_forward": "<left_carry_forward>",
            "right_carry_forward": "<right_carry_forward>"
        },
        "TeamPerformance": {
            "Rank Overview": [
                {
                    "Rank": "<rank_name>",
                    "Rank Image": "<rank_image>",
                    "Count": <achieved_users_count>
                },
                ...
            ],
            "Package Overview": [
                {
                    "Package": "<package_name>",
                    "Package Image": [
                        <package_image>,
                    ],
                    "Count": <user_count>
                },
                ...
            ],
            "Top Earners": [
                {
                    "Uid": <uid>,
                    "Name": "<fiirst_name_last_name>",
                    "Username": "<user_name>",
                    "Email": "<email>",
                    "Amount": <earnigs>,
                    "Earnings": "<earnigs_with_currency>",
                    "Profile Image": "<profile_image>"
                }
                ....
            ],
            "Recent Joinings": [
                {
                    "Uid": <uid>,
                    "Name": "<fiirst_name_last_name>",
                    "Username": "<user_name>",
                    "Email": "<email>",
                    "Created": "<joining_date>",
                    "Profile Image": "<profile_image>"
                },
                ...
            ],
        },
        "RankAnalysis": {
            "Current Rank": {
                "id": <rank_id>,
                "title": "<rank_name>",
                "image": "<rank_image>",
                "weight": <rank_weight>
            },
            "Next Rank": {
                "id": <rank_id>,
                "title": "<rank_name>",
                "image": "<rank_image>",
                "weight": <rank_weight>
            },
            "Rank Conditions": [
                {
                    "required": <required_value>,
                    "achieved": <achieved_value>,
                    "name": "<name>",
                    "title": "<rank_title>",
                    "current_rank_name": "<rank_name>",
                    "satisfied": <satisfied>,
                    "satisfied_percent": <satisfied_percent>
                }
                ...
            ],
            "Current Package": {
                "title": "<package_name>",
                "description": "<Current_Package>",
                "bundle": <bundl_id>,
                "image": [
                    "<image>"
                ],
                "base_price": <base_price>
            }
        },
        "CommisionData": {
            "Earnings": [
                {
                    "amount": "<amount>",
                    "category": "<incom_category>",
                    "currency_code": "<currency_code>"
                },
                ...
            ],
            "Expenses": [
                {
                    "amount": "<amount>",
                    "category": "<charges_tds_category>",
                    "currency_code": "<currency_code>"
                },
                ...
            ],
            "Withdrawal": [
                {
                    "amount": "<amount>",
                    "category": "<payout_category>",
                    "currency_code": "<currency_code>",
                    "payout_method": "<payout_method>",
                    "payout_status": <payout_status>
                }
                ...
            ]
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/dashboard/',
  '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/dashboard/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | FIeld          | Description            |
| ----------- | ---------------- | -------------- | ---------------------- |
| 400         | Validation Error | filter\_val    | Invalid filter value.  |
| 400         | Validation Error | wallet\_name   | Invalid wallet name    |
| 400         | Validation Error | currency\_code | Invalid Currency Code. |


# Manage Network

## Referral Downline List&#x20;

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

This API endpoint will return list of referral downline.

#### Query Parameters

| Name           | Type   | Description                               |
| -------------- | ------ | ----------------------------------------- |
| offset         | string |                                           |
| limit          | string |                                           |
| list\_type     | string | Possible values are "overall" and "month" |
| username       | string | username                                  |
| currency\_code | string | currency code                             |
| from\_date     | string | format - MM/DD/YY                         |
| to\_date       | string | format - MM/DD/YY                         |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "uid_id": <uid>,
                "username": "<username>",
                "name": "<name>",
                "sponsor": "<sponsor_username>",
                "sale": "<sale>",
                "earned": "<earned>",
                "rank": {
                    "title": "<rank_name>",
                    "image": "<rank_image>"
                },
                "package": {
                    "package_name": "<package_name>",
                    "package_image": "<package_image>"
                },
                "created": "<registerd_date>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page>,
        "next": <next_page>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/referraldownline/',
  '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/referraldownline/',
  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_POSTFIELDS => array(),
  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 | list\_type     | Invalid list type. Please check again. |
| 400         | Validation Error | currency\_code | Invalid Currency Code.                 |
| 400         | Validation Error | username       | Invalid username.                      |

## Team Downline List

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

This API endpoint will return list of team downline users.&#x20;

#### Query Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| limit      | string |                                           |
| offset     | string |                                           |
| from\_date | string | format - MM/DD/YY                         |
| to\_date   | string | format - MM/DD/YY                         |
| list\_type | string | Possible values are "overall" and "month" |
| username   | string | username                                  |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "uid_id": <uid>,
                "username": "<username>",
                "name": "<name>",
                "parent": "<parent_username>",
                "level": <level>,
                "sale": "<sale>",
                "rank": {
                    "title": "<rank_title>",
                    "image": "<rank_image>"
                },
                "package": {
                    "package_name": "<package_name>",
                    "package_image": "<package_image>"
                },
                "created": "<registerd_date>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/teamdownline/',
  '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/teamdownline/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld      | Description                            |
| ----------- | ---------------- | ---------- | -------------------------------------- |
| 400         | Validation Error | list\_type | Invalid list type. Please check again. |
| 400         | Validation Error | username   | Invalid username.                      |

## Customer Downline List

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

This API endpoint will return customer downline list.

#### Query Parameters

| Name       | Type   | Description                               |
| ---------- | ------ | ----------------------------------------- |
| list\_type | string | Possible values are "overall" and "month" |
| limit      | string |                                           |
| offset     | string |                                           |
| from\_date | string | format - MM/DD/YY                         |
| to\_date   | string | format - MM/DD/YY                         |
| username   | string | username                                  |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "uid_id": <uid>,
                "username": "<username>",
                "name": "<customer_name>",
                "role": [
                    {
                        "name": "<user_role>"
                    }
                ],
                "sale": "<sales>",
                "created": "<registerd_date>"
            },
        ],
        "count": <count_list>,
        "previous": <previous_page>,
        "next": <next_page>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/mycustomers/',
  '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/mycustomers/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld      | Description                            |
| ----------- | ---------------- | ---------- | -------------------------------------- |
| 400         | Validation Error | list\_type | Invalid list type. Please check again. |
| 400         | Validation Error | username   | Invalid username.                      |

## Get Spilling Preference

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

This API endpoint will return spilling preference choices, and user user selected choice.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "choices": [
            [
                "<choice_key>",
                "<choice_short_name>",
                "<choice_description>",
                "<image_path>"
            ],
            ...
        ],
        "pref_value": "<user_current_choise_key>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/spiling-preference/',
  '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/spiling-preference/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

## Change Spilling Preference

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

This API endpoint will update user spilling preference choice.

#### 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                 |
| -------------------------------------------------- | ------ | --------------------------- |
| spiliing\_prefer<mark style="color:red;">\*</mark> | string | Spilling prefer choice key. |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/spiling-preference/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'spiliing_prefer': '<choice_key>'
  }
};
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/spiling-preference/',
  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('spiliing_prefer' => '<choice_key>'),
  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 | spiliing\_prefer | Invalid spiliing prefer choice. |


# Referral Link

User Referral Link

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

This API endpoint will return user referral link.

#### Headers

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

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "links": [
            {
                "head": "<head>",
                "link": "<link>",
                "desc": "<description>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/refferal-link/',
  '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/refferal-link/',
  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-tokem>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```


# FAQ

Frequently Asked Questions List

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

This API endpoint will return a list of FAQ.

#### Query Parameters

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| limit    | string |             |
| offset   | string |             |
| question | string |             |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <id>,
                "question": "<question>",
                "answer": "<answer>"
            },
            ...
        ],
        "count": 3,
        "previous": <previous_pahe_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>/get/faq/list/',
  'headers': {
    'apikey': '<apikey>'
  }
};
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>/get/faq/list/',
  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>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```


# Leads & CRM

Manage leads & CRM

## Lead Overview

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/overview/`

This API endpoint will return lead summary and appointments.

#### Query Parameters

| Name        | Type   | Description                                            |
| ----------- | ------ | ------------------------------------------------------ |
| appointment | string | Possible values are: upcoming, today, week, and month. |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "LeadsData": {
            "status": [
                {
                    "status": <status>,
                    "count": <count>,
                    "Description": "<short_description>",
                    "Color": "<color>"
                },
                ...
            ],
            "source": [
                {
                    "source": <source>
                    "count": <count>
                },
                ...
            ]
        },
        "TotalLeads": <total_leads_count>,
        "appointments": [
            {
                "appointment_note": "<appointment_note>",
                "appointment_status": "<appointment_status>",
                "appointment_date": "<appointment_date>",
                "appointment_to": "<appointment_to>"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/leads/overview/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/leads/overview/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field       | Description                       |
| ----------- | ---------------- | ----------- | --------------------------------- |
| 400         | Validation Error | appointment | Invalid appointment filter value. |

## List Leads

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/list/`

This API endpoint will return a list of owned leads. Use the same URL to get a list of assigned leads with a query parameter list\_type as 'assigned'.&#x20;

#### Query Parameters

| Name           | Type   | Description                                                                                     |
| -------------- | ------ | ----------------------------------------------------------------------------------------------- |
| campaign\_slug | string | Get the list of leads under a campaign.                                                         |
| offset         | string |                                                                                                 |
| limit          | string |                                                                                                 |
| list\_type     | string | Possible value is 'assigned'                                                                    |
| first\_name    | string | first name                                                                                      |
| last\_name     | string | last name                                                                                       |
| email          | string | email address                                                                                   |
| phone          | string | phone number                                                                                    |
| status         | string | lead status, possible values are prospect, tentative, potential, closed, contact, and customer. |
| owner          | string | owner username                                                                                  |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <lead_id>,
                "slug": "<lead_slug>",
                "first_name": "<first_name>",
                "last_name": "<last_name>",
                "name": "<full_name>",
                "phone": "<phone_number>",
                "email": "<email_address>",
                "added_on": "<created_date>",
                "status": "<lead_status>",
                "source": "<lead_source>",
                "owner": "<owner_name>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/leads/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/leads/list/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## List Appointments

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/appointments/list/`

This API endpoint will return a list of appointments.

#### Query Parameters

| Name        | Type   | Description                                                                                     |
| ----------- | ------ | ----------------------------------------------------------------------------------------------- |
| offset      | string |                                                                                                 |
| limit       | string |                                                                                                 |
| datesetting | string | Possible values are on, before, and after.                                                      |
| ondate      | string | required when datesettigs is given, Formate: MM/DD/YYYY                                         |
| status      | string | <p>Possible values are pending, rescheduled, cancelled, <br> fullfilled, and confirmed.    </p> |
| lead        | string | lead firstname                                                                                  |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <appointment_id>,
                "lead_id": <lead_id>,
                "lead": "<lead_name>",
                "leadslug": "<lead_slug>",
                "leadstatus": "<lead_status>",
                "fromdate": "<from_date>",
                "appointment_note": "<appointment_note>",
                "appointment_status": "<appointment_status>",
                "todate": "<to_date>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/appointments/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/appointments/list/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## Lead Details

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/view/lead/`

This API endpoint will return details of a lead.

#### Query Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| slug | string | Lead slug.  |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "id": <lead_id>,
        "slug": "<lead_slug>",
        "first_name": "<first_name>",
        "name": "<name>",
        "last_name": "<last_name>",
        "phone": "<phone_number>",
        "email": "<email_address>",
        "status": "<lead_status>",
        "source": "<lead_source>",
        "message": "<lead_message>",
        "added_on": "<created_date>",
        "recent_activities": [
            {
                "id": <activity_id>,
                "activity_type": "<activity_type>",
                "created": "<activity_added_date>",
                "activity": "<activity>"
            },
            ...
        ],
        "notes": [
            {
                "id": <note_id>,
                "note": "<note>",
                "note_created": "<note_created_date>",
                "user": "<note_created_user>"
            }
            ...
        ],
        "conversion": <conversion_percentage>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/view/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/view/lead/',
  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 token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | Field | Description                                                                               |
| ----------- | ---------------- | ----- | ----------------------------------------------------------------------------------------- |
| 400         | Validation Error | slug  | <p>This field is required and this may not be blank.</p><p>Requested slug is invalid.</p> |

## Create Appointment

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/create/appointment/`

This API endpoint will create an appointment in a lead.

#### 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                                                                                                                              |
| --------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark>              | string | Lead slug                                                                                                                                |
| appointment\_date<mark style="color:red;">\*</mark> | string | Appointment date, format: yyyy-mm-dd hh:mm                                                                                               |
| appointment\_to<mark style="color:red;">\*</mark>   | string | Appointment to date, format: yyyy-mm-dd hh:mm                                                                                            |
| appointment\_note                                   | string | Appointment note. default value is "Prospect appointment''.                                                                              |
| appointment\_status                                 | string | <p>Appointment status, possible values are pending, rescheduled, cancelled, fullfilled, and, confirmed.<br>default value is pending.</p> |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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>/create/appointment/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'slug': '<lead_slug>',
    'appointment_date': '<yyyy-mm-dd HH:MM>',
    'appointment_note': '<appointment_note>',
    'appointment_status': '<appointment_status>',
    'appointment_to': '<yyyy-mm-dd HH:MM>'
  }
};
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>/create/appointment/',
  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('slug' => '<lead_slug>','appointment_date' => '<yyyy-mm-dd HH:MM>','appointment_note' => '<appointment_note>','appointment_status' => '<appointment_status>','appointment_to' => '<yyyy-mm-dd HH:MM>'),
  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                                                                                                                                                          |
| ----------- | ---------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |                     | <p>Body data not found.</p><p>Appointment schedule exists for this time.</p><p>End Date Can't be prior to Start Date.</p><p>Please Specify a date in the future.</p> |
| 400         | Validation Error | slug                | <p>This field is required.</p><p>This field is may not be blank.</p><p>Requested slug is invalid.</p><p>You can't take appointment under this lead.</p>              |
| 400         | Validation Error | appointment\_date   | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                      |
| 400         | Validation Error | appointment\_to     | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                      |
| 400         | Validation Error | appointment\_note   | Ensure this field has no more than 200 characters.                                                                                                                   |
| 400         | Validation Error | appointment\_status | Invalid appointment status.                                                                                                                                          |

## Update Appointment

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/update/appointment/`

This API endpoint will update an appointment.

#### Query Parameters

| Name                | Type   | Description                                                                                                                    |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| appointment\_id     | string | Id of appointment.                                                                                                             |
| slug                | string | Lead slug.                                                                                                                     |
| appointment\_date   | string | Appointment date, format: yyyy-mm-dd hh-mm                                                                                     |
| appointment\_note   | string | mmappointment\_note                                                                                                            |
| appointment\_to     | string | Appointment to date, format: yyyy-mm-dd hh-mm                                                                                  |
| appointment\_status | string | Appointment status, possible values are pending, rescheduled, cancelled, fullfilled, and, confirmed. default value is pending. |

#### Headers

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

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/update/appointment/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'appointment_id': '<appointment_id>'
    'slug': '<lead_slug>',
    'appointment_date': '<appointment_date>',
    'appointment_note': '<appointment_note>',
    'appointment_status': '<appointment_status>',
    'appointment_to': '<appointment_to>'
  }
};
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>/update/appointment/',
  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('slug' => '<lead_slug>','appointment_date' => '<appointment_date>','appointment_note' => '<appointment_note>','appointment_status' => '<appointment_status>','appointment_to' => '<appointment_to>','appointment_id' => '<appointment_id>'),
  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                                                                                                                                                                                                   |
| ----------- | ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |                     | <p>Body data not found.</p><p>Appointment schedule exists for this time.</p><p>End Date Can't be prior to Start Date.</p><p>Please Specify a date in the future.</p><p>You can't update this appointment.</p> |
| 400         | Validation Error | appointment\_id     | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid appointment id.</p><p>Requested appointment not found.</p><p></p>                                                              |
| 400         | Validation Error | slug                | <p>This field is may not be blank.</p><p>Requested slug is invalid.</p><p>You can't take appointment under this lead.</p>                                                                                     |
| 400         | Validation Error | appointment\_date   | <p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                                                                                             |
| 400         | Validation Error | appointment\_to     | <p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                                                                                             |
| 400         | Validation Error | appointment\_note   | Ensure this field has no more than 200 characters.                                                                                                                                                            |
| 400         | Validation Error | appointment\_status | Invalid appointment status.                                                                                                                                                                                   |

## Delete Appointment

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/delete/appointment/`

This API endpoint will delete an appointment.

#### 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    |
| ------------------------------------------------- | ------ | -------------- |
| appointment\_id<mark style="color:red;">\*</mark> | string | Appointment id |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/delete/appointment/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'appointment_id': '<appointment id>'
  }
};
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>/delete/appointment/',
  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('appointment_id' => '<appointment id>'),
  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                                                                                                                                      |
| ----------- | ---------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 401         | Request Failed   |                 | You can't delete this appointment.                                                                                                               |
| 400         | Validation Error | appointment\_id | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid appointment id.</p><p>Requested appointment not found.</p><p></p> |

## Create Lead

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/v1/leads/create/lead/`

This API endpoint will create a lead.

#### Headers

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

#### Request Body

| Name                                          | Type   | Description                                                                                                           |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| first\_name<mark style="color:red;">\*</mark> | string | First name.                                                                                                           |
| last\_name<mark style="color:red;">\*</mark>  | string | Last name.                                                                                                            |
| email<mark style="color:red;">\*</mark>       | string | Email address                                                                                                         |
| status                                        | string | Lead status, possible values are prospect, tentative, potential, closed, contact, and customer.                       |
| source                                        | string | Lead source, possible values are direct, website, facebook, twitter, instagram, search, pinterest, reddit and, other. |
| phone<mark style="color:red;">\*</mark>       | string | Phone number.                                                                                                         |
| location<mark style="color:red;">\*</mark>    | string | Location                                                                                                              |
| message<mark style="color:red;">\*</mark>     | string | Lead message.                                                                                                         |
| assignee<mark style="color:red;">\*</mark>    | string | Assignee username.                                                                                                    |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/v1/create/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'first_name': '<first_name>',
    'last_name': '<last_name>',
    'email': '<email>',
    'status': '<status>',
    'source': '<source>',
    'phone': '<phone>',
    'location': '<location>',
    'message': '<message>',
    'assignee': '<assignee_username>'
  }
};
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>/v1/create/lead/',
  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('first_name' => '<first_name>','last_name' => '<last_name>','email' => '<email>','status' => '<status>','source' => '<source>','phone' => '<phone>','location' => '<location>','message' => '<message>','assignee' => '<assignee>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Response

| **Status Code** | Error Type       | Field       | Description                                                                                                                                               |
| --------------- | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400             | Validation Error | first\_name | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | last\_name  | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | email       | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p><p>Invalid email.</p>           |
| 400             | Validation Error | phone       | <p>This field is required.</p><p>This field may not be blank.</p><p>Phone number must be entered in the format: '999999999'. Up to 15 digits allowed.</p> |
| 400             | Validation Error | location    | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | message     | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | status      | \<status> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | source      | \<source> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | assignee    | <p>This field may not be blank.</p><p>Assignee not found.</p>                                                                                             |

## Update Lead

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/update/lead/`

This API endpoint will update a lead.

#### Headers

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

#### Request Body

| Name                                          | Type   | Description                                                                                                           |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark>        | string | Lead slug                                                                                                             |
| first\_name<mark style="color:red;">\*</mark> | string | First name.- existing or new                                                                                          |
| last\_name<mark style="color:red;">\*</mark>  | string | Last name.- existing or new                                                                                           |
| email<mark style="color:red;">\*</mark>       | string | Email address.- existing or new                                                                                       |
| status                                        | string | Lead status, possible values are prospect, tentative, potential, closed, contact, and customer.                       |
| source                                        | string | Lead source, possible values are direct, website, facebook, twitter, instagram, search, pinterest, reddit and, other. |
| phone<mark style="color:red;">\*</mark>       | string | Phone number.- existing or new.                                                                                       |
| location<mark style="color:red;">\*</mark>    | string | Location                                                                                                              |
| message<mark style="color:red;">\*</mark>     | string | Message                                                                                                               |
| assignee<mark style="color:red;">\*</mark>    | string | Assignee username.                                                                                                    |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/update/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'first_name': '<first_name>',
    'last_name': '<last_name>',
    'email': '<email>',
    'status': '<status>',
    'source': '<source>',
    'phone': '<phone>',
    'location': '<location>',
    'message': '<message>',
    'slug': '<lead_slug>',
    'assignee': '<assignee_username>'
  }
};
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>/update/lead/',
  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('first_name' => '<first_name>','last_name' => '<last_name>','email' => '<email>','status' => '<status>','source' => '<source>','phone' => '<phone>','location' => '<location>','message' => '<message>','slug' => '<lead_slug>','assignee' => '<assignee_username>'),
  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 | slug        | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 258 characters.</p>                                |
| 400             | Validation Error | first\_name | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | last\_name  | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | email       | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p><p>Invalid email.</p>           |
| 400             | Validation Error | phone       | <p>This field is required.</p><p>This field may not be blank.</p><p>Phone number must be entered in the format: '999999999'. Up to 15 digits allowed.</p> |
| 400             | Validation Error | location    | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | message     | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | status      | \<status> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | source      | \<source> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | assignee    | <p>This field may not be blank.</p><p>Assignee not found.</p>                                                                                             |
| 401             | Request Failed   |             | <p>Requested lead does not esixt.</p><p>You are not owner of this lead.</p>                                                                               |

## Delete Lead

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/delete/lead/`

This API endpoint will delete a lead.

#### 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 |
| -------------------------------------- | ------ | ----------- |
| slug<mark style="color:red;">\*</mark> | string | Lead slug   |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/delete/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'slug': '<lead_slug>'
  }
};
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>/delete/lead/',
  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('slug' => 'binuser1'),
  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 | slug  | <p>This field is required.</p><p>This field may not be blank.<br>Requested lead not found.</p><p>Requested lead already has a deleted status.</p> |
| 401             | Request Failed   |       | You can't delete this lead.                                                                                                                       |

## Create Lead Note

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/create/leadnote/`

This API endpoint will create a note on lead.

#### 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 |
| -------------------------------------- | ------ | ----------- |
| note<mark style="color:red;">\*</mark> | string | Lead note.  |
| slug<mark style="color:red;">\*</mark> | string | Lead slug   |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/create/leadnote/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'slug': '<lead_slug>',
    'note': '<note>'
  }
};
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>/create/leadnote/',
  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('slug' => '<lead_slug>','note' => '<note>'),
  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 | slug  | <p>This field is required.</p><p>This field may not be blank.<br>Requested lead not found.</p><p>Requested lead already has a deleted status.</p> |
| 400             | Validation Error | note  | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 499 characters.</p>                        |
| 401             | Request Failed   |       | You can't add note on this lead.                                                                                                                  |

## Delete Lead Note

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/delete/leadnote/`

This API endpoint will delete a note of lead.

#### 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 |
| ------------------------------------------ | ------ | ----------- |
| note\_id<mark style="color:red;">\*</mark> | string | Note id     |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/delete/leadnote/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'note_id': '<note_id>'
  }
};
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>/delete/leadnote/',
  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('note_id' => '<nit_id>'),
  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 | note\_id | <p>This field is required.</p><p>This field may not be blank.<br>Requested note not found.</p><p>Invalid note id.</p> |
| 401             | Request Failed   |          | You can't delete this note.                                                                                           |


# Cart

Manage Cart

## Get Cart Items

<mark style="color:blue;">`GET`</mark> `https://<domain>/<api prefix>/<version>/commerce/cart-items/`

get the list of items in the cart

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "cartitems": [
            {
                "id": <id>,
                "order_id_id": <orderid>,
                "vendor_id": <vendor id>,
                "product_id": <produc id>,
                "bundle_id": <bundle id>,
                "line_item_type": <item type>,
                "line_item_label": <item label>,
                "quantity": <quantity>,
                "price": <price>,
                "data": <data>,
                "status": <status>,
                "unit_price": <unit price>,
                "currency_code": <currency_code>,
                "currency_symbol": <currency_symbol>
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```javascript
var request = require("request");

var options = { method: 'GET',
  url: 'https://<domain>/<api prefix>/<version>/commerce/cart-items/',
  headers: 
   { authorization: 'Bearer <access-token>',
     apikey: '<apikey>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/cart-items/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "authorization: Bearer <access-token>",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

## Remove an item from the cart

<mark style="color:green;">`POST`</mark> `https://<domain>/<api prefix>/<version>/commerce/remove-cart-item/`&#x20;

remove an item from cart by passing item id and order id

#### 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 |
| ------------------------------------------- | ------ | ----------- |
| pk<mark style="color:red;">\*</mark>        | number | item id     |
| order\_id<mark style="color:red;">\*</mark> | number | order id    |

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

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

Body:
{
    "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>/commerce/remove-cart-item/',
  headers: 
   { authorization: 'Bearer <access-token>',
     apikey: '<apikey>',
     'content-type': 'multipart/form-data' },
  formData: { order_id: '9558', pk: '10465' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/remove-cart-item/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"order_id\"\r\n\r\n9558\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"pk\"\r\n\r\n10465\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "authorization: Bearer <access-token>",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

#### Error Responses

| Status Code | Error Type       | Field     | Description                  |
| ----------- | ---------------- | --------- | ---------------------------- |
| 400         | Validation Error | order\_id | This field may not be blank. |
| 400         | Validation Error | pk        | This field may not be blank. |

## Update Cart

<mark style="color:green;">`POST`</mark> `https://<domain>/<api prefix>/<version>/commerce/update-cart/`

update cart item quantity

#### 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 |
| ------------------------------------------------ | ------ | ----------- |
| quantity<mark style="color:red;">\*</mark>       | number |             |
| line\_item\_id<mark style="color:red;">\*</mark> | number |             |
| cart\_id<mark style="color:red;">\*</mark>       | number |             |

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

```
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': '<domain>/<api prefix>/<version>/commerce/update-cart/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'cart_id': '34',
    'line_item_id': '43',
    'quantity': '34'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

#### PHP

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('<domain>/<api prefix>/<version>/commerce/update-cart/');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'apikey' => '<apikey>',
  'Authorization' => 'Bearer <access token>'
));
$request->addPostParameter(array(
  'cart_id' => '34',
  'line_item_id' => '43',
  'quantity' => '34'
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```


# Whishlist

Manage wishlist

## Get wishlist items

<mark style="color:blue;">`GET`</mark> `https://<domain>/<api prefix>/<version>/commerce/wishlist-items/`

get the list of items in wishlist

#### Query Parameters

| Name   | Type   | Description  |
| ------ | ------ | ------------ |
| offset | string | Offset value |

#### Headers

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

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": [
        {
            "wished_products": <items>,
            "currency_symbol": <currency_symbol>
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```javascript
var request = require("request");

var options = { method: 'GET',
  url: 'https://<domain>/<api prefix>/<version>/commerce/wishlist-items/',
  headers: 
   { authorization: 'Bearer <access-token>',
     apikey: '<apikey>',
     'content-type': 'multipart/form-data' },
  formData: { order_id: '9558', pk: '' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/wishlist-items/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"order_id\"\r\n\r\n9558\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"pk\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "authorization: Bearer <access-token>",
    "content-type: multipart/form-data;",    
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

## Add to wishlist

<mark style="color:green;">`POST`</mark> `https://<domain>/<api prefix>/<version>/commerce/wishlist-add/`

add product to wishlist

#### Headers

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

#### Request Body

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| product\_id<mark style="color:red;">\*</mark> | integer | product\_id |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/wishlist-add/',
  'headers': {
    'apikey': '<api key>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'product_id': '<product_id>'
  }
};
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>/commerce/wishlist-add/',
  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('product_id' => '<product_id>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <api key>',
    'Authorization: Bearer <access-token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status code | Error Type       | Field       | Description             |
| ----------- | ---------------- | ----------- | ----------------------- |
| 400         | Validation Error | product\_id | This field is required. |
| 400         | Validation Error | product\_id | Invalid product\_id.    |

## Remove item from the wishlist

<mark style="color:green;">`POST`</mark> `https://<domain>/<api prefix>/<version>/commerce/wishlist-remove/`

remove a specific item from wishlist

#### 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 " %}

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

Body:
{
    "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>/commerce/wishlist-remove/',
  headers: 
   { authorization: 'Bearer <access-token>',
     apikey: '<apikey>',
     'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
  formData: { product_id: '<product_id>' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/wishlist-remove/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"product_id\"\r\n\r\n<product_id>\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "authorization: Bearer <access-token>",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

#### Error Responses

| Status Code | Error Type       | Field             | Description                  |
| ----------- | ---------------- | ----------------- | ---------------------------- |
| 400         | Validation Error | product\_id       | This field may not be blank. |
| 400         | Not Found        | product not found | Product not found            |


# Payout

## Get Payment Methods

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

This API endpoint will return a list of available payment methods with user active payment method status.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "Payment_methods": [
            {
                "key": "<method_key>",
                "name": "<method_name>",
                "<method_key>-status": <user_active_status>
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/payment-methods/',
  '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/payment-methods/',
  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_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

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

## Change Payment Method

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

This API endpoint will change user payment method.

#### 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                                                                                      |
| ------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------ |
| \<method\_key>-status<mark style="color:red;">\*</mark> | string | Need to add all available payment method status to update. formate: \<method\_key>-status:1 or 0 |
| \<method\_key>-status<mark style="color:red;">\*</mark> | string | <p>example:<br>bank-status:1<br>paypal-status:0</p>                                              |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/change/payment-method/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    '<method_key>-status': '<0 or 1>',
    '<method_key>-status': '<0 or 1>',
    ...
  }
};
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/change/payment-method/',
  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('<method_key>-status' => '<0 or 1>','<method_key>-status' => '<0 or 1>',..),
  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 | \<method\_key>-status | <p>\<method\_key>-status field not found.<br>\<method\_key>-status value not found.</p><p>\<method\_key>-status recieved a invalid value.</p> |

## Get Payment Method Settings

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

This API endpoint will return a payment method settings fields with value.

#### Query Parameters

| Name   | Type   | Description             |
| ------ | ------ | ----------------------- |
| method | string | Payment method key name |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "label": "<method> Settings",
        "fields": [
            {
                "field_name": "<field_name>",
                "value": "<value>",
                "required": <boolean>,
                "max_length": <max_length>,
                "min_length": <min_length>,
                "srtipe": <boolean>,
                "input_type": "<input_type>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/payment-method/settings/?method=<method_key>',
  '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/payment-method/settings/?method=<method_key>',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field  | Description                                                                                                                                        |
| ----------- | ---------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | method | <p>This field is required.</p><p>This field is may not be blank.</p><p>Requested method is not found.</p><p>Requested method is not activated.</p> |

## Get Checksum Token

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

This API endpoint will give a token to user mail and a checksum token in response.&#x20;

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "success": 1,
        "token_checksum": "<token_checksum>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/checksum-token/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Cookie': 'store_user=admin_store; sessionid=5zuhah7hbh4newylvnluxvpgt1clo0i1'
  },
  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>/get/checksum-token/',
  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_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

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

## Update Payment Method Settings

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/update/payment-method/settings/`

This API endpoint will update payment method configurations.

#### 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                                                                 |
| -------------------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| fields<mark style="color:red;">\*</mark>                 | string | Required fields for the payment method.                                     |
| method<mark style="color:red;">\*</mark>                 | string | Payment method key.                                                         |
| token\_field<mark style="color:red;">\*</mark>           | string | Get token through mail when **Get Checksum Token** endpoint is called.      |
| token\_checksum\_field<mark style="color:red;">\*</mark> | string | Get checksum token through the response of **Get Checksum Token** endpoint. |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/update/payment-method/settings/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'method': '<method_key>',
    'token_field': '<token>',
    'token_checksum_field': '<token_checksum>',
    '<required_field_1>': '<field_value>',
    '<required_field_2>': '<field_value>',
    ...
  }
};
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/update/payment-method/settings/',
  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('method' => '<method_key>','token_field' => '<token>','token_checksum_field' => '<token_checksum>','<other_required_fields>' => '<field_values>',..),
  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 | method                                                      | <p>This field is required.</p><p>This field is may not be blank.</p><p>Requested method is not found.</p><p>Requested method is not activated.</p> |
| 400         | Validation Error | token\_field                                                | <p>This field is required.</p><p>This field is may not be blank.</p>                                                                               |
| 400         | Validation Error | token\_checksum\_field                                      | <p>This field is required.</p><p>This field is may not be blank.</p>                                                                               |
| 400         | Validation Error | <p>other required fields for the </p><p>payment method.</p> | other fields validation errors.                                                                                                                    |

## Payout History

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

This API endpoint will return a list of payout history.

#### Query Parameters

| Name           | Type   | Description                                                                                                  |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| offset         | string |                                                                                                              |
| limit          | string |                                                                                                              |
| currency\_code | string |                                                                                                              |
| wallet         | string | wallet1, walle2, ...                                                                                         |
| type           | string | all, active, reject, completed, cancelled                                                                    |
| status         | string | 0:  'Requested',1: 'Processing' ,2: 'Paid',3: 'Rejected / Pay later',4: 'Spam' ,5: 'Removed', 6: 'Cancelled' |
| from\_date     | string | fromate: mm/dd/yyyy                                                                                          |
| to\_date       | string | fromate: mm/dd/yyyy                                                                                          |

#### Headers

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

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <id>,
                "amount_requested": "<amount_requested>",
                "charge": "<charge>",
                "payable_amount": "<payable_amount>",
                "status": {
                    "label": "<status_label>",
                    "color ": "<color>"
                },
                "payout_method": "<payout_method>",
                "extra": {
                    "amount": <amount_requested>,
                    "charge": <charge>,
                    "amount_paid": <amount_paid>,
                    "payout_method": "<payout_method>",
                    "payout_wallet": "<payout_wallet>",
                    "payout_currency": "<payout_currency>"
                },
                "payable_converted_amount": "<Ƀ0.00075748>",
                "process_date": "<process_date>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/get/payout/history/',
  '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/payout/history/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field          | Description            |
| ----------- | ---------------- | -------------- | ---------------------- |
| 400         | Validation Error | currency\_code | Invalid Currency Code. |
| 400         | Validation Error | from\_date     | Invalid date format    |
| 400         | Validation Error | to\_date       | Invalid date format    |
| 400         | Validation Error | status         | Invalid status value.  |

## Request Payout

### Get Payout Enabled Wallets

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

This API endpoint will return a list of withdrawal enabled wallets.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": [
        {
            "key": "<wallet_key>",
            "name": "<Wallet_name>"
        },
        ...
    ]
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/withdraw/request/',
  '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/withdraw/request/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

### Get Payment Methods

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

This API endpoint will return a list of active payment methods and their details, under the selected wallet.

#### Query Parameters

| Name           | Type   | Description                      |
| -------------- | ------ | -------------------------------- |
| wallet         | string | Key of wallet you were selected. |
| currency\_code | string | Currency code                    |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "payout_methods_available": [
            {
                "key": "<method_key>",
                "name": "<method_name>"
            },
            ...
        ],
        "payment_method_settings": [
            [
                {
                    "enable_wallet_withdrwal": <enabled_status>,
                    "payment_method": [
                        "<method_key>",
                        ...
                    ],
                    "available_roles": [
                        <available_roles>
                    ],
                    "min_withdraw_amount": "<min_withdraw_amount>",
                    "max_withdraw_amount": "<max_withdraw_amount>",
                    "widraw_charge": "<widraw_charge>",
                    "widraw_charge_type": "<widraw_charge_type>",
                    "available_days": [
                        "All",
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday",
                        "Saturday",
                        "Sunday"
                    ],
                    "payout_limit": "<payout_limit>",
                    "payout_limit_period": [
                        "<payout_limit_period>"
                    ]
                },
                ...
            ]
        ],
        "currency_code": "<currency_code>",
        "currency_rate_details": {
            "decimals": <decimals>,
            "symbol_placement": "<symbol_placement>",
            "symbol": "<currency_symbol>",
            "rate": <currency_convertion_rate>
        },
        "wallet_balance": <wallet_balance>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/withdraw/request/',
  '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/withdraw/request/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field          | Description                                               |
| ----------- | ---------------- | -------------- | --------------------------------------------------------- |
| 400         | Validation Error | wallet         | This field may not be blank.                              |
| 400         | Validation Error | wallet         | Wallet withdrawal is disabled, Please contact your admin. |
| 400         | Validation Error | currency\_code | Invalid Currency Code.                                    |

### Request Payout

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

This API endpoint will create a withdrawal request.

#### 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                                         |
| -------------------------------------------------------- | ------ | --------------------------------------------------- |
| form\_key<mark style="color:red;">\*</mark>              | string | Get form key through the (**Form Key**) endpoint.   |
| currency\_code<mark style="color:red;">\*</mark>         | string | Currency code                                       |
| wallet<mark style="color:red;">\*</mark>                 | string | wallet key                                          |
| method<mark style="color:red;">\*</mark>                 | string | payment method key                                  |
| amount<mark style="color:red;">\*</mark>                 | string | withdraw amount                                     |
| token\_field<mark style="color:red;">\*</mark>           | string | mail token                                          |
| token\_checksum\_field<mark style="color:red;">\*</mark> | string | token checksum - response of **Get Checksum Token** |

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

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

Body:
{
    "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/withdraw/request/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <acess token>'
  },
  formData: {
    'method': '<payment_method>',
    'wallet': '<wallet_key>',
    'amount': '<amount>',
    'token_field': '<mail_token>',
    'token_checksum_field': '<token_checksum>'
    'form_key':'<form_post_key>'
  }
};
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/withdraw/request/',
  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('method' => '<payment_method>','wallet' => '<wallet_key>','amount' => '<amount>','token_field' => '<mail_token>','token_checksum_field' => '<token_checksum>','form_key':'<form_post_key>'),
  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 | currency\_code         | Invalid Currency Code.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| 400         | Validation Error | wallet                 | <p>wallet is not defined.</p><p>Wallet withdrawal is disabled, Please contact your admin.</p><p>Already a request is pending.</p><p>Insufficient wallet balance.</p>                                                                                                                                                                                                                                                                    |
| 400         | Validation Error | amount                 | <p>amount is not defined.</p><p>Please enter valid amount.</p><p>Minimum withdrawal amount is \<min\_amount></p><p>Maximum withdrawal amount is \<min\_amount></p>                                                                                                                                                                                                                                                                      |
| 400         | Validation Error | method                 | <p>method is not defined.</p><p>Please choose a valid payout methods.</p><p>Some encryption error occured.</p><p>No account details found for this wallet.</p><p>No payment method details found for this wallet.</p><p>insufficient wallet balance.</p><p>You can't create the request, your \<payout\_limit\_period> balance is \<max\_formated\_amount></p><p>Unable to continue this request, Please contact your administrator</p> |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>This field is may not be blank.</p><p>Token is not matching.</p>                                                                                                                                                                                                                                                                                                                                       |
| 400         | Validation Error | token\_checksum\_field | <p>This field is required.</p><p>This field is may not be blank.</p>                                                                                                                                                                                                                                                                                                                                                                    |
| 401         | Request Failed   |                        | <p>Payout Request History Failed.</p><p>Payout Request Failed.</p>                                                                                                                                                                                                                                                                                                                                                                      |
| 400         | Validation Error | form\_key              | <p>This field is required.</p><p>This field is may not be blank.</p><p>You have another form running, Please reload.</p>                                                                                                                                                                                                                                                                                                                |

## Cancel Payout Request

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/user/cancel/withdraw/request/`

This API endpoint will cancel a payout request.

#### Query Parameters

| Name                                         | Type   | Description                          |
| -------------------------------------------- | ------ | ------------------------------------ |
| wallet<mark style="color:red;">\*</mark>     | string | Wallet name eg:wallet1,wallet2,..... |
| payout\_id<mark style="color:red;">\*</mark> | string | Withdrawal request-id.               |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/user/cancel/withdraw/request/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access tooken>',
  },
  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/cancel/withdraw/request/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  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 | wallet     | <p>This field is required.</p><p>This field may not be blank.</p><p>Invalid wallet.</p>         |
| 400         | ￼￼Validation Error | payout\_id | <p>This field is required.</p><p>This field may not be blank.</p><p>Invalid payout id.</p>      |
| 400         | ￼￼Validation Error | payout\_id | <p>Withdrawal request is invalid.</p><p>Withdrawal request is invalid.No transaction found.</p> |


# Announcement

## Announcement List

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

This API endpoint will return a list of announcements.&#x20;

#### Query Parameters

| Name         | Type   | Description                               |
| ------------ | ------ | ----------------------------------------- |
| offset       | string |                                           |
| limit        | string |                                           |
| read\_status | string | 0(unread) or 1(readed),default value is 1 |
| subject      | string | subject text                              |
| start\_date  | string | formate: mm/dd/yyyy                       |
| end\_date    | string | formate: mm/dd/yyyy                       |
| created      | string | formate: mm/dd/yyyy                       |

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <announcement_id>,
                "subject": "<announcement_subject>",
                "message": "<announcement_meessage>",
                "types": "<announcement_types>",
                "image": "<image>",
                "slug": "<announcement_slug>",
                "start_date": "<start_date>",
                "end_date": <end_date>,
                "created": "<created_date>"
            },
            ...
        ],
        "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>/get/announcements-list/',
  '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>/get/announcements-list/',
  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_POSTFIELDS => array(),
  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 | <p>start\_date,</p><p>end\_date,</p><p>created</p> | Invalid date format. |

## Close Announcement

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

This API endpoint will close an announcement.

#### 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       |
| -------------------------------------- | ------ | ----------------- |
| slug<mark style="color:red;">\*</mark> | string | Announcement slug |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/close/announcement/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'slug': '<announcement_slug>'
  }
};
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>/close/announcement/',
  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('slug' => '<announcement_slug>'),
  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 | slug  | <p>This field is required.</p><p>This field may not be blank.</p><p>Requested announcement not found.</p><p>You can't close the requested announcement.</p> |


# Form Key

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

This API endpoint will return a key that is used to post some multi-wallet processing endpoints.

#### Headers

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

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

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": "<key>"
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/get/form-key/',
  '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>/get/form-key/',
  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_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

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


# Prepaid Coupons(Epin)

Manage Coupons

## Active Coupons

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

This API endpoint will return a list of active coupons.

#### Query Parameters

| Name   | Type   | Description                |
| ------ | ------ | -------------------------- |
| wallet | string | eg: wallet1, wallet2, .... |
| code   | string | coupon code                |

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <coupon_id>,
                "pin": "<coupon_pin>",
                "charge": "<coupon_charge>",
                "balance": "<balance>",
                "reusable": <reusable_status>,
                "transferable": <transferable_status>,
                "wallet_type": "<wallet_type>",
                "currecy_data": {
                    "decimals": <decimals>,
                    "symbol_placement": "<symbol_placement>",
                    "symbol": "<currency_symbol>",
                    "rate": <currency_multiple_rate>
                },
                "currency_code": "<currency_code>"
            },
            ...
        ],
        "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/active-epin/',
  '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/active-epin/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Transfer Coupon

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

This API endpoint will transfer a coupon to a user.

#### 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 |
| ---- | ------ | ----------- |
| user | string | Username    |
| epin | string | Coupon id   |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/transfer/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'user': '<username>',
    'epin': '<coupon id>'
  }
};
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/transfer/epin/',
  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('user' => '<username>','epin' => '<coupon id>'),
  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 | user  | <p>User is not found.</p><p>Field may not be blank.</p><p>Self transfer not allowed.</p><p>User already has the maximum number of active coupons.</p> |
| 400         | Validation Error | epin  | <p>Coupon is not found.</p><p>Coupon is not transferable.</p><p>Invalid coupon.</p>                                                                   |

## Share Coupon

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

This API endpoint will share an amount from coupon to anonymous user.

#### 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       |
| ----------------------------------------------- | ------ | ----------------- |
| email<mark style="color:red;">\*</mark>         | string | user mail address |
| epin<mark style="color:red;">\*</mark>          | string | coupon id         |
| share\_amount<mark style="color:red;">\*</mark> | string | amount to share   |

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

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/share/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'email': '<user_mail>',
    'epin': '<coupon_id>',
    'share_amount': '<amount>'
  }
};
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/share/epin/',
  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('email' => '<user_mail>','epin' => '<coupon_id>','share_amount' => '<share_amount>'),
  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 | email         | <p>This field is required.</p><p>This field may not be blank.</p><p>Enter a valid email address.</p>                                                                      |
| 400         | Validation Error | epin          | <p>This field is required.</p><p>This field may not be blank.</p><p>Only numeric characters are allowed.</p><p>Coupon is not found.</p><p>Coupon is not transferable.</p> |
| 400         | Validation Error | share\_amount | <p>This field is required.</p><p>This field may not be blank.</p><p>Only numeric characters are allowed.</p><p>Insufficient Balance.</p>                                  |

## Delete Coupon

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/user/delete/epin/`

This API endpoint will delete a coupon.\
Use the same endpoint to get refund status without status in query params.&#x20;

#### Query Parameters

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| epin<mark style="color:red;">\*</mark> | string | Coupon id   |
| status                                 | string | 1           |

#### 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 " %}

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

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/user/delete/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
    'Cookie': 'store_user=admin_store; sessionid=2ysk6htgc4b3w2f87zvw9cn4v5rxqkws'
  },
  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/delete/epin/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  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 | epin  | <p>This field is required.</p><p>This field may not be blank.</p><p>Only numeric characters are allowed.</p><p>Coupon is not found.</p> |

## Generate Coupon

### Get Wallet List

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

This API endpoint will return the coupon facility enabled wallet list with data.

#### Headers

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

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": [
        {
            "wallet_name": "<wallet_name>",
            "wallet_key": "<wallet>",
            "charges": "<coupon_generate_charge>",
            "ewallet_balance": "<wallet_balance>",
            "active_pins": <active_coupons>,
            "max_active_pins": <maximum_active_coupons>
        },
        ...
    ]
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/generate/epin/',
  '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/generate/epin/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type     | Description                                                     |
| ----------- | -------------- | --------------------------------------------------------------- |
| 401         | Request Failed | Coupon facility is disabled, Please contact your administrator. |

### Create Coupon

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

This API endpoint will create a coupon.

#### 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       |
| -------------------------------------------------------- | ------ | ----------------- |
| wallet\_type<mark style="color:red;">\*</mark>           | string | wallet key        |
| epin\_amount<mark style="color:red;">\*</mark>           | string | amount            |
| number\_of\_pins<mark style="color:red;">\*</mark>       | string | number of coupons |
| transferable<mark style="color:red;">\*</mark>           | string | True or False     |
| reusable<mark style="color:red;">\*</mark>               | string | True or False     |
| token\_field<mark style="color:red;">\*</mark>           | string | Mail token        |
| token\_checksum\_field<mark style="color:red;">\*</mark> | string | token checksum    |
| form\_key<mark style="color:red;">\*</mark>              | string | form post key     |

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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/generate/epin/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'wallet_type': '<wallet_key>',
    'epin_amount': '<amount>',
    'number_of_pins': '<number_of_coupon>',
    'form_key': '<form_key>',
    'token_checksum_field': '<token_checksum>',
    'token_field': '<token>',
    'transferable': '<True or False>',
    'reusable': '<True or False>'
  }
};
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/generate/epin/',
  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('wallet_type' => '<wallet_key>','epin_amount' => '<amount>','number_of_pins' => '<number of coupon>','form_key' => '<form key>','token_checksum_field' => '<token_cheksum>','token_field' => '<token>','transferable' => '<True or False>','reusable' => '<True or False>'),
  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 | wallet\_type           | <p>This field is required.</p><p>This field may not be blank.</p><p>You don't have sufficient balance to continue with this operation.</p>                                                                                                       |
| 400         | Validation Error | epin\_amount           | <p>Invalid or empty Amount.</p><p>This field is required.</p><p>This field may not be blank.</p><p>Please enter an amount between \<min> and \<max>.</p><p>Only integers are allowed.</p><p>Ensure this field has no more than 7 characters.</p> |
| 400         | Validation Error | number\_of\_pins       | <p>This field is required.</p><p>This field may not be blank.</p><p>This operation exceeds the maximum number of active Coupons.</p><p>Invalid number of Coupon.</p><p>Only numeric characters are allowed.</p>                                  |
| 400         | Validation Error | transferable           | <p>This field is required.</p><p>This field may not be blank.</p><p>Select True or False</p>                                                                                                                                                     |
| 400         | Validation Error | reusable               | <p>This field is required.</p><p>This field may not be blank.</p><p>Select True or False</p>                                                                                                                                                     |
| 400         | Validation Error | token\_checksum\_field | <p>This field is required.</p><p>This field may not be blank.</p>                                                                                                                                                                                |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>This field may not be blank.</p><p>Token is not matching.</p>                                                                                                                                                   |
| 400         | Validation Error | form\_key              | You have another form running, Please reload.                                                                                                                                                                                                    |
| 401         | Request Failed   |                        | Coupon facility is disabled, Please contact your administrator.                                                                                                                                                                                  |

## Coupon History

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

This API endpoint will return the history of used coupons.

#### Query Parameters

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| wallet | string | wallet key, eg: wallet1, wallet2, etc |

#### Headers

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

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

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "charge": "<charge>",
                "currecy_data": {
                    "decimals": <decimals>,
                    "symbol_placement": "<symbol_placement>",
                    "symbol": "<symbol>",
                    "rate": <multiple_rate>
                },
                "currency_code": "<currency_code>",
                "pin": "<coupon_pin>",
                "used_on": "<used_date>"
            }
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url> 
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/epin/history/',
  '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/epin/history/',
  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_POSTFIELDS => array(),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

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


# P2P Transfer

## Get Transfer Data

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

This API endpoint will return p2p transfer charges and user data.&#x20;

#### Query Parameters

| Name     | Type   | Description                    |
| -------- | ------ | ------------------------------ |
| wallet   | string | wallet key, default is wallet1 |
| reciever | string | username                       |

#### 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 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "wallet_data": {
            "wallet_balance": <wallet_balance>,
            "transfer_charges": {
                "transfer_charge": "<transfer_charge>",
                "max_transfer_amount": "<max_transfer_amount>",
                "min_transfer_amount": "<min_transfer_amount>",
                "transfer_charge_type": "<transfer_charge_type>"
            },
            "currency_data": {
                "decimals": <decimals>,
                "symbol_placement": "<symbol_placement>",
                "symbol": "<symbol>",
                "rate": <multiple_rate>
            }
        },
        "userdata": {
            "username": "<reciever_username>",
            "name": "<name>",
            "profile_image": "<profile_image_url>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

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

```

**PHP**

```javascript
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/user/p2p/transfer/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | FIeld    | Description                                                                                         |
| ----------- | ---------------- | -------- | --------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |          | P2P transactions are disabled, Please contact your administrator.                                   |
| 400         | Validation Error | wallet   | P2P transactions are disabled for this wallet, Please contact your administrator or invalid wallet. |
| 400         | Validation Error | reciever | <p>This field is required.</p><p>Reciever not found.</p><p>Self transfer not allowed.</p>           |

## P2P Transfer

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

This API endpoint will perform a p2p transfer.

#### 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       |
| ---------------------- | ------ | ----------------- |
| wallet                 | string | wallet key        |
| transfer\_amount       | string | transfer amount   |
| reciever               | string | reciever username |
| form\_key              | string | form key          |
| token\_checksum\_field | string | token checksum    |
| token\_field           | string | mail token        |

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

```
​​​​​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "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/p2p/transfer/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'wallet': '<wallet_key>',
    'transfer_amount': '<amount>',
    'reciever': '<reciever_username>',
    'form_key': '<form_key>',
    'token_checksum_field': '<token_checksum>',
    'token_field': '<token>'
  }
};
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/p2p/transfer/',
  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('wallet' => '<wallet_key>','transfer_amount' => '<amount>','reciever' => '<reciever_username>','form_key' => '<form_key>','token_checksum_field' => '<token_cheksum>','token_field' => '<token>'),
  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 | wallet                 | <p>This field is required.</p><p>This field may not be blank.</p><p>P2P transactions are disabled for this wallet, Please contact your administrator or invalid wallet.</p>                                                                                                                                                         |
| 400         | Validation Error | transfer\_amount       | <p>This field is required.</p><p>This field may not be blank.</p><p>Minimum transaction amount is \<min\_amount>.</p><p>Transaction Limit is \<max\_amount>.</p><p>Ensure this field has no more than 7 characters.</p><p>Only integers are allowed.</p><p>Entered amount is greater than wallet balance.</p><p>Invalid amount.</p> |
| 400         | Validation Error | reciever               | <p>This field is required.</p><p>This field may not be blank.</p><p>Reciever user not found.</p><p>Self transfer not allowed.</p>                                                                                                                                                                                                   |
| 400         | Validation Error | form\_key              | <p>This field is required.</p><p>This field may not be blank.</p><p>You have another form running, Please reload.</p>                                                                                                                                                                                                               |
| 400         | Validation Error | token\_checksum\_field | <p>This field is required.</p><p>This field may not be blank.</p>                                                                                                                                                                                                                                                                   |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>This field may not be blank.</p><p>Token is not matching.</p><p>Only numeric characters are allowed.</p>                                                                                                                                                                                           |
| 401         | Request Failed   |                        | P2P transactions are disabled, Please contact your administrator.                                                                                                                                                                                                                                                                   |


# Internal Transfer

## Get Transfer Data

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/internal-wallet/transfer/`

This API endpoint will return destination wallets with transfer charge data.

#### Query Parameters

| Name           | Type   | Description                  |
| -------------- | ------ | ---------------------------- |
| source\_wallet | string | wallet key, defaule: wallet1 |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "destination_wallets": [
            {
                "destination_wallet": "<wallet_key>",
                "destination_wallet_name": "<wallet_name>",
                "wallet_balance": <wallet_balance>,
                "transfer_charges": {
                    "transfer_charge": "<transfer_charge>",
                    "max_transfer_amount": "<max_transfer_amount>",
                    "min_transfer_amount": "<min_transfer_amount>",
                    "transfer_charge_type": "<transfer_charge_type>"
                }
            },
            ...
        ],
        "currency_data": {
            "decimals": <decimals>,
            "symbol_placement": "<symbol_placement>",
            "symbol": "<currency_symbol>",
            "rate": <currency_rate>
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/internal-wallet/transfer/',
  '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/internal-wallet/transfer/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| <p>Status Code<br></p> | Error Type       | FIeld          | Description                                                                                                                      |
| ---------------------- | ---------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| 400                    | Validation Error | source\_wallet | <p>Internal transactions are disabled for this wallet, Please contact your administrator.</p><p>No destination wallet found.</p> |
| 401                    | Request Failed   |                | Internal transactions are disabled, Please contact your administrator.                                                           |

## Internal Transfer

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

This API endpoint will perform an internal wallet transfer.

#### 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            |
| ---------------------- | ------ | ---------------------- |
| source\_wallet         | string | source wallet key      |
| destination\_wallet    | string | destination wallet key |
| transfer\_amount       | string | transfer amount        |
| form\_key              | string | form key               |
| token\_checksum\_field | string | token checksum         |
| token\_field           | string | token                  |

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

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

Body:
{
    "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/internal-wallet/transfer/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'source_wallet': '<source_wallet>',
    'destination_wallet': '<destination_wallet>',
    'transfer_amount': '<transfer_amount>',
    'form_key': '<form_key>',
    'token_checksum_field': '<token_checksum>',
    'token_field': '<token>'
  }
};
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/internal-wallet/transfer/',
  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('source_wallet' => '<source_wallet>','destination_wallet' => '<destination_wallet>','transfer_amount' => '<transfer_amount>','form_key' => '<form_key>','token_checksum_field' => '<token_checksum>','token_field' => '<token>'),
  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 | source\_wallet         | <p>This field is required.</p><p>This field may not be blank.</p><p>Internal transactions are disabled for this wallet, Please contact your administrator or invalid source wallet.</p>                                                                                                                                             |
| 400         | Validation Error | destination\_wallet    | <p>This field is required.</p><p>This field may not be blank.</p><p>Invalid destination wallet choosen.</p>                                                                                                                                                                                                                         |
| 400         | Validation Error | transfer\_amount       | <p>This field is required.</p><p>This field may not be blank.</p><p>Transaction Limit is \<max\_amount>.</p><p>Minimum transaction amount is \<min\_amount>.</p><p>Only integers are allowed.</p><p>Ensure this field has no more than 7 characters.</p><p>Entered amount is greater than wallet balance.</p><p>Invalid amount.</p> |
| 400         | Validation Error | form\_key              | <p>This field is required.</p><p>This field may not be blank.</p><p>You have another form running, Please reload.</p>                                                                                                                                                                                                               |
| 400         | Validation Error | token\_checksum\_field | <p>This field is required.</p><p>This field may not be blank.</p>                                                                                                                                                                                                                                                                   |
| 400         | Validation Error | token\_field           | <p>This field is required.</p><p>This field may not be blank.</p><p>Token is not matching.</p><p>Only numeric characters are allowed.</p>                                                                                                                                                                                           |
| 401         | Request Failed   |                        | <p>Some errors occured.</p><p>Internal transactions are disabled, Please contact your administrator.</p><p>No destination wallets found for this source wallet.</p>                                                                                                                                                                 |


# History

## Rank History

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

This API endpoint will return a list of user rank history.

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| limit  | string |             |
| offset | string |             |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "rank": {
                    "titile": "<rank_title>",
                    "image": "<rank_image>"
                },
                "created": "<created_date>",
                "username": "<username>"
            }
            ...
        ],
        "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/rank/history/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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/rank/history/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Package History

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

This API endpoint will return a list of user package history.

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| offset | string |             |
| limit  | string |             |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "pre_package": {
                    "name": "<previous_package_name>",
                    "image": "<previous_package_image>"
                },
                "new_package": {
                    "name": "<next_package_name>",
                    "image": "<next_package_name>"
                },
                "created": "<purchased_date>"
            }
            ...
        ],
        "count": <lit_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/package/history/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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/package/history/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# KYC Details

Manage user kyc details.

## Get Documents

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

This API endpoint will return kyc document data with verify status.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "documents": {
            "<document_key>": {
                "type": "<doc_type>",
                "doc_type": "<doc_key>",
                "doc_name": "<doc_name>",
                "verify_status": <verify_status>,
                "note": "<note>",
                "data":"<base64_data>"
            },
            ...
        },
        "kyc_verify_status": <kyc_verify_status>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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/kyc/documents/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Upload Documents

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

This API endpoint will upload user kyc documents.

#### 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                                                                                                      |
| --------- | ------ | ---------------------------------------------------------------------------------------------------------------- |
| document  | string | ID Proof :- Allowed file formats includes: Documents(.PDF) and Images (.JPG, .PNG) and maximum size: 8MB.        |
| document1 | string | Utility Bills:- Allowed file formats includes: Documents(.PDF) and Images (.JPG, .PNG) and maximum size: 8MB.    |
| document2 | string | Account statement:-Allowed file formats includes: Documents(.PDF) and Images (.JPG, .PNG) and maximum size: 8MB. |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'document': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>',
        'contentType': null
      }
    },
    'document1': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>'
        'contentType': null
      }
    },
    'document2': {
      'value': fs.createReadStream('<file_path>'),
      'options': {
        'filename': '<file_name>',
        'contentType': null
      }
    }
  }
};
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/kyc/documents/',
  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('document'=> new CURLFILE('<file_path>'),'document1'=> new CURLFILE('<file_path>'),'document2'=> new CURLFILE('<file_path>')),
  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                                                                                            |
| ----------- | ---------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| 401         | Request Failed   |                                                   | <p>Please upload all required KYC documents and submit the form.</p><p>Maximum upload size is 8MB.</p> |
| 400         | Validation Error | <p>document,</p><p>document1,</p><p>document2</p> | File type '\<file\_type>' is not allowed. Allowed types are: 'image/png, application/pdf, image/jpeg'. |

## Delete Document

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/user/kyc/documents/`

This API endpoint will delete a kyc document.

#### Query Parameters

| Name        | Type   | Description                                     |
| ----------- | ------ | ----------------------------------------------- |
| remove\_doc | string | Document key: document, document1 or document2. |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/user/kyc/documents/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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/kyc/documents/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  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                                                                                             |
| ----------- | ---------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |             | <p>Sorry! Some error occurred. You can not remove your document now.</p><p>KYC Documents not found.</p> |
| 400         | Validation Error | remove\_doc | <p>This field is required and it may not be blank.</p><p>Invalid document key.</p>                      |


# Education Platform

## List Courses

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/available/course/`

This API endpoint will return a list of available and subscribed courses.&#x20;

#### Query Parameters

| Name   | Type   | Description                                                             |
| ------ | ------ | ----------------------------------------------------------------------- |
| page   | string | page number                                                             |
| filter | object | { 'name': \<course title>, 'category': \<category>, 'price': \<price> } |
| limit  | string |                                                                         |
| sort   | string |                                                                         |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "courses": [
            {
                "id": <id>,
                "slug": "<slug>",
                "title": "<cource_title>",
                "thumbnail":"<image>",                                                                                     
                "short_description": "<short_description>",
                "long_description": "<long_description>",
                "detail_url": "<detail_url>",
                "authors": [
                    {
                        "name": "<author_name>"
                    }
                ],
                "duration": "<duration>",
                "progress": <progress>,
                "skills": [
                    "<skills>"
                ],
                "price": <price>,
                "course_type": "<course_type>",
                "total_reviews": "<reviews_count>"
            },

        ],
        "filterParams": {
            "category": [
                {
                    "pk": <id>,
                    "name": "<name>",
                    "slug": "<slug>"
                },
           ],
            "price": [
                {
                    "label": <label>,
                    "value": <value>
                },
            ],
            "sortOptions": [
                {
                    "label": "<label>",
                    "value": "<value>"
                },
            ]
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/available/course/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/education-platform/available/course/',
  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 token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## List Subscribed Courses

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/dashboard/my-courses/`

This API endpoint will return a list of subscribed courses.

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "courses": [
            {
                "id": <id>,
                "slug": "<slug>",
                "title": "<cource_title>",
                "thumbnail":"<image>",                                                                                     
                "short_description": "<short_description>",
                "long_description": "<long_description>",
                "detail_url": "<detail_url>",
                "authors": [
                    {
                        "name": "<author_name>"
                    }
                ],
                "duration": "<duration>",
                "progress": <progress>,
                "skills": [
                    "<skills>"
                ],
                "price": <price>,
                "course_type": "<course_type>",
                "total_reviews": "<reviews_count>"
            },
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/dashboard/my-courses/',
  '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>/education-platform/dashboard/my-courses/',
  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-token>',
  ),
));

$response = curl_exec($curl);

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

## List Internal Courses

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/dashboard/internal-courses/`

This API endpoint will return a list of internal courses

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "courses": [
            {
                "id": <id>,
                "slug": "<slug>",
                "title": "<cource_title>",
                "thumbnail":"<image>",                                                                                     
                "short_description": "<short_description>",
                "long_description": "<long_description>",
                "detail_url": "<detail_url>",
                "authors": [
                    {
                        "name": "<author_name>"
                    }
                ],
                "duration": "<duration>",
                "progress": <progress>,
                "skills": [
                    "<skills>"
                ],
                "price": <price>,
                "course_type": "<course_type>",
                "total_reviews": "<reviews_count>"
            },
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/dashboard/internal-courses/',
  '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>/education-platform/dashboard/internal-courses/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Subscribe Course

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/subscribe/free-course/`

This API endpoint will subscribe to a free course.

#### Headers

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

#### Request Body

| Name                                           | Type   | Description |
| ---------------------------------------------- | ------ | ----------- |
| course\_slug<mark style="color:red;">\*</mark> | string | Course slug |

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

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

Body:
{
    "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>/education-platform/subscribe/free-course/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'course_slug': '<course_slug>'
  }
};
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>/education-platform/subscribe/free-course/',
  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('course_slug' => '<course_slug>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

## Unsubscribe Course

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/unsubscribe/course/`

This API endpoint will unsubscribe to a course.

#### 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 |
| ---------------------------------------------- | ------ | ----------- |
| course\_slug<mark style="color:red;">\*</mark> | string | Course slug |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/unsubscribe/course/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'course_slug': '<course_slug>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/education-platform/unsubscribe/course/',
  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('course_slug' => '<course_slug>'),
  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 | slug  | <p>This field is required and it may not be blank.</p><p>Invalid course slug.</p> |

## Course Detailed View

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/course/detailed-view/`

This API endpoint will return a detailed view of the course.

#### Path Parameters

| Name                                   | Type                    | Description                                                                         |
| -------------------------------------- | ----------------------- | ----------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark> | string                  | Course slug                                                                         |
| subscribed                             | boolean - True or False | If requesting for details of subscribed course, Must add subscribed params as True. |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        
        if the course is not subscribed
        
        "course_slug": "<course_slug>",
        "author": "<author>",
        subscriber_count": <subscriber_count>,
        "course_content": {
            "id": <id>,
            "language": "<language>",
            "title": "<title>",
            "short_description": "<short_description>",
            "long_description": "<long_description>",
            "is_set": <is_set>
        },
        "course_type": "<course_type>",
        "prerequisite": [
            "<badg_name>"
        ],
        "total_modules": <total_modules>,
        "modules": [
            {
                "name": "<module_name>",
                "total_chapters": <total_chapters>,
                "chapters": [
                    {
                        "name": "<chapter_name>"
                        "is_preview": <is_preview>,
                        "resource_url": "<resource_url>",
                        "vimeo_id": "<vimeo_id>"
                    },
                    ....
                ]
            },
            ....
        ],
        "duration": "<duration>",
        "subcribed": <subcribed>,
        "eligible": <eligible>,
        "eligibility": {
            "ranks": [<eligible_rank_names>],
            "groups": [<eligible_groups_names>]
        },
        "currency": "<currency>",
        "first_preview": {
            "id": <id>,
            "number": <chapter_number>,
            "resource_url": "<resource_url>",
            "name": "<name>",
            "description": "<description>",
            "long_description": "<long_description>",
            "duration": "<duration>",
            "is_preview": <is_preview>,
            "slug": "<slug>",
            "module": <module_number>
        },
        
        if the course is subscribed
        "course_id": <course_id>,
        "title": "<title>",
        "duration": "<duration>",
        "subscriber_count": <subscriber_count>,
        "badge_list": [
            "<badge_list>"
        ],
        "course_slug": "<course_slug>",
        "author": "<author>",
        "progress": <progress>,
        "last_visited": {
            "id": <id>,
            "number": <chapter_number>,
            "resource_url": "<resource_url>",
            "name": "<name>",
            "description": "<description>",
            "long_description": "<long_description>",
            "duration": "<duration>",
            "is_preview": <is_preview>,
            "slug": "<slug>",
            "module": <module_number>
        },
        "modules": [
            {
                "module": <module_number>,
                "name": "<name>",
                "description": "<description>",
                "total_chapters": <total_chapters>,
                "chapters": [
                    {
                        "number": <chapter_number>,
                        "slug": "<slug>",
                        "name": "<name>",
                        "description": "<description>",
                        "long_description": "<long_description>",
                        "duration": "<duration>",
                        "is_preview": <is_preview>,
                        "resource_url": "<resource_url>",
                        "vimeo_id": "<vimeo_id>",
                        "module_number": <module_number>
                    },
                   
                ]
            },
            ...
        ],
        
        common data
        
        "review_data": [
            {
                "id": <id>,
                "object_pk": "<object_pk>",
                "comment": "<comment>",
                "rating": <rating>,
                "user__first_name": "<user__first_name>",
                "user__last_name": "<user__last_name>"
            }
        ],
        "ratings_data": {
            "rating_average": <ratings_data>,
            "rating_average_num": <rating_average_num>,
            "rating_total": <rating_total>,
            "review_total": <review_total>
        },
        "already_reviewed": <already_reviewed>,
        "already_reviewed_data": {
            "id": <id>,
            "object_pk": "<object_pk>",
            "comment": "<comment>",
            "rating": <rating>,
            "user__first_name": "<user__first_name>",
            "user__last_name": "<user__last_name>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/course/detailed-view/',
  '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>/education-platform/course/detailed-view/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

<table data-header-hidden><thead><tr><th>Status Code  </th><th width="200">Error Type</th><th>Field</th><th>Description</th></tr></thead><tbody><tr><td>Status Code  </td><td>Error Type</td><td>FIeld</td><td>Description</td></tr><tr><td>400</td><td>Validation Error</td><td>slug</td><td><p>This course is not pusblished, Permission denied.</p><p>This field is required and it may not be blank.</p><p>Invalid slug.</p></td></tr></tbody></table>

## Previous and Next Chapters

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/chapter/next-previous/`

This API endpoint will return next and previous chapter details of selected chapter

#### Query Parameters

| Name                                      | Type    | Description    |
| ----------------------------------------- | ------- | -------------- |
| slug<mark style="color:red;">\*</mark>    | string  | Course slug    |
| module<mark style="color:red;">\*</mark>  | integer | Module number  |
| chapter<mark style="color:red;">\*</mark> | integer | Chapter number |

#### 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": {
        "next_chapter": {
            "id": <id>,
            "number": <chapter_number>,
            "resource_url": "<resource_url>",
            "name": "<name>",
            "description": "<description>",
            "long_description": "<long_description>",
            "duration": "<duration>",
            "is_preview": <is_preview>,
            "slug": "<slug>",
            "module": <module_number>
        },
        "previous_chapter": {
            "id": <id>,
            "number": <chapter_number>,
            "resource_url": "<resource_url>",
            "name": "<name>",
            "description": "<description>",
            "long_description": "<long_description>",
            "duration": "<duration>",
            "is_preview": <is_preview>,
            "slug": "<slug>",
            "module": <module_number>        
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/chapter/next-previous/',
  '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>/education-platform/chapter/next-previous/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field | Description                                                                                                          |
| ----------- | ---------------- | ----- | -------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | slug  | <p>This field is required and it may not be blank.</p><p>Invalid slug.</p><p>You are not subscribed this course.</p> |
| 401         | Request Failed   |       | Module and chapter number is required.                                                                               |

## Update Course Progress

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/course/progress/`

This API endpoint will update course progress.

#### 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 |
| ----------------------------------------------- | ------ | ----------- |
| course\_slug<mark style="color:red;">\*</mark>  | String |             |
| chapter\_slug<mark style="color:red;">\*</mark> | String |             |

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

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

Body:
{
    "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>/education-platform/course/progress/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {
    'course_slug': '<course_slug>',
    'chapter_slug': '<chapter_slug>'
  }
};
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>/education-platform/course/progress/',
  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('course_slug' => '<course_slug>','chapter_slug' => '<chapter_slug>'),
  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 | course\_slug  | <p>This field is required and it may not be blank.</p><p>Invalid course slug.</p> |
| 400         | Validation Error | chapter\_slug | Invalid chapter slug.                                                             |
|             |                  |               |                                                                                   |

####

## Course Review

To add a review for subscribed course use the same endpoint for [product review](/product-review#write-a-review), use course\_id as a bundle in params.

## Get Certificate

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/education-platform/get/certificate/`

This API endpoint is used to get a certificate of a completed subscribed course.

#### Query Parameters

| Name                                           | Type   | Description |
| ---------------------------------------------- | ------ | ----------- |
| course\_slug<mark style="color:red;">\*</mark> | string | Course slug |

#### 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 HttpResponse of certificate" %}

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/education-platform/get/certificate/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
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>/education-platform/get/certificate/',
  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 token>'
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field        | Description                                                                                                          |
| ----------- | ---------------- | ------------ | -------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | course\_slug | <p>This field is required and it may not be blank.</p><p>Invalid course slug.</p><p>Course is not completed yet.</p> |


# Quiz

## Quiz List

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/quiz/list/`

This API endpoint will return a list of the available quiz.

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| limit  | string |             |
| offset | string |             |
| name   | string | Quiz name   |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "slug": "<quiz_slug>",
                "name": "<quiz_name>",
                "question_count": <question_count>,
                "description": "<description>",
                "quiz_details": {
                    "name": "<name>",
                    "maximum_questions": <maximum_questions>,
                    "quiz_duration": "<quiz_duration>",
                    "total_score": <total_score>,
                    "badge": "<badge>",
                    "description": "<description>",
                    "rules": "<rules>"
                }
            }
            ...
        ],
        "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>/quiz/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/quiz/list/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Quiz Summary List

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/quiz/list/results/`

This API endpoint will return a list of quiz summary list with details.

#### Query Parameters

| Name   | Type   | Description |
| ------ | ------ | ----------- |
| name   | string | Quiz name   |
| offset | string |             |
| limit  | string |             |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "score": <score>,
                "total_score": <total_score>,
                "reward": <reward>,
                "last_attempt": "<last_attempt>",
                "attempts": <attempts>,
                "name": "<name>",
                "status": "<status>",
                "badge": {
                    "name": "<badg-name>",
                    "image": "<image>",
                    "slug": "<slug>"
                },
                "related_courses": [
                    {
                        "id": <id>,
                        "slug": "<slug>",
                        "title": "<title>",
                        "thumbnail": "<thumbnail>",
                        "short_description": "<short_description>",
                        "long_description": "<long_description>",
                        "detail_url": "<detail_url>",
                        "authors": [
                            {
                                "name": "<author_name>"
                            }
                        ],
                        "duration": "<duration>",
                        "progress": <progress>,
                        "skills": [
                            "<skills>"
                        ],
                        "price": <price>,
                        "converted_price": "<converted_price>",
                        "course_type": "<course_type>",
                        "total_reviews": "<total_reviews>"
                    },
                    ...
                ]
            },
            ...
        ],
        "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>/quiz/list/results/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/quiz/list/results/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Start Quiz

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/quiz/start/`

This API endpoint will start a quiz and return all the questions and options of the quiz.

#### Query Parameters

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| slug<mark style="color:red;">\*</mark> | string | Quiz slug   |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "questions": [
            {
                "id": <question_id>,
                "number": <question_number>,
                "question": "<question>",
                "score": <score>,
                "duration": "<duration>",
                "options": [
                    {
                        "number": <option_number>,
                        "question": <question_id>,
                        "option": "<option>",
                        "answer": <is_option>
                    },
                    ...
                ]
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/quiz/start/',
  '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>/quiz/start/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | FIeld | Description                                                                            |
| ----------- | ---------------- | ----- | -------------------------------------------------------------------------------------- |
| 400         | Validation Error | slug  | <p>Requested quiz not found.</p><p>This field is required and it may not be blank.</p> |

## Submit Answer

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/quiz/submit/answer/`

This API endpoint will submit answer options of all quiz questions and end the quiz.

#### 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark>    | string | Course Slug                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| options<mark style="color:red;">\*</mark> | String | <p>Options - an array of selected options of each question,  the selected option must contain following key as per the following structure,</p><p> <strong>{ "id": \<option\_</strong><em><strong>id>, "number": \<option\_number>, "question": \<questionid>, "option": "\<option>", "answer": \<falseortrue> }</strong>, if any question is skipped or time out just add an additional key "func" with any option of corresponding question, and set the value for <strong>"func":"skip"</strong> (if question is skipped) or <strong>"func":"time\_</strong></em><strong>out"</strong> (if question time out) </p><p></p> |

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

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/quiz/submit/answer/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',

  },
  body: JSON.stringify({"slug":"<course_slug>","options":[
  {"id":<option_id>,"number":<option_number>,"question":<question_number>,"option":"<option>","answer":<answer>},...
  ]})

};
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>/quiz/submit/answer/',
  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 =>'{
    "slug": "<course_slug>",
    "options":[
        {
            "id": <option_id>,
            "number": <option_number>,
            "question": <question_number>,
            "option": "<option>",
            "answer": <answer>,
        },
        ...
    ]
}',
  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 | slug  | <p>This field is required and it may not be blank.</p><p>Requested quiz not found.</p> |

#### &#x20;


# Lead Campaign

## List Category

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/campaign/list/category/`

This API endpoint will return a list of campaign categories.

#### Query Parameters

| Name        | Type   | Description                                             |
| ----------- | ------ | ------------------------------------------------------- |
| datesetting | string | Possible values are 'on', 'before', and  'after'        |
| dateon      | string | Required if datesetting is provided, formate mm/dd/yyyy |
| offset      | string |                                                         |
| limit       | string |                                                         |
| name        | string | Category name                                           |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <id>,
                "category": "<category_name>",
                "description": "<category_description>",
                "slug": "<category_slug>"
            }
            ...
        ],
        "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>/campaign/list/category/',
  '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>/campaign/list/category/',
  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 token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | FIeld       | Description                |
| ----------- | ---------------- | ----------- | -------------------------- |
| 400         | Validation Error | datesetting | Inavalid date settings.    |
| 400         | dateon           | dateon      | Invalid date formate...etc |

## List Campaign

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/campaign/list/`

This API endpoint will return a list of lead campaigns.

#### Query Parameters

| Name        | Type   | Description                                             |
| ----------- | ------ | ------------------------------------------------------- |
| datesetting | string | Possible values are on, before, and after               |
| dateon      | string | Required if datesetting is provided, formate mm/dd/yyyy |
| offset      | string |                                                         |
| linit       | string |                                                         |
| title       | string | Campaign title                                          |
| category    | string | Category name                                           |
| user        | string | user name                                               |

#### Headers

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

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

```markup
HTTP/1.1 200 OK
Content-Type: application/json
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
             {
                "id": <campaign_id>,
                "campaign": "<campaign_title>",
                "description": "<description>",
                "slug": "<slug>",
                "created": "<created>",
                "campaign_image": "<campaign_image>"
            },

        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/campaign/list/campaign/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

**Node**

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

```

#### Error Responses

| Status Code | Error Type       | FIeld       | Description                |
| ----------- | ---------------- | ----------- | -------------------------- |
| 400         | Validation Error | datesetting | Inavalid date settings.    |
| 400         | dateon           | dateon      | Invalid date formate...etc |

## List Campaign Pages

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/campaign/list/pages/`

This API endpoint will return a list of pages under a campaign.

#### Query Parameters

| Name           | Type   | Description                                                |
| -------------- | ------ | ---------------------------------------------------------- |
| campaign\_slug | string | Slug of the campaign.                                      |
| offset         | string |                                                            |
| limit          | string |                                                            |
| datesetting    | string | Possible values are on, before, and after.                 |
| dateon         | string | Required if datesetting is provided. formate is mm/dd/yyyy |
| title          | string | Page title                                                 |
| user           | string | user                                                       |

#### 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 " %}

```markup

HTTP/1.1 200 OK
Content-Type: application/json
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <id>,
                "slug": "<slug>",
                "title": "<title>",
                "description": "<description>"
                "body": "<body>",
                "image": "<image>",
                "created": "<created>",
                "preview_url": "<page_preview_url>",
                "facebooklink": "<facebooke_share_link>",
                "twitterlink": "<twitter_share_link>"
            }
        ],
        "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>/campaign/list/pages/?campaign_slug=<slug>',
  '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>/campaign/list/pages/?campaign_slug=<slug>',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | FIeld          | Description                |
| ----------- | ---------------- | -------------- | -------------------------- |
| 400         | Validation Error | campaign\_slug | Campaign slug is required. |
| 400         | Validation Error | datesetting    | Inavalid date settings.    |
| 400         | Validation Error | dateon         | Invalid date formate...etc |


# EMI

Records of EMI transactions

## Active EMI Records

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/emi/active-emi-records/`

get the list of active EMI records

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            <array>
        ],
        "count": <count>,
        "previous": null,
        "next": null
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/emi/active-emi-records/',
  '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>/commerce/emi/active-emi-records/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Completed EMI Records

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/emi/completed-emi-records/`

get the list of completed EMI records

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [],
        "count": 0,
        "previous": null,
        "next": null
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/emi/completed-emi-records/',
  '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>/commerce/emi/completed-emi-records/',
  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 token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## All EMI Transaction

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/commerce/emi/all-emi-transactions/`

get the list of all EMI transaction

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [<array>],
        "count": 0,
        "previous": null,
        "next": null
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/commerce/emi/all-emi-transactions/',
  '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>/commerce/emi/all-emi-transactions/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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


# Multi Wallet

## Multi Wallet Transactions

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/mlm/mwallet-transactions/`

get the multi-wallet transactions

#### Query Parameters

| Name     | Type   | Description                                                                                                       |
| -------- | ------ | ----------------------------------------------------------------------------------------------------------------- |
| wallet   | string | <p>Wallet Key</p><p><a data-mention href="/ewallet#ewallet-list">/pages/-MLufW2Ao9fXVKBADjSk#ewallet-list</a></p> |
| category | string | Possible values are tds-other-charge, payout, earnings,  earning\_credited, credited and debited                  |
| period   | string | Possible values are today, yesterday, this-week, last-week, this-month, last-month, this-year, and last-year      |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": [
        {
            "category": "<category>",
            "amount_paid": "<amount_paid>",
            "currency_code": "<currency_code>",
            "currency_symbol": "<currency_symbol>",
            "credit_status": "<credit_status>",
            "created": "<created>",
            "associated_user_id__username": "<ssociated_user_id__username>"
       },
       ...
    ]
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/mlm/mwallet-transactions/',
  '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>/mlm/mwallet-transactions/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Multi Wallet Summary

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/mlm/mwallet-summary/`

get the summary of transactions

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "walletdata": [
            {
                "wallet_overview_data": [
                    {
                        "category": "<category>",
                        "total_vol": "<total_vol>",
                        "amount": <amount>
                    },
                    ...
                ],
                "wallet_data": {
                    "hold_amount": "<hold_amount>",
                    "available_balance": "<available_balance>",
                    "total_earnings": "<total_earnings>",
                    "total_debits": "<total_debits>",
                    "pending_commissions": "<pending_commissions>",
                    "payout_completed": "<payout_completed>",
                    "payout_in_progress": "<payout_in_progress>"
                },
                "wallet": "<wallet>",
                "wallet_name": "<wallet_name>",
                "currency": "<currency>"
            },
            ...
        ],
        "finance": {
            "total_investments": {
                "amount": <amount>,
                "value": "<value>"
            },
            "tds_or_charges": {
               "amount": <amount>,
               "value": "<value>"
            },
            "completed_withrawal": {
                "amount": <amount>,
                "value": "<value>"
            },
            "net_benifits": {
                "amount": <amount>,
                "value": "<value>"
            },
            "total_bonus": {
                "amount": <amount>,
                "value": "<value>"
            },
            "currency_symbol": "<currency_symbol>"
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

#### Node

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/mlm/mwallet-summary/',
  '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>/mlm/mwallet-summary/',
  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 token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```


# Profiles - Goals

## Goals Overview&#x20;

Dashboard widget

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/profiles/overview/`

This endpoint will return goals overview data (dashboard widget).

#### Query Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string | Profile Id  |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "user_goals": {
            "<goal_key>": {
                "period": "<period>",
                "maximum": <maximum>,
                "minimum": <minimum>,
                "display_name": "<display_name>",
                "currency_code": "<currency_code>",
                "current": <current>,
                "percentage": <percentage>,
                "difference": <difference>
            },
            ...
        },
        "eligibleforupdate": <eligibleforupdate_status>,
        "profiles": [
            {
                "id": <profile_id>,
                "profilename": "<profile_name>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/profiles/overview/',
  'headers': {
    'apikey': '<apikey>',
    'api-signature': '<api-signature>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/profiles/overview/',
  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>',
    'api-signature: <api-signature>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

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

## User Goals Leaderboard

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/profiles/user/goals-leaderboard/`

This API endpoint will return user goal leaderboard data.

#### Query Parameters

| Name    | Type   | Description  |
| ------- | ------ | ------------ |
| profile | string | profile id   |
| goal    | string | goal keyword |

#### 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 " %}

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

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "courseList": [
            {
                thumbnail: "<thumbnail>",
                duration: <duration>,
                title: "<title>",
                short_description: "<short_description>",
                detail_url: "<detail_url>"
            },
            ...
        ],
        "goals": {
            "<goal_key>": {
                "period": "<period>",
                "maximum": <maximum>,
                "minimum": <minimum>,
                "display_name": "<display_name>",
                "currency_code": "<currency_code>"
            },
            ...
        },
        "selected_goal": "<selected_goal_keyword>",
        "selected_profile": <selected_profile_id>,
        "profiles_leader_board_data": {
            "<user_id>": {
                "name": "<name>",
                "level": <level>,
                "overall": <overall>,
                "percentage": <percentage>,
                "image": "<profile_image>"
            },
            ...
        },
        "goal_leader_board_user_data": {
            "<user_id>": {
                "value": <value>,
                "image": "<profile_image>",
                "firstname": "<firstname>",
                "surname": "<surname>",
                "percentage": <percentage>
            },
            ...
        },
        "current_goal_info": {
            "<goal_keyword>": {
                "period": "<period>",
                "maximum": <maximum>,
                "minimum": <minimum>,
                "display_name": "<display_name>",
                "currency_code": "<currency_code>",
                "current": <current>,
                "percentage": <percentage>,
                "difference": <difference>
            }
        },
        "goal_status": {
            "goal": "<max_goal_value>",
            "achieved": "<achieved_value>",
            "status_text": "<status_text>"
        },
        "current_goal_details": {
            "variants": [
                {
                    "step": "<step>",
                    "active_link": "<active_link>",
                    "recommended_course": "<recommended_course>",
                    "recommended_article": "<recommended_article>"
                },
                ...
            ]
        },
        "profiles": [
            {
                "id": <profil_id>,
                "profilename": "<profile_name>"
            },
            ...
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/profiles/user/goals-leaderboard/',
  'headers': {
    'apikey': '<apikey>',
    'api-signature': '<api-signature>',
    'Authorization': 'Bearer <access-token>',
  }
};
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>/profiles/user/goals-leaderboard/',
  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>',
    'api-signature: <api-signature>',
    'Authorization: Bearer <access-token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

| Status Code | Error Type       | Field   | Description           |
| ----------- | ---------------- | ------- | --------------------- |
| 400         | Validation Error | profile | Invalid profile id.   |
| 400         | Validation Error | goal    | Invalid goal keyword. |


# Saved Cards

List of saved stripe and authnet cards

## Saved Stripe Cards

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/saved/stripe-cards/`

This API endpoint will return a list of user saved stripe cards.&#x20;

#### Query Parameters

| Name   | Type   | Description                                                   |
| ------ | ------ | ------------------------------------------------------------- |
| status | string | Card status, possible values are 1(Active) and 0(Deactivated) |

#### 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 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "pk": <id>,
                "live": "<live_or_test>",
                "api": "<card_data>",
                "status": "<active_status>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page>,
        "next": <next_page>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/saved/stripe-cards/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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/saved/stripe-cards/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Saved Authnet Cards

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/user/saved/authnet-cards/`

This API endpoint will return a list of user-saved authnet cards.

#### Query Parameters

| Name   | Type   | Description                                                   |
| ------ | ------ | ------------------------------------------------------------- |
| status | string | Card status, possible values are 1(Active) and 0(Deactivated) |

#### 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 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "pk": <id>,
                "live": "<live_or_test>",
                "data": "<card_data>",
                "status": "<active_status>"
            },
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page>,
        "next": <next_page>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/user/saved/authnet-cards/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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/saved/authnet-cards/',
  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 token>',
  ),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;
```


# Webhook

Webhook Management

## Introduction

A webhook (also called a web callback or HTTP push API) is a **way for an app to provide other applications with real-time information**. A webhook delivers data to other applications as it happens, meaning you get data immediately.

For using webhook service clients have to register an API application that will have an API key, api-admin credential, and an encryption file for further authentications. This is taken place for a successful webhook event subscription validation. For implementing the webhook service follow the given steps.&#x20;

Available webhook event slugs and their provided data are listed at the end of the webhook document.

## List Events

## List Provided Webhook Events

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/webhook/list/events/`

This API endpoint provided a list of available webhook events.

#### 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": [
            {
                "id": <id>,
                "slug": "<event_slug>",
                "name": "<event_name>",
                "trigger_immediate": <trigger_immediate>,
                "is_active": <is_active_status>
            },
            ...
        ],
        "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>/webhook/list/events/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>'
  }
};
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>/webhook/list/events/',
  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-token>'
  ),
));

$response = curl_exec($curl);

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

## Subscribe Event

## Subscribe an event

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

This API endpoint is used to subscribe to a webhook event. For subscribing to an event minimum of one event slug and an URL is required. Before initiating the validation flow, the system will generate a string that will act as a challenge code.&#x20;

Use this challenge code as a query parameter to make an HTTP POST to your webhook endpoint.&#x20;

eg: [https://webhooks.example.com?challenge\_code](https://webhooks.example.com/linkedin?challengeCode=890e4665-4dfe-4ab1-b689-ed553bceeed0)="\<challange\_code>"

Your application must compute the challenge\_response using the provided encryption file. Return both the challenge\_code and challenge\_response in a JSON payload with a 200 OK status.

challenge\_code - given challenge code through your webhook endpoint as a query param,

challenge\_response - encrypt the challenge code using provided encryption file keys,&#x20;

clientSecret key for encryption is **"webhook",**

eg response (JSON):

**`{"challenge_code`*****`" : "<`*****`challenge_code>", "challenge_response" : "<challenge_response>" }`**

On receiving the validation response, the system will verify by computing the challenge\_response and comparing it with the challenge\_response returned by the app.

If the challenge\_response is successfully verified, then the webhook is ready to be used in subscriptions. If the verification fails, an email will be sent to the admin user, for validating again use the **Webhook Subscriber Validation** endpoint, which is given below. if the validation fails continuously the subscription will be blocked permanently.

An event in the system will post a request to the subscribed URL with a header and payload data. the request header contains a webhook signature which is an encrypted event slug and authorization, to identify the event decrypt the event signature using provided encryption file keys, and the clientSecret Key for event-signature is **"webhook-event"**.

#### 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                                                                              |
| ---------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| events<mark style="color:red;">\*</mark> | array  | <p>An array of event slug</p><p><a data-mention href="#list-events">#list-events</a></p> |
| url<mark style="color:red;">\*</mark>    | string | Endpoint url                                                                             |

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

```html
HTTP/1.1 200 OK
Content-Type: application/json
{
    "status_code": 200,
    "errors": {},
    "data": {
        "uuid": "<unique_subscription_id>", //save this uuid for future subscription manage.
        "user": "<admin_user_mail>",
        "events": [
            "<event_slug>", ...
        ],
        "url": "<subscription_endpoint_url>",
        "content_type": "<content_type>",
        "is_broken": <is_broken>,
        "is_verified": <is_verified>,
        "is_disabled": <is_disabled>,
        "is_plugin": <is_plugin>,
        "created": "<created_date>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/webhook/subscribe/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access_token>',
  },
  body: JSON.stringify({"events":["event_slug",..],"url":"<endpoit_url>"})
};
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>/webhook/subscribe/',
  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 =>'    {
        "events": ["<event_slug>",...],
        "url": "<endpoint_url>"
    }',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access_token>',
  ),
));

$response = curl_exec($curl);

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

**Error Responses**

<table><thead><tr><th data-type="number">Status Code</th><th>Error Type</th><th>Field</th><th>Description</th></tr></thead><tbody><tr><td>400</td><td>Validation Error</td><td>events</td><td><p>This field is required.</p><p>This list may not be empty.</p><p>'&#x3C;event-slug>' this webhook event is already subscribed for this API User.</p></td></tr><tr><td>400</td><td>Validation Error</td><td>url</td><td><p>This field is required.</p><p>This field may not be blank.</p><p>Enter a valid URL.</p><p>Protocol of recipient URL not allowed (('https://',) only).</p></td></tr></tbody></table>

## **Webhook Subscriber Validation**

## Webhook Validation

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/webhook/subscribe/validate/<uuid>/`

This API endpoint is used to validate or verify a non-verified webhook subscription.

#### 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
{
    "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>/webhook/subscribe/validate/<uuid>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  }
};
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>/webhook/subscribe/validate/<uuid>/',
  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_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access-token>',
  ),
));

$response = curl_exec($curl);

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

#### Error Responses

<table><thead><tr><th data-type="number">Status Code</th><th>Error Type</th><th>Field</th><th>Description</th></tr></thead><tbody><tr><td>400</td><td>Validation Error</td><td>uuid</td><td><p>This subscription is blocked due to maximum validation attempt (&#x3C;max<em>attempt</em>count>), Please contact admin for unblocking your subscription.</p><p></p><p>This subscription is already verified.</p></td></tr><tr><td>404</td><td>Not Found</td><td></td><td>The requested resource not found.</td></tr><tr><td>null</td><td></td><td></td><td></td></tr></tbody></table>

## Update Subscription

## Update a subscription

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/webhook/update/<uuid>/`

This API endpoint is used to update a webhook event subscription.

#### 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       |
| ------------ | ------- | ----------------- |
| url          | sring   | URL               |
| events       | array   | List of events    |
| is\_disabled | boolean | Enable or Disable |

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

```html
HTTP/1.1 200 OK
Content-Type: application/json
{
    "status_code": 200,
    "errors": {},
    "data": {
        "uuid": "<unique_subscription_id>", //save this uuid for future subscription manage.
        "user": "<admin_user_mail>",
        "events": [
            "<event_slug>", ...
        ],
        "url": "<subscription_endpoint_url>",
        "content_type": "<content_type>",
        "is_broken": <is_broken>,
        "is_verified": <is_verified>,
        "is_disabled": <is_disabled>,
        "is_plugin": <is_plugin>,
        "created": "<created_date>"
    }
}
```

{% endtab %}
{% endtabs %}

#### **Sample Code**

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/webhook/update/<uuid>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access_token>',
  },
  body: JSON.stringify({"events":["event_slug",..],"url":"<endpoit_url>","is_disabled":<boolean>})
};
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>/webhook/update/<uuid>/',
  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 =>'    {
        "events": ["<event_slug>",...],
        "url": "<endpoint_url>",
        "is_disabled":<boolean>
    }',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access_token>',
  ),
));

$response = curl_exec($curl);

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

**Note:-** Error Responses are the same as an event subscription.&#x20;

## Webhook Info

## Webhook Info

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/webhook/info/<uuid>/`

This API endpoint is used to get webhook subscription details.

#### 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 " %}

```javascript
HTTP/1.1 200 OK
Content-Type: application/json
{
    "status_code": 200,
    "errors": {},
    "data": {
        "uuid": "<unique_subscription_id>", //save this uuid for future subscription manage.
        "user": "<admin_user_mail>",
        "events": [
            "<event_slug>", ...
        ],
        "url": "<subscription_endpoint_url>",
        "content_type": "<content_type>",
        "is_broken": <is_broken>,
        "is_verified": <is_verified>,
        "is_disabled": <is_disabled>,
        "is_plugin": <is_plugin>,
        "created": "<created_date>"
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/webhook/info/<uuid>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  }
};
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>/webhook/info/<uuid>/',
  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-token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## Unsubscribe Event

## Unsubscribe webhook event

<mark style="color:red;">`DELETE`</mark> `‎https://<domain>/<api prefix>/<version>/webhook/unsubscribe/<uuid>/`

This API endpoint is used to unsubscribe or delete an event subscription.

#### Headers

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

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

```html
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### **Sample Code**

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://<domain>/<api prefix>/<version>/webhook/unsubscribe/<uuid>/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/webhook/unsubscribe/<uuid>/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access-token>',
  ),
));

$response = curl_exec($curl);

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

## List Subscriptions

## List event subscriptions

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/webhook/list/`

This API endpoint is used to list webhook event subscriptions.

#### 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
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                 "uuid": "<unique_subscription_id>",
                 "user": "<admin_user_mail>",
                 "events": [
                    "<event_slug>", ...
                 ],
                 "url": "<subscription_endpoint_url>",
                 "content_type": "<content_type>",
                 "is_broken": <is_broken>,
                 "is_verified": <is_verified>,
                 "is_disabled": <is_disabled>,
                 "is_plugin": <is_plugin>,
                 "created": "<created_date>"
           },
           ...
        ],
        "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>/webhook/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  }
};
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>/webhook/list/',
  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 token>',
  ),
));

$response = curl_exec($curl);

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

## Provided Webhook Events

These are available webhook events in the system and the data given by the event.

{% tabs %}
{% tab title="Event Name" %}
**User Registration**
{% endtab %}

{% tab title="Event Slug" %}
**user-registration**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
{
    'email': '<user_email_address>', 
    'sponsor': '<sponsor_user_name>', 
    'username': '<username>', 
    'is_active': <user_status>, 
    'last_name': '<last_name>', 
    'unique_id': '<unique_id>', 
    'user_role': 
        [
            {
                'name': '<user_role_name>'
            }
        ], 
    'first_name': '<first_name>', 
    'phone_code': <phone_code>, 
    'phone_number': '<phone_number>'
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Order Creation**
{% endtab %}

{% tab title="Event Slug" %}
**order-creation**
{% endtab %}

{% tab title="Data (JSON)" %}
if the order type is **Commerce,**

```html
{
    'uid': '<user_unique_id>', 
    'status': '<order_status>', 
    'products': [
        {
            'bv': <bv>, 
            'cv': <cv>, 
            'point': <points> 
            'total': <product_total_price>, 
            'quantity': <quantity>, 
            'product_name': '<product_name>', 
            'product_base_price': '<product_base_price>',
            'product_id': '<product_id>'
        },
        ...
    ], 
    'username': '<username>', 
    'last_name': '<last_name>', 
    'first_name': '<first_name>', 
    'order_type': '<order_type>', 
    'order_total': '<order_total>', 
    'currency_code': '<currency_code>',
    'order_number': '<order_number>'
}
```

if the order type is **Enrollment,**

```html
{
    'bv': '<bv>', 
    'cv': '<cv>', 
    'uid': '<user_unique_id>', 
    'points': '<points>', 
    'status': '<order_status>', 
    'username': '<username>', 
    'last_name': '<last_name>', 
    'first_name': '<first_name>', 
    'order_type': 'ENROLLMENT', 
    'product_id': '<product_id>', 
    'amount_paid': '<amount_paid>', 
    'order_total': '<order_total>', 
    'product_name': '<product_name>', 
    'actual_amount': '<actual_amount>', 
    'currency_code': '<currency_code>', 
    'payment_status': '<payment_status>', 
    'product_base_price': '<product_base_price>',
    'order_number': '<order_number>'
}	
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Block User**
{% endtab %}

{% tab title="Event Slug" %}
**block-user**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
[
    {'unique_id': '<blocked_user_unique_id>'},
    ...
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Unblock User**
{% endtab %}

{% tab title="Event Slug" %}
**unblock-user**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
[
    {'unique_id': '<blocked_user_unique_id>'},
    ...
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Product Creation**
{% endtab %}

{% tab title="Event Slug" %}
**product-creation**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
{
    'bundle_id': '<bundle_id>'
}	
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Product Update**
{% endtab %}

{% tab title="Event Slug" %}
**product-update**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
{
    'bundle_id': '<bundle_id>'
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Product Delete**
{% endtab %}

{% tab title="Event Slug" %}
**product-delete**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
{
    'bundle_id': '<bundle_id>'
}	
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Event Name" %}
**Profile Update**
{% endtab %}

{% tab title="Event Slug" %}
**profile-update**
{% endtab %}

{% tab title="Data (JSON)" %}

```html
{
    'unique_id': '<unique_id>'
}	
```

{% endtab %}
{% endtabs %}


