> For the complete documentation index, see [llms.txt](https://legacy-docs.usesmileid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://legacy-docs.usesmileid.com/integration-options/server-to-server/javascript/generate-signature.md).

# Signature

Required Class: **Signature Class**

## Generating a Signature

Smile ID requires you to send a unique signature and timestamp with every job you run. Although running jobs using any of our libraries will automatically calculate the signature, there might be instances you want to run a job using our REST API or generate signatures. In such instances you can use the sample code below to calculate a signature:

```javascript
const smileIdentityCore = require("smile-identity-core");
const Signature = smileIdentityCore.Signature;

// Initialize
partner_id = "<Put your partner ID here>"; // login to the Smile ID portal to view your partner id
api_key = "<Put your base64 encoded API key here>"; // copy your API key from the Smile ID portal

connection = new Signature(partner_id, api_key);

// Generate the Signature
generated_signature = connection.generate_signature(
  "<put your custom timestamp>",
); // where timestamp is optional
```

### Response

The response will be a hash:

```json
{
  "signature": "<the generated signature>",
  "timestamp": "2023-12-17T01:41:13.845Z"
}
```

## Confirming an Incoming Signature

To ensure the response you receive from your callback is actually from Smile ID, you can confirm the returned signature and timestamp. You can use the sample code below to confirm the signature:

```javascript
const smileIdentityCore = require("smile-identity-core");
const Signature = smileIdentityCore.Signature;

// Initialize
partner_id = "<Put your partner ID here>"; // login to the Smile ID portal to view your partner id
api_key = "<Put your API key here>"; // copy your API key from the Smile ID portal

connection = new Signature(partner_id, api_key);

// Confirm a signature
signature = connection.confirm_signature(
  "<put the received timestamp>",
  "<put the received signature>",
);
```

### Response

The response will be a boolean

```
true or false
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://legacy-docs.usesmileid.com/integration-options/server-to-server/javascript/generate-signature.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
