Skip to main content
Best answer

Problems with Twilio API Request {"code":21604,"message":"A 'To' phone number is required."


Hi, i’m having erros trying to call Twilio API Request, the error that appears is “{"code":21604,"message":"A 'To' phone number is required.","more_info":"https://www.twilio.com/docs/errors/21604","status":400}”.

I tried  a lot of forms to add the ‘TO’ Parameter without result.

I attach the configurations of the step

Thank you for your help. 

Best answer by SamBBest answer by SamB

Hi @milobenavides 👋

I did some digging and found an existing feature request for the ability to support sending WhatsApp messages via the Twilio app, so that may be why it’s not working. I’ve gone ahead and added your vote to that feature request. While we can’t make any promises around when/if it will be implemented we’ll be sure to send you an email notification once it is.

In the meantime, I found a post on Stack Overflow here that gives details of how to do it using a Webhooks action in a Zap
069fd7d260ff70e516041913e7519336.png


Hopefully that helps to get your desired workflow up and running​ for now​​​. 🤞

View original
Did this topic help you find an answer to your question?

Troy Tessalone
Forum|alt.badge.img+14

Hi @milobenavides 

Please link to the Twilio API endpoint documentation you used to configure the API request.


This is the information, this is in my Twilio account, probably it doesn’t public.

 

https://console.twilio.com/us1/develop/sms/try-it-out/whatsapp-learn?frameUrl=%2Fconsole%2Fsms%2Fwhatsapp%2Flearn%3Fx-target-region%3Dus1

 

The response is

 

201 - CREATED - The request was successful. We created a new resource and the response body contains the representation.
{
  "account_sid": "AC00812c3f10e0864cfa0b91f3a921de48",
  "api_version": "2010-04-01",
  "body": "Your appointment is coming up on July 21 at 3PM",
  "date_created": "Fri, 09 Aug 2024 21:35:09 +0000",
  "date_sent": null,
  "date_updated": "Fri, 09 Aug 2024 21:35:09 +0000",
  "direction": "outbound-api",
  "error_code": null,
  "error_message": null,
  "from": "whatsapp:+XXXXXXXXXX",
  "messaging_service_sid": null,
  "num_media": "0",
  "num_segments": "1",
  "price": null,
  "price_unit": null,
  "sid": "SM8e1bd585b5ddb3d045553b5289a08b1e",
  "status": "queued",
  "subresource_uris": {
    "media": "/2010-04-01/Accounts/AC00812c3f10e0864cfa0b91f3a921de48/Messages/SM8e1bd585b5ddb3d045553b5289a08b1e/Media.json"
  },
  "to": "whatsapp:+XXXXXXXXXXXX",
  "uri": "/2010-04-01/Accounts/AC00812c3f10e0864cfa0b91f3a921de48/Messages/SM8e1bd585b5ddb3d045553b5289a08b1e.json"
}


Troy Tessalone
Forum|alt.badge.img+14

@milobenavides 

First, remove the configured Query String Parameters.

 

Then check your parameter capitalization.

  • To instead of to
  • From instead of from
  • Body instead of body

i chaged the configuration, but i have the same error.

 

{"code":21604,"message":"A 'To' phone number is required.","more_info":"https://www.twilio.com/docs/errors/21604","status":400}

 

 


Troy Tessalone
Forum|alt.badge.img+14

@milobenavides 

Body needs to be valid JSON structure.

{
  "From": "whatsapp:+1111111111",
  "To": "whatsapp:+2222222222",
  "Body": "Ahoy world!"
}

 


I has changed the body, the error persists.

 


Troy Tessalone
Forum|alt.badge.img+14

@milobenavides 

For us to have current context, post screenshots with how your Zap step is configured in EDIT mode.


Send the screens

 

Send the DATA IN

method

method

POST

url

url

https://api.twilio.com/2010-04-01/Accounts/AC00812c3f10e0864cfa0b91f3a921de48/Messages.json

querystring

querystring

body

body

{ "From": "whatsapp:+XXXXXX", "To": "whatsapp:+XXXXXXXXX", "Body": "Ahoy world!" }

headers

headers

 

DATA OUTPUT

🔍 Full Response Data 🔎

🔍_full_response_data_🔎

https://zapier.com/engine/hydrate/15095448/.eJw1zdEOgiAUxvF3OddQYKjoXc_RGmNwaExDJ7ByznePXN3-v7Pf2cBMIWFIKq0zQg9XIOBDTDoYVN5CL2TDJOeMgMkxTc8ccTkGXrOuFkIS0MZMuRD_KkTbEXAeR6uCfn5Z50eMhR5eenlE6LejqHny5ftSwm2DAddyGS9nW3GBznXU6UpSYYylmiGj3FnRomtMLWWxfvSCMY_plN4J9vu-fwCUeELN:1sdXeR:vMxDkjOILL3qbjivP4SA4hMvMTu8aBU5VcTKxhnXF0Y/

request

request

Request Method

method

POST

Request Url

url

https://api.twilio.com/2010-04-01/Accounts/AC00812c3f10e0864cfa0b91f3a921de48/Messages.json

Request Querystring

querystring

Request Headers

headers

Request Body

body

{ "From": "whatsapp:+XXXXXXXX", "To": "whatsapp:+XXXXXXXXX", "Body": "Ahoy world!" }

data

data

Request Data From

From

whatsapp:+XXXXXXX

Request Data To

To

whatsapp:+XXXXXXXX

Request Data Body

Body

Ahoy world!

response

response

Response Status

status

400

Response Headers

headers

Response Headers Date

date

Mon, 12 Aug 2024 16:12:07 GMT

Response Headers Content Type

content-type

application/json

Response Headers Content Length

content-length

127

Response Headers Connection

connection

keep-alive

Response Headers X Twilio Error Code

x-twilio-error-code

21604

Response Headers Twilio Concurrent Requests

twilio-concurrent-requests

1

Response Headers Twilio Request ID

twilio-request-id

RQ0772741ded6c3be2fe5e37fa0bf88358

Response Headers Twilio Request Duration

twilio-request-duration

0.032

Response Headers X Api Domain

x-api-domain

api.twilio.com

Response Headers Strict Transport Security

strict-transport-security

max-age=31536000

Response Headers Access Control Allow Origin

access-control-allow-origin

*

Response Headers Access Control Allow Headers

access-control-allow-headers

Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Idempotency-Key, X-Pre-Auth-Context, X-Target-Region

Response Headers Access Control Allow Methods

access-control-allow-methods

GET, POST, PATCH, PUT, DELETE, OPTIONS

Response Headers Access Control Expose Headers

access-control-expose-headers

ETag, Twilio-Request-Id

Response Headers Access Control Allow Credentials

access-control-allow-credentials

true

Response Headers X Shenanigans

x-shenanigans

none

Response Headers X Powered By

x-powered-by

AT-5000

Response Headers X Home Region

x-home-region

us1

Response Body

body

{"code":21604,"message":"A 'To' phone number is required.","more_info":"https://www.twilio.com/docs/errors/21604","status":400}

data

data

Response Data Code

code

21604

Response Data Message

message

A 'To' phone number is required.

Response Data More Info

more_info

https://www.twilio.com/docs/errors/21604

Response Data Status

status

400


Troy Tessalone
Forum|alt.badge.img+14

@milobenavides 

There are limitations to using the Twilio endpoint to be aware of that may be contributing to the encountered error.

 

Try setting the To line to before the From line in the JSON body.

 


How can change to call from webhook zapier functionality.


Troy Tessalone
Forum|alt.badge.img+14

@milobenavides 

Did you try this?

{
  "To": "whatsapp:+2222222222",
  "From": "whatsapp:+1111111111",
  "Body": "Ahoy world!"
}

 


Same result.


Troy Tessalone
Forum|alt.badge.img+14

@milobenavides 

Help links for using WhatsApp in Twilio that may provide guidance on prerequisites:

https://help.twilio.com/articles/360007721954-Getting-Started-with-Twilio-for-WhatsApp


Hi, I cant send WhatsAPP Message whit zapier.

Then I try to send a basic SMS message using zapier and twilio. All is configured.

When send a message using curl (out of zapier) all is OK.

Here is the code.

 

curl 'https://api.twilio.com/2010-04-01/Accounts/AC00812c3f10e0864cfa0b91f3a921de48/Messages.json' -X POST \
--data-urlencode 'To=+XXXXXXXX' \
--data-urlencode 'MessagingServiceSid=MGd1ee3ff9fc2fb565fea055e7204b00ce' \
--data-urlencode 'Body=dfdsf' \
-u AC00812c3f10e0864cfa0b91f3a921de48:[AuthToken]

 But when i try to send a message using zapier, an error appears.

Response Body

body

{"code":21604,"message":"A 'To' phone number is required.","more_info":"https://www.twilio.com/docs/errors/21604","status":400}

 


Hi, I cant send WhatsAPP Message whit zapier.

Then I try to send a basic SMS message using zapier and twilio. All is configured.

When send a message using curl (out of zapier) all is OK.

Here is the code.

 

curl 'https://api.twilio.com/2010-04-01/Accounts/AC00812c3f10e0864cfa0b91f3a921de48/Messages.json' -X POST \
--data-urlencode 'To=+XXXXXXXX' \
--data-urlencode 'MessagingServiceSid=MGd1ee3ff9fc2fb565fea055e7204b00ce' \
--data-urlencode 'Body=dfdsf' \
-u AC00812c3f10e0864cfa0b91f3a921de48:[AuthToken]

 But when i try to send a message using zapier, an error appears.

Response Body

body

{"code":21604,"message":"A 'To' phone number is required.","more_info":"https://www.twilio.com/docs/errors/21604","status":400}


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • August 29, 2024

Hi @milobenavides 👋

I did some digging and found an existing feature request for the ability to support sending WhatsApp messages via the Twilio app, so that may be why it’s not working. I’ve gone ahead and added your vote to that feature request. While we can’t make any promises around when/if it will be implemented we’ll be sure to send you an email notification once it is.

In the meantime, I found a post on Stack Overflow here that gives details of how to do it using a Webhooks action in a Zap
069fd7d260ff70e516041913e7519336.png


Hopefully that helps to get your desired workflow up and running​ for now​​​. 🤞


Hola, cómo están?

Finalmente alguien encontró solución a esto? 

Llevo 2 semanas tratando de enviar mensajes whatsapp con zapier a través de twilio y tengo los mismos errores que uds mencionan. Tendrán la estructura final?

Se habrá solucionado? de lo contrario, alguien me puede recomendar otra herramienta de reemplazo? 

gracias.

 

Moderator edit to include Google Translation of original message:

Hi, how are you?

Has anyone finally found a solution to this?

I've been trying to send whatsapp messages with zapier through twilio for 2 weeks and I have the same errors that you mention. Do you have the final structure?

Has it been solved? If not, can anyone recommend me another replacement tool?

thanks


JammerS
Forum|alt.badge.img+6
  • Zapier Staff
  • January 8, 2025

Hi ​@victoralvarezh,

 

I’ve added your vote for this feature request, and we’ll notify you via email once an update is readily available. Meanwhile ​@SamB found a post on Stack Overflow here that gives details of how to do it using a Webhooks action in a Zap: Might as well give it a try while waiting for the update with the request?


Reply