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

post
β€Ž
β€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žhttps://<domain>/<api prefix>/<version>/user/login/

Sample Code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'β€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žhttps://<domain>/<api prefix>/<version>/user/login/',
5
'headers': {
6
'apikey': '<apikey>',
7
},
8
formData: {
9
'username': '<username>',
10
'password': '<password>'
11
}
12
};
13
request(options, function (error, response) {
14
if (error) throw new Error(error);
15
console.log(response.body);
16
});
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "β€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žβ€Žhttps://<domain>/<api prefix>/<version>/user/login/",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS => array('username' => '<username>','password' => '<password>'),
15
CURLOPT_HTTPHEADER => array(
16
"apikey: <apikey>"
17
),
18
));
19
​
20
$response = curl_exec($curl);
21
​
22
curl_close($curl);
23
echo $response;
Copied!
Error Reponses
Status
Code Error
Type Description
401
Authentication failed
The supplied authentication credentials are invalid.
401
Inactive 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

post
β€Ž
β€Žhttps://<domain>/<api prefix>/<version>/user/token/refresh/

Sample code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'β€Žhttps://<domain>/<api prefix>/<version>/user/token/refresh/',
5
'headers': {
6
'apikey': '<apikey>'
7
},
8
formData: {
9
'refresh': '<refresh token>'
10
}
11
};
12
request(options, function (error, response) {
13
if (error) throw new Error(error);
14
console.log(response.body);
15
});
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "β€Žhttps://<domain>/<api prefix>/<version>/user/token/refresh/",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS => array('refresh' => '<refresh token>'),
15
CURLOPT_HTTPHEADER => array(
16
"apikey: <spaikey>"
17
),
18
));
19
​
20
$response = curl_exec($curl);
21
​
22
curl_close($curl);
23
echo $response;
Copied!

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

post
β€Ž
β€Žhttps://<domain>/<api prefix>/<version>/user/logout/

Sample code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'β€Žhttps://<domain>/<api prefix>/<version>/user/logout/',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>'
8
},
9
formData: {
10
'refresh': '<refresh token>'
11
}
12
};
13
request(options, function (error, response) {
14
if (error) throw new Error(error);
15
console.log(response.body);
16
});
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "β€Žhttps://<domain>/<api prefix>/<version>/user/logout/",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS => array('refresh' => '<refresh token>'),
15
CURLOPT_HTTPHEADER => array(
16
"apikey: <apikey>",
17
"Authorization: Bearer <access token>"
18
),
19
));
20
​
21
$response = curl_exec($curl);
22
​
23
curl_close($curl);
24
echo $response;
Copied!

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.
​
​
​