Skip to content

Widget

The widget route lets a trusted client (typically a server backing your website embed) open a customer-side conversation with a business in your organization and send an initial message.

Endpoint: POST https://me.instaply.com/api/widget/send-message-to-business

HeaderValue
tokenAPI token (same as the Instaply API token header)
Content-Typeapplication/json

Start a conversation directed at a business and send an initial customer message. On success the response includes the customer thread id you can use with other APIs if needed.

{
"businessId": "12345",
"message": "Hello, I need help with my order.",
"user": {
"sms": "+15551234567",
"locale": "en"
}
}
FieldRequiredDescription
businessIdyesInstaply business (store) id the customer is messaging. Must belong to the same organization as your API token.
messageyesFirst message text.
useryesCustomer identity and channel. See User object below.

The user object identifies the end customer. Provide exactly one contact field of email, sms, or whatsapp, depending on the contact channel you wish to use.

FieldRequiredDescription
emailconditionalValid email address. Starts an email conversation.
smsconditionalValid E.164 phone number to start an SMS conversation.
whatsappconditionalValid E.164 phone number to start a WhatsApp conversation. The business must have a WhatsApp sender configured and be in the online state.
localenoOptional locale string for the invited user.

HTTP 200

{
"result": "ok",
"customerThreadId": ""
}

customerThreadId is the conversation identifier returned by the underlying conversations API.

HTTPMeaning
400Validation failed (headers or body). Details follow the shared validator shape for this service. Common cases: invalid email or E.164 phone number, more than one contact field on user, whatsapp: prefix in the sms/whatsapp field, or no active WhatsApp sender for the business when using whatsapp.
401Missing or invalid API token (or invalid token header).
403developerMessage: Business does not belong to this organizationbusinessId is not allowed for this API token.
Terminal window
curl -X POST "https://me.instaply.com/api/widget/send-message-to-business" \
-H "token: your-api-token" \
-H "Content-Type: application/json" \
-d '{
"businessId": "12345",
"message": "Hello, I need help with my order.",
"user": {
"email": "customer@example.com",
"locale": "en"
}
}'