Send a message

Sends a plain-text WhatsApp message as the agency. If the 24-hour window is closed, Alia queues the text and asks the contact for consent first. A send takes over the conversation and turns the AI off for this contact.

POSThttps://api.alia.cx/api/v1/agencies/{agencyId}/messages

Path parameters

  • agencyIdstringRequired

    Agency ID from GET /me, such as agy_9f2c4e1a7b3d4c5e8f60a1b2c3d4e5f6.

Request body

application/json
  • tostringRequired

    Contact phone number in E.164 format.

  • bodystringRequired

    Plain text to send. Files are not supported yet.

  • operationIdstring

    Your id for this send. While the window is open, a retry with the same id does not send twice. Reusing an id with a different body fails. Without an id, every request is a new message.

  • subaccountIdstring (uuid) or null

    The agency's WhatsApp sender to use. Leave it out to use the agency's default sender.

  • consentLanguagestring

    Language of the consent template, such as fr, used only when the window is closed. Required when the agency has more than one consent language. See windowReopenReadiness.availableLanguages.

Responses

200OKThe text was sent or queued.
  • successbooleanRequired

    Always true on success.

  • queuedbooleanRequired

    False: Alia sent the text now. True: the 24-hour window was closed, so Alia queued the text and sent the contact a consent template. Alia sends the text once the contact accepts. A new send while one is queued replaces the queued text.

  • messageIdstring or nullRequired

    Twilio message SID of the sent text. Null when queued.

  • queueIdstring or nullRequired

    Queue entry id. Null when sent now.

  • statusstring or nullRequired

    Twilio status right after sending, such as queued or accepted. Null when queued or on a retry.

  • windowOpenbooleanRequired

    True when the WhatsApp 24-hour window was open.

  • windowExpiresAtstring or nullRequired

    When the 24-hour window closes. Null when the contact has never written.

Errors

  • 400Bad requestPartnerBadRequestThe request is not valid.
  • 401UnauthorizedPartnerUnauthorizedThe bearer token is missing or not valid.
  • 403ForbiddenPartnerForbiddenThe key may not do this.
  • 409ConflictPartnerConflictThe conversation changed during the request.
  • 500Server errorPartnerInternalErrorAlia failed to handle the request.

Every error body is JSON with the same two fields: _tag names the error and message explains it. How errors work