API keys
Create API key
Create a new scoped API key with the Java SDK.
POST
/api-keysUse blnk.apiKeys().create for this operation.
Call the method
ApiResponse<JsonNode> response = blnk.apiKeys().create(
CreateApiKeyData.create()
.name("Read-only key")
.owner("merchant_a")
.scopes(List.of("ledgers:read"))
.expiresAt("2030-01-01T00:00:00Z"));
| 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 | List<String> | List of permissions in resource:action format (for example ledgers:read). |
expires_at | String | Expiration timestamp (ISO 8601, for example 2026-12-31T23:59:59Z). |
Store the plaintext key
Save response.data().get("key").asText() 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
}
| Field | Type | Description |
|---|---|---|
api_key_id | 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. |
scopes | List<String> | Permissions granted to the key. |
expires_at | String | Date and time the key expires. |
is_revoked | boolean | Whether the key has been revoked. |