Skip to main content
curl --request POST \
  --url https://api.usedatabrain.com/api/v2/data-app/rotate-api \
  --header 'Authorization: Bearer service_token_xyz...' \
  --header 'Content-Type: application/json' \
  --data '{
    "key": "550e8400-e29b-41d4-a716-446655440000",
    "expireAt": 0
  }'
{
  "key": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
POST
https://api.usedatabrain.com
/
api
/
v2
/
data-app
/
rotate-api
curl --request POST \
  --url https://api.usedatabrain.com/api/v2/data-app/rotate-api \
  --header 'Authorization: Bearer service_token_xyz...' \
  --header 'Content-Type: application/json' \
  --data '{
    "key": "550e8400-e29b-41d4-a716-446655440000",
    "expireAt": 0
  }'
{
  "key": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
Rotate API keys to maintain security best practices by periodically refreshing credentials. This endpoint expires the old API key and generates a new one, ensuring seamless transition while maintaining security.
API key rotation is a critical security practice. This endpoint allows you to programmatically rotate keys, set expiration times for old keys, and receive new keys immediately - enabling zero-downtime key rotation.
Authentication Requirement: This endpoint requires a service token (not a data app API key). Service tokens have elevated permissions to manage API keys across your organization.

Authentication

This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions. To access your service token:
  1. Go to your Databrain dashboard and open Settings.
  2. Navigate to Settings.
  3. Find the Service Tokens section .
  4. Click the “Generate Token” button to generate a new service token if you don’t have one already.
Use this token as the Bearer value in your Authorization header.

Headers

Authorization
string
required
Bearer token for API authentication. Use your service token (not data app API key).
Authorization: Bearer service_token_xyz...
Content-Type
string
required
Must be set to application/json for all requests.
Content-Type: application/json

Request Body

key
string
required
The current API key (UUID format) that you want to rotate. This key will be expired and replaced with a new one.
expireAt
number
required
Duration in seconds until the old API key expires. This allows for a grace period to update your applications.

Response

key
string
The newly generated API key (UUID format). Use this key for all future API requests.
error
object
Error object returned only when the request fails. Not included in successful responses.

Examples

HTTP Status Code Summary

Status CodeDescription
200OK - Key rotated successfully
400Bad Request - Invalid request parameters
500Internal Server Error - Server error occurred

Possible Errors

Error CodeHTTP StatusDescription
INVALID_REQUEST_BODY400Missing or invalid parameters
AUTHENTICATION_ERROR400Invalid or missing service token
INVALID_DATA_APP_API_KEY400API key not found or already expired
INTERNAL_SERVER_ERROR500Server error