# Create a restriction

> Source: https://elaichi.ai/docs/api-reference/restrictions/restriction/createrestriction/

`POST /restriction`

Resource: **Restriction** · API: **Restrictions**

## Request body

- **`effect`** _(string)_
  Allowed: `allow`, `block`
- **`target_type`** _(string)_
  Allowed: `connector`, `tool`
- **`connector_slug`** _(string)_
- **`tool_name`** _(string)_
- **`role_ids`** _(array<string>)_
- **`user_ids`** _(array<string>)_

## Code examples

### curl

```bash
curl -X POST 'https://api.elaichi.ai/restriction' \
  -H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"effect":"allow","target_type":"connector","connector_slug":"your_connector_slug","tool_name":"your_tool_name","role_ids":[],"user_ids":[]}'
```

### JavaScript

```javascript
const body = {
  "effect": "allow",
  "target_type": "connector",
  "connector_slug": "your_connector_slug",
  "tool_name": "your_tool_name",
  "role_ids": [],
  "user_ids": []
};

const response = await fetch('https://api.elaichi.ai/restriction', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + process.env.ELAICHI_API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import os
import requests

url = "https://api.elaichi.ai/restriction"
headers = {
    "Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
    "Content-Type": "application/json",
}
payload = {
    "effect": "allow",
    "target_type": "connector",
    "connector_slug": "your_connector_slug",
    "tool_name": "your_tool_name",
    "role_ids": [],
    "user_ids": []
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```
