Safeguard Docs
Safeguard AI SDKs

Create an API key

Create a Safeguard AI key with the ai:chat scope in the web app, keep it safe, and revoke it.

Create an API key

The SDKs authenticate with a secret key. A Safeguard AI key starts with sg_sk_ and carries the ai:chat scope, which is the only scope the SDKs need.

Secret keys are available where your workspace has the API keys feature enabled. If you do not see the Developer tab in Settings, or the Safeguard AI key type is missing, contact us to enable it: hi@safeguard.sh.

Steps

  1. Sign in to the Safeguard web app and open Settings.
  2. Open the Developer tab. The page is titled Guard SDK secret keys and lists your keys.
  3. Choose to create a key and pick the type Safeguard AI key. Its scope is ai:chat.
  4. Give it a name that says where it will run, for example ci-triage-script, and create it.
  5. Copy the key now. It is shown once, when it is created. Store it in your secret manager.
  6. In the environment where your code runs, set it as SAFEGUARD_API_KEY:
export SAFEGUARD_API_KEY=sg_sk_...

What the key decides

  • Who you are. The key belongs to the member who created it. Every request runs as that member, in that member's tenant and organization, with that member's access to products and conversations. The SDKs have no tenant or organization option because the key already fixes them.
  • What it can do. Only conversations and queries (ai:chat). The key cannot call other Safeguard APIs.
  • Which conversations you see. The conversations of the key's owner. Conversations that belong to someone else, or that are shared read-only, answer NOT_FOUND.

Keep it safe

  • Keep keys out of source control, images and logs. Read them from the environment or a secret store.
  • Use one key per script or pipeline, so you can revoke one without touching the others.
  • Revoke a key in Settings, Developer. A revoked key, or a key whose owner is removed or deactivated, is refused with 401 INVALID_SECRET_KEY. Safeguard checks keys through short-lived sessions, so the change takes effect within a few minutes.

Next: Install.

On this page