1
votes

I am working on an Opt-In /Opt-Out api that integrates with Twilio. The way our Opt-In/Opt-Out works is each company (our customer) signs up for one or more Twilio phone numbers and their customers can opt-in/opt-out into these numbers.

When Twilio receives these opt-in/opt-outs we want Twilio to call us into a webhook URL.

So my question is: how do we register these callback URLs? Do these have to be defined at the time when each company signs up for a phone number? If so whats the API end point for that?

These numbers can be added by different companies at any time. Please advise how to do that. We already have URLs defined for sending and receiving SMS messages with Twilio. In this case we first send the message to Twilio and we specify a callback url in that. Can the Opt-In/Opt-outs work with these already registered end points?

All the phone numbers these companies sing up for are created as a subaccount under us. So is that fine with Twilio and can Twilio call us back on the already registered end points (URLs).

If you have any documentation on how to set up an Opt-In/Opt-Out,please include that. I couldn't find one anywhere. The API method we use for creating subaccounts when companies sign up for a phone number is CreateSubAccount and there is no parameter to specify an call back endpoint URL. I tried contacting their support but they haven't gotten back to us yet.

1

1 Answers

1
votes

Twilio developer evangelist here.

I'm not sure exactly what you mean when you say "When Twilio receives these opt-in/opt-outs" as the only thing you will get webhooks for is when a number receives an incoming SMS (or phone call, but we're talking SMS right now).

You can set a different SMS webhook URL per each phone number using the API when you buy the phone number. As part of the POST request to the Incoming Phone Numbers resource you can add the optional parameters SmsUrl and SmsMethod.

Once you have purchased the number, you can also update the webhook URLs for it, by POSTing or PUTing to the instance resource, using the same parameters.

Let me know if this helps at all.