Skip to main content

List API Keys

Retrieve all API keys for a specific bucket.

Endpoint

GET /api/buckets/:bucketId/keys

Authentication

Key TypeAllowed
Admin (dakkio_a_)✅ Yes
Write (dakkio_w_)❌ No
Read (dakkio_r_)❌ No

Required: Admin key (dakkio_a_). Only Admin keys can manage API keys.

Key Security

For security reasons, the full API key value is never returned after creation. Only the key prefix (first 12 characters) is shown when listing keys.

Request

Headers

HeaderTypeRequiredDescription
X-API-Keystring✅ YesYour Admin API key

Path Parameters

ParameterTypeRequiredDescription
bucketIdstring✅ YesThe bucket ID (24-character hex string)

Example Request

curl -X GET "https://api.dakkio.io/api/buckets/507f1f77bcf86cd799439011/keys" \
-H "X-API-Key: dakkio_a_your_admin_key..."

Response

Success Response (200 OK)

{
"apiKeys": [
{
"_id": "507f1f77bcf86cd799439013",
"name": "Living Room Sensor",
"type": "write",
"keyPrefix": "dakkio_w_abc1...",
"bucketId": "507f1f77bcf86cd799439011",
"createdAt": "2024-01-15T10:05:00Z",
"lastUsedAt": "2024-01-15T14:30:00Z"
},
{
"_id": "507f1f77bcf86cd799439014",
"name": "Dashboard Reader",
"type": "read",
"keyPrefix": "dakkio_r_xyz7...",
"bucketId": "507f1f77bcf86cd799439011",
"createdAt": "2024-01-15T10:06:00Z",
"lastUsedAt": "2024-01-15T15:00:00Z"
}
]
}

Empty Response (200 OK)

{
"apiKeys": []
}

Error Responses

401 Unauthorized

{
"error": "Unauthorized",
"message": "Invalid or missing API key"
}

403 Forbidden

{
"error": "Forbidden",
"message": "Only Admin keys can list API keys"
}

404 Not Found

{
"error": "Not Found",
"message": "Bucket not found"
}

Code Examples

JavaScript/Node.js

const axios = require('axios');

async function listApiKeys(bucketId) {
const response = await axios.get(
`https://api.dakkio.io/api/buckets/${bucketId}/keys`,
{
headers: {
'X-API-Key': process.env.DAKKIO_ADMIN_KEY
}
}
);

return response.data.apiKeys;
}

// List all API keys for a bucket
const keys = await listApiKeys('507f1f77bcf86cd799439011');
console.log(`Found ${keys.length} API keys:`);
keys.forEach(key => {
console.log(`- ${key.name} (${key.type}): ${key.keyPrefix}`);
});

Python

import requests
import os

def list_api_keys(bucket_id):
response = requests.get(
f'https://api.dakkio.io/api/buckets/{bucket_id}/keys',
headers={
'X-API-Key': os.environ['DAKKIO_ADMIN_KEY']
}
)

if response.status_code == 200:
return response.json()['apiKeys']
else:
print('Error:', response.json())
return []

# List all API keys
keys = list_api_keys('507f1f77bcf86cd799439011')
for key in keys:
print(f"- {key['name']} ({key['type']}): {key['keyPrefix']}")

Response Fields

FieldTypeDescription
_idstringUnique key identifier
namestringDescriptive name for the key
typestringKey type: write or read
keyPrefixstringFirst 12 characters of the key (for identification)
bucketIdstringBucket this key is scoped to
createdAtstringCreation timestamp (ISO 8601)
lastUsedAtstringLast usage timestamp (ISO 8601)