# Assinatura

### 🔐 Autenticação via HMAC

Cada requisição deve conter os seguintes headers:

| Header        | Tipo     | Descrição                                   |
| ------------- | -------- | ------------------------------------------- |
| `x-client-id` | `string` | Identificador exclusivo do parceiro         |
| `x-timestamp` | `string` | Timestamp UNIX (em segundos) da requisição  |
| `x-signature` | `string` | Assinatura HMAC gerada com o `clientSecret` |

#### 🧾 Como gerar a assinatura

A `stringToSign` usada para gerar a assinatura deve seguir a seguinte ordem exata:

METHOD + PATH + TIMESTAMP + CLIENT\_ID + BODY

* `METHOD`: método HTTP da requisição (ex: `POST`)
* `PATH`: caminho da URL (ex: `/api/partners/get-dolar`)
* `TIMESTAMP`: UNIX timestamp válido em segundos, com até 5 minutos de tolerância
* `CLIENT_ID`: mesmo valor enviado no header `x-client-id`
* `BODY`: conteúdo da requisição serializado com `JSON.stringify()` (mesmo que vazio `{}`)

{% tabs %}
{% tab title="Typescript" %}
{% code overflow="wrap" %}

```typescript
import CryptoJS from "crypto-js";
const method = "POST";
const path = "/api/partners/get-dolar";
const timestamp = "1746924610";
const clientId = "...";
const body = JSON.stringify({ usdtAmount: 10, quoteType: "DEPOSIT" });
const stringToSign = method + path + timestamp + clientId + body;
const clientSecret = "yourClientSecret";
const signature = CryptoJS.HmacSHA256(stringToSign, clientSecret).toString(CryptoJS.enc.Hex);
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}

```php
<?php
$method = "POST";
$path = "/api/partners/get-dolar";
$timestamp = "1746924610";
$clientId = "58BAAA...";
$body = '{"usdtAmount":10, "quoteType:"DEPOSIT"}';
$clientSecret = "suaChaveSecretaAqui";

$stringToSign = $method . $path . $timestamp . $clientId . $body;
$signature = hash_hmac('sha256', $stringToSign, $clientSecret);

echo "Signature: " . $signature;
?>
```

{% 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://docs.criptonopix.app.br/docs/cripto-no-pix-partner-api/partners/assinatura.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.
