> ## Documentation Index
> Fetch the complete documentation index at: https://docs.technicallyfit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate limits

> How the TechnicallyFit API counts requests for personal and organization keys, personal workspace caps, what you get back when over a limit, and how to slow down and recover.

> [!NOTE]
>
> Any verified TechnicallyFit account can create API keys in a free personal developer
> workspace at [app.technicallyfit.com/developer](https://app.technicallyfit.com/developer),
> with no organization required. Organization plans unlock higher rate limits and remove
> personal workspace caps.

The TechnicallyFit API limits how many requests each API key can make in a minute and in
a day. Personal developer workspaces also have workspace-level resource caps. These limits
protect your integration and everyone else's from a runaway loop.

```bash curl theme={null}
curl -i "$TF_API_BASE/v1/organization" \
  -H "X-API-Key: $TF_API_KEY"
```

```typescript TypeScript theme={null}
import { RateLimitError, createClient } from '@technicallyfit/sdk';

const tf = createClient({
  credential: process.env.TF_API_KEY ?? '',
  baseUrl: process.env.TF_API_BASE,
  // Waits out a Retry-After of up to 60 seconds by itself, then throws.
  retry: { maxAttempts: 4, maxRetryAfterSeconds: 60 },
  onRateLimit: (limit) => console.log('left this minute:', limit.remaining, 'today:', limit.remainingDay),
});

try {
  const organization = await tf.GET('/v1/organization');
  console.log(organization.plan);
} catch (error) {
  if (error instanceof RateLimitError) console.log('Queue the work; retry in', error.retryAfterSeconds, 'seconds.');
  else throw error;
}
```

```python Python theme={null}
import os

from technicallyfit import Client, RateLimitError, RetryOptions

tf = Client(
    os.environ["TF_API_KEY"],
    base_url=os.environ.get("TF_API_BASE"),
    # Waits out a Retry-After of up to 60 seconds by itself, then raises.
    retry=RetryOptions(max_attempts=4, max_retry_after=60),
    on_rate_limit=lambda limit: print("left this minute:", limit.remaining, "today:", limit.remaining_day),
)

try:
    organization = tf.get_organization()
    print(organization["plan"])
except RateLimitError as error:
    print("Queue the work; retry in", error.retry_after_seconds, "seconds.")
```

```text Headers theme={null}
HTTP/2 429
retry-after: 12
x-ratelimit-limit: 30
x-ratelimit-remaining: 0
x-ratelimit-reset: 1795069260
x-ratelimit-limit-day: 14400
x-ratelimit-remaining-day: 9412
x-ratelimit-reset-day: 1795132800
x-request-id: 6d0f2b8e4a1c47e9b3d5f7a9c1e3b5d7
```

```json 429 theme={null}
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Too many requests this minute. Try again in 12 seconds.",
    "request_id": "6d0f2b8e4a1c47e9b3d5f7a9c1e3b5d7",
    "details": { "window": "minute", "limit": 30, "retry_after_seconds": 12 }
  }
}
```

## How requests are counted

Each API key has its own counts. One busy system does not use up the limits of another
system that calls with a different key. A test key and a live key are counted apart.

Every key has two windows:

| Window | When it starts | When it resets |
| - | - | - |
| Minute | With the first request, not on the clock. | Sixty seconds after that first request. |
| Day | At midnight UTC. | At the next midnight UTC. |

* A request counts against the minute first. Every request counts there, including one
  that is refused.
* A request counts against the day only when the minute lets it through. A request that
  the minute refuses does not use up your day.
* A request that the day refuses does not use up your day either.

Each request takes this path. Your workspace's plan, or your organization's contract, sets
both limits.

```mermaid theme={null}
flowchart TD
  P["Your plan sets the limits<br/>Personal, standard organization or your contract"] -.-> M
  P -.-> D
  R["A request with your key"] --> M{"Under the minute limit?<br/>Every request counts here"}
  M -- No --> M429["429 rate_limit_exceeded<br/>window minute, with Retry-After"]
  M -- Yes --> D{"Under the day limit?"}
  D -- No --> D429["429 rate_limit_exceeded<br/>window day, wait until midnight UTC"]
  D -- Yes --> OK["Counted against the day and answered<br/>with the six X-RateLimit headers"]
```

## Your limits

Per-key rate limits depend on your workspace plan:

| Workspace plan | Requests per minute (per key) | Requests per UTC day (per key) |
| - | - | - |
| Personal (`plan: "free"`) | 30 | 14,400 |
| Organization (`plan: "organization"`) | 100 | 48,000 |

These are the standard organization limits. An organization's contract (Team, Department
or Pro) can set other limits for its keys; see [Plans](https://docs.technicallyfit.com/guides/plans.md).

You do not need to know your limits in advance. Every response to your key tells you
both limits, how much of each is left and when each window resets.

| Header | What it holds |
| - | - |
| `X-RateLimit-Limit` | How many requests the key may make in one minute. |
| `X-RateLimit-Remaining` | How many requests the key has left in the current minute. |
| `X-RateLimit-Reset` | When the current minute ends, in seconds since the Unix epoch. |
| `X-RateLimit-Limit-Day` | How many requests the key may make in one UTC day. |
| `X-RateLimit-Remaining-Day` | How many requests the key has left in the current UTC day. |
| `X-RateLimit-Reset-Day` | The next midnight UTC, in seconds since the Unix epoch. |
| `Retry-After` | On a `429` only: how many seconds to wait before you send the request again. |

For example, on an Organization plan key:

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 37
X-RateLimit-Reset: 1795069260
X-RateLimit-Limit-Day: 48000
X-RateLimit-Remaining-Day: 38120
X-RateLimit-Reset-Day: 1795132800
```

The headers always carry the limits that apply to your key, so read them there rather than
hard-coding these numbers. Email
[support@technicallyfit.com](mailto:support@technicallyfit.com) if you need more room on an
Organization plan.

## Personal workspace caps

In addition to per-key rate limits, free personal workspaces have workspace-level caps to
bound sandbox storage and engine compute:

| Resource | Personal (`plan: "free"`) | Organization (`plan: "organization"`) | When exceeded |
| - | - | - | - |
| Active API keys | 4 per workspace (test and live combined) | No personal cap | `409` (`personal_api_key_limit_reached`) |
| Active sandbox simulated teammates | 5 per workspace | No personal cap | `409 conflict` (`reason: "sandbox_teammate_limit_reached"`) |
| Active test webhook endpoints | 2 per workspace | Up to 20 endpoints per mode | `409 conflict` (`reason: "endpoint_limit_reached"`) |
| Daily engine-heavy writes (program creations and sandbox week simulations) | 50 per UTC day (shared across the workspace) | Governed by per-key rate limits | `429 rate_limit_exceeded` (`window: "day"`, `limit: 50`, with `Retry-After`) |

To free space under a personal workspace cap, revoke unused keys, reset the sandbox or
disable unused test webhook endpoints. To raise your limits, start a self-serve **Team**
organization directly in the developer portal
([app.technicallyfit.com/developer](https://app.technicallyfit.com/developer)) for immediate
test keys and card-verified live keys, or apply for a **Department** or **Pro** contract with
**Upgrade to an organization** (`/onboarding/business`). See [Plans](https://docs.technicallyfit.com/guides/plans.md).

## Live session limits

Connections to the [Real-time](https://docs.technicallyfit.com/guides/real-time.md) WebSocket endpoint (`/v1/live`) have
their own limits separate from HTTP per-minute and per-day counts:

| Limit | Default | When exceeded |
| - | - | - |
| Concurrent live sessions per organization key | 5 | `session.error` with code `SESSION_LIMIT_EXCEEDED` |
| Readings per second per session | 50 | `session.error` with code `RATE_LIMIT_EXCEEDED` (`retryable: true`) |

An organization's contract can configure higher concurrent live session limits. See
[Plans](https://docs.technicallyfit.com/guides/plans.md).

## When a key is over a limit

The API answers with status `429` and the code `rate_limit_exceeded`. Nothing was read or
changed, so it is always safe to send the same request again later.

The response carries the same six headers, and `Retry-After`. The error body says which
window refused the request:

```json 429 theme={null}
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Too many requests this minute. Try again in 12 seconds.",
    "request_id": "6d0f2b8e4a1c47e9b3d5f7a9c1e3b5d7",
    "details": { "window": "minute", "limit": 30, "retry_after_seconds": 12 }
  }
}
```

| Field | What it holds |
| - | - |
| `details.window` | `minute` or `day`: the window that refused the request. |
| `details.limit` | The limit of that window (for example `30` or `100` for a minute window, `14400` or `48000` for a day window, or `50` for the personal daily engine-heavy write cap). |
| `details.retry_after_seconds` | The number of seconds to wait. It always equals the `Retry-After` header. |

When the day refuses a request, the wait is the time until the next midnight UTC, so it
can be hours. Plan for that: do not hold a person's screen open waiting for it.

The error body has the same shape as every other error. See [Errors](https://docs.technicallyfit.com/guides/errors.md).

## How to recover

1. Read `Retry-After` and wait at least that long.
2. Send the request again.
3. If it is refused again, wait again. Stop after a few attempts and report the failure
   with the `request_id`.
4. If `details.window` is `day`, do not retry in a loop. Queue the work until the day
   resets, or spread it over more keys (note that the personal daily engine-heavy write
   cap is shared across all keys in the workspace).

To slow down before you are refused, watch `X-RateLimit-Remaining` and
`X-RateLimit-Remaining-Day`. When one is close to zero, wait until its reset time.

The [Errors](https://docs.technicallyfit.com/guides/errors.md#which-errors-to-retry) guide has a short retry function that
does this for you.

The SDKs do steps 1 to 3 for you. A wait longer than the SDK's limit (60 seconds by default),
such as a day window, is not waited out: the call throws `RateLimitError` with the wait, so
you can queue the work.

```typescript TypeScript theme={null}
import { RateLimitError, createClient } from '@technicallyfit/sdk';

