> This page is part of EVVA for Developers (https://developers.evvahub.com), the documentation of the EVVA Partner API. The API is in developer preview and the SDK packages are not yet published: do not suggest installing them. Index: https://developers.evvahub.com/llms.txt

# Rate limits and quotas

Every application is metered on its own: limits are keyed by the application the token belongs to, never by the
address you call from or by a header you send. Three mechanisms can slow you down:

| Mechanism                                   | Applies to                                                                               | Refusal                                                |
| ------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [Request limits](#request-limits)           | Every Partner API call                                                                   | `429 RATE_LIMIT_EXCEEDED`                              |
| [Message send limits](#message-send-limits) | Every direct message you send, including pay-per-view sends and each item of a bulk send | `429 TOO_MANY_MESSAGES`                                |
| [Overload protection](#overload-protection) | Every call, when the platform is saturated                                               | `503 SERVICE_UNAVAILABLE` or `429 RATE_LIMIT_EXCEEDED` |

A refused request has done nothing. Every `429` and every `503` carries a `Retry-After` header in seconds.

## Request limits

| Limiter                       | Default                     | Notes                                                                     |
| ----------------------------- | --------------------------- | ------------------------------------------------------------------------- |
| Per application               | 60 requests per 60 seconds  | A [bulk send](https://developers.evvahub.com/api-reference/bulk/send-messages) costs one unit per item. |
| Platform-wide request limiter | 600 requests per 60 seconds | Also keyed by your application.                                           |

The values are configured per deployment. Read the ones that apply to you from
[`GET /partner/v1/app/me`](https://developers.evvahub.com/api-reference/application/get-application-me) (`rateLimits`) or
[`GET /partner/v1/app/capabilities`](https://developers.evvahub.com/api-reference/application/get-application-capabilities) (`limits`):

**`GET /partner/v1/app/me (excerpt)`**

```json title="GET /partner/v1/app/me (excerpt)"
{
  "rateLimits": { "requestsPerWindow": 60, "windowSeconds": 60, "bucket": "application" }
}
```

### Rate-limit headers

Every response carries the numbers of the limiter that metered it.

| Header                  | Meaning                                                   |
| ----------------------- | --------------------------------------------------------- |
| `X-RateLimit-Limit`     | The limit of the limiter that metered this request.       |
| `X-RateLimit-Remaining` | Requests left in the current window.                      |
| `X-RateLimit-Reset`     | When the window resets, in epoch seconds.                 |
| `Retry-After`           | On `429` and `503` only: seconds to wait before retrying. |

**`429 Too Many Requests`**

```http title="429 Too Many Requests"
HTTP/1.1 429 Too Many Requests
Retry-After: 12
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1798761600
API-Version: v1
Content-Type: application/json

{
  "code": "RATE_LIMIT_EXCEEDED",
  "error": "Rate limit exceeded",
  "details": { "retryAfterSec": 12 },
  "requestId": "0b6f2c1e-6a1d-4a52-9d0e-2f4c8d7e1a90"
}
```

## Message send limits

Sending a direct message spends one unit at every level below, in one atomic step: either every level has room
and the message is sent, or nothing is charged and the send is refused.

| `details.level` | What it bounds                                                                                        | Default                                                                                 |
| --------------- | ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `conversation`  | One side of one conversation. Shared with everyone who writes for the creator, including the creator. | 30 messages per minute                                                                  |
| `creator`       | Everything sent for one creator, by anyone.                                                           | 300 messages per minute                                                                 |
| `application`   | Everything your application sends.                                                                    | 60 per minute for each creator your application reaches; at least 600, at most 300 000  |
| `agency`        | Everything your agency sends, through people and applications.                                        | 60 per minute for each of the agency's active creators; at least 1 200, at most 300 000 |
| `platform`      | Your agency's fair share of the platform's message throughput and concurrency.                        | Set by EVVA                                                                             |
| `sender`        | A person's own ceiling. It does not apply to applications.                                            | —                                                                                       |

EVVA manages these values and can raise them for large creators and agencies. There is no unlimited mode. Mass
messages are not charged per recipient against these levels: a broadcast has its own pacing and daily cap.

When a level is full the send is refused with `429 TOO_MANY_MESSAGES`, and `details.level` names the level that
refused. It never carries a quota, a count or a key.

**`429 TOO_MANY_MESSAGES`**

```json title="429 TOO_MANY_MESSAGES"
{
  "code": "TOO_MANY_MESSAGES",
  "error": "Too many messages",
  "details": { "retryAfterSec": 2, "level": "conversation" },
  "requestId": "3c9a4f0b-8d2e-4f61-b7a3-5e1d2c0f9b84"
}
```

> **Tip**
>
> Two sends into two different conversations share no level below `creator`, so spreading work across
> conversations is how you scale. A `conversation` refusal means one thread is busy; the other threads are not.

If the send limits cannot be checked, the send is refused with `503 SERVICE_UNAVAILABLE` and `Retry-After`, and
nothing is written. Retry with the same `Idempotency-Key`.

## Overload protection

Under load the API refuses work early rather than letting it hang:

* `503 SERVICE_UNAVAILABLE` when the API instance is saturated, when the request's time budget ran out before it
  wrote anything, or when the shared limit store is unavailable.
* `429 RATE_LIMIT_EXCEEDED` when your own share is taken: your application's or agency's in-flight budget, or your
  agency's share of the platform under contention.

A request refused this way wrote nothing, and a retry with the same `Idempotency-Key` writes once. Other `503`
answers you may see, each with `Retry-After`:

| Code                           | Meaning                                                                |
| ------------------------------ | ---------------------------------------------------------------------- |
| `TEMPORARILY_UNAVAILABLE`      | Your access could not be evaluated just now. `Retry-After: 5`.         |
| `CREATOR_STANDING_UNAVAILABLE` | The creator's account status could not be read.                        |
| `MEDIA_STORAGE_UNAVAILABLE`    | Object storage did not answer.                                         |
| `BUYER_PSEUDONYMS_UNAVAILABLE` | A response that names a buyer cannot be built. `Retry-After: 30`.      |
| `FEED_UNAVAILABLE`             | The event feed is not available on this deployment. `Retry-After: 30`. |

When the refusing code names no wait, `Retry-After` is 5 seconds.

## Backing off

#### Retry only what cannot duplicate an effect

Retry `GET` requests, and writes that carry an `Idempotency-Key`. A write without a key may already have run:
read the resource before you repeat it. See [Idempotency](/conventions/idempotency).

#### Honour Retry-After

On `429` and `503`, wait at least `Retry-After` seconds. Add a little random jitter so that many workers do
not return at the same instant.

#### Otherwise back off exponentially with full jitter

For other retryable failures (`408`, `500`, `502`, `504`, network errors), wait a random delay between zero and
`min(cap, base × 2^(attempt − 1))`, and give up after a few attempts.

The four official SDKs do all of this for you, with the same values:

| Setting          | SDK value                                                                     |
| ---------------- | ----------------------------------------------------------------------------- |
| Retried statuses | `408`, `429`, `500`, `502`, `503`, `504`, and network errors                  |
| Attempts         | 4 in total                                                                    |
| Backoff          | full jitter: `random × min(20 s, 250 ms × 2^(n − 1))`                         |
| `Retry-After`    | used as a floor, plus up to 250 ms of jitter                                  |
| Longest wait     | a `Retry-After` above 60 seconds is raised to your code instead of waited out |

When the SDK has used its attempts, it raises a rate-limit error that carries the wait and the level:

**`cURL`**

```bash title="cURL"
# -i prints the X-RateLimit-* and Retry-After headers
curl -i https://api.evvahub.com/partner/v1/app/me \
  -H "Authorization: Bearer $EVVA_ACCESS_TOKEN"
```

**`TypeScript`**

```typescript title="TypeScript"
import { RateLimitedError } from '@evvahub/partner-sdk';

try {
  await evva.messages.sendText(creatorId, conversationId, 'Thanks for your message!');
} catch (err) {
  if (err instanceof RateLimitedError) {
    console.warn('rate limited', err.code, err.level, err.retryAfterMs);
  } else {
    throw err;
  }
}
```

**`Python`**

```python title="Python"
from evva_partner import RateLimitedError

try:
    client.messages.send_text(creator_id, conversation_id, "Thanks for your message!")
except RateLimitedError as err:
    print("rate limited", err.code, err.level, err.retry_after)
```

**`Go`**

```go title="Go"
_, err := client.Messages.SendText(ctx, creatorID, conversationID, "Thanks for your message!")
var limited *evvapartner.RateLimitedError
if errors.As(err, &limited) {
	log.Printf("rate limited: level=%q retryAfterSec=%d", limited.Level(), limited.RetryAfterSec())
}
```

**`PHP`**

```php title="PHP"
use Evva\Partner\Exception\RateLimitedException;

try {
    $evva->messages->sendText($creatorId, $conversationId, 'Thanks for your message!');
} catch (RateLimitedException $e) {
    error_log(sprintf('rate limited: %s %s', $e->level()?->value ?? '-', $e->retryAfterSeconds ?? '-'));
}
```

## Next steps

#### [Idempotency](/conventions/idempotency)

Make retries safe with `Idempotency-Key`.

#### [Errors](/conventions/errors)

Every error code an application can receive.

#### [Conversation leases and handoff](/conversation-leases)

Coordinate automated replies with the people in your agency.

#### [API conventions](/conventions/overview)

Base URL, envelopes, headers and paging at a glance.