Search code examples
twiliotwilio-php

Add Twilio numbers into "messaging service" via API


I have a Twilio number that I want to add into my Twilio "messaging service" via the API.

enter image description here

Example request (that doesn't work):

$add_number = $twilio->account->incoming_phone_numbers->create(array(
    "PhoneNumber" => $number,
    "MessagingServiceSid" => "MG68f3...4b72", // Messaging Service ID on Twilio
));

The Twilio API docs only seem to mention SmsApplicationSid which doesn't achieve the outcome I want.

I want to be able to add existing numbers (that I've already purchased) into my messaging service, and when I buy new numbers be able to add those into the messaging service at the same time.

Is this possible?


Solution

  • Twilio developer evangelist here.

    Unfortunately at the time or writing you can't create messaging services via the API. The same goes for associating numbers. To do that you will need to go via the console and add them manually.

    The page Sending Messages with Copilot shows you how to use an existing messaging service though.

    Hope this helps.