> ## Documentation Index
> Fetch the complete documentation index at: https://docs.requestly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Hawk

> Sign requests with a Hawk message authentication code.

Hawk signs each request with a message authentication code computed from a shared key. The key itself never leaves your machine, and the signature covers the method, the URI, the host, the port, and optionally the request body, so a replayed or tampered request fails verification.

Requestly builds the `Authorization: Hawk` header on every send. You supply the ID and the key; the nonce and the timestamp can be left to Requestly.

Hawk is offered for HTTP, GraphQL, WebSocket and Socket.IO requests. It is not offered for gRPC.

<Frame>
  <img src="https://mintcdn.com/requestly/eVaYS_FXw1j-9uVi/images/authorization/hawk-form.light.png?fit=max&auto=format&n=eVaYS_FXw1j-9uVi&q=85&s=2cf184ab38901759203343f66a48cb9e" alt="Hawk form in the Authorization tab showing auth ID, auth key, algorithm, user, nonce, timestamp, ext, app, dlg, and the include payload hash toggle." className="dark:hidden" width="1280" height="900" data-path="images/authorization/hawk-form.light.png" />

  <img src="https://mintcdn.com/requestly/eVaYS_FXw1j-9uVi/images/authorization/hawk-form.dark.png?fit=max&auto=format&n=eVaYS_FXw1j-9uVi&q=85&s=47e068db4521e796003a5339283950ce" alt="Hawk form in the Authorization tab showing auth ID, auth key, algorithm, user, nonce, timestamp, ext, app, dlg, and the include payload hash toggle." className="hidden dark:block" width="1280" height="900" data-path="images/authorization/hawk-form.dark.png" />
</Frame>

## Set up Hawk

<Steps>
  <Step title="Open the Authorization tab">
    Open any request or collection, then go to the **Authorization** tab.
  </Step>

  <Step title="Select Hawk">
    Pick **Hawk** from the **Authorization Type** dropdown. The Hawk fields appear below the dropdown.
  </Step>

  <Step title="Enter the ID and key your API issued">
    Fill in **Hawk Auth ID** and **Hawk Auth Key**. These are the credential pair the API gave you; everything else is optional.
  </Step>

  <Step title="Match the algorithm">
    Leave **Algorithm** on `SHA-256` unless the API specifies `SHA-1`. The two sides must agree or verification fails.
  </Step>

  <Step title="Send the request">
    Click **Send**. Requestly computes the MAC and attaches the `Authorization: Hawk` header.
  </Step>
</Steps>

## Field reference

### Required

| Field             | Purpose                                                                           |
| ----------------- | --------------------------------------------------------------------------------- |
| **Hawk Auth ID**  | The public identifier for your credential pair. Travels on the wire as `id`.      |
| **Hawk Auth Key** | The shared secret used to compute the MAC. Never sent; only the resulting MAC is. |
| **Algorithm**     | `SHA-256` (default) or `SHA-1`. Must match what the server expects.               |

Both credential fields accept Requestly [variables](../../environments-and-variables) and [vault](../../vault/vault) references. Store the key as a vault secret and reference it as `{{vault:hawk_key}}`.

### Optional

| Field         | Purpose                                                                                          |
| ------------- | ------------------------------------------------------------------------------------------------ |
| **User**      | A local label for your own reference. Requestly does not send it, and it is not part of the MAC. |
| **Nonce**     | A unique value per request. Leave blank and Requestly generates a random one on every send.      |
| **Timestamp** | Unix time in seconds. Leave blank and Requestly uses the current time on every send.             |
| **ext**       | Free-form application data. It is bound into the MAC and echoed in the header as `ext`.          |
| **app**       | Application ID, from the Oz extension to Hawk.                                                   |
| **dlg**       | Delegated-by application ID, also from Oz. It is only sent when **app** is also set.             |

<Tip>
  Leave **Nonce** and **Timestamp** blank. A fresh nonce and a current timestamp are what stop a captured request from being replayed, and Requestly produces both for you.
</Tip>

### Include payload hash

When this is on, Requestly hashes the request body and binds the result into the MAC, so the signature covers the body as well as the request line. Turn it on when the API validates payload integrity, and leave it off otherwise. A server that does not expect a payload hash will reject the request when one is present.

## Inherit Hawk from a collection

Set Hawk once on the collection and leave every request inside it on **Inherit from parent**. Requestly walks up from the request to the nearest ancestor that sets a concrete auth type and signs with that credential pair. The nonce and timestamp are still generated per request, so inheriting one configuration does not reuse one signature.

A request that picks its own auth type stops inheriting, and a collection or folder whose auth type is cleared or left unset stops the walk for everything below it.

## Troubleshooting

<AccordionGroup>
  <Accordion title="The server rejects the MAC">
    Check the algorithm first: a `SHA-256` signature against a `SHA-1` verifier always fails. Then check that the key was pasted without a trailing newline, and that your machine clock is accurate, since most Hawk servers reject timestamps more than a minute or two out.
  </Accordion>

  <Accordion title="Requests work without a body and fail with one">
    Turn **Include payload hash** off, or turn it on, depending on which side you changed. Both ends must agree on whether the body is part of the signature.
  </Accordion>

  <Accordion title="The dlg value never reaches the server">
    `dlg` only travels when `app` is also set. Fill in **app** as well.
  </Accordion>
</AccordionGroup>

## What's Next?

<CardGroup cols={3}>
  <Card title="AWS Signature v4" icon="cloud" href="/api-client/send-api-request/authorization/aws-signature-v4">
    The other per-request signing scheme in the dropdown.
  </Card>

  <Card title="Vault" icon="lock" href="/api-client/vault/vault">
    Keep the Hawk key out of the collection.
  </Card>

  <Card title="Authorization" icon="key" href="/api-client/send-api-request/authorization">
    Back to every auth type Requestly supports.
  </Card>
</CardGroup>
