---
title: "ResourceShark source keys"
description: "Learn how source keys identify a business change and how idempotency keys identify request attempts."
url: "https://agentpost.tools/docs/resourceshark/concepts/source-keys"
kind: concept
---

# Source keys

A `sourceKey` identifies a change your app asks ResourceShark to make, such as adding a delivery or committing the hold for an order. It lets ResourceShark recognize that change if your app sends it again with a different `Idempotency-Key`.

## Repeating a change

ResourceShark keeps the source key with the work it records. Repeating the same request under that source key answers with `duplicate: true` without applying the change again. A repeated hold placement gives the original hold as it stands now. A different request that collides with the same source key answers [`duplicate_source`](/docs/resourceshark/errors.md#duplicate_source). The refusal includes details about an earlier record only when the caller can read that record.

Each operation defines where a source key is unique. A supply entry’s key is unique on its resource. A hold’s placement key is unique in the project. A commit’s key is unique on each resource it takes from and shares that space with consume keys. These keys stay recorded after the request replay window ends, including after [hold retention](/docs/resourceshark/concepts/holds.md#retention) removes the hold’s details.

## Idempotency keys

An `Idempotency-Key` identifies one HTTP request, where a source key identifies the change it asks for. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule for the header. [ResourceShark’s own rules](/docs/resourceshark/reference.md#retrying-a-write) add that a retry repeats an error too, such as a shortage.

For example, a server retries an unanswered hold placement with both keys unchanged. After a shortage, it uses a new `Idempotency-Key` for the next attempt. It keeps the same `sourceKey` if the hold still represents the same change and the error left no hold behind.

## Limits

A `sourceKey` is 1 to 200 characters after trimming. An `Idempotency-Key` is 1 to 255 characters after trimming.

## Where to act on it

-   The [ResourceShark quickstart](/docs/resourceshark/quickstart.md) uses both keys when it adds stock, places a hold, and commits it.
-   [Sell prepaid credits](/docs/resourceshark/guides/prepaid-credits.md) repeats a delivery with the same source key and a different `Idempotency-Key`.
-   The [ResourceShark API reference](/docs/resourceshark/reference.md) lists the key requirements by operation.
