# Set the rate limit of an app

> Set the most requests Stacksync makes to one app of the sync per period. The sync may stay on. Leave rate limits at Stacksync's default unless the app asks for less.

Source: https://docs.stacksync.com/api-reference/syncs/set_sync_app_rate_limit

`POST https://api.stacksync.com/v1/workspaces/{workspace_id}/bases/{base_id}/apps/{app_id}/rate-limit`

- Operation: `set_sync_app_rate_limit`
- Resource: Syncs
- Access: writes data

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.
- `Content-Type: application/json` on every request with a body.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace the resources belong to |
| `base_id` | string (uuid) | Yes | The sync (a sync is called a base in these paths) |
| `app_id` | string | Yes | One of the two apps of the sync, by its app_id (read it from the sync) |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) | Yes | Data region of the sync |

## Request body

`application/json`. The rate limit

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rate` | integer, 1 to 2147483647 | Yes | The number of requests allowed per period, 1 to 2147483647 |
| `frequency` | integer (1 \| 60 \| 3600 \| 86400), default 1 | No | The period of the rate in seconds: 1 (per second), 60, 3600 or 86400; per second when left out |

## Returns

### 200 The rate limit stored

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object (SyncRateLimit) | Yes | The most requests Stacksync makes to the app in a period |
| `data.rate` | integer, 1 to 2147483647 | Yes | The number of requests allowed per period, 1 to 2147483647 |
| `data.frequency` | integer (1 \| 60 \| 3600 \| 86400) | Yes | The period of the rate in seconds: 1 (per second), 60 (per minute), 3600 (per hour) or 86400 (per day) |

## Example request

```bash
curl -X POST "https://api.stacksync.com/v1/workspaces/{workspace_id}/bases/{base_id}/apps/{app_id}/rate-limit?region=besg" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "rate": 20,
  "frequency": 1
}'
```

## Example response (200)

```json
{
  "data": {
    "rate": 20,
    "frequency": 1
  }
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | The `region` is missing or not one of besg, usnv; the body is not valid JSON; `rate` is missing or not an integer (`Invalid Request Body`); `rate` is below 1 or above 2147483647, or `frequency` is not 1, 60, 3600 or 86400 (`Error validating rate limit`); the sync does not exist in the workspace (`Error retrieving base schema`); `app_id` is not an app of the sync (`Error retrieving app schema`); the rate limit could not be stored (`Error updating the app rate limit`) | `{ "error": string }` |
| 403 | Forbidden: invalid API key, API key of another workspace, insufficient scope, workspace unavailable, or a non-GET request without `Content-Type: application/json` | `{ "error": string }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List syncs](https://docs.stacksync.com/api-reference/syncs/list_syncs)
- [Get a sync](https://docs.stacksync.com/api-reference/syncs/get_sync)
- [Get the status of a sync](https://docs.stacksync.com/api-reference/syncs/get_sync_status)
- [Get sync metrics](https://docs.stacksync.com/api-reference/syncs/get_sync_metrics)
- [Get sync diagnostics](https://docs.stacksync.com/api-reference/syncs/get_sync_diagnostics)
- [Create a sync](https://docs.stacksync.com/api-reference/syncs/create_sync)
- [Update sync settings](https://docs.stacksync.com/api-reference/syncs/update_sync_settings)
- [Edit a sync](https://docs.stacksync.com/api-reference/syncs/edit_sync)
- [Delete a sync](https://docs.stacksync.com/api-reference/syncs/delete_sync)
- [Rename a sync](https://docs.stacksync.com/api-reference/syncs/rename_sync)
- [Switch a sync on or off](https://docs.stacksync.com/api-reference/syncs/switch_sync)
- [Set the change capture method](https://docs.stacksync.com/api-reference/syncs/set_sync_app_cdc_method)
- [Set Salesforce Bulk API access](https://docs.stacksync.com/api-reference/syncs/set_sync_app_bulk_api_access)
- [Set delete protection of an app](https://docs.stacksync.com/api-reference/syncs/set_sync_app_delete_protection)