> For the complete documentation index, see [llms.txt](https://payment.excoinz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://payment.excoinz.com/authentication-settings.md).

# Authentication settings

How to set up authentication and headers to use the ExPay API.

## Authentication headers

The Excoinz API typically uses a secret key for Restful API authentication. The secret key can be found in [ExPay Admin](/client-secret-key.md).

## Authenticate with a secret key

1. Check my secret key value in [ExPay Admin](/client-secret-key.md)
2. Add your secret key to the header

{% tabs %}
{% tab title="Node.js" %}

```javascript
const axios = require('axios');

const REQUEST_PATH = 'ANY_PATH';

const headers = {
  'EXCOINZ_SECRET': `Bearer ${process.env.SECRET_KEY}`,
  'Content-Type': 'application/json'
};

const data = {
  //ANY_DATA
};

axios.post(`https://api.excoinz.com/${REQUEST_PATH}`, data, { headers: headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error('Error:', error.response.data);
  });
```

{% endtab %}

{% tab title="JAVA" %}

<pre class="language-java"><code class="lang-java"><strong>import okhttp3.*;
</strong>import java.io.IOException;

public static void main(String[] args) {
    String url = "https://api.excoinz.com/${ANY_PATH}";
    String SECRET_KEY = "YOUR_SECRET_KEY";
    
    OkHttpClient client = new OkHttpClient();

    RequestBody body = RequestBody.create(
        MediaType.parse("application/json"), 
        "{
         //ANY_DATA
        }"  
    );

    Request request = new Request.Builder()
        .url(url)
        .post(body)
        .addHeader("EXCOINZ_SECRET", "Bearer " + SECRET_KEY)
        .addHeader("Content-Type", "application/json")
        .build();

    try {
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
</code></pre>

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$SECRET_KEY = 'YOUR_SECRET_KEY';
$url = "https://api.excoinz.com/${ANY_PATH}";

$data = json_encode(array(
    //ANY_DATA
));

$headers = array(
    "EXCOINZ_SECRET: Bearer $SECRET_KEY",
    "Content-Type: application/json"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);

?>
```

{% endtab %}
{% endtabs %}
