curl -X POST "https://developer.encrata.com/api/account/keys/limit" \
-H "Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-0000-4000-8000-000000000000", "credit_limit": 5000}'
{
"message": "Credit limit updated",
"credit_limit": 5000
}
{
"success": false,
"result": { "code": "bad_request" },
"message": "Credit limit must be a positive number",
"request_id": "req_7f3a9c21",
"error": "Credit limit must be a positive number"
}
{
"success": false,
"result": { "code": "not_found" },
"message": "API key not found",
"request_id": "req_7f3a9c21",
"error": "API key not found"
}
API Keys
Set API Key Credit Limit
Cap how many credits an API key can spend, or remove the cap.
POST
/
api
/
account
/
keys
/
limit
curl -X POST "https://developer.encrata.com/api/account/keys/limit" \
-H "Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-0000-4000-8000-000000000000", "credit_limit": 5000}'
{
"message": "Credit limit updated",
"credit_limit": 5000
}
{
"success": false,
"result": { "code": "bad_request" },
"message": "Credit limit must be a positive number",
"request_id": "req_7f3a9c21",
"error": "Credit limit must be a positive number"
}
{
"success": false,
"result": { "code": "not_found" },
"message": "API key not found",
"request_id": "req_7f3a9c21",
"error": "API key not found"
}
Authentication
Requires an API key in theAuthorization header.
Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Request
The key’s database id, as returned by
List API keys. Not the
key_prefix.The maximum number of credits this key may spend. Must be between
0 and
2147483647. 0 blocks all spending on the key. Send null, or omit the
field entirely, to remove the cap.Set a limit
curl -X POST "https://developer.encrata.com/api/account/keys/limit" \
-H "Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-0000-4000-8000-000000000000", "credit_limit": 5000}'
Remove the limit (unlimited)
curl -X POST "https://developer.encrata.com/api/account/keys/limit" \
-H "Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-0000-4000-8000-000000000000", "credit_limit": null}'
Response
Known issue: A
credit_limit above 2147483647 returns 404 with
API key not found instead of a validation error.{
"message": "Credit limit updated",
"credit_limit": 5000
}
Permissions
readonly members get 403. A tech member can only change their own keys;
only a workspace admin can change another member’s key. A key that is out of
your scope returns 404, the same as an unknown id.
Errors
Errors return the shared envelope withsuccess, result.code, message, and
request_id. A legacy error key is included alongside it.
curl -X POST "https://developer.encrata.com/api/account/keys/limit" \
-H "Authorization: Bearer enc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-0000-4000-8000-000000000000", "credit_limit": 5000}'
{
"message": "Credit limit updated",
"credit_limit": 5000
}
{
"success": false,
"result": { "code": "bad_request" },
"message": "Credit limit must be a positive number",
"request_id": "req_7f3a9c21",
"error": "Credit limit must be a positive number"
}
{
"success": false,
"result": { "code": "not_found" },
"message": "API key not found",
"request_id": "req_7f3a9c21",
"error": "API key not found"
}
Was this page helpful?