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

# Authentication and access

> API keys, permissions and scopes, keyless OIDC access, per-user document permissions, secrets and BYOK, audit logs, and the domains to allowlist.

Every request to Mixpeek carries an API key in `Authorization: Bearer`, and every request on namespace data carries the namespace id in `X-Namespace`. Keys belong to your organization and are owned by a user. A key's **permissions** decide what it may do, its **scopes** decide which resources it may touch, and a key with a `principal_id` acts for one end-user of your app, so each user sees only their own documents. Namespaces isolate data: every query filters on the namespace, and each namespace has its own vector store namespace.

## Check a key

`GET /v1/me` works for any valid key and tells you which organization it belongs to and what it can do. Run it as the first step of every CI job so a key pointed at the wrong organization fails loudly instead of writing data somewhere you did not intend.

```bash cURL theme={null}
curl "https://api.mixpeek.com/v1/me" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY"
```

```python Python theme={null}
import os
import requests

resp = requests.get(
    "https://api.mixpeek.com/v1/me",
    headers={"Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}"},
)
me = resp.json()
print(me["organization_id"], me["key"]["permissions"], me["principal_scoped"])
```

```javascript JavaScript theme={null}
const resp = await fetch("https://api.mixpeek.com/v1/me", {
  headers: { Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}` },
});
const me = await resp.json();
console.log(me.organization_id, me.key.permissions, me.principal_scoped);
```

```json Response theme={null}
{
  "organization_id": "org_a1b2c3d4e5f6",
  "organization_name": "Acme",
  "account_type": "BUILD",
  "user_email": "you@example.com",
  "key": { "name": "ci-ingest", "key_type": "SECRET", "permissions": ["READ", "WRITE"], "expires_at": null },
  "rate_limits": {},
  "principal_scoped": false
}
```

`rate_limits` holds the key's effective per-minute limits by category; `principal_scoped` is `true` for an end-user key.

## Create an API key

Managing keys needs a key with `admin`. Your organization ships with a protected `admin-key`, which cannot be updated, rotated or deleted because Studio depends on it; use it to mint scoped keys. `POST /v1/organizations/users/{user_email}/api-keys` creates a key owned by that user.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/organizations/users/$USER_EMAIL/api-keys" \
  -H "Authorization: Bearer $MIXPEEK_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "acme-readonly",
    "permissions": ["read"],
    "scopes": [
      { "resource_type": "namespace", "resource_id": "'"$NAMESPACE_ID"'", "operations": ["read_data", "execute_retriever"] }
    ]
  }'
```

The response returns the plaintext `key` (`mxp_sk_`, 60 characters) **once**. It is stored as a SHA-256 hash and can never be read back; store it immediately. The response also has `key_id` (used for usage lookups), `key_prefix` (the first 10 characters, safe to display) and `name` (used in update, rotate and revoke calls).

