Skip to main content
Post the necessary fields for the API to send a new message.
POST https://services.leadconnectorhq.com/conversations/messages

Autorización

Authorization
string
required
Bearer token generado desde el portal Leadway. Ver Autenticación.
Version
string
default:"2021-07-28"
required
Versión de la API.

Body

type
string
default:"Email"
required
Type of message being sent Posibles valores: ‘SMS’, ‘RCS’, ‘Email’, ‘WhatsApp’, ‘IG’, ‘FB’, ‘Custom’, ‘Live_Chat’, ‘TIKTOK’
subType
object
default:"Email"
required
Type of message being sent
contactId
string
default:"abc123def456"
required
ID of the contact receiving the message
appointmentId
string
default:"appt123"
ID of the associated appointment
attachments
string[]
Array of attachment URLs
emailFrom
string
default:"sender@company.com"
Email address to send from
emailCc
string[]
Array of CC email addresses
emailBcc
string[]
Array of BCC email addresses
html
string
default:"<p>Hello World</p>"
HTML content of the message
message
string
default:"Hello, how can I help you today?"
Text content of the message
subject
string
default:"Important Update"
Subject line for email messages
replyMessageId
string
default:"msg123"
ID of message being replied to
templateId
string
default:"template123"
ID of message template
threadId
string
default:"thread123"
ID of message thread. For email messages, this is the message ID that contains multiple email messages in the thread
scheduledTimestamp
number
default:"1669287863"
UTC Timestamp (in seconds) at which the message should be scheduled
conversationProviderId
string
default:"provider123"
ID of conversation provider
emailTo
string
default:"recipient@company.com"
Email address to send to, if different from contact’s primary email. This should be a valid email address associated with the contact.
customSubtypeId
string
default:"507f1f77bcf86cd799439011"
Custom subtype ID for email unsubscription preferences. Only applies to email messages.
emailReplyMode
string
default:"reply_all"
Mode for email replies Posibles valores: ‘reply’, ‘reply_all’
fromNumber
string
default:"+1499499299"
Phone number used as the sender number for outbound messages
toNumber
string
default:"+1439499299"
Recipient phone number for outbound messages
forward
object
Forwarding configuration for emails
status
string
default:"delivered"
required
Message status Posibles valores: ‘delivered’, ‘failed’, ‘pending’, ‘read’
usesNativeSchedulingAi
boolean
default:"False"
Whether the scheduled email uses native AI for the email scheduling
optimizationPeriod
string
default:"24h"
Optimization period in hours (24h, 48h, or 72h) Posibles valores: ‘24h’, ‘48h’, ‘72h’

Respuestas

conversationId
string
default:"ABC12h2F6uBrIkfXYazb"
required
Conversation ID.
emailMessageId
string
default:"rnGyqh2F6uBrIkfhFo9A"
This contains the email message id (only for Email type). Use this ID to send inbound replies to GHL to create a threaded email.
messageId
string
default:"t22c6DQcTDf3MjRhwf77"
required
This is the main Message ID
messageIds
string[]
When sending via the GMB channel, we will be returning list of messageIds instead of single messageId.
msg
string
default:"Message queued successfully."
Additional response message when sending a workflow message
forwardData
object
Optional metadata for forwarded email
status
string
default:"delivered"
required
Message status Posibles valores: ‘delivered’, ‘failed’, ‘pending’, ‘read’
{
  "conversationId": "ABC12h2F6uBrIkfXYazb",
  "emailMessageId": "rnGyqh2F6uBrIkfhFo9A",
  "messageId": "t22c6DQcTDf3MjRhwf77",
  "messageIds": [
    "string"
  ],
  "msg": "Message queued successfully.",
  "forwardData": {
    "forwardWholeThread": false,
    "messageId": "t22c6DQcTDf3MjRhwf77",
    "emailMessageId": "rnGyqh2F6uBrIkfhFo9A",
    "forwardToEmail": "recipient@example.com",
    "recipientContactId": "DEF56h2F6uBrIkfXYacd"
  },
  "status": "delivered"
}
{}
{}

Ejemplo

