ApiKeyService
Create API Key
Create a new API key for the caller account, including public key material and metadata. Requires the acting caller to have accepted the current terms.
Request
curl --request POST \ \
--url 'https://api.testnet.polyester.com/v1/auth/api-keys' \
--header 'Accept: */*' \
--header 'X-API-KEY-ID: YOUR_API_KEY_ID' \
--header 'X-API-TIMESTAMP: YOUR_API_TIMESTAMP' \
--header 'X-API-SIGNATURE: YOUR_API_SIGNATURE' \
--header 'Content-Type: application/json' \
--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": "ADVPd9FYi2",
"publicKeyEd25519": "AA==",
"revision": "1",
"status": "ACTIVE",
"subaccountId": "39HwgZg2gCw",
"updatedAt": "2025-01-01T00:00:00Z"
}
}Optional user-chosen color token for UI display.
Optional user-chosen icon/emoji for UI display.
Optional CIDR whitelist. Empty means no IP restriction. Maximum 32 unique entries.
Human-readable label for the key. Required; 1 to 64 characters.
Ed25519 public key bytes. Must be exactly 32 bytes. The private key or seed must never be sent to the API. bytes.const = []
Optional sub-account to scope this key to (opaque ID). If unset, the key is root-level.
Stable opaque identifier used to refer to this key, formatted as "ak_" followed by 32 lowercase hex characters.
ak_1a3c6de8153d5a5b04cd2a6529779542Human-readable label for the key. Maximum length is 64 characters.
Trading BotOptional user-chosen icon/emoji for UI display.
💰Optional user-chosen color token for UI display.
#7C3AEDOptional CIDR whitelist. Empty means no IP restriction. Maximum 32 unique entries.
["203.0.113.0/24"]Current key status.
ACTIVEOptional sub-account this key is scoped to (opaque ID; empty = root-level).
39HwgZg2gCwOptional API policy attached to this key (opaque ID). Empty means no policy is attached and the key has no permissions.
ADVPd9FYi2Time in UTC when this key was created.
2025-01-01T00:00:00ZLast time in UTC when this key authenticated a request. Omitted when the key has not been used.
2025-01-01T00:00:00ZEd25519 public key bytes associated with this API key. The private key or seed is never returned by the API.
AA==Optional expiry time in UTC. When set, the key cannot authenticate requests after this time, regardless of status.
2025-01-01T00:00:00ZRead-only actor label describing who created this key, such as a username or account label.
dashboardTime 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.
2025-01-01T00:00:00ZMonotonic resource revision used for conditional updates.
1| Key | Status | Error | When |
|---|---|---|---|
| unauthenticated | 401 | Unauthenticated | Authentication required. |
| permission-denied | 403 | Permission Denied | Permission denied. |
| invalid-argument | 400 | Invalid Argument | Invalid argument. |
| not-found | 404 | Not Found | Not found. |
| unavailable | 503 | Unavailable | Service unavailable. |