Send Message
Send a new message in a conversation.- Endpoint:
POST /messages
- Authentication: API Key Required
Headers
Message Types
Thecontent_type
field determines the message format and required fields:
-
TEXT (
"content_type": "text"
)- Basic text messages
- Requires
content
field - No file handling needed
-
MEDIA (
audio/*, image/*, application/pdf, etc.
)- Used for file attachments
- Requires
filename
field - Must obtain pre-signed URL before upload
- Supports various formats (audio, image, PDF, XLSX, CSV)
- More detail below Media Handling
Request Body
Field | Type | Required | Description |
---|---|---|---|
conversation | string | Yes | ID of the conversation |
content | string | Conditional | Message text (required for text messages) |
content_type | string | Yes | Message format (see Supported Types) |
filename | string | Conditional | File path/name (required for media) |
metadata | object | No | Custom message data |
channel | string | No | Defaults to “api” |
Example: Text Message
Example: Media Message
Response
Supported Content Types
Type | Content Type | Required Fields | Max Size | Description |
---|---|---|---|---|
Text | text | content | 4KB | Plain text messages |
Audio | audio/* | filename | 10MB | Voice messages, audio files |
Image | image/* | filename | 5MB | Photos and images |
application/pdf | filename | 10MB | PDF documents | |
Excel | application/xlsx | filename | 10MB | Excel spreadsheets |
CSV | text/csv | filename | 5MB | CSV data files |
Status Codes
200
: Message sent successfully400
: Validation error401
: Invalid or missing API key422
: Missing organization ID500
: Server error
Example Request
Notes
-
File Uploads:
- Obtain pre-signed URL before uploading media
- Use appropriate content type headers
- Respect file size limits
-
Message Processing:
- Messages are processed asynchronously
- Check message status for delivery confirmation
- All timestamps are in UTC
-
Metadata Usage:
- Use metadata for custom tracking
- Metadata must be valid JSON
- Maximum metadata size: 4KB
-
Rate Limits:
- 100 messages per minute per organization
- Larger limits available for enterprise plans
Media Handling
For sending media messages (images, audio, PDFs, etc.), you’ll need to follow a three-step process:Step 1: Get Pre-signed URL
Endpoint:POST /media/presigned-url
Headers:
Step 2: Upload File
Use the pre-signed URL to upload your file:${PRESIGNED_URL}
with the URL received from Step 1, and adjust the file path to your local file
location.
Step 3: Send Message
After successful upload, send the message:Supported File Types
File Type | Content Type | Storage Folder |
---|---|---|
Audio | audio/* | audio/ |
Image | image/* | images/ |
application/pdf | pdfs/ | |
Excel | application/xlsx | xlsx/ |
CSV | text/csv | csv/ |
Complete Example
Media Upload Notes
-
File Naming:
- Uploaded files are automatically prefixed with timestamp
- Format:
YYYYMMDD_HHMMSS_original_filename
-
Storage Organization:
- Files are stored in type-specific folders
- Each organization has its own directory
- Maintains clean separation of different file types
-
Limitations:
- Text files are not supported for pre-signed URLs
- Pre-signed URLs expire after 15 minutes
- File type must match the declared content type
-
Error Cases:
422
: Missing organization ID400
: Invalid file type or unsupported operation500
: Server error during URL generation
Message Metadata
Themetadata
field in messages serves several critical functions:
-
File Storage Information
- Tracks file storage details for system generated files
- Used when system generates a file response
- System automatically processes the file:
- Extracts bucket and path information
- Transfers file to conversation media bucket
- Updates message with standardized S3 URI
- Supports both HTTPS and S3 protocol URLs
- File access requires proper authentication
- Example message metadata:
-
Workflow Instance Status
The metadata tracks workflow execution state through the
workflow_instance_status
field: Available Status Values
Example Status Updates === “Initial workflow start”Status Description RUNNING
Workflow is actively executing tasks PAUSED
Workflow execution has been temporarily suspended COMPLETED
All tasks have successfully finished FAILED
Workflow stopped due to an error CANCELLED
Workflow was manually cancelled by user TERMINATED
Workflow stopped due to system intervention === “Workflow paused for user input”=== “Workflow completion”Status TransitionsRUNNING
→ Any statusPAUSED
→RUNNING
,CANCELLED
,TERMINATED
COMPLETED
(Terminal state)FAILED
(Terminal state)CANCELLED
(Terminal state)TERMINATED
(Terminal state)
- Status updates are real-time
- Terminal states cannot transition to other states
- Each status update includes timestamp information
- Status changes may trigger notifications or webhook events
- Historical status changes are preserved in workflow logs
-
Ticket Integration
The metadata contains ticket information that automatically manages support ticket lifecycles: Status Management
- Ticket status is automatically updated based on task instance status:
- Updates are handled atomically to prevent race conditions
- Status changes are tracked in ticket history
Example Metadata UsageNotification System When tickets are created or updated:- Assignees receive email notifications
- Notifications include:
- Ticket ID
- Task name and description
- Workflow name
- Exception details (if any)
- Assignment details
- Ticket updates are processed atomically using database transactions
- Missing ticket IDs are safely ignored
- Status updates are immediate and automatic
- All ticket activities are logged for audit purposes
- Ticket status is automatically updated based on task instance status: