Skip to main content

Login

All interaction with the XGate API is secured and requires authentication. The first step for any integration is to obtain your access token.

This Endpoint allows you to exchange your email and password for a Bearer Token (in JWT format). This token must be sent in all future requests in the Authorization Header.

Important

The generated token is valid for 15 days. After this period, you will need to generate a new token using the same route.


Endpoint​

  • Method: POST
Endpoint URL
https://api.xgateglobal.com/auth/token

Test Integration​

Use the form below to generate a valid token directly from your browser.

🔐

Test: Authentication

1. Your Credentials

Request​

Send a JSON object in the request body with the following properties:

FieldTypeRequiredDescription
emailStringYesYour platform access email.
passwordStringYesYour access password.

Example Body (JSON)​

{
"email": "email@company.com",
"password": "Your.Password"
}

Responses​

Success (200 OK)​

On success, the API will return a JSON object containing your access token:

{
"token": "eyJhbGciOiJIUzI1NiIsIn6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibm******************************"
}

Common Errors​

StatusMessageLikely Reason
401Unauthorized• Incorrect email or password.
500Internal Server ErrorInternal server error. Contact support.

How to use​

After receiving the token, you should store it securely and send it in all subsequent requests to protected routes.

The token must be sent in the Authorization Header using the Bearer prefix (followed by a space).

Example Header

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
Expiration Reminder

The token expires in 15 days. If you start receiving 401 Unauthorized errors in your requests (even with the token), it is likely expired. Simply login again to generate a new token.


Integration​

The integration example uses the Axios library in Node.js.

Installing Axios:

npm install axios

JavaScript Example:

const axios = require("axios");

const apiUrl = "https://api.xgateglobal.com";
const credentials = {
email: "your_email@domain.com",
password: "**********"
};

(async () => {
try {
const response = await axios.post(`${apiUrl}/auth/token`, credentials);
console.log(response.data);
} catch (error) {
if (error.response && error.response.data) {
console.error(error.response.data.message || "An error occurred");
} else {
console.error(error.message);
}
}
})();