Using Management API to create a Twilio connection

Hi Auth0,

I am trying to create a Twilio connection using the Management API and am not sure how to do it.

When I create one manually and call the getAllConnections api endpoint I get the following parameters:

{
  "id": "<con_id>",
  "options": {
    "disable_signup": false,
    "name": "sms",
    "twilio_sid": "<twilio_sid>",
    "twilio_token": "<twilio_token>",
    "from": "+61xxxxxxxxx",
    "syntax": "md_with_macros",
    "template": "@@password@@",
    "totp": {
      "time_step": 300,
      "length": 6
    },
    "messaging_service_sid": null,
    "brute_force_protection": true
  },
  "strategy": "sms",
  "name": "sms",
  "is_domain_connection": false,
  "realms": [
    "sms"
  ],
  "enabled_clients": [
    "<client_id>",
    "<client_id>"
  ]
}

However the createConnection API endpoint does not accept most of these parameters. How do I add this information to create and configure the Twilio connection using the Management API?

Thanks,
Alex

I agree that the documentation for individual connection options is far from ideal and I know this is being tracked by the documentation team.

Your approach of creating one through the dashboard and then obtaining its data through Management API is actually the same I use when I need to refresh my memory on the field name for a specific option.

The above does have the side-effect that getting (reading) a connection may return more information than the one you can use during creation/update, but we can compensate that by removing any root properties that cannot be modified.

For example, from a quick test you should be able to create a passwordless connection with the following payload:

{
  "options": {
    "disable_signup": true,
    "name": "sms",
    "twilio_sid": "<twilio_sid>",
    "twilio_token": "<twilio_token>",
    "from": "+61xxxxxxxxx",
    "syntax": "md_with_macros",
    "template": "@@password@@",
    "totp": {
      "time_step": 300,
      "length": 6
    },
    "messaging_service_sid": null,
    "brute_force_protection": true
  },
  "strategy": "sms",
  "name": "sms",
  "is_domain_connection": false,
  "enabled_clients": [  ]
}

You’ll need to adjust the enabled clients and also ensure that a connection with the same name does not already exists.

1 Like

Thanks so much, that worked.

I was worried I was going to have to squeeze the options into upstream_connections or some other property.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.