const tf = createClient({
  credential: process.env.TF_API_KEY ?? '',
  baseUrl: process.env.TF_API_BASE,
  // Waits out a Retry-After of up to 60 seconds by itself, then throws.
  retry: { maxAttempts: 4, maxRetryAfterSeconds: 60 },
  onRateLimit: (limit) => console.log('left this minute:', limit.remaining, 'today:', limit.remainingDay),
});

try {
  const organization = await tf.GET('/v1/organization');
  console.log(organization.plan);
} catch (error) {
  if (error instanceof RateLimitError) console.log('Queue the work; retry in', error.retryAfterSeconds, 'seconds.');
  else throw error;
}
```

```python Python theme={null}
import os

from technicallyfit import Client, RateLimitError, RetryOptions

tf = Client(
    os.environ["TF_API_KEY"],
    base_url=os.environ.get("TF_API_BASE"),
    # Waits out a Retry-After of up to 60 seconds by itself, then raises.
    retry=RetryOptions(max_attempts=4, max_retry_after=60),
    on_rate_limit=lambda limit: print("left this minute:", limit.remaining, "today:", limit.remaining_day),
)

try:
    organization = tf.get_organization()
    print(organization["plan"])
except RateLimitError as error:
    print("Queue the work; retry in", error.retry_after_seconds, "seconds.")
