Write First Message

Send a message when no conversation with the recipient exists

POSThttps://api.pact.im/api/p2/messages

Allows to send message when no conversation with this recipient exists.

Only these providers available at this moment: max, whatsapp, telegram_personal, whatsapp_business, vkontakte_direct

Body Parameters (JSON)

ParameterRequiredValidationsDescription
private_api_tokentrueMust be a stringYOUR_API_TOKEN
company_idtrueMust be an integerID of the company
providertrueMust be a string and one of: max, whatsapp, telegram_personal, whatsapp_business, vkontakte_directProvider
phonefalseMust be a stringRecipient phone
nicknamefalseMust be a stringRecipient nickname (for telegram_personal)
vkontakte_idfalseMust be a stringRecipient ID vkontakte (Mutually exclusive with vkontakte_domain)
vkontakte_domainfalseMust be a stringRecipient domain vkontakte (Mutually exclusive with vkontakte_id)
textfalseMust be a stringText of the message
attachment_idsfalseMust be an array of integersID of the attachments. One message can contain only one array with one ID. To send multiple attachments, you must send multiple requests with different IDs.
waba_idfalseMust be a stringWABA template ID
substitutionsfalseMust be an array of stringsWABA template substitutions (if template has them)
send_to_crmfalsebooleanSync initializing message to CRM integrations. Default: true

You should use waba_id if you want to write first with whatsapp_business provider. More about WABA Templates.

Example

Request

shell
curl -X POST 'https://api.pact.im/api/p2/messages' \
--header 'Content-Type: application/json' \
--data '{
    "private_api_token": YOUR_API_TOKEN,
    "company_id": COMPANY_ID,
    "text": "test"
  }'

Response

json
{
  "message": {
    "id": 239,
    "external_id": null,
    "company_id": 52204,
    "conversation_id": 18642824,
    "contact_id": 3,
    "replied_to_id": null,
    "created_at": "2025-02-13T14:07:51.582Z",
    "external_created_at": "2025-02-13T14:07:51.000Z",
    "income": false,
    "status": "sent",
    "message": null,
    "reactions": [],
    "details": null,
    "attachments": [
      {
        "id": 5,
        "message_id": 239,
        "file_name": "5287346531311154701.png",
        "mime_type": "image/jpeg",
        "size": 65030,
        "attachment_url": "https://cdn.pact.im/uploads/storage/attachment/file/a845515c570e285e2ae22d9d493e3abc.png",
        "preview_url": "https://cdn.pact.im/uploads/storage/attachment/file/small-3a46073e438fa82c6c04fd2ff3e1cfef.png",
        "aspect_ratio": 0.46,
        "data": {
          "width": 591,
          "height": 1280
        }
      }
    ]
  }
}

Search…

Start typing to search