---
updatedAt: 2026-02-26T13:10:33.000Z
agentTools:
  projectIndex: https://docs.ksa.ngenius-payments.com/llms.txt
---

# Request an access token

This section will describe how you will authenticate yourself to the N-Genius Online identity services, and receive an access token in return, which you can then use to perform more meaningful operations using the N-Genius Online payment APIs.

## Request an access token

The first step for any **N-Genius Online** gateway interaction is to validate ourselves with the identity service and obtain an access token. This token allows us to execute operations on the gateway APIs with authority, and whilst a single token will expire after 5 minutes, we can use our Service Account API key to generate one at any time.

**HTTP Request Method**: POST\
**Resource (URI)**: https\://api-gateway.sandbox.ksa.ngenius-payments.com/identity/auth/access-token

## Headers:

Add these headers to your request (note that you should replace '*your\_api\_key*' with the service account API key in the [Getting started](https://docs.ksa.ngenius-payments.com/ksa/reference/getting-started-paypage) section).

| Header        | Value                               |
| :------------ | :---------------------------------- |
| Content-Type  | application/vnd.ni-identity.v1+json |
| Authorization | Basic *your\_api\_key*              |

## Example response (body):

```json
{     
  "access_token": "eyJhbGciOiJSUzI1N…0eDloZnVRI",     
  "expires_in": 300,     
  "refresh_expires_in": 1800,     
  "refresh_token": "eyJhbGciOi…eDloZnVRIn0",
  "token_type": "bearer"
}
```

## Code example (PHP + cURL):

```php
$apikey = "[your-api-key]"; // enter your API key here

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api-gateway.sandbox.ksa.ngenius-payments.com/identity/auth/access-token");

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "accept: application/vnd.ni-identity.v1+json",
    "authorization: Basic " . $apikey,
    "content-type: application/vnd.ni-identity.v1+json"
));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"realmName\":\"ni\"}");

$output = json_decode(curl_exec($ch));
$access_token = $output->access_token;

```
```text
```

**Note**: you will require the *access\_token* value for any subsequent calls to the N-Genius Online platform APIs.