```

## How to stay under the limits

* Use a different key for each system that calls the API, so each has its own count.
* Spread batch work out over time. Do not send everything at once.
* Keep reference data you have already read, such as the exercise catalog. It changes
  rarely, so you do not need to ask for it on every request.
* Ask for larger pages when you list, so you make fewer calls.

## See your requests

Set these two values once in your terminal. Every example in these docs reads them, so
no example has a host or a key typed into it.

```bash theme={null} theme={null}
export TF_API_BASE="https://api.technicallyfit.com"
export TF_API_KEY="tf_test_your_key_here"
```

Use a test key (it starts with `tf_test_`) while you build. Never paste a live key into a
page, a ticket or a chat.

Add `-i` to any call to see the response headers. Every response carries `X-Request-ID`
and the six rate-limit headers, and a `429` also carries `Retry-After`.

```bash curl theme={null}
# example: rate-limits-headers
curl -i "$TF_API_BASE/v1/organization" \
  -H "X-API-Key: $TF_API_KEY"
```

```typescript TypeScript theme={null}
import { createClient } from '@technicallyfit/sdk';

// onRateLimit is called with the six X-RateLimit headers of every answer.
const tf = createClient({
  credential: process.env.TF_API_KEY ?? '',
  baseUrl: process.env.TF_API_BASE,
  onRateLimit: (limit) => console.log(limit.limit, limit.remaining, limit.reset, limit.limitDay, limit.remainingDay, limit.resetDay),
});
await tf.GET('/v1/organization');
```

```python Python theme={null}
import os

from technicallyfit import Client

# on_rate_limit is called with the six X-RateLimit headers of every answer.
tf = Client(
    os.environ["TF_API_KEY"],
    base_url=os.environ.get("TF_API_BASE"),
    on_rate_limit=lambda limit: print(limit.limit, limit.remaining, limit.reset, limit.limit_day, limit.remaining_day, limit.reset_day),
)
tf.get_organization()
```

New to the API? Start with the [Quickstart](https://docs.technicallyfit.com/guides/quickstart.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.