Block access to tasks
You can block a user's access to one or more projects. This lets you control which users will complete tasks. For example, you can select users with a skill value lower than N and block their access to tasks. You can also unblock access.
Block access to tasks
To block a user from accessing tasks, send a PUT request to the /user-restrictions
resource.
Request
PUT /api/v1/user-restrictions
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
Content-Type: application/JSON
{
"scope": "PROJECT",
"user_id": "f25a5f41-94e8-49bf-977f-3611087a16b3",
"project_id": "10",
"private_comment": "Too many mistakes",
"will_expire": "2016-04-10T18:08:07"
}
PUT /api/v1/user-restrictions
Host: https://toloka.yandex.ru
Authorization: OAuth <OAuth token>
Content-Type: application/JSON
{
"scope": "PROJECT",
"user_id": "f25a5f41-94e8-49bf-977f-3611087a16b3",
"project_id": "10",
"private_comment": "Too many mistakes",
"will_expire": "2016-04-10T18:08:07"
}
ALL_PROJECTS
— All the requester's projects.PROJECT
— A single project (specify theproject_id
).POOL
— A pool (specify thepool_id
).ALL_PROJECTS
— All the requester's projects.PROJECT
— A single project (specify theproject_id
).POOL
— A pool (specify thepool_id
).
Key | Value | Data type | Required during creation |
---|---|---|---|
| The scope of the ban: | String | Yes |
| User ID. | String | Yes |
| The ID of the project that is blocked. | String | Yes, if |
| The ID of the pool that is blocked. | String | Yes, if |
| Comments: the reason for blocking access. | String | No |
| The UTC date and time when access will be restored. It uses ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| The UTC date and time of the ban, in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | Not used |
| ID of the ban. | String | Not used |
Key | Value | Data type | Required during creation |
---|---|---|---|
| The scope of the ban: | String | Yes |
| User ID. | String | Yes |
| The ID of the project that is blocked. | String | Yes, if |
| The ID of the pool that is blocked. | String | Yes, if |
| Comments: the reason for blocking access. | String | No |
| The UTC date and time when access will be restored. It uses ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| The UTC date and time of the ban, in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | Not used |
| ID of the ban. | String | Not used |
Response
Contains the ban ID and parameters, and the date when access was blocked.
{
"scope": "PROJECT",
"user_id": "f25a5f41-94e8-49bf-977f-3611087a16b3",
"project_id": "10",
"private_comment": "Too many mistakes",
"will_expire": "2016-04-10T18:08:07",
"id": "54",
"created": "2016-03-28T18:08:07"
}
Get a list of bans
To get a list of bans, send a GET request to the /user-restrictions
resource.
Request
GET /api/v1/user-restrictions ?
[scope=POOL]
& [user_id=<user ID>]
& [project_id=<project ID>]
& [pool_id=<pool ID>]
& [limit=<maximum number of results in the response>]
& [sort=<fields to sort by>]
& [id_gt=<ban ID>]
& [id_gte=<ban ID>]
& [id_lt=<ban ID>]
& [id_lte=<ban ID>]
& [created_gt=<date>]
& [created_gte=<date>]
& [created_lt=<date>]
& [created_lte=<date>]
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
GET /api/v1/user-restrictions ?
[scope=POOL]
& [user_id=<user ID>]
& [project_id=<project ID>]
& [pool_id=<pool ID>]
& [limit=<maximum number of results in the response>]
& [sort=<fields to sort by>]
& [id_gt=<ban ID>]
& [id_gte=<ban ID>]
& [id_lt=<ban ID>]
& [id_lte=<ban ID>]
& [created_gt=<date>]
& [created_gte=<date>]
& [created_lt=<date>]
& [created_lte=<date>]
Host: https://toloka.yandex.ru
Authorization: OAuth <OAuth token>
ALL_PROJECTS
— All the requester's projects.PROJECT
— A single project (specify theproject_id
).POOL
— A pool (specify thepool_id
).id
— The ID.created
— Date of creation, in UTC in the format YYYY-MM-DD.ALL_PROJECTS
— All the requester's projects.PROJECT
— A single project (specify theproject_id
).POOL
— A pool (specify thepool_id
).id
— The ID.created
— Date of creation, in UTC in the format YYYY-MM-DD.
Parameter | Description | Data type | Required |
---|---|---|---|
| The scope of the ban: | String | No |
| User ID. | String | No |
| The ID of the project that is blocked. | String | Yes, if |
| The ID of the pool that is blocked. | String | Yes, if |
| Limit on the number of results to return. By default — “20”; maximum — “300”. | Number | No |
| Parameters for sorting in ascending order: You can set multiple comma-separated parameters. To change the sorting direction to descending, add the minus sign before the parameter. For example, | String | No |
| Bans with an ID greater than the specified value. | String | No |
| Bans with an ID greater than or equal to the specified value. | String | No |
| Bans with an ID less than the specified value. | String | No |
| Bans with an ID less than or equal to the specified value. | String | No |
| Bans created after the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| Bans created after or on the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| Bans created before the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| Bans created before or on the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
Parameter | Description | Data type | Required |
---|---|---|---|
| The scope of the ban: | String | No |
| User ID. | String | No |
| The ID of the project that is blocked. | String | Yes, if |
| The ID of the pool that is blocked. | String | Yes, if |
| Limit on the number of results to return. By default — “20”; maximum — “300”. | Number | No |
| Parameters for sorting in ascending order: You can set multiple comma-separated parameters. To change the sorting direction to descending, add the minus sign before the parameter. For example, | String | No |
| Bans with an ID greater than the specified value. | String | No |
| Bans with an ID greater than or equal to the specified value. | String | No |
| Bans with an ID less than the specified value. | String | No |
| Bans with an ID less than or equal to the specified value. | String | No |
| Bans created after the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| Bans created after or on the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| Bans created before the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
| Bans created before or on the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss]. | String | No |
To get the list of bans in parts (for example, 10 bans at a time), use a combination of parameters in requests:
Response
Contains a list of bans in the items
array:
{"items" : [{parameters of ban 1}, {parameters of ban 2}, ... {parameters of ban n}], "has_more": true}
Get information about a ban
To get information about a ban, send a GET request to the resource /user-restrictions/<ban ID>
.
Request
GET /api/v1/user-restrictions/<ban ID>
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
GET /api/v1/user-restrictions/<ban ID>
Host: https://toloka.yandex.ru
Authorization: OAuth <OAuth token>
Response
Contains ban parameters in JSON format. Example:
{
"scope": "PROJECT",
"user_id": "f25a5f41-94e8-49bf-977f-3611087a16b3",
"project_id": "10",
"private_comment": "Too many mistakes",
"will_expire": "2016-04-10T18:08:07",
"id": "54",
"created": "2016-03-28T18:08:07"
}
Unblock access
To unblock access to tasks, send a DELETE request to the resource /user-restrictions/<ban ID>
.
Request
DELETE /api/v1/user-restrictions/<ban ID>
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
DELETE /api/v1/user-restrictions/<ban ID>
Host: https://toloka.yandex.ru
Authorization: OAuth <OAuth token>