• Choose:

Twexit API

The Twexit API allows users to send messages and receive message notifications with minimal changes to existing Twilio messaging code. This makes it easier than ever to leave Twilio and begin utilizing Telnyx to send and receive text messages.

Mission Control Portal Setup

To use the Twexit API, please ensure the following:

  1. You have active numbers on the portal.
  2. You have created a Messaging Profile to send and receive messages.

Once you have your profile created, select Twexit API under API Version in the Messaging Profile settings.

You should now receive inbound messages and webhooks in Twilio's format.

Finding the organization id

To find your organization id, run the following curl command:

curl --request GET \
  --url https://api.telnyx.com/v2/whoami \
  --header 'Authorization: Bearer ${auth_v2_api_key}'

This endpoint will respond with

{
  "data": {
    "organization_id": "ORGANIZATION_ID",
    "user_id": "USER_ID"
  }
}

Sending a Message

Fill in the organization id and the auth v2 api key below:

curl -u "\${organization_id}":"\${auth_v2_api_key}" \\
--data-urlencode 'From=+13125550000' \\
--data-urlencode 'To=+13125550001' \\
--data-urlencode 'Body=Hello, World!' \\
https://api.telnyx.com/2010-04-01/Accounts/{organization_id}/Messages.json

The response will contain:

{
  "sid": "40317159-f30d-4940-b751-9a6e81727249",
  "date_created": "Wed, 08 Apr 2020 13:20:33 +0000",
  "date_updated": "Wed, 08 Apr 2020 13:20:33 +0000",
  "date_sent": null,
  "account_sid": "${account_id}",
  "to": "+13125550000",
  "from": "+13125550001",
  "messaging_service_sid": "40017155-44c7-4d18-8fa5-332c1a776db5",
  "body": "Hello, World!",
  "status": "queued",
  "num_segments": "1",
  "num_media": "0",
  "direction": "outbound-api",
  "api_version": "2010-04-01",
  "price": null,
  "price_unit": "USD",
  "error_code": null,
  "error_message": null,
  "uri": "/2010-04-01/Accounts/{organization_id}/Messages/40317159-f30d-4940-b751-9a6e81727249.json",
  "subresource_uris": {
    "media": "/2010-04-01/Accounts/{organization_id}/Messages/40317159-f30d-4940-b751-9a6e81727249/Media.json"
  }
}
Was this page helpful?