API keys
Create, list, update and revoke Pictograph API keys, and set each key's role and request limit.
On this page
The app manages the same keys in
Settings → API Keys. Changes need an
admin key. These routes live under /api/v1/api-keys/, not /developer/.
list
Your keys, without their secrets.
Source: ApiKeys.list
| Arg | Type | Default | Notes |
|---|---|---|---|
organization |
str | None |
None |
Organization whose keys to list (default: the key’s own) |
for key in client.api_keys.list():
print(key.name, key.role, key.key_prefix, key.last_used_at)
pictograph api-keys list
curl -s "https://api.pictograph.io/api/v1/api-keys/" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns list[ApiKey]
ApiKey · 10 fields
class ApiKey(BaseModel):
"""API key metadata returned by list/get/update endpoints."""
id: str
organization_id: str
name: str
# First 12 characters (e.g., 'pk_live_abc1') - safe to log.
key_prefix: str
role: Literal['viewer', 'member', 'admin', 'owner']
rate_limit: int
is_active: bool
last_used_at: datetime | None = None
expires_at: datetime | None = None
created_at: datetime
create
Create a key. Its secret comes back here, once; Settings can show it again later. To give an
agent a key of its own, create --save-profile <name> keeps it in a
CLI profile instead of printing it. REST names the organization by its
UUID.
Source: ApiKeys.create
| Arg | Type | Default | Notes |
|---|---|---|---|
name |
str |
required | Label, 1 to 100 characters; need not be unique |
organization |
str | None |
None |
Organization name, slug or id (default: the key’s own, the only one it can address) |
role |
ApiKeyRole |
"member" |
viewer, member, admin or owner, up to your key’s own role |
rate_limit |
int | None |
None |
Per-key cap in requests an hour; it can lower the key below its plan’s limit, never raise it (Rate limits) |
expires_at |
datetime | str | None |
None |
Expiry time (ISO 8601); None never expires |
created = client.api_keys.create(
name="ci-pipeline",
role="member",
)
print("Save this:", created.api_key) # viewable again from Settings
# Prints the secret once.
pictograph api-keys create ci-pipeline --role member
# Or keep it in a CLI profile, unprinted, and run as it.
pictograph api-keys create labeller --role viewer --rate-limit 1000 --save-profile labeller
pictograph --profile labeller datasets list
curl -s -X POST "https://api.pictograph.io/api/v1/api-keys/" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"organization_id": "<org-uuid>", "name": "ci-pipeline", "role": "member"}'
Returns CreatedApiKey
CreatedApiKey · 8 fields
class CreatedApiKey(BaseModel):
"""Response from ApiKeys.create - includes the secret one time only."""
# The full secret. The API returns it only here - store it securely (Settings can
# reveal it again, once per sign-in).
api_key: str
key_id: str
key_prefix: str
name: str
role: Literal['viewer', 'member', 'admin', 'owner']
rate_limit: int
expires_at: datetime | None = None
created_at: datetime
get
One key, without its secret.
Source: ApiKeys.get
| Arg | Type | Default | Notes |
|---|---|---|---|
key |
str |
required | API key id (not the key itself) |
key = client.api_keys.get(key="c7d8e9f0-1a2b-4c34-8d5e-6f708192a3b4")
print(key.role, key.created_at, key.last_used_at)
pictograph api-keys get ci-pipeline
curl -s "https://api.pictograph.io/api/v1/api-keys/$KEY_ID" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns ApiKey
ApiKey · 10 fields
class ApiKey(BaseModel):
"""API key metadata returned by list/get/update endpoints."""
id: str
organization_id: str
name: str
# First 12 characters (e.g., 'pk_live_abc1') - safe to log.
key_prefix: str
role: Literal['viewer', 'member', 'admin', 'owner']
rate_limit: int
is_active: bool
last_used_at: datetime | None = None
expires_at: datetime | None = None
created_at: datetime
update
Change a key’s name, its rate_limit cap or is_active (pass at least one). A key’s role
never changes: create a key with the new role and revoke the old one.
Source: ApiKeys.update
| Arg | Type | Default | Notes |
|---|---|---|---|
key |
str |
required | API key id (not the key itself) |
name |
str | None |
None |
New label |
rate_limit |
int | None |
None |
New per-key cap in requests an hour (never above the plan’s limit) |
clear_rate_limit |
bool |
False |
Remove the cap so the key follows its plan’s limit; can’t combine with rate_limit |
is_active |
bool | None |
None |
False disables the key without revoking it |
# Rename the key and hold it below its plan's limit.
client.api_keys.update(
key="c7d8e9f0-1a2b-4c34-8d5e-6f708192a3b4",
name="renamed",
rate_limit=10000,
)
# Remove the cap - the key follows its plan again.
client.api_keys.update(
key="c7d8e9f0-1a2b-4c34-8d5e-6f708192a3b4",
clear_rate_limit=True,
)
client.api_keys.update(
key="c7d8e9f0-1a2b-4c34-8d5e-6f708192a3b4",
is_active=False,
)
pictograph api-keys update ci-pipeline --name renamed --rate-limit 10000
pictograph api-keys update renamed --clear-rate-limit
pictograph api-keys update renamed --inactive
curl -s -X PATCH "https://api.pictograph.io/api/v1/api-keys/$KEY_ID" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "renamed", "rate_limit": 10000}'
# Remove the cap: send rate_limit as null.
curl -s -X PATCH "https://api.pictograph.io/api/v1/api-keys/$KEY_ID" \
-H "X-API-Key: $PICTOGRAPH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rate_limit": null}'
Returns ApiKey
ApiKey · 10 fields
class ApiKey(BaseModel):
"""API key metadata returned by list/get/update endpoints."""
id: str
organization_id: str
name: str
# First 12 characters (e.g., 'pk_live_abc1') - safe to log.
key_prefix: str
role: Literal['viewer', 'member', 'admin', 'owner']
rate_limit: int
is_active: bool
last_used_at: datetime | None = None
expires_at: datetime | None = None
created_at: datetime
revoke
Permanently revoke a key. Requests with it fail with AuthError (401) within a second.
Source: ApiKeys.revoke
| Arg | Type | Default | Notes |
|---|---|---|---|
key |
str |
required | API key id (not the key itself) |
client.api_keys.revoke(key="c7d8e9f0-1a2b-4c34-8d5e-6f708192a3b4")
pictograph api-keys revoke renamed --yes
curl -s -X DELETE "https://api.pictograph.io/api/v1/api-keys/$KEY_ID" \
-H "X-API-Key: $PICTOGRAPH_API_KEY"
Returns None
Role hierarchy
A key creates keys of its own role or lower:
| Caller role | Can create |
|---|---|
viewer, member |
- |
admin |
viewer, member, admin |
owner |
viewer, member, admin, owner |
Common errors
| Status | Exception | Cause |
|---|---|---|
| 403 | ForbiddenError |
A key below admin, or another organization named |
| 404 | NotFoundError |
The key doesn’t exist in this organization |
| 422 | ValidationError |
An invalid role, a malformed expires_at, or a rate_limit below 1 |