| Field | Effect | Default |
| - | - | - |
| `name` | Label, 1 to 100 characters, unique among your active keys | Required |
| `permissions` | `read`, `write`, `delete`, `admin` | `read`, `write`, `delete` |
| `scopes` | Resources the key may touch | `[]`, which is **org-wide** |
| `rate_limit_override` | A per-minute cap for this key, below the organization limit all keys share ([Limits and billing](https://docs.mixpeek.com/docs/production/limits-and-billing.md)) | None |
| `expires_at` | ISO 8601 cutoff; the key becomes `expired` and cannot be reactivated | No expiry |
| `allowed_origins` | Browser origins allowed to use the key | Any |
| `principal_id` | Makes the key an end-user key (`usr_sk_`) | None |
| `description` | Up to 500 characters | None |

### Permissions

Each level implies the ones below it: `admin` includes `delete`, which includes `write`, which includes `read`. A route declares the minimum level it needs.

| Permission | Use it for |
| - | - |
| `read` | Dashboards, analytics, search-only clients |
| `write` | Ingestion and service accounts that create documents |
| `delete` | Full data management |
| `admin` | Managing keys, users and the organization |

### Scopes

A scope is `{ resource_type, resource_id, operations }`. `resource_id` is a literal id, `*`, or a prefix pattern such as `ns_customer_*`. `operations` narrows what the key may do inside the scope; omit it to allow everything the key's permissions grant.

> [!WARNING]
>
> An empty `scopes` list grants **org-wide** access. To confine a key you must give at least one scope, and setting `scopes` to `[]` on an update widens the key back to the whole organization.

A key with `collection` scopes runs a retriever only on collections it may read; naming another returns `403` with `error_code: "insufficient_scope"`. Inside the run, stages that look up other documents (`document_enrich`, `traverse_edge`, `cross_compare`, taxonomy lookups, agentic example lookups) also read only those collections, and a lineage walk that leaves them drops the hit as `ancestor_unreadable`. Such a key neither reads nor writes the retriever result cache.

> [accordion] resource\_type and operations values
>
> `resource_type`: `organization`, `user`, `api_key`, `namespace`, `collection`, `bucket`, `retriever`, `cluster`, `taxonomy`, `storage_connection`, `alert`, `annotation`, `secret`, `webhook`.
>
> `operations`: `read_data`, `write_data`, `delete_data`, `execute_retriever`, `create_retriever`, `delete_retriever`, `execute_job`, `cancel_job`, `create_cluster`, `delete_cluster`, `modify_cluster`, `modify_infrastructure`, `manage_permissions`.
>
> Common sets: read-only `["read_data", "execute_retriever"]`; data engineer `["read_data", "write_data", "execute_job"]`.

### Browser keys and CORS

`allowed_origins` takes exact origins (`https://app.yourcompany.com`) or wildcard subdomains (`https://*.yourcompany.com`). A browser request whose `Origin` does not match returns `403`; requests with no `Origin` header (server code and SDKs) are unaffected. An empty list clears the restriction, and the list survives rotation. A stolen key used outside a browser can omit `Origin`, so pair the allowlist with narrow permissions and scopes, and treat any key in a browser as public.

### Key types

| Type | Prefix | Purpose |
| - | - | - |
| Standard | `mxp_sk_` | Organization key for your backend; bypasses document ACL |
| End-user | `usr_sk_` | Carries a `principal_id`; every read is filtered to that user's documents |
| Retriever-scoped | `ret_sk_` | Executes one published retriever and nothing else. Create with `POST /v1/retrievers/{retriever_id}/api-keys`; only the retriever's owner can. Accepts `expires_at` and `allowed_origins` |
| Marketplace | `sk_marketplace_` | Access to a subscribed marketplace retriever |
| Session | None | Minted by Studio on login; hidden from key lists |

### Rotate, expire and revoke

* **Rotate:** `POST /v1/organizations/users/{user_email}/api-keys/{key_name}/rotate` returns a new plaintext `key` and revokes the old secret at once. `key_id` and settings carry over.
* **Revoke:** `DELETE /v1/organizations/users/{user_email}/api-keys/{key_name}` sets `status` to `revoked`, keeps the record for audit, and cannot be undone. It is refused when a live published app embeds the key or the key authenticated in the last 7 days; `?force=true` overrides.

> [!WARNING]
>
> Before forcing a revoke, search every Kubernetes Secret, CI secret and deployment config that could hold the key, comparing SHA-256 digests so the key never prints. The refusal can only name published apps and recent use. A forced revoke past an empty `referencing_apps` once took a public widget offline for 43 minutes, and a scheduled job on the same key failed for 26 hours unnoticed. After rotating, search again for the old key's digest: any holder still on it is failing now. For a CronJob, read `lastSuccessfulTime`, not the pod list.

`status` is `active`, `revoked` or `expired`; `last_used_at` finds stale keys. List a user's keys with `GET /v1/organizations/users/{user_email}/api-keys` (`?include_revoked=true` adds revoked ones). Per-key traffic and spend for the last 7 days (or `start` and `end`) come from `GET /v1/organizations/api-keys/{key_id}/usage`, and a per-endpoint breakdown from `.../usage/endpoints`. Studio's **Settings > API Keys** does all of this without the API.

## Call Mixpeek from CI without a stored key

A workload on Vercel, GitHub Actions or another OIDC platform can trade its platform's short-lived token for a Mixpeek key that expires in minutes, so no long-lived key sits in its environment.

**1. Add a workload identity provider**

An admin sends the full provider list with `PATCH /v1/organizations`. Keep each existing `provider_id` to preserve it; omit it to add one; leave a provider out to remove it.

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/organizations" \
  -H "Authorization: Bearer $MIXPEEK_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workload_identity_providers": [{
      "name": "github-deploys",
      "issuer": "https://token.actions.githubusercontent.com",
      "audience": ["https://api.mixpeek.com"],
      "claim_conditions": { "repository": ["acme/api"], "ref": ["refs/heads/main"] },
      "permissions": ["read", "write"]
    }]
  }'
