Skip to main content
Validate user requests against rate limits and usage policies using the Limitly REST API.

Validate Request

Validate a user’s request using their API key:

Request Parameters

string
required
The user’s API key to validate
string
required
The endpoint being accessed
string
required
The HTTP method being used (GET, POST, PUT, DELETE, etc.)

Response

Error Response

When a request is denied due to rate limiting:

Validation Errors

Invalid API Key

API Key Not Found

Disabled API Key

Invalid Request

JavaScript Example

cURL Example

Response Headers

When validation is successful, the response includes useful headers:

Rate Limit Headers

The API includes rate limit information in response headers:
  • X-RateLimit-Limit: Total requests allowed per period
  • X-RateLimit-Remaining: Remaining requests for the current period
  • X-RateLimit-Reset: Unix timestamp when the limit resets
  • X-RateLimit-Plan: Name of the plan associated with the API key

Validation Flow

  1. Extract API Key: Get the API key from the request (header, query param, etc.)
  2. Validate Request: Send validation request to Limitly API
  3. Check Response: If success: true, allow the request; if success: false, deny
  4. Handle Errors: Provide appropriate error responses for different scenarios

Integration Examples

Express.js Middleware

Next.js API Route

Best Practices

Cache Validation Results

For high-traffic applications, consider caching validation results for a short period to reduce API calls.

Handle Errors Gracefully

Always handle validation errors gracefully and provide meaningful error messages to your users.

Monitor Usage

Regularly monitor usage patterns to optimize rate limits and plan assignments.

Next Steps