Authentication
Authenticate ZeroLeaks API requests with a server-side API key, and tell scan access apart from Shield access.
Create an API key in ZeroLeaks dashboard settings. Send it to https://zeroleaks.ai/api/v1 in the Authorization header:
Authorization: Bearer zl_live_...
Content-Type: application/jsonWith @zeroleaks/sdk, set the ZEROLEAKS_API_KEY environment variable on the server and initialize new ZeroLeaks().
Never include an API key in browser bundles, NEXT_PUBLIC_ variables, mobile apps, source control, or logs. Endpoint configuration reads omit target credentials. Those credentials are separate from your ZeroLeaks API key.
Scan access
Scan creation requires an active scan plan and access to the requested workspace. Reads are scoped to the API key owner. Public health, capabilities, OpenAPI, agent instructions, and MCP documentation resources do not require an API key.
Shield access
The Shield API uses https://api.zeroleaks.ai/v1 and has separate access rules: acknowledged free keys can use shield, while paid subscriptions include the other Shield models and accounts without one can use them with pay as you go. A free Shield key does not grant scan access.
Errors
A 401 means the API key is missing, invalid, or revoked. A 403 means access or subscription requirements are unmet. Fix the API key or access before you retry. See Errors.