# Security and data handling

How keys, sessions and upstream credentials are protected, what is stored for each call and for how long, how upstream calls are isolated, and how to report a vulnerability.

This page is the developer's view of our controls: what happens to your key, your inputs and your results. The [Security](https://primaryapi.com/security) page covers the same ground for a general audience, including what we do not have yet.

## Credentials

| Item | How it is protected |
|---|---|
| API keys | Shown once. We store a SHA-256 hash, never the key. Logs and the dashboard show only the first 12 characters. |
| Dashboard passwords | Hashed with argon2id. Sign-in and password-reset responses are identical whether or not an account exists. |
| Browser sessions | A random token in an HTTP-only, `SameSite=Lax` cookie; only its hash is stored; it expires after 30 days without use. Cookie-authenticated requests that change anything must come from our own web origin. |
| Upstream credentials | Read from the server environment by name, used only to call that upstream, and never written to logs, errors or responses. An upstream without working credentials is simply not used. |

Your side of the bargain: keep keys on servers, one key per service or agent with a spend limit, `view` keys for read-only tools, and rotate a key the moment it may have leaked. See [Authentication](/docs/authentication#good-practice).

## What we store for each call

| Data | Kept | Why |
|---|---|---|
| Request metadata: SKU, status, cost, latency, key, timestamps | With your request history | Usage, billing, support |
| Your input (non-restricted APIs, up to 16 KB) | With your request history | Support and debugging. Never used to re-run a call. |
| Your input (restricted APIs) | Never. Only a one-way fingerprint, for idempotency. | Minimisation |
| The full result envelope | By plan, fixed when the call is made: 24 hours on Pay as you go, 7 days on Builder, 30 on Pro, 90 on Scale and Enterprise; then deleted. | Free re-reads with `GET /v1/results/{id}` and idempotent replays |
| A webhook event's body | By plan, fixed when the event is made: until delivered on Pay as you go, then 7, 30 or 90 days like results. | Retries and redelivery |
| Webhook delivery attempt logs: time, duration, status or error, the first 1,024 bytes of your endpoint's response | With the delivery: 30 days, or as long as the event's body when that is longer | Showing you why a delivery failed |
| Each upstream attempt: outcome and latency | Aggregated into health statistics | Routing decisions, support, and the public reliability figures |
| Payment card data | Never: payments run on Stripe Checkout | |

Requests are scoped to the account that made them: another account's request id answers `404`, exactly like one that does not exist. Ids in URLs are never trusted on their own; every query is filtered by the authenticated account.

To delete your request history, or to act on a deletion request from a person whose data you obtained through us, write to support@primaryapi.com.

## Calls to upstreams

- **Fail closed.** Inputs are validated against a strict schema before any upstream call; unknown fields are rejected. Request bodies are capped at 2 MB.
- **Cost caps.** Every upstream call carries its own hard limits (maximum items, maximum charge), so a misbehaving upstream cannot run up an unbounded bill. The credits held for a call cap what it can be charged.
- **URLs you supply** (for example a page to scrape) are fetched through a guarded client that refuses private, loopback, link-local and cloud-metadata addresses, re-checks every redirect, and limits size and time.
- **Sanitised errors.** When upstreams fail, error bodies carry only a stable code and a short message, never upstream names, URLs, bodies or credentials.
- **At most once.** A paid upstream job is submitted once. If a request is interrupted on our side, it is expired and its credits come back instead of it being re-run.

## Transport and browsers

The website and API are served over HTTPS; always call `https://api.primaryapi.com` with `https://`. API responses do not send credentialed CORS headers, so a web page on another origin cannot use a visitor's dashboard session to call the API. Do not call the API from browser code with your key; put a small server endpoint in between.

## Agents

- Trial keys from `POST /agent/signup` have a small budget, `run` access and a 7-day expiry, and can never call restricted APIs.
- The MCP server never asks a model for its key and never returns one. Keys belong in the MCP client's configuration, not in prompts.
- A human approves any spend beyond a trial budget, and chooses the key's spend limit when doing so.

## Reporting a vulnerability

Email support@primaryapi.com with "Security report" in the subject, including what the issue is, steps to reproduce, and request ids if you have them. Please test only with your own account and keys, never access or spend another customer's data or money, and give us time to fix the issue before disclosing it. We do not run a paid bug bounty.
