# Authentication

LeaderOS uses a HTTP header to authenticate requests with an API key.\
The header is called `X-Api-Key` and the value is the API key.

{% hint style="info" %}
The API key can be found in the LeaderOS settings.
{% endhint %}

#### Examples

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

#### GET Request

```
curl https://yourwebsite.com/api/store/products
   -H "X-Api-Key: YOUR_API_KEY"
```

#### POST Request

```
curl https://yourwebsite.com/api/store/products
   -H "X-Api-Key: YOUR_API_KEY"
   -H "Content-Type: multipart/form-data"
   -X POST
   -d "username=test&password=test"
```

{% endtab %}

{% tab title="PHP" %}

#### GET Request

<pre class="language-php"><code class="lang-php">// GET
<strong>$ch = curl_init();
</strong>curl_setopt($ch, CURLOPT_URL, "https://yourwebsite.com/api/store/products");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
    'X-Api-Key: YOUR_API_KEY'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$output = curl_exec ($ch);
curl_close ($ch);
</code></pre>

#### POST Request

```php
// POST
curl_setopt($ch, CURLOPT_URL, "https://yourwebsite.com/api/auth/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'username' => 'test',
    'password' => 'test'
]);

$headers = [
    'X-Api-Key: YOUR_API_KEY'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$output = curl_exec ($ch);
curl_close ($ch);
```

{% endtab %}

{% tab title="JavaScript" %}

#### GET Request

```javascript
const instance = axios.create({
  baseURL: 'https://yourwebsite.com',
  headers: {
    'X-API-KEY': 'YOUR_API_KEY',
  },
});

// GET
instance.get('/api/store/products');
```

#### POST Request

```javascript
const instance = axios.create({
  baseURL: 'https://yourwebsite.com',
  headers: {
    'X-API-KEY': 'YOUR_API_KEY',
  },
});

// POST
instance.post('/api/auth/login', {
  username: 'test',
  password: 'test'
}, {
  headers: {
    'Content-Type': 'multipart/form-data',
  }
});
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.leaderos.net/getting-started/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
