> For the complete documentation index, see [llms.txt](https://airvend.gitbook.io/airgate-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://airvend.gitbook.io/airgate-documentation/integration-guide/authentication/authorizing-api-calls.md). Agents can also search and read this documentation through its [MCP server](https://airvend.gitbook.io/airgate-documentation/~gitbook/mcp).

# Authorizing API Calls

We authenticate all API calls on Airgate. If an API request is made without authorization, the request will fail with the status code `401: Unauthorized`.

{% hint style="warning" %}
Your secret key can perform any actions on your Airgate account without restriction. Keep this key confidential and only store it on your servers (preferably as an environment variable).

**NEVER** include your secret key in your Git repository or front-end JavaScript code.
{% endhint %}

To authorize API calls from your server, you are required to pass your secret key and merchant key in your request header. This means passing header with a value of `{"secret-key": YOUR_SECRET_KEY, "merchant-key": YOUR_PUBLIC_KEY}`

For instance, an API call could look like this in JavaScript:

```javascript
const axios = require('axios');
let data = JSON.stringify({
  "amount": 1000,
  "user": {
    "name": "Alex Hunter",
    "phone": "08134575575",
    "email": "alexhunter@callphoneng.com"
  },
  "callback_url": 'YOUR_CALLBACK_URL'
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: '/payment_initiate_hosted' ,
  headers: { 
    'secret-key': 'YOUR_SECRET_KEY', 
    'merchant-key': 'YOUR_MERCHANT_KEY', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

With our SDK's when available, you don’t need to pass the header manually; instead, you’ll provide your keys when initializing the library.

Contact [<mark style="color:red;">Airgate Support</mark>](mailto:support@airgate.com) if you have questions or need help authorizing your requests during integration.
