# Signature

The Signature is calculated based on the `timestamp`, `request body` and your `Secret Key` with HMAC hash using SHA256 Algorithm.&#x20;

Here is an example on how to generate the Signature for `otp` type with `Secret Key=12345ABCDE`, `timestamp=1706191612` and following request body:

```json
{
  "type": "otp",
  "data": {
    "code": "1234",
    "msisdn": "+260977223120"
  }
}
```

In order to generate the Signature all spaces must be removed from the request body:

```json
{"type":"otp","data":{"code":"1234","msisdn":"+260977223120"}}
```

{% hint style="info" %}
Please note that the order of the fields matters for calculating the signature. It will always be `type` first then `data`. Fields in `data` must be in the same order they are listed on doc pages for types.
{% endhint %}

Then message for HMAC algorithm has to be formed using following template:

```
{timestamp}{request body with removed spaces}
```

So the message should look like the following:

```
1706191612{"type":"otp","data":{"code":"1234","msisdn":"+260977223120"}}
```

The computed Signature for this request is:

```
46b1ec8d2a05129bb57c8256f2cdd3029b2cf72dbed57f0d3eedd6b156573433
```

A free online HMAC Generator for testing is available on <https://www.freeformatter.com/hmac-generator.html#before-output>.&#x20;

Here is how we calculated the Signature from above example using **Free Formatter**

<figure><img src="/files/RSi0Fz9ZdRDFU2bUrbDb" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Your `Secret Key` is located on your API Settings page. Login to Betstack to access your `Secret Key`
{% endhint %}

<figure><img src="/files/1SMyjRbApAjJRygB84MA" alt=""><figcaption><p>Secret Key is locate in API Settings profile page</p></figcaption></figure>


---

# 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.betstack.io/sms-notifications/signature.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.
