API keys
Create API key
Create a new scoped API key with the Go SDK.
POST
/api-keysUse client.ApiKeys.Create to create a scoped API key.
Call the method
apiKey, _, _ := client.ApiKeys.Create(
blnkgo.CreateApiKeyRequest{
Name: "Service Account",
Owner: "merchant_a",
Scopes: []string{
"ledgers:read",
"balances:write",
},
ExpiresAt: time.Date(
2026, 12, 31, 23, 59, 59, 0, time.UTC,
),
},
)
| Field | Type | Description |
|---|---|---|
Name | string | Descriptive name for the key or service account. |
Owner | string | Owner identifier you assign, such as a team, service, or user ID. |
Scopes | []string | List of permissions in resource:action format (for example ledgers:read). |
ExpiresAt | time.Time | Expiration timestamp. Must be a non-zero time. |
Store the plaintext key
Save apiKey.Key immediately. It is only returned at creation and cannot be retrieved later.
Response
{
"api_key_id": "api_key_879f0ecb-e29f-4137-801b-1048366381db",
"key": "YVLIhuIplUzLRCcT9r7DQ_jsGKCXAn39JQ3n_o-Ll2Q=",
"name": "Service Account",
"owner_id": "owner_id",
"scopes": ["ledgers:read", "balances:write"],
"expires_at": "2026-03-11T00:00:00Z",
"created_at": "2025-11-18T13:39:50.390457762Z",
"last_used_at": "0001-01-01T00:00:00Z",
"is_revoked": false
}Go response (*blnkgo.ApiKeyResponse)
| Field | Type | Description |
|---|---|---|
ApiKeyID | string | Unique ID for the key. Use it to revoke the key. |
Key | string | Plaintext secret. Store it now. It is only returned at creation. |
Name | string | Name you passed in the request. |
OwnerID | string | Owner assigned to the key. |
Scopes | []string | Permissions granted to the key. |
ExpiresAt | string | Date and time the key expires. |
CreatedAt | string | Date and time the key was created. |
LastUsedAt | string | Date and time the key was last used. |
IsRevoked | bool | Whether the key has been revoked. |
RevokedAt | string | Revocation timestamp when present. |