Skip to main content

Authentication

Introduction

Authentication is a process of verifying the identity of a user or application. ekoDB uses API keys for authentication. API keys are used to request for a JWT token, which is then used to authenticate requests to the ekoDB API.

By default, ekoDB App generates an admin API key for your convenience. This admin API key is generated when you first create an ekoDB instance. You can find it in the ekoDB App under the Keys tab within the database deployment view:

https://app.ekodb.io/deployments/{YOUR_DEPLOYMENT_ID}?active_tab=keys

You can use this API key or generate a new API key by following the Register API Key section below.

Register API Key

Register a new API key for authentication:

POST https://{EKODB_API_URL}/api/auth/register
Content-Type: application/json

{
"api_key": "{ADMIN_KEY}",
"label": "{LABEL}",
"description": "{DESCRIPTION}",
# Only required if you want to grant collection permissions to a non-admin API key
"collection_permissions": {
"{COLLECTION_NAME}": ["write", "read"]
},
"is_admin": true || false,
}

# Response
{
"label": "{LABEL}",
"description": "{DESCRIPTION}",
"collection_permissions": {
"{COLLECTION_NAME}": ["write", "read"]
},
"is_admin": true || false,
"key": "{YOUR_NEW_API_KEY}"
}

Generate JWT Token

Generate a JWT token using your API key:

POST https://{EKODB_API_URL}/api/auth/token
Content-Type: application/json

{
"api_key": "{YOUR_API_KEY}"
}

# Response
{
"token": "{YOUR_JWT_TOKEN}"
}

Use JWT Token

Use the JWT token in the Authorization header:

GET https://{EKODB_API_URL}/api/collections
Authorization: Bearer {YOUR_JWT_TOKEN}

Great! You can now use the JWT token to authenticate your requests to the ekoDB API.

Next, you can learn how to use the ekoDB API to manage your data!

If you have any issues, please email support@ekodb.io to create a ticket.