```

**2. Exchange the platform token**

```yaml GitHub Actions step theme={null}
permissions:
  id-token: write
  contents: read

steps:
  - name: Get a Mixpeek key
    run: |
      TOKEN=$(curl -sSf -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
        "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://api.mixpeek.com" | jq -r .value)
      KEY=$(curl -sSf -X POST https://api.mixpeek.com/v1/auth/token-exchange \
        -H "Content-Type: application/json" \
        -d "{\"provider_id\":\"$MIXPEEK_PROVIDER_ID\",\"subject_token\":\"$TOKEN\"}" \
        | jq -r .access_token)
      echo "::add-mask::$KEY"
      echo "MIXPEEK_API_KEY=$KEY" >> "$GITHUB_ENV"
```

On Vercel, get the token with `getVercelOidcToken()` from `@vercel/oidc` and POST the same body. The response has `access_token`, `expires_in`, `expires_at`, `key_id` and `permissions`.

| Provider field | Effect |
| - | - |
| `issuer` | Exact `iss`. Vercel team mode: `https://oidc.vercel.com/<team_slug>`; global mode: `https://oidc.vercel.com`. GitHub: `https://token.actions.githubusercontent.com` |
| `audience` | Accepted `aud` values. Vercel's default is `https://vercel.com/<team_slug>` |
| `claim_conditions` | Claim name to allowed values; every listed claim must match. A value ending in `*` matches by prefix. At least one claim beyond the standard ones is required, and a bare `*` is refused |
| `permissions` | `read`, `write`, `delete`; never `admin` |
| `token_ttl_seconds` | 300 to 3,600, default 900 |
| `jwks_url` | Optional; read from the issuer's discovery document when unset |
| `enabled` | `false` stops exchanges without deleting the provider |

The issued key behaves like any API key, belongs to the admin who added the provider, does not appear in key lists, and stops being issued if that admin is removed. Exchanges are limited to 120 per provider per minute, so reuse a key until shortly before `expires_at`. Errors are `401` (`workload_identity_unknown_provider`, `_invalid_signature`, `_wrong_issuer`, `_wrong_audience`, `_token_expired`) or `403` (`_claim_mismatch` with `details.claim`, `_claim_missing`, `_provider_disabled`).

## Per-user document permissions

Two opt-in, fail-closed ways restrict which documents an end-user sees. Both are enforced in the API at retrieval time, so a client cannot widen its own view, and both apply only to traffic through the Mixpeek API.

| | Built-in document ACL | External authorization (OpenFGA) |
| - | - | - |
| Source of truth | An `_acl` on each document | Your OpenFGA store |
| Grant model | Owner, `read` and `write` lists, `public` flag | Your full model: groups, roles, folder inheritance |
| Use it when | Mixpeek owns who-can-see-what | An external system already does |

### Document ACL

Create an end-user key by setting `principal_id` (your stable user id; avoid emails) on key create. Documents that key creates get `_internal._acl` set to `owner` and `read` and `write` lists holding that principal, with `public: false`. Every read with the key (retriever runs, listings, searches) is filtered to documents whose `read` list contains the principal or that are `public`. Updates and deletes check the `write` list and return `403` otherwise. `mxp_sk_` keys bypass ACL; keep them on your backend.

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/collections/$COLLECTION_ID/documents/$DOCUMENT_ID/acl" \
  -H "Authorization: Bearer $MIXPEEK_USER_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{ "read": ["user_123", "user_456"], "write": ["user_123"], "public": false }'
