# Construct Signature

## Option 1

If `userId` is sent in `InitConfig` then the callback signature will be constructed the following way:

Data required to generate signature:

1. `transactionId`
2. `userId`
3. `secretKey`

The signature variable is calculated by taking the MD5 hash of `transactionId, userId, secretKey` separated by colons. In Python, it can be calculated using the code snippet below:

{% code overflow="wrap" %}

```python
import hashlib
signature = hashlib.md5(f"{transactionId}:{userId}:{secretKey}".encode('utf-8')).hexdigest())
```

{% endcode %}

## Option 2

If  `clientId` is sent in `InitConfig` then the callback signature will be constructed the following way:

Data required to generate signature:

1. `transactionId`
2. `clientId`
3. `secretKey`

The signature variable is calculated by taking the MD5 hash of `transactionId, clientId, secretKey` separated by colons. In Python, it can be calculated using the code snippet below:

{% code overflow="wrap" %}

```python
import hashlib
signature = hashlib.md5(f"{transactionId}:{clientId}:{secretKey}".encode('utf-8')).hexdigest())
```

{% endcode %}

### NOTE:

ArcPlay will send a `signature` variable in the postback payload as an Auth token. The publisher server must recalculate the `signature` and match it to the `signature` sent to securely validate the transaction. The `secretKey` will be shared with by the ArcPlay Customer Success Team. Each application should have a unique secretKey. Please do not use the same secretKey for all of your applications, as this might lead to a situation where rewarding the user in one application will also reward the user in another application.


---

# 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://arcplay-ai.gitbook.io/knowledge-portal/for-consumer-apps/unlock-with-ads/engineering-team/optional-callback-url-integration/signature/construct-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.
