# Authentication settings

## 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 %}


---

# 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://payment.excoinz.com/authentication-settings.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.