```

Only the owner or an org key can change a document's ACL. To revoke access, send the list without that principal; to publish, send `{"public": true}`.

> [!WARNING]
>
> Documents created before you used end-user keys have no `_acl` and are invisible to `usr_sk_` keys. Backfill them with an org key through `PATCH /v1/collections/{collection_id}/documents/bulk`, setting `update_data` to `{"_internal._acl": {"owner": "system", "read": [], "write": [], "public": true}}` and optionally `filters`. The call returns `task_id` and `status: "PENDING"` before anything changes; poll `GET /v1/tasks/{task_id}` until it ends.

### External authorization with OpenFGA

Mixpeek asks your OpenFGA what the acting user can see and filters results to match. The acting subject is the end-user key's `principal_id`, as `user:<principal_id>`. Model each Mixpeek document as `document:<document_id>` with a `viewer` relation; `user:*` marks a public document. Opt a namespace in:

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/namespaces/$NAMESPACE_ID" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "infrastructure": {
      "authorization": {
        "enabled": true,
        "provider": "openfga",
        "api_url": "https://openfga.yourcompany.com",
        "store_id": "01J0XEXAMPLESTORE",
        "api_token_secret_ref": "openfga_token",
        "relation": "viewer",
        "mode": "auto"
      }
    }
  }'
```

