Skip to main content

Authentication

All Guardian Layer API endpoints require your CustodianAI API key in the X-API-Key request header.

Header format

X-API-Key: cai_your_key_here

Where to find your key

Your API key is generated automatically after you subscribe. Go to API Keys in the dashboard to view it.

Keys follow the format cai_ followed by a 32-character string.

Example

curl -X POST https://api.custodianai.com/api/v1/deidentify/text \
-H "X-API-Key: cai_your_key_here" \
-H "Content-Type: application/json" \
-d '{"text": "Jane Smith", "compliance_mode": "MASKED"}'

Authentication errors

StatusMeaningResolution
401 UnauthorizedKey missing or not recognisedCheck the header name is X-API-Key and the value is correct
403 ForbiddenKey valid but expired or out of creditsRenew your subscription or upgrade your plan

Storing your key safely

Always load your API key from an environment variable. Never hard-code it in source files or commit it to version control.

# .env
CUSTODIAN_API_KEY=cai_your_key_here
import os, requests

headers = {"X-API-Key": os.environ["CUSTODIAN_API_KEY"]}