Guide

API keys and scopes

The console signs you in with your email. Everything else, your product, your pipelines and your agents, authenticates with a key that carries exactly the permissions it needs.

Every endpoint except /health requires a bearer token:

curl https://api.hayfork.dev/me -H "Authorization: Bearer $HAYFORK_KEY"

GET /me tells you which workspace the key belongs to, its scopes, your plan and this month's usage. It is the quickest way to check a key works.

Scopes

Higher scopes include the lower ones.

ScopeAllowsGive it to
searchPOST /search and POST /retrieve; list and read collections, sources, documents and chunks.Website search boxes, in-app search, agents, MCP servers. Read-only, so safe in customer-facing code.
ingestEverything in search, plus create and delete collections and sources, upload files, start crawls, reindex.Backend services, CI pipelines, sync jobs.
adminEverything in ingest, plus list, create and revoke API keys.Workspace owners, provisioning scripts.

Creating a key

In the console, open Settings, name the key, tick its scopes and optionally set an expiry, then create it. The plaintext is shown once. Copy it into your secret store now; the server keeps only a SHA-256 hash and cannot show it again.

From the API, with an admin key:

curl https://api.hayfork.dev/api-keys \
  -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
  -d '{"name": "Docs search widget", "scopes": ["search"], "expires_in_days": 90}'

The response includes the key in a key field, once. GET /api-keys lists keys by id, name, scopes and expiry, and DELETE /api-keys/KEY_ID revokes one immediately.

Rules

What errors mean

StatusMeaning
401No key, or a revoked or expired one.
403Valid key without the required scope. The message names the scope. Also returned for ingest calls before your email is verified.
404The resource does not exist in your workspace. Resources in other workspaces look identical, so ids cannot be probed.
429A plan limit: sources, documents or searches this month. The message says which and how much room is left.
Keys in the browser. A search key can be shipped in a website widget: it cannot change anything and cannot see other workspaces. Its searches still count towards your monthly quota, so give it its own key and an expiry, and rotate it if you see traffic you do not recognise.