Manage API keys for your users using the Limitly REST API.
List API Keys
Get all API keys for your account:
curl -X GET \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
https://api.limitly.dev/functions/v1/keys
Response
{
"data": [
{
"id": "key_123",
"name": "Production API Key",
"user_id": 456,
"plan_id": "plan_789",
"status": "active",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
],
"count": 1
}
Create API Key
Create a new API key for a user:
curl -X POST \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"name": "New API Key",
"user_id": 123,
"plan_id": "plan_456",
"status": "active"
}' \
https://api.limitly.dev/functions/v1/keys
Request Parameters
A descriptive name for the API key
The ID of the user who will use this API key
The ID of the plan to associate with this API key
The status of the API key (active, inactive)
Response
{
"data": {
"id": "key_123",
"api_key": "lk_user_abcdef1234567890abcdef1234567890",
"name": "New API Key",
"user_id": 123,
"plan_id": "plan_456",
"status": "active",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}
Get API Key
Retrieve a specific API key by ID:
curl -X GET \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
https://api.limitly.dev/functions/v1/keys/key_123
Response
{
"data": {
"id": "key_123",
"name": "Production API Key",
"user_id": 456,
"plan_id": "plan_789",
"status": "active",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}
Update API Key
Update an existing API key:
curl -X PUT \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated API Key Name",
"status": "inactive"
}' \
https://api.limitly.dev/functions/v1/keys/key_123
Request Parameters
New status for the API key (active, inactive)
Delete API Key
Delete an API key:
curl -X DELETE \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
https://api.limitly.dev/functions/v1/keys/key_123
Response
{
"data": {
"message": "API key deleted successfully"
}
}
Regenerate API Key
Regenerate an existing API key (creates a new key value):
curl -X POST \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
https://api.limitly.dev/functions/v1/keys/key_123/regenerate
Response
{
"data": {
"id": "key_123",
"api_key": "lk_user_newabcdef1234567890abcdef1234567890",
"name": "Production API Key",
"user_id": 456,
"plan_id": "plan_789",
"status": "active",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}
Get API Key Usage
Get usage statistics for a specific API key:
curl -X GET \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
https://api.limitly.dev/functions/v1/keys/key_123/usage
Response
{
"data": {
"current_usage": 45,
"limit": 1000,
"remaining": 955,
"reset_time": "2024-02-01T00:00:00Z",
"period": "month"
}
}
Get API Key Requests
Get detailed request history for an API key:
curl -X GET \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
https://api.limitly.dev/functions/v1/keys/key_123/requests
Response
{
"data": {
"requests": [
{
"timestamp": "2024-01-01T12:00:00Z",
"endpoint": "/api/users",
"method": "GET",
"status": "allowed",
"ip_address": "192.168.1.1"
}
],
"count": 1
}
}
Error Responses
Invalid API Key
{
"error": "Invalid API key",
"code": "INVALID_API_KEY"
}
API Key Not Found
{
"error": "API key not found",
"code": "API_KEY_NOT_FOUND"
}
Validation Error
{
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"field": "name",
"message": "Name is required"
}
}
List endpoints support pagination with the following query parameters:
Number of items per page (default: 10, max: 100)
Example
curl -X GET \
-H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \
"https://api.limitly.dev/functions/v1/keys?page=2&limit=20"
Next Steps