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

# Idempotency-Key and File Checksums

> Generate operation IDs and SHA-256 file checksums without confusing them with your API key.

## Three values, three different jobs

| Value | What it does | Where it comes from |
| - | - | - |
| Platform API key | Allows access to your workspace | Create it in Layarva Settings |
| Idempotency-Key | Identifies one change, so a retry does not duplicate it | Generate a UUID yourself |
| checksumSha256 | Confirms that the uploaded file matches your original | Calculate SHA-256 from the file |

**Idempotency-Key is not an API key.** It grants no access. A checksum is not an API key either.

## Generate an Idempotency-Key

Use a fresh UUID for each new change. Save it with that change and reuse it if you retry the exact same request.

> [tab] Postman
>
> In your request's **Scripts → Pre-request** tab:
>
> ```javascript theme={null}
> if (!pm.collectionVariables.get("operation_key")) {
>   pm.collectionVariables.set(
>     "operation_key",
>     pm.variables.replaceIn("{{$guid}}")
>   );
> }
> ```
>
> Add the header:
>
> ```http theme={null}
> Idempotency-Key: {{operation_key}}
> ```
>
> Before starting a **different operation**, clear the collection variable `operation_key` or replace it with a new UUID. Do not clear it when retrying the same operation.
>
> Do not put `{{$guid}}` directly in the header for retries: it generates a new value on each send.

> [tab] PowerShell
>
> ```powershell theme={null}
> [guid]::NewGuid().ToString()
> ```
>
> Copy the result into the `Idempotency-Key` header.

> [tab] Node.js
>
> ```javascript theme={null}
> import { randomUUID } from "node:crypto";
> const operationKey = randomUUID();
> // Save this value. Reuse it when retrying this operation.
> ```

For example, creating a folder and creating a Playlist are two operations, so use two different keys. GET requests do not need this header. Changing the body while reusing a key produces a conflict; use a new key for the new change.

## Generate checksumSha256

Calculate it from the **exact file you will upload**. The result is 64 lowercase hexadecimal characters. If you edit the file, calculate it again.

> [tab] Windows PowerShell
>
> ```powershell theme={null}
> (Get-FileHash -Algorithm SHA256 -LiteralPath "C:\Media\poster.png").Hash.ToLowerInvariant()
> ```
>
> Copy the result into `checksumSha256`.

> [tab] macOS / Linux
>
> ```sh theme={null}
> # macOS
> shasum -a 256 poster.png
>
> # Linux
> sha256sum poster.png
> ```
>
> Copy only the 64-character hash, not the filename.

> [tab] Node.js
>
> ```javascript theme={null}
> import { readFile } from "node:fs/promises";
> import { createHash } from "node:crypto";
> const bytes = await readFile("./poster.png");
> const checksumSha256 = createHash("sha256").update(bytes).digest("hex");
> ```

Use the [Library upload guide](https://docs.layarva.com/developers/platform-library.md) for the complete upload steps. Postman sends your chosen file as **Body → binary**; do not send JSON or form-data to the returned upload URL.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.