Skip to main content

Outgoing SMS

API Outbound SMS

You can initiate a text thread with a number using this API.

To begin, retrieve your API key and Agent ID from your settings page.

Example Outbound SMS

import requests

# Replace [YOUR API KEY] and [YOUR AGENT ID] with your actual API key and Agent ID.
HEADERS = {"Authorization": "Bearer [YOUR API KEY]"}

# Replace [DESTINATION_NUMBER] with the recipient's phone number in E.164 format (e.g., +1234567890).
DATA = {
"agentId": "[YOUR AGENT ID]",
"to": "[DESTINATION_NUMBER]",
"trigger":"[Trigger to launch appropriate Task]",
"metadata":{"KEY":"VALUE"}
}

response = requests.post("https://api.agent4.ai/v1/startsms/", json=DATA, headers=HEADERS)

Ensure that the destination number is in the correct format and that your account has outbound SMS support.