Create and manage usage plans via the REST API
curl -X GET \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ https://api.limitly.dev/v1/plans
{ "data": [ { "id": "plan_123", "name": "Basic Plan", "description": "Plan for basic users", "max_requests": 10000, "request_period": "month", "is_active": true, "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-01T00:00:00Z" } ], "count": 1 }
curl -X POST \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ -H "Content-Type: application/json" \ -d '{ "name": "Basic Plan", "description": "Plan for basic users", "max_requests": 10000, "request_period": "month", "is_active": true }' \ https://api.limitly.dev/v1/plans
{ "data": { "id": "plan_123", "name": "Basic Plan", "description": "Plan for basic users", "max_requests": 10000, "request_period": "month", "is_active": true, "created_at": "2024-01-01T00:00:00Z", "updated_at": "2024-01-01T00:00:00Z" } }
curl -X GET \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ https://api.limitly.dev/v1/plans/plan_123
curl -X PUT \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Basic Plan", "max_requests": 15000, "is_active": true }' \ https://api.limitly.dev/v1/plans/plan_123
curl -X DELETE \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ https://api.limitly.dev/v1/plans/plan_123
{ "data": { "message": "Plan deleted successfully" } }
curl -X GET \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ https://api.limitly.dev/v1/plans/plan_123/usage
{ "data": { "total_users": 25, "total_requests": 150000, "average_usage": 6000, "period": "month" } }
curl -X GET \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ https://api.limitly.dev/v1/plans/plan_123/users
{ "data": [ { "user_id": 123, "name": "John Doe", "email": "john@example.com", "created_at": "2024-01-01T00:00:00Z" } ], "count": 1 }
curl -X GET \ -H "Authorization: Bearer lk_1234567890abcdef1234567890abcdef" \ https://api.limitly.dev/v1/plans/plan_123/keys
{ "data": [ { "id": "key_123", "name": "Production API Key", "user_id": 456, "status": "active", "created_at": "2024-01-01T00:00:00Z" } ], "count": 1 }
{ "error": "Plan not found", "code": "PLAN_NOT_FOUND" }
{ "error": "Validation failed", "code": "VALIDATION_ERROR", "details": { "field": "max_requests", "message": "Max requests must be greater than 0" } }
day
week
month
year
Was this page helpful?