- Print
- DarkLight
CreateServicePrincipalKey
- Print
- DarkLight
Availability
Early Access: July 1, 2026
Early Access is gated; contact the Backblaze Sales team for access.
Limited Availability: July 1, 2026
This API is available only to customers with access to the Backblaze Enterprise Web Console. For more information, contact the Backblaze Sales team.
Create a new API key for a Service Principal
The response includes a credentialId and secret for authentication. The secret is returned only in this response and cannot be retrieved later; callers must store it securely at creation time.
Either expireTime or ttl may be supplied to bound the key's lifetime. If both are provided, ttl is used to derive expireTime. If neither is set, the key does not expire.
ttl is input-only and is not returned. Format: protobuf Duration JSON, for example 3600s.
Short-lived bearer token obtained from GET /orgs/v1/authorize. Sent as Authorization - Bearer .
The numeric identifier of the account. Valid account IDs match 9[0-4][0-9]{10}.
The identifier of the service principal.
With explicit expireTime
{
"displayName": "my-key",
"expireTime": "2026-12-31T23:59:59Z"
}With TTL
{
"displayName": "my-key",
"ttl": "3600s"
}No expiration
{
"displayName": "my-key"
}Optional absolute expiration. Mutually exclusive with ttl for derivation purposes; if both are supplied, ttl is used to derive expireTime.
Optional duration string in protobuf Duration JSON format (e.g. 3600s). Input-only; not returned in responses.
The request succeeded. The credentialId and secret are returned here; the secret cannot be retrieved later.
{
"name": "accounts/942733365851/servicePrincipals/2/keys/019e6a8a-678e-7298-9167-4bd65df2f272",
"displayName": "my-key",
"credentialId": "bz_spk_AAAA0_Jywr8AAAAAAAAABwGfPoLG0nO0nEZ4NpErFtw",
"secret": "bz_spksec1__exampleSecretValue",
"expireTime": "2026-12-31T23:59:59Z",
"createTime": "2026-04-22T20:30:00Z",
"updateTime": "2026-04-22T20:30:00Z",
"disabled": false,
"etag": "BwXk9a2J8p0="
}Resource name in the form accounts//servicePrincipals//keys/.
Absolute expiration timestamp. If absent, the key does not expire.
When true, the key cannot mint new bearer tokens. Outstanding tokens remain valid until they expire.
Opaque concurrency token.
The credential ID used as the HTTP Basic username when calling /orgs/v1/authorize.
The key secret. Returned only on creation and cannot be retrieved later.
The request was malformed or failed validation.
| HTTP Status | Code | Description |
|---|---|---|
| 400 | INVALID_ARGUMENT | One or more request parameters were invalid. |
Opaque correlation identifier matching the Request-Id response header. Include in support requests.
Numeric error code.
Human-readable description of the error.
Reserved for structured, non-sensitive diagnostic information related to the error condition.
The request was not authenticated.
| HTTP Status | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing, expired, or invalid bearer token. |
Opaque correlation identifier matching the Request-Id response header. Include in support requests.
Numeric error code.
Human-readable description of the error.
Reserved for structured, non-sensitive diagnostic information related to the error condition.
The caller is not authorized to perform this operation.
| HTTP Status | Code | Description |
|---|---|---|
| 403 | FORBIDDEN | The authenticated principal lacks permission for this action. |
Opaque correlation identifier matching the Request-Id response header. Include in support requests.
Numeric error code.
Human-readable description of the error.
Reserved for structured, non-sensitive diagnostic information related to the error condition.
The request conflicted with the current state of the resource.
| HTTP Status | Code | Description |
|---|---|---|
| 409 | CONFLICT | etag mismatch, resource already exists, or precondition failed. |
Opaque correlation identifier matching the Request-Id response header. Include in support requests.
Numeric error code.
Human-readable description of the error.
Reserved for structured, non-sensitive diagnostic information related to the error condition.
The request was rate-limited.
| HTTP Status | Code | Description |
|---|---|---|
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded. Use exponential backoff. |
Opaque correlation identifier matching the Request-Id response header. Include in support requests.
Numeric error code.
Human-readable description of the error.
Reserved for structured, non-sensitive diagnostic information related to the error condition.
The server encountered an unexpected condition.
| HTTP Status | Code | Description |
|---|---|---|
| 500 | INTERNAL | Unexpected server error. Include the requestId when contacting support. |
Opaque correlation identifier matching the Request-Id response header. Include in support requests.
Numeric error code.
Human-readable description of the error.
Reserved for structured, non-sensitive diagnostic information related to the error condition.