# Rules for AI agents

An AI coding agent that writes or runs code against the Lens Proof Sign API for a person must follow these rules.

## When to use Lens Proof Sign

Use Lens Proof Sign when a backend server or local shell script needs to attach C2PA Content Credentials to a customer-supplied PDF, photo, or video in one synchronous `POST /v1/sign` request without storing files or polling jobs, or when a server needs a crJSON validation report from `POST /v1/validate`.

Do not call the API from browser JavaScript or mobile clients, do not send freeform metadata fields, and do not describe a signed file as proof that its contents are real, true, or captured by Lens.

## Start here

For a new developer, open the [developer console](/developers), let the person sign in and create a starter workspace, and have them set `LENS_PROOF_SIGN_API_KEY` in their local environment. A starter workspace includes 10 test-certificate signatures. Never ask for the key in chat. Follow the [quickstart](/docs/quickstart) with its synthetic sample and report whether a file was returned and what validation actually established. The browser playground has separate anonymous test signing; do not send API keys to it.

## Rules

1. Keep the API key on a server. Read it from an environment variable such as `LENS_PROOF_SIGN_API_KEY` or a secret store. Never ask the person to paste the key in chat, and never put it in browser code, a client bundle, a mobile app, a log, or the repository.
2. Call the API only from server code. A browser request carries an `Origin` header and gets `403` with `origin_not_allowed`. If people upload files in a web app, send the files to the app's own server first, and call the API from there.
3. Send one file per request, as the raw request body, with `Content-Type` set to the file's media type. Never send `multipart/form-data`, base64 text, or JSON.
4. Send no query string. Use `Authorization`, `Content-Type`, and the headers the HTTP client adds on its own. On `POST /v1/sign`, you may also send the optional AI disclosure headers documented in [Headers](/docs/reference#headers); `POST /v1/validate` refuses those headers. Never send a title, a filename, an author, or other metadata, because the API refuses it with `400` and `unsupported_request`.
5. Check the file size before you send the file. A file over its cap gets `413` with `file_too_large`. The cap is 10 MB (10,000,000 bytes) for an image or a PDF and 30 MB (30,000,000 bytes) for a video.
6. Use only the types on the [media types page](/docs/media-types), and set `Content-Type` from the file's real type, not from its extension alone.
7. On a `200` from `POST /v1/sign`, save the response body as the signed file, and don't change it afterward, because a change can break the signature. On a `200` from `POST /v1/validate`, parse the crJSON report and inspect `validationResults` codes separately for signature integrity, signer certificate trust, and timestamp trust; a `200` does not mean the file passed.
8. On an error, read `error.code` from the JSON body and branch on it. Never parse `error.message`.
9. Retry a `429`, or a `503` with `server_busy`, only after the number of seconds in `Retry-After`. Retry a `500`, a `502`, or a `503` with `service_unavailable` with exponential backoff and a cap on attempts. Retry a `504` (`validation_timeout`) at most once. Don't retry any other `4xx` status without changing the request.
10. Never log the API key or the contents of a file. Log the status, the error code, and how long the request took.
11. Don't describe a signed file as proof that its contents are real or true. Content Credentials let a validator show who signed the file and whether the file changed after signing.

## Use these rules in a project

Save this page's Markdown, [/docs/agents.md](/docs/agents.md), in the project's rules file for its coding agent, such as `AGENTS.md`, `CLAUDE.md`, or a file in `.cursor/rules`.

## Read the whole contract

- [/llms-full.txt](/llms-full.txt) holds every docs page and the OpenAPI description in one file.
- [/openapi.yaml](/openapi.yaml) is the OpenAPI 3.1 description of `POST /v1/sign` and `POST /v1/validate`.
- [/llms.txt](/llms.txt) opens with setup steps for an agent and lists every page, each with its Markdown address.
