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"
}
Key descriptions

Key

Value

Data type

Required during creation

scope

The scope of the ban:

  • ALL_PROJECTS — All the requester's projects.

  • PROJECT — A single project (specify the project_id).

  • POOL — A pool (specify the pool_id).

String

Yes

user_id

User ID.

String

Yes

project_id

The ID of the project that is blocked.

String

Yes, if "scope": "PROJECT"

pool_id

The ID of the pool that is blocked.

String

Yes, if "scope": "POOL"

private_comment

Comments: the reason for blocking access.

String

No

will_expire

The UTC date and time when access will be restored. It uses ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss].

String

No

created

The UTC date and time of the ban, in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss].

String

Not used

id

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> 
Request parameters

Parameter

Description

Data type

Required

scope

The scope of the ban:

  • ALL_PROJECTS — All the requester's projects.

  • PROJECT — A single project (specify the project_id).

  • POOL — A pool (specify the pool_id).

String

No

user_id

User ID.

String

No

project_id

The ID of the project that is blocked.

String

Yes, if scope=PROJECT

pool_id

The ID of the pool that is blocked.

String

Yes, if scope= POOL

limit

Limit on the number of results to return. By default — “20”; maximum — “300”.

Number

No

sort

Parameters for sorting in ascending order:

  • id — The ID.

  • created — Date of creation, in UTC in the format YYYY-MM-DD.

You can set multiple comma-separated parameters.

To change the sorting direction to descending, add the minus sign before the parameter. For example, sort=-id.

String

No

id_gt

Bans with an ID greater than the specified value.

String

No

id_gte

Bans with an ID greater than or equal to the specified value.

String

No

id_lt

Bans with an ID less than the specified value.

String

No

id_lte

Bans with an ID less than or equal to the specified value.

String

No

created_gt

Bans created after the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss].

String

No

created_gte

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

created_lt

Bans created before the specified date. The date is specified in UTC in ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss].

String

No

created_lte

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:

GET /api/v1/user-restrictions ?sort=id&limit=10
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
GET /api/v1/user-restrictions ?sort=id&limit=10&id_gt=<last ban ID from the previous request>
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth-token>

Response

Contains a list of bans in the items array:

{"items" : [{параметры блокировки 1}, {параметры блокировки 2}, ... {параметры блокировки 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>

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

GET /api/v1/user-restrictions/<ban ID>
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>