auth.v1.ApiKeyService
CreateApiKey
Create a new API key for the caller. Account security settings may require MFA enrollment or a fresh step-up proof. The acting caller's root account must have accepted the current terms, including when targeting a shared subaccount; otherwise FailedPrecondition with AUTH_TERMS_NOT_ACCEPTED is returned.
Request
curl --request POST \ \
--url 'https://api.testnet.polyester.com/auth.v1.ApiKeyService/CreateApiKey' \
--header 'Content-Type: application/json' \
--header 'Connect-Protocol-Version: 1' \
--data '{
"color": "#7C3AED",
"icon": "💰",
"ipWhitelist": [
"203.0.113.0/24"
],
"label": "Trading Bot",
"publicKeyEd25519": "AA==",
"subaccountId": "6789012345678"
}'Responses
{
"apiKey": {
"color": "#7C3AED",
"createdAt": "2025-01-01T00:00:00Z",
"createdByActor": "dashboard",
"expiresAt": "2025-01-01T00:00:00Z",
"icon": "💰",
"ipWhitelist": [
"203.0.113.0/24"
],
"keyId": "ak_1a3c6de8153d5a5b04cd2a6529779542",
"label": "Trading Bot",
"lastUsedAt": "2025-01-01T00:00:00Z",
"policyId": "1",
"publicKeyEd25519": "AA==",
"revision": "1",
"status": "ACTIVE",
"subaccountId": "6789012345678",
"updatedAt": "2025-01-01T00:00:00Z"
}
}auth.v1.CreateApiKeyRequestauth.v1.CreateApiKeyResponseHuman-readable label for the key. Required; 1 to 64 characters, and must not contain '<' or '>'.
Optional sub-account to scope this key to (opaque ID). If unset, the key is root-level.
Optional user-chosen icon/emoji for UI display.
Optional user-chosen color token for UI display.
Optional CIDR whitelist. Empty means no IP restriction. Maximum 32 unique entries.
Ed25519 public key bytes. Must be exactly 32 bytes. The private key or seed must never be sent to the API.
Stable opaque identifier used to refer to this key, formatted as "ak_" followed by 32 lowercase hex characters.
Human-readable label for the key. Maximum length is 64 characters.
Optional user-chosen icon/emoji for UI display.
Optional user-chosen color token for UI display.
Optional CIDR whitelist. Empty means no IP restriction. Maximum 32 unique entries.
Current key status.
Optional sub-account this key is scoped to (opaque ID; empty = root-level).
Optional API policy attached to this key (opaque ID). Empty means no policy is attached and the key has no permissions.
Time in UTC when this key was created.
Approximate last time in UTC when this key authenticated a request, recorded at most about once a minute; it may lag recent use by a few minutes. Omitted when no use has been recorded.
Ed25519 public key bytes associated with this API key. The private key or seed is never returned by the API.
Optional expiry time in UTC. When set, the key cannot authenticate requests after this time, regardless of status.
Read-only actor label describing who created this key, such as a username or account label.
Time in UTC when this key's configuration was last changed. For the same key, later is fresher, equal is an idempotent replay, and earlier is stale. Equal timestamps with different configuration indicate an invariant failure. This is independent of last_used_at, which tracks authentication activity.
Monotonic resource revision used for conditional updates.
| Key | HTTP status | Connect code | Error | When |
|---|---|---|---|---|
| unauthenticated | 401 | unauthenticated | Unauthenticated | Authentication required. |
| permission-denied | 403 | permission_denied | Permission Denied | Permission denied. |
| invalid-argument | 400 | invalid_argument | Invalid Argument | Invalid argument. |
| not-found | 404 | not_found | Not Found | Not found. |
| unavailable | 503 | unavailable | Unavailable | Service unavailable. |