curl -X POST 'https://services.leadconnectorhq.com/conversations/messages' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "Email",
  "subType": "Email",
  "contactId": "abc123def456",
  "appointmentId": "appt123",
  "attachments": [
    "https://storage.com/file1.pdf",
    "https://storage.com/file2.jpg"
  ],
  "emailFrom": "sender@company.com",
  "emailCc": [
    "cc1@company.com",
    "cc2@company.com"
  ],
  "emailBcc": [
    "bcc1@company.com",
    "bcc2@company.com"
  ],
  "html": "<p>Hello World</p>",
  "message": "Hello, how can I help you today?",
  "subject": "Important Update",
  "replyMessageId": "msg123",
  "templateId": "template123",
  "threadId": "thread123",
  "scheduledTimestamp": 1669287863,
  "conversationProviderId": "provider123",
  "emailTo": "recipient@company.com",
  "customSubtypeId": "507f1f77bcf86cd799439011",
  "emailReplyMode": "reply_all",
  "fromNumber": "+1499499299",
  "toNumber": "+1439499299",
  "forward": {
    "isForwarded": true,
    "forwardWholeThread": false,
    "messageId": "t22c6DQcTDf3MjRhwf77",
    "emailMessageId": "rnGyqh2F6uBrIkfhFo9A",
    "toEmail": "forward@example.com",
    "recipientContactId": "DEF56h2F6uBrIkfXYacd"
  },
  "status": "delivered",
  "usesNativeSchedulingAi": false,
  "optimizationPeriod": "24h"
}'
const response = await fetch('https://services.leadconnectorhq.com/conversations/messages', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
    Version: '2021-07-28',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"type": "Email", "subType": "Email", "contactId": "abc123def456", "appointmentId": "appt123", "attachments": ["https://storage.com/file1.pdf", "https://storage.com/file2.jpg"], "emailFrom": "sender@company.com", "emailCc": ["cc1@company.com", "cc2@company.com"], "emailBcc": ["bcc1@company.com", "bcc2@company.com"], "html": "<p>Hello World</p>", "message": "Hello, how can I help you today?", "subject": "Important Update", "replyMessageId": "msg123", "templateId": "template123", "threadId": "thread123", "scheduledTimestamp": 1669287863, "conversationProviderId": "provider123", "emailTo": "recipient@company.com", "customSubtypeId": "507f1f77bcf86cd799439011", "emailReplyMode": "reply_all", "fromNumber": "+1499499299", "toNumber": "+1439499299", "forward": {"isForwarded": true, "forwardWholeThread": false, "messageId": "t22c6DQcTDf3MjRhwf77", "emailMessageId": "rnGyqh2F6uBrIkfhFo9A", "toEmail": "forward@example.com", "recipientContactId": "DEF56h2F6uBrIkfXYacd"}, "status": "delivered", "usesNativeSchedulingAi": false, "optimizationPeriod": "24h"}),
});
const data = await response.json();
import os, requests
response = requests.request(
    'POST',
    'https://services.leadconnectorhq.com/conversations/messages',
    headers={
        'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
        'Version': '2021-07-28',
        'Content-Type': 'application/json',
    },
    json={"type": "Email", "subType": "Email", "contactId": "abc123def456", "appointmentId": "appt123", "attachments": ["https://storage.com/file1.pdf", "https://storage.com/file2.jpg"], "emailFrom": "sender@company.com", "emailCc": ["cc1@company.com", "cc2@company.com"], "emailBcc": ["bcc1@company.com", "bcc2@company.com"], "html": "<p>Hello World</p>", "message": "Hello, how can I help you today?", "subject": "Important Update", "replyMessageId": "msg123", "templateId": "template123", "threadId": "thread123", "scheduledTimestamp": 1669287863, "conversationProviderId": "provider123", "emailTo": "recipient@company.com", "customSubtypeId": "507f1f77bcf86cd799439011", "emailReplyMode": "reply_all", "fromNumber": "+1499499299", "toNumber": "+1439499299", "forward": {"isForwarded": true, "forwardWholeThread": false, "messageId": "t22c6DQcTDf3MjRhwf77", "emailMessageId": "rnGyqh2F6uBrIkfhFo9A", "toEmail": "forward@example.com", "recipientContactId": "DEF56h2F6uBrIkfXYacd"}, "status": "delivered", "usesNativeSchedulingAi": false, "optimizationPeriod": "24h"},
)
data = response.json()
<?php
$ch = curl_init('https://services.leadconnectorhq.com/conversations/messages');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
        'Version: 2021-07-28',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode({'type': 'Email', 'subType': 'Email', 'contactId': 'abc123def456', 'appointmentId': 'appt123', 'attachments': ['https://storage.com/file1.pdf', 'https://storage.com/file2.jpg'], 'emailFrom': 'sender@company.com', 'emailCc': ['cc1@company.com', 'cc2@company.com'], 'emailBcc': ['bcc1@company.com', 'bcc2@company.com'], 'html': '<p>Hello World</p>', 'message': 'Hello, how can I help you today?', 'subject': 'Important Update', 'replyMessageId': 'msg123', 'templateId': 'template123', 'threadId': 'thread123', 'scheduledTimestamp': 1669287863, 'conversationProviderId': 'provider123', 'emailTo': 'recipient@company.com', 'customSubtypeId': '507f1f77bcf86cd799439011', 'emailReplyMode': 'reply_all', 'fromNumber': '+1499499299', 'toNumber': '+1439499299', 'forward': {'isForwarded': true, 'forwardWholeThread': false, 'messageId': 't22c6DQcTDf3MjRhwf77', 'emailMessageId': 'rnGyqh2F6uBrIkfhFo9A', 'toEmail': 'forward@example.com', 'recipientContactId': 'DEF56h2F6uBrIkfXYacd'}, 'status': 'delivered', 'usesNativeSchedulingAi': false, 'optimizationPeriod': '24h'}),
]);
$data = json_decode(curl_exec($ch), true);