To send a message

To send a message to performers, send a POST request to the message-threads/compose resource:

The sent message is added to a new message thread.

Message with a list of recipients

POST /api/v1/message-threads/compose
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
Content-Type: application/JSON

{
  "topic": {
    "RU": "Вы получили бонус!",
    "EN": "You received a bonus!"
  },
  "text": {
    "RU": "Вам был начислен бонус за хорошую работу!",
    "EN": "You were awarded a bonus for good work!"
  },
  "recipients_select_type": "DIRECT",
  "recipients_ids": [
    "2225cfb24c15b7d691818f5ac9d07f70"
  ],
  "answerable": true
}
Request parameters

Parameter

Description

Data type

Required

topic

Subject of the message. You can enter the subject in multiple languages (the message is sent in the user's language). Format: "<language RU/EN/TR/ID/FR>": "<title text>".

JSON

Yes

answerable

Whether the message can be responded to:

  • true — Users can respond to the message.

  • false — Users can't respond to the message.

The default value is true.

Boolean

Yes

text

Message text. You can enter the text in multiple languages (the message is sent in the user's language). Format: "<language RU/EN/TR/ID/FR>": "<message text>".

JSON

Yes

recipients_select_type

Method for selecting recipients:

  • DIRECT — Specify user IDs.

  • FILTER — Use a filter to select users.

  • ALL — Send the message to all users who have tried to complete a task at least once.

String

Yes

recipients_ids

The list of IDs of users who will receive the message.

Array of strings

Yes, if recipients_select_type=DIRECT.

Filter message

POST /api/v1/message-threads/compose
Host: https://sandbox.toloka.yandex.ru
Authorization: OAuth <OAuth token>
Content-Type: application/JSON

{
  "topic": {
    "RU": "Вы получили бонус!",
    "EN": "You received a bonus!"
  },
  "text": {
    "RU": "Вам был начислен бонус за хорошую работу!",
    "EN": "You were awarded a bonus for good work!"
  },
  "recipients_select_type": "FILTER",
  "recipients_filter": {
    "and": [
      {
        "category": "skill",
        "key": "2022",
        "operator": "GT",
        "value": 90
      }
    ]
  },
  "answerable": true
}
Request parameters

Parameter

Description

Data type

Required

topic
Subject of the message. You can enter the subject in multiple languages (the message is sent in the user's language). Format:
"<language RU/EN/TR/ID/FR>": "<title text>"
.

JSON

Yes

answerable

Whether the message can be responded to:

  • true — Users can respond to the message.

  • false — Users can't respond to the message.

The default value is true.

Boolean

Yes

text
Message text. You can enter the text in multiple languages (the message is sent in the user's language). Format:
"<language RU/EN/TR/ID/FR>": "<message text>".
.

JSON

Yes

recipients_select_type

Method for selecting recipients:

  • DIRECT — Specify user IDs.

  • FILTER — Use a filter to select users.

  • ALL — Send the message to all users who have tried to complete a task at least once.

String

Yes

recipients_filter

Filter for selecting recipients.

JSON

Yes, if
recipients_select_type=FILTER
.

Response

In response, you will receive a message as a new thread (see the example in the section User messages).