> For the complete documentation index, see [llms.txt](https://developer.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.mediarithmics.io/advanced-usages/plugins/throttling.md).

# Throttling

Some plugins call external providers that embedded API limitations. Because some plugins have trouble handling errors when limits are reached, we may want to reduce plugin calls before reaching those limits.

Using *Throttlings*, you can limit usage of a given plugin version, in 3 different ways :&#x20;

* Rate limit :  you can limit the number of calls by second, by using `max_qps` field.
* Concurrency : you can limit the number of simultaneous calls, by using `max_concurrency` field.
* Timeout : you can define a maximum duration for the calls, by using `timeout_qps` field.

{% hint style="warning" %}
You have to define at least one of those restrictions.
{% endhint %}

*Throttling* can be defined at 4 different levels :&#x20;

* GLOBAL
* CONTAINER
* ORGANISATION
* DATAMART

You can define a *Throttling* using this route :

## Create a throttling

<mark style="color:green;">`POST`</mark> `https://api.mediarithmics.com/v1/plugins/:plugin_id/versions/:version_id/throttlings`

#### Request Body

| Name                                                  | Type    | Description                                                                                                             |
| ----------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
| scope<mark style="color:red;">\*</mark>               | String  | Define the application scope of the Throttling. Possible values : GLOBAL, CONTAINER, DATAMART or ORGANISATION.          |
| plugin\_version\_id<mark style="color:red;">\*</mark> | String  | The ID of the plugin version.                                                                                           |
| throttling\_key                                       | String  | Is equals to the datamart id if the scope is DATAMART or the organisation id if the scope is ORGANISATION.              |
| max\_concurrency                                      | Integer | The maximum number of simultaneous calls to the end\_point.                                                             |
| max\_qps                                              | Double  | The maximum number of calls to the end\_point by second. It can be decimal, 0.5 means : maximum 1 call every 2 seconds. |
| plugin\_endpoint<mark style="color:red;">\*</mark>    | String  | The plugin routes affected by this throttling. Exemple : `/v1/user_segment_update`                                      |
| timeout\_ms                                           | Integer | The call to the endpoint is killed if it lasts more than this duration (in ms).                                         |

{% tabs %}
{% tab title="201: Created " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

You can list, delete or update Throttlings by using thoses routes :

## Get throttlings for the Plugin Version

<mark style="color:blue;">`GET`</mark> `https://api.mediarithmics.com/v1/plugins/:plugin_id/versions/:version_id/throttlings`

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Delete a throttling

<mark style="color:red;">`DELETE`</mark> `https://api.mediarithmics.com/v1/plugins/:plugin_id/versions/:version_id/throttlings/:throttling_id`

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

## Update a throttling

<mark style="color:orange;">`PUT`</mark> `https://api.mediarithmics.com/v1/plugins/:plugin_id/versions/:version_id/throttlings/:throttling_id`

#### Request Body

| Name                                               | Type    | Description                                                                                                             |
| -------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
| scope<mark style="color:red;">\*</mark>            | String  | Define the application scope of the Throttling. Possible values : GLOBAL, CONTAINER, DATAMART or ORGANISATION.          |
| throttling\_key                                    | String  | Is equals to the datamart id if the scope is DATAMART or the organisation id if the scope is ORGANISATION.              |
| max\_concurrency                                   | Integer | The maximum number of simultaneous calls to the end\_point.                                                             |
| max\_qps                                           | Double  | The maximum number of calls to the end\_point by second. It can be decimal, 0.5 means : maximum 1 call every 2 seconds. |
| plugin\_endpoint<mark style="color:red;">\*</mark> | String  | The plugin routes affected by this throttling. Exemple : `/v1/user_segment_update`                                      |
| timeout\_ms                                        | Integer | The call to the endpoint is killed if it lasts more than this duration (in ms).                                         |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.mediarithmics.io/advanced-usages/plugins/throttling.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
