Skip to content

Rate Limits

AMP enforces rate limits to ensure fair usage and system stability.

Overview

Plan Requests/Minute Burst
Free 60 10
Pro 300 50
Enterprise 1000+ Custom

Rate Limit Headers

Every response includes rate limit information:

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 287
X-RateLimit-Reset: 1705319400
Header Description
X-RateLimit-Limit Maximum requests per window
X-RateLimit-Remaining Requests remaining
X-RateLimit-Reset Unix timestamp when limit resets

Rate Limit Response

When rate limited, you receive a 429 Too Many Requests:

{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Retry after 45 seconds.",
    "retry_after": 45
  }
}

The Retry-After header is also included.

Endpoint-Specific Limits

Some endpoints have additional limits:

Endpoint Additional Limit
POST /missions 10/hour
POST /content/*/regenerate 20/hour
POST /onboard 5/hour
GET /analytics/export 5/hour

Best Practices

Exponential Backoff

async function withRetry(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (error.code === 'rate_limit_exceeded') {
        const delay = Math.min(1000 * Math.pow(2, i), 30000);
        await sleep(delay);
      } else {
        throw error;
      }
    }
  }
}

Request Batching

Instead of many small requests, batch operations:

// Instead of this
for (const id of ids) {
  await client.content.approve(id);
}

// Do this
await client.content.bulkApprove(ids);

Caching

Cache responses when possible:

const cache = new Map();

async function getCachedMission(id) {
  if (cache.has(id)) {
    return cache.get(id);
  }
  const mission = await client.missions.get(id);
  cache.set(id, mission);
  return mission;
}

Requesting Limit Increase

Enterprise customers can request higher limits:

  1. Contact your account manager
  2. Provide use case details
  3. Specify required limits
  4. Allow 24-48 hours for approval

Monitoring Usage

View your current usage:

curl https://api.amp.dev/v1/usage \
  -H "Authorization: Bearer $AMP_API_KEY"
{
  "current_period": {
    "requests": 12456,
    "limit": 300,
    "reset_at": "2024-01-15T11:00:00Z"
  },
  "daily_usage": [
    {"date": "2024-01-14", "requests": 8500},
    {"date": "2024-01-13", "requests": 7200}
  ]
}