# Rate Limits | Signal House API Docs

> The Signal House API rate limits, and how to handle a 429 Too Many Requests response.

Source: https://docs.signalhouse.io/rate-limits

---

## Rate Limits

## Overview

The Signal House API enforces rate limits to ensure fair usage and platform stability. When you exceed the allowed request rate, the API responds with HTTP status `429 Too Many Requests`.

Design your integrations to handle rate limits gracefully by using retry logic, batching operations, and caching responses where appropriate.

## Identifying Rate-Limited Responses

429 Response

```json
{
  "success": false,
  "error": "Rate limit exceeded. Please retry after a brief delay.",
  "status": 429
}
```

## Retry Strategy: Exponential Backoff

When you receive a `429` response, wait before retrying. Increase the delay with each consecutive retry.

| Attempt | Base Delay | Approximate Wait |
| --- | --- | --- |
| 1 | 1 s | 0.5 – 1.5 s |
| 2 | 2 s | 1 – 3 s |
| 3 | 4 s | 2 – 6 s |
| 4 | 8 s | 4 – 12 s |
| 5 | 16 s | 8 – 24 s |

JavaScript

```
async function withRetry(fn, { maxRetries = 3, baseDelay = 1000 } = {}) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const response = await fn();
    if (response.success) return response;
    const isRetryable = response.status === 429 || response.status >= 500;
    if (!isRetryable || attempt === maxRetries) return response;
    const delay = baseDelay * Math.pow(2, attempt);
    await new Promise(r => setTimeout(r, delay * (0.5 + Math.random() * 0.5)));
  }
}
```

Python

```
import time, random

def with_retry(fn, max_retries=3, base_delay=1.0):
    for attempt in range(max_retries + 1):
        response = fn()
        if response["success"]: return response
        if response["status"] not in (429, 500, 502, 503): return response
        if attempt == max_retries: return response
        delay = base_delay * (2 ** attempt) * (0.5 + random.random() * 0.5)
        time.sleep(delay)
```

GoLang

```
func withRetry(fn func() (*Response, error), maxRetries int) (*Response, error) {
    for attempt := 0; attempt <= maxRetries; attempt++ {
        resp, err := fn()
        if err != nil { return nil, err }
        if resp.Success { return resp, nil }
        if resp.Status != 429 && resp.Status < 500 { return resp, nil }
        if attempt == maxRetries { return resp, nil }
        time.Sleep(time.Duration(math.Pow(2, float64(attempt))) * time.Second)
    }
    return nil, nil
}
```

PHP

```
function withRetry(callable $fn, int $maxRetries = 3, float $baseDelay = 1.0) {
    for ($attempt = 0; $attempt <= $maxRetries; $attempt++) {
        $response = $fn();
        if ($response['success']) return $response;
        if (!in_array($response['status'], [429, 500, 502, 503])) return $response;
        if ($attempt === $maxRetries) return $response;
        usleep((int)($baseDelay * pow(2, $attempt) * 1_000_000));
    }
}
```

.NET

```
async Task<Response> WithRetry(Func<Task<Response>> fn, int maxRetries = 3) {
    for (int attempt = 0; attempt <= maxRetries; attempt++) {
        var response = await fn();
        if (response.Success) return response;
        if (response.Status != 429 && response.Status < 500) return response;
        if (attempt == maxRetries) return response;
        await Task.Delay((int)(Math.Pow(2, attempt) * 1000));
    }
    return null;
}
```

Ruby

```
def with_retry(max_retries: 3, base_delay: 1.0, &block)
  (0..max_retries).each do |attempt|
    response = block.call
    return response if response["success"]
    return response unless [429, 500, 502, 503].include?(response["status"])
    return response if attempt == max_retries
    sleep(base_delay * (2 ** attempt))
  end
end
```

Rust

```
async fn with_retry<F, Fut>(f: F, max_retries: u32) -> Result<Response>
where F: Fn() -> Fut, Fut: Future<Output = Result<Response>> {
    for attempt in 0..=max_retries {
        let resp = f().await?;
        if resp.success { return Ok(resp); }
        if resp.status != 429 && resp.status < 500 { return Ok(resp); }
        if attempt == max_retries { return Ok(resp); }
        tokio::time::sleep(Duration::from_secs(2u64.pow(attempt))).await;
    }
    unreachable!()
}
```

## Best Practices

1. **Batch operations where possible:** Some endpoints accept bulk inputs. Use them instead of making many individual requests.
2. **Use pagination for list endpoints:** Most list endpoints support `page` and `limit` parameters. Fetch only the data you need.
3. **Cache responses when appropriate:** Data that changes infrequently (group settings, brand registrations) can be cached to reduce API calls.
4. **Use webhooks instead of polling:** For asynchronous outcomes (message delivery, number porting), configure webhooks for real-time updates.

## Summary

| Strategy | Impact |
| --- | --- |
| Exponential backoff | Recovers from transient 429/5xx errors |
| Batch operations | Fewer requests for the same work |
| Pagination | Fetch only what you need per request |
| Client-side caching | Eliminates redundant calls |
| Webhooks over polling | Removes repetitive status-check requests |
