Send Whatsapp

Estimated reading: 2 minutes 5 views

Use Case

Send a Whatsapp to the target phone number.

Request

curl --location 'https://api.twilio.com/2010-04-01/Accounts/AC9c6a1ee066be3caae243b8111f3adea8/Messages.json' 
--header 'Content-Type: application/x-www-form-urlencoded' 
--header 'Authorization: Basic QUM5YzZhMWVlMDY2YmUzY2FhZTI0M2I4MTExZjNhZGVhODphYTgxMGE3MzEyMzAyYmQ1MjVlMGQ0MjA2ZmVjZTI5Zg==' 
--data-urlencode 'To=whatsapp:+34649485975' 
--data-urlencode 'From=whatsapp:+14155238886' 
--data-urlencode 'Body=Test'

Success Response

{
    "body": "Test",
    "num_segments": "1",
    "direction": "outbound-api",
    "from": "whatsapp:+14155238886",
    "date_updated": "Wed, 29 Nov 2023 12:41:27 +0000",
    "price": null,
    "error_message": null,
    "uri": "/2010-04-01/Accounts/AC9c6a1ee066be3caae243b8111f3adea8/Messages/SMf88345c6e8e21d7394287f6ef13268a3.json",
    "account_sid": "AC9c6a1ee066be3caae243b8111f3adea8",
    "num_media": "0",
    "to": "whatsapp:+34649485975",
    "date_created": "Wed, 29 Nov 2023 12:41:27 +0000",
    "status": "queued",
    "sid": "SMf88345c6e8e21d7394287f6ef13268a3",
    "date_sent": null,
    "messaging_service_sid": null,
    "error_code": null,
    "price_unit": null,
    "api_version": "2010-04-01",
    "subresource_uris": {
        "media": "/2010-04-01/Accounts/AC9c6a1ee066be3caae243b8111f3adea8/Messages/SMf88345c6e8e21d7394287f6ef13268a3/Media.json"
    }
}

Error Response

This is a sample error response not related to the request above.

   {
    "code": 21910,
    "message": "Invalid From and To pair. From and To should be of the same channel",
    "more_info": "https://www.twilio.com/docs/errors/21910",
    "status": 400
}

Credentials

  • Account SID: SK7e82bc756f747ae82f76f3e0fa58bfa9
  • Secret: 6o1WeSLZ72IiiEfhktZkseKlxAfzd6Pm

Leave a Comment

       
Euphoria, forever till the end of times

Euphoria

Share this Doc

Send Whatsapp

Or copy link

CONTENTS