Talk with Archie
Managing keys

Create, Change, Rotate and Revoke Keys

You manage API keys from the Python SDK, the archie CLI or the REST API at /api/v1/connect-keys. All of them use the same backend, with the same checks, the same audit log and the same cache clearing.

Pick whichever suits how you work.

What a key carries

Fixed When You Create It

A key is an sk_ bearer value plus a few fields. The value and permissions are held by WorkOS, our secret store. The other fields live in Archie's own record of the key and can be changed without rotating it.

name
string

A readable label. Renaming changes Archie's copy only; WorkOS keeps the original.

permissions
list, fixed

Cannot be edited. Create a replacement key; rotating copies the list unchanged.

Editable any time

Fields You Can Change

These three can be changed whenever you like, and the change applies to the same key.

workspace_id
uuid or null

Pins the key to one workspace in a multi-workspace org. null means the earliest one.

rate_limit_per_minute
integer or null

Beats the org override and the default. 0 blocks every request; null clears it.

description
string

A free-text note shown with the key.

From the SDK

Create a Key in Code

The new key's rate limit is in force from its very first request. Show key.value to the person who needs it straight away, then discard it: it cannot be fetched again.

python
from heyarchie import Archie

client = Archie(api_key="sk_...", base_url="https://uk.heyarchie.com")

key = client.keys.create(
    name="ci-deploys",
    permissions=["ask:execute", "search:read"],
    workspace_id="b0000000-0000-0000-0000-000000000001",  # optional
    rate_limit_per_minute=30,                              # optional
    description="staging deploy bot",                      # optional
)

# Show key.value to the operator now. WorkOS will not return it again.
print(key.value)
Permission names

Permissions must come from the current eleven scopes listed on the Authentication page. A retired or unknown name, such as messages:create, fails with 400 unknown_permissions and the response lists the valid names. Keys made with old names still sign in, but an old name matches no skill, so create a replacement with current scopes and revoke the old key.

Editing

Change a Key's Fields

Change the workspace pin, rate limit and description with client.keys.update or PATCH /api/v1/connect-keys/{key_id}. Permissions cannot be edited: a PATCH to permissions returns 501, because WorkOS has no way to change them. Create a replacement key with the scopes you want and revoke the old one.

python
# Pin to a workspace
client.keys.update(key.id, workspace_id="b0000000-...")

# Set a per-key rate limit (None to clear, 0 to block)
client.keys.update(key.id, rate_limit_per_minute=30)

# Change several fields in one call
client.keys.update(
    key.id,
    description="staging deploy bot, updated",
    rate_limit_per_minute=60,
)
Rotating

Rotate a Key

Rotating creates a replacement that copies the old key's name, permissions, workspace, rate limit and description. The old key keeps working for a grace period, 24 hours by default, and is then revoked automatically. The new value is returned once.

python
# Default: the old key stops after 24 hours
new_key = client.keys.rotate(key.id)

# Or a shorter grace period
new_key = client.keys.rotate(key.id, grace_period_hours=1)

print(new_key.value)                # the new sk_ value, shown once
print(new_key.rotated_from_key_id)  # the old key's id
Revoking

Revoke a Key

Revoking takes effect at once. Archie deletes the key at WorkOS, marks it revoked and clears every cache that held it, so the very next call with it gets 401.

python
client.keys.revoke(key.id)
# Any later call with this key gets 401 auth_required.
Listing

List and Inspect Keys

Listing returns every key with its preview value, never the full secret. Fetching one key returns all its fields together.

python
page = client.keys.list()
for k in page.data:
    print(k.id, k.obfuscated_value, k.workspace_id, k.rate_limit_per_minute)

# One key, all fields:
key = client.keys.get("api_key_01KRVGB...")
print(key.description, key.revoked_at)