# Rate limits

> What a 429 means, how long to wait, and which operations have limits.

Source: https://legion.ambient.xyz/docs/api/rate-limits

Some operations limit how often your organization, or you, can call them. Over a limit, the API answers `429 Too Many Requests`.

## What a 429 looks like

- `code` is `rate_limited`.
- The `Retry-After` header says how many seconds to wait.

`inspectImage` and `createRental` can also answer `429 mirror_quota_exceeded`: your organization asked Legion to copy in too many different tags or digests of one image repository today. Use a tag you've used before, or wait until tomorrow (UTC).

## What to do

- Wait at least `Retry-After` seconds, then try again.
- For an operation that takes an `Idempotency-Key`, retry with the same key. See [Idempotency](https://legion.ambient.xyz/docs/api/idempotency).
- Don't retry in a tight loop. Add jitter if several workers share a key.

## Operations with limits

These operations can answer `429`. Each one's reference page says what its limit is.

- [Rent GPUs on a host](https://legion.ambient.xyz/docs/api/rentals/create-rental) `POST /v1/rentals`
- [Change a rental's settings](https://legion.ambient.xyz/docs/api/rentals/update-rental) `PATCH /v1/rentals/{rental_id}`
- [Delete a rental and its workspace](https://legion.ambient.xyz/docs/api/rentals/delete-rental) `DELETE /v1/rentals/{rental_id}`
- [What the rental's network blocked or would have blocked in the last 24 hours](https://legion.ambient.xyz/docs/api/rentals/get-rental-network-activity) `GET /v1/rentals/{rental_id}/network/activity`
- [Read a rental's logs](https://legion.ambient.xyz/docs/api/rentals/get-rental-logs) `GET /v1/rentals/{rental_id}/logs`
- [Stop a rental](https://legion.ambient.xyz/docs/api/rentals/stop-rental) `POST /v1/rentals/{rental_id}/stop`
- [Export a stopped rental's workspace](https://legion.ambient.xyz/docs/api/rentals/create-workspace-export) `POST /v1/rentals/{rental_id}/workspace-exports`
- [Back up a stopped or failed rental's workspace](https://legion.ambient.xyz/docs/api/rentals/create-rental-backup) `POST /v1/rentals/{rental_id}/backups`
- [Mint a download link for a ready backup](https://legion.ambient.xyz/docs/api/rentals/create-backup-download-link) `POST /v1/backups/{backup_id}/download-links`
- [Create a service](https://legion.ambient.xyz/docs/api/services/create-service) `POST /v1/services`
- [Create a service key](https://legion.ambient.xyz/docs/api/services/create-service-key) `POST /v1/services/{service_id}/keys`
- [Rotate a service key](https://legion.ambient.xyz/docs/api/services/rotate-service-key) `POST /v1/services/{service_id}/keys/{key_id}/rotate`
- [Read a service's logs, every replica](https://legion.ambient.xyz/docs/api/services/get-service-logs) `GET /v1/services/{service_id}/logs`
- [Inspect a container image before renting it](https://legion.ambient.xyz/docs/api/images/inspect-image) `POST /v1/images/inspect`
- [Save the organization's sign-in for a registry](https://legion.ambient.xyz/docs/api/images/put-registry-sign-in) `PUT /v1/registry-sign-ins/{registry}`
- [Save a registry credential](https://legion.ambient.xyz/docs/api/images/create-registry-credential) `POST /v1/registry-credentials`
- [Rename a registry credential or replace its secret](https://legion.ambient.xyz/docs/api/images/update-registry-credential) `PATCH /v1/registry-credentials/{credential_id}`
- [Top up the organization's balance](https://legion.ambient.xyz/docs/api/billing/create-top-up) `POST /v1/billing/top-ups`
- [Turn auto top-up on or off and set its amounts](https://legion.ambient.xyz/docs/api/billing/put-auto-top-up) `PUT /v1/billing/auto-top-up`
- [Save or replace the card auto top-up charges](https://legion.ambient.xyz/docs/api/billing/create-auto-top-up-card) `POST /v1/billing/auto-top-up/card`
- [Refund unused credit to the cards and bank accounts it came from](https://legion.ambient.xyz/docs/api/billing/create-credit-refund) `POST /v1/billing/credit-refunds`
- [Check what a promo code gives the organization](https://legion.ambient.xyz/docs/api/billing/preview-promo-code) `POST /v1/billing/promo-codes/preview`
- [Redeem a promo code](https://legion.ambient.xyz/docs/api/billing/redeem-promo-code) `POST /v1/billing/promo-codes/redeem`
- [Ask for a destination to be added to the allow-list](https://legion.ambient.xyz/docs/api/network/create-egress-request) `POST /v1/egress-requests`
- [Schedule maintenance on one or many hosts](https://legion.ambient.xyz/docs/api/hosts/schedule-maintenance) `POST /v1/maintenance-windows`
- [Move or change scheduled maintenance windows](https://legion.ambient.xyz/docs/api/hosts/reschedule-maintenance) `POST /v1/maintenance-windows/reschedule`
- [Cancel scheduled maintenance windows](https://legion.ambient.xyz/docs/api/hosts/cancel-maintenance) `POST /v1/maintenance-windows/cancel`
- [End active maintenance windows now ("done with maintenance")](https://legion.ambient.xyz/docs/api/hosts/end-maintenance) `POST /v1/maintenance-windows/end`
- [Ask your host to benchmark again](https://legion.ambient.xyz/docs/api/hosts/request-host-benchmark) `POST /v1/hosts/{host_id}/benchmark-request`
- [A host's network state and the abuse flags raised on its rentals](https://legion.ambient.xyz/docs/api/hosts/get-host-network) `GET /v1/hosts/{host_id}/network`
- [Invite a person to the organization](https://legion.ambient.xyz/docs/api/identity/create-invitation) `POST /v1/invitations`
- [Email an invitation again](https://legion.ambient.xyz/docs/api/identity/resend-invitation) `POST /v1/invitations/{invitation_id}/resend`
- [What GPUs can be rented now, and from what price (public)](https://legion.ambient.xyz/docs/api/public/get-public-market) `GET /api/public/market`
