How to create a new API key with fine-grained permissions in Blnk.
curl --request POST \
--url http://localhost:5001/api-keys \
--header 'X-blnk-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Service Account",
"owner": "owner_id",
"scopes": ["ledgers:read", "balances:write"],
"expires_at": "2026-03-11T00:00:00Z"
}'
{
"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
}
server.secret_key from your configuration).X-blnk-key: <api-key>.
Replace <api-key> with your secret API key. Ensure the key is kept secure and not exposed in public repositories or client-side code.
See also: Secure your Blnk server
resource:action. See Understanding Scopes for available resources and actions.Examples:["ledgers:read"] - Can only view ledgers["transactions:write", "balances:read"] - Can create/modify transactions and view balances["*:*"] - Full access to all resources and actions"2026-03-11T00:00:00Z").X-Blnk-Key header for authenticated requests.api_key value is only returned once when the key is created. If you lose it, you’ll need to create a new API key. Never commit API keys to version control or expose them in client-side code."0001-01-01T00:00:00Z" if the key has never been used.false for newly created keys.curl --request POST \
--url http://localhost:5001/api-keys \
--header 'X-blnk-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Service Account",
"owner": "owner_id",
"scopes": ["ledgers:read", "balances:write"],
"expires_at": "2026-03-11T00:00:00Z"
}'
{
"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
}
Was this page helpful?
curl --request POST \
--url http://localhost:5001/api-keys \
--header 'X-blnk-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Service Account",
"owner": "owner_id",
"scopes": ["ledgers:read", "balances:write"],
"expires_at": "2026-03-11T00:00:00Z"
}'
{
"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
}