| Field | Effect | Default |
| - | - | - |
| `enabled` | Master switch | `false` |
| `api_url`, `store_id` | Your OpenFGA API and store | Required |
| `model_id` | Authorization model | The store's latest |
| `api_token_secret_ref` | Name of an [organization secret](#organization-secrets-and-your-own-llm-keys) holding the bearer token; required for an `https://` OpenFGA. Plaintext `api_token` is accepted only for `http://` or `localhost` | None |
| `object_type`, `relation` | How documents and access are modeled | `document`, `viewer` |
| `mode` | `auto`, `pull_list_objects`, `pull_batch_check` or `push` | `auto` |
| `over_fetch_factor` | Candidates fetched per result before the check, so a page stays full | `2` |

| `mode` | Behavior |
| - | - |
| `auto` | `ListObjects` pre-filter when the accessible set is at most `list_objects_max`, otherwise `BatchCheck` post-filter |
| `pull_list_objects` | Always pre-filter by `document_id`; suits up to about 1,000 accessible documents per user |
| `pull_batch_check` | Search, then check candidates and drop unauthorized ones; a short page carries a warning |
| `push` | Syncs grants from your OpenFGA changelog into an indexed field; lowest latency, eventually consistent |

If OpenFGA is unreachable, queries return fewer results, never unauthorized ones. With authorization on, the retriever result cache is bypassed.

## Organization secrets and your own LLM keys

Organization secrets are named, encrypted values (Fernet at rest) such as third-party API keys. The API never returns a value; listing returns names only.

| Call | Does |
| - | - |
| `POST /v1/organizations/secrets` with `secret_name` and `secret_value` | Creates a secret |
| `GET /v1/organizations/secrets` | Lists names and a `count` |
| `PUT /v1/organizations/secrets/{secret_name}` with `secret_value` | Replaces the value; the old value is gone |
| `DELETE /v1/organizations/secrets/{secret_name}` | Deletes it at once; anything still referencing it fails |

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/organizations/secrets" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "secret_name": "openai_api_key", "secret_value": "'"$OPENAI_API_KEY"'" }'
```

**Referencing a secret.** In a [manifest](https://docs.mixpeek.com/docs/manage/manifests.md), write `${{ secrets.NAME }}` in a storage connection's `config`, an alert's `notification_config`, a webhook's `channels` or a bucket sync's `connection`; apply fills in the value. In a retriever, apply keeps it as a reference (`{{secrets.NAME}}`) that the stage resolves on each run, so the key is never stored on the retriever. A reference in any other field is refused, because those fields are readable by any read key. The secret must exist before you apply; the manifest validate call lists missing ones. An export writes credentials back out as `${{ secrets.NAME }}` placeholders.

**Bring your own LLM key (BYOK).** Run LLM calls on your OpenAI, Anthropic or Google account for your own billing, rate limits and compliance. Store the key as a secret, then make it the organization default for that provider:

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/organizations" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "default_llm_credentials": { "openai": "openai_api_key", "anthropic": "anthropic_api_key" } }'
```

Values in `default_llm_credentials` are secret names, not keys. The default applies to every LLM operation: extractors, retriever stages, clustering, taxonomy inference and manifest generation. Studio offers the same through **Use as default LLM key** when you create a secret. To use a different key on one stage, extractor or cluster, set `"api_key": "{{secrets.NAME}}"` in its parameters. Mixpeek resolves credentials in this order: the resource's own `api_key`, then the organization default, then Mixpeek's platform keys (billed to your Mixpeek account). Keys are decrypted per call and never shared between organizations.

## Audit log

Audited writes record who changed what. Read them with `GET /v1/organizations/audit/logs` (filter by `resource_id`), one entry with `GET /v1/organizations/audit/logs/{audit_id}`, or everything as NDJSON from `GET /v1/organizations/audit/logs/export`. API key lifecycle events appear as `api_key_created`, `api_key_rotated`, `api_key_revoked` and `api_key_scope_updated`.

Send `X-Change-Reason` on any audited write to record why; it comes back as `reason` on every audit event the request writes. The value is trimmed, stripped of control characters and capped at 1,000 characters. The header is read for the whole request, so it is not listed on any endpoint in the API reference.

| Resource | `changes` holds |
| - | - |
| Retriever, namespace, cluster, taxonomy, collection PATCH, bucket updates | `{field: {old, new}}` |
| Alert updates, object and document updates, the collection `feature_extractor` repair path | Changed field names only |

A dedicated deployment rolls out separately from the shared API, so before building a compliance report on `reason` or `changes`, make one write with the header against the host you use and read the entry back.

## Network access

If Studio loads a blank page, hangs at sign-in, or shows no thumbnails behind a corporate proxy, the network is blocking requests. Allow outbound HTTPS on port 443, including `wss://`, from the browser to:

| Domain | Purpose |
| - | - |
| `*.mixpeek.com` | API, sign-in and Studio |
| `*.mxp.co` | Mixpeek content delivery |
| `js.stripe.com`, `*.stripe.com` | Billing |
| `*.amazonaws.com` or, strictly, `s3.*.amazonaws.com`, `*.s3.amazonaws.com`, `*.s3.*.amazonaws.com` | Signed S3 media URLs |
| `*.googleapis.com` or, strictly, `storage.googleapis.com` | Signed GCS media URLs |

Allowing only `*.mixpeek.com` lets Studio sign in with blank media. Google Drive sync also needs `drive.googleapis.com` and `www.googleapis.com`; with your own object storage, allow your bucket's host. Optional: `*.posthog.com` (analytics), `*.intercom.io` and `*.intercomcdn.com` (support chat), `*.ingest.us.sentry.io` (error reports), `*.cloudflareinsights.com` (performance). A TLS-inspecting proxy must present a certificate the browser trusts. To confirm a block, check the browser's Network tab for `net::ERR_BLOCKED_BY_CLIENT`, CSP violations or proxy pages on `api.mixpeek.com`, and compare off the corporate network.

## Related

* [Limits and billing](https://docs.mixpeek.com/docs/production/limits-and-billing.md): rate limits and quotas per plan and key
* [Monitoring and troubleshooting](https://docs.mixpeek.com/docs/production/monitoring.md#api-errors): 401 and 403 errors
* [Namespaces](https://docs.mixpeek.com/docs/manage/namespaces.md): the isolation boundary
* [Customer-hosted Mixpeek](https://docs.mixpeek.com/docs/production/customer-hosted.md#permissions): Kubernetes permissions for running in your cloud
* [Create API key](https://docs.mixpeek.com/docs/api-reference/organization-api-keys/create-api-key.md) in the API reference


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