Create a subscription

To create a subscription, send a PUT request to the /webhook-subscriptions resource. In the request body, specify the subscription parameters.

You can create multiple subscriptions with a single request.

Request

PUT /api/v1/webhook-subscriptions
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
Content-Type: application/JSON
[
  {
     "webhook_url": "https://awesome-requester.com/toloka-webhook",
     "event_type": "ASSIGNMENT_CREATED",
     "pool_id": "121212"
  },
  {
     "webhook_url": "https://awesome-requester.com/toloka-webhook",
     "event_type": "POOL_CLOSED",
     "pool_id": "121212"
  }
]
Key descriptions

Key

Value

Data type

Required

webhook_url

The URL that notifications will be sent to.

String

Yes

event_type

Event type.

Acceptable values:

  • POOL_CLOSED — The pool is closed.
  • DYNAMIC_OVERLAP_COMPLETED — An aggregated result appeared after dynamic overlap.
  • ASSIGNMENT_CREATED — A task was created.
  • ASSIGNMENT_SUBMITTED — A task is completed and waiting for acceptance by the requester.
  • ASSIGNMENT_SKIPPED — A task was taken by the performer who then skipped it and won't return to it.
  • ASSIGNMENT_EXPIRED — A task was taken by the performer who failed to complete it within the time allowed or rejected it before it expired.
  • ASSIGNMENT_APPROVED — A task was completed by the performer and approved by the requester.
  • ASSIGNMENT_REJECTED — A task was completed by the performer but rejected by the requester.

String

Yes

pool_id

ID of the pool that the subscription was created for.

String

Yes

Key

Value

Data type

Required

webhook_url

The URL that notifications will be sent to.

String

Yes

event_type

Event type.

Acceptable values:

  • POOL_CLOSED — The pool is closed.
  • DYNAMIC_OVERLAP_COMPLETED — An aggregated result appeared after dynamic overlap.
  • ASSIGNMENT_CREATED — A task was created.
  • ASSIGNMENT_SUBMITTED — A task is completed and waiting for acceptance by the requester.
  • ASSIGNMENT_SKIPPED — A task was taken by the performer who then skipped it and won't return to it.
  • ASSIGNMENT_EXPIRED — A task was taken by the performer who failed to complete it within the time allowed or rejected it before it expired.
  • ASSIGNMENT_APPROVED — A task was completed by the performer and approved by the requester.
  • ASSIGNMENT_REJECTED — A task was completed by the performer but rejected by the requester.

String

Yes

pool_id

ID of the pool that the subscription was created for.

String

Yes

Response

Contains information about created subscriptions in JSON format. Each subscription is assigned a unique identifier (id) and creation date (created).

Sample response when creating a single subscription:

[
  {
     "webhook_url": "https://awesome-requester.com/toloka-webhook",
     "event_type": "ASSIGNMENT_CREATED",
     "pool_id": "121212",
     "id": "webhook-subscription-1",
     "created": "2020-02-03T15:00:00"
  }
]

Sample response when creating multiple subscriptions at a time:

{
   "items": {
      "0": {
         "webhook_url": "https://awesome-requester.com/toloka-webhook",
         "event_type": "ASSIGNMENT_CREATED",
         "pool_id": "121212",
         "id": "webhook-subscription-1",
         "created": "2020-02-03T15:00:00"
      },  
      "1": {
         "webhook_url": "https://awesome-requester.com/toloka-webhook",
         "event_type": "POOL_CLOSED",
         "pool_id": "121212",
         "id": "webhook-subscription-2",
         "created": "2020-02-03T15:00:00"
      }
   },
   "validation_errors": {}
}
Key descriptions
Key Value Data type

items

An object with information about the subscriptions created.

Array

<n>

Sequential number of the subscription in the creation request (starting from 0).

Array

webhook_url

The URL that notifications will be sent to.

String

event_type

Event type.

Acceptable values:

  • POOL_CLOSED — The pool is closed.
  • DYNAMIC_OVERLAP_COMPLETED — An aggregated result appeared after dynamic overlap.
  • ASSIGNMENT_CREATED — A task was created.
  • ASSIGNMENT_SUBMITTED — A task is completed and waiting for acceptance by the requester.
  • ASSIGNMENT_SKIPPED — A task was taken by the performer who then skipped it and won't return to it.
  • ASSIGNMENT_EXPIRED — A task was taken by the performer who failed to complete it within the time allowed or rejected it before it expired.
  • ASSIGNMENT_APPROVED — A task was completed by the performer and approved by the requester.
  • ASSIGNMENT_REJECTED — A task was completed by the performer but rejected by the requester.

String

pool_id

ID of the pool that the subscription was created for.

String

id

ID of the subscription. Generated automatically.

String

created

The date and time when the subscription was created (UTC). It uses ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss].

String

validation_errors

Object with validation errors.

Array

Key Value Data type

items

An object with information about the subscriptions created.

Array

<n>

Sequential number of the subscription in the creation request (starting from 0).

Array

webhook_url

The URL that notifications will be sent to.

String

event_type

Event type.

Acceptable values:

  • POOL_CLOSED — The pool is closed.
  • DYNAMIC_OVERLAP_COMPLETED — An aggregated result appeared after dynamic overlap.
  • ASSIGNMENT_CREATED — A task was created.
  • ASSIGNMENT_SUBMITTED — A task is completed and waiting for acceptance by the requester.
  • ASSIGNMENT_SKIPPED — A task was taken by the performer who then skipped it and won't return to it.
  • ASSIGNMENT_EXPIRED — A task was taken by the performer who failed to complete it within the time allowed or rejected it before it expired.
  • ASSIGNMENT_APPROVED — A task was completed by the performer and approved by the requester.
  • ASSIGNMENT_REJECTED — A task was completed by the performer but rejected by the requester.

String

pool_id

ID of the pool that the subscription was created for.

String

id

ID of the subscription. Generated automatically.

String

created

The date and time when the subscription was created (UTC). It uses ISO 8601 format: YYYY-MM-DDThh:mm:ss[.sss].

String

validation_errors

Object with validation errors.

Array