Skip to content

API Reference / API keys

Create a workspace API key

Creates an API key scoped to a workspace with the given policies and optional expiry. The full key is returned only once at creation and must be stored immediately. A recent two-factor re-verification is required.

POST/accounts.v1.Accounts/CreateAPIKey

Request body

application/jsonRequired

Request to create an API key in the caller's workspace. Requires an accepted membership and a two-factor step-up in the last 5 minutes. The caller is emailed a notification.

expiresAt?string

When the key should stop authenticating. Absent creates a key that never expires.

Format"date-time"

name?string

Label for the key, 1 to 256 characters after trimming surrounding whitespace.

policies?array<string>

Names of the policies to grant, at least one, each a name returned by ListPolicies, such as "trading" or "steam".

Response body

application/json

Success

apiKey?APIKey

The created key's details, without the secret.

Show attributes
createdAt?string

When the key was created.

Format"date-time"

createdBy?string

Opaque 16-byte identifier of the user who created the key and owns it, base64-encoded in JSON.

Format"byte" base64

expiresAt?string

When the key stops authenticating. Requests at or after this time are rejected as unauthenticated. Absent when the key never expires.

Format"date-time"

id?string

Opaque 16-byte identifier of the API key, assigned on creation. Base64-encoded in JSON.

Format"byte" base64

keyPrefix?string

The first 8 characters of the secret, kept so a key can be recognised in lists. Cannot authenticate on its own.

lastUsedAt?string

When the key last authenticated a request. Absent when the key has never been used.

Format"date-time"

name?string

Label chosen when the key was created, 1 to 256 characters, to tell keys apart.

policies?array<string>

Names of the policies granted to the key, at least one, such as "trading" or "steam". ListPolicies lists the valid names and the permissions each grants.

previousKeyExpiresAt?string

When the secret this key had before its last rotation stops authenticating. A time in the past means it has stopped. Absent when the key was never rotated with a grace period, or was last rotated with none.

Format"date-time"

revealable?boolean

Whether RevealAPIKey can return this key's secret. False for a key created before secrets were stored. Rotate it to make it revealable.

workspaceId?string

Opaque 16-byte identifier of the workspace the key is confined to, base64-encoded in JSON.

Format"byte" base64

rawKey?string

The key's secret, 64 hexadecimal characters, sent as a Bearer token in the Authorization header. Store it securely. RevealAPIKey can return it again after a two-factor step-up.

curl -X POST "https://api.goldmine.to/accounts.v1.Accounts/CreateAPIKey" \
  -H "Authorization: Bearer $CSTRADER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "CI deploy key",
    "expiresAt": "2027-06-29T00:00:00Z",
    "policies": [
      "trading",
      "analytics"
    ]
  }'
{
  "apiKey": {
    "id": "CgsMDQ4PEBESExQVFhcYGQ==",
    "name": "CI deploy key",
    "keyPrefix": "gm_live_8f3a",
    "workspaceId": "AAECAwQFBgcICQoLDA0ODw==",
    "expiresAt": "2027-06-29T00:00:00Z",
    "createdAt": "2026-06-29T12:00:00Z",
    "policies": [
      "trading",
      "analytics"
    ]
  },
  "rawKey": "gm_live_8f3a2b1c9d4e5f60718293a4b5c6d7e8"
}