> For the complete documentation index, see [llms.txt](https://docs.irrevocable.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.irrevocable.dev/sdk-reference/add-secure-key.md).

# Add Secure Key

To enhance the security and control over who can execute the assigned `LitAction` granted to your PKP, you have the option to implement a Secure Key. This mechanism is analogous to using an API key, serving as an additional layer of authorization.

**Generating the Secure Key**

This secure key is generated when running `setActions()` where you will receive a 32-byte hash key. This key is generated randomly and returned.

{% hint style="warning" %}
Store this key in a secure location, your LitAction will not run without it.
{% endhint %}

**How It Works**

1. **Hash Generation**: The SHA-256 hash of the Secure Key is computed and permanently associated with the `LitAction`.
2. **Execution**: When you attempt to run the `LitAction`, you must provide the correct Secure Key as a parameter.
3. **Validation**: A function within the `LitAction` will then compare the SHA-256 hash of the provided key against the original hash stored in the`LitAction`.&#x20;
4. **Outcome**:
   * **Success**: If the hashes match, the `LitAction` will execute.
   * **Failure**: If the hashes do not match, the `LitAction` will not execute.

{% code overflow="wrap" fullWidth="true" %}

```typescript
// Pass true after the actions array to create and apply the Secure Key to your LitAction. Retrieve the secureKey value from the returned object array.
const {unsignedTransactionDataObject, litActionCode, secureKey} = await newCircuit.setActions([fetchAction, contractAction], true);

// Pass in the correct secure key to start
await newCircuit.start({publicKey, ipfsCID, authSig, secureKey});
```

{% endcode %}


---

# 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://docs.irrevocable.dev/sdk-reference/add-secure-key.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.
