Twilio Examples

Link Tracking

Link Shortening is a feature of Messaging Services that allows you to shorten URLs in your messages and track clicks.

You’ll need: See help guide

  • A Twilio account which resides within an Organization
  • Step 1: Setting up an Organization
  • Step 2: Registering Domains
    • Add a Name
    • Verify Domain, I used "HTTPS - Upload an HTML file"
    • Download the HTML file
    • Upload to the root of your domain
    • I used https://vip.ventraip.com.au/ as my provide and created a sub-domain
      • Step 3: Adding DNS Records
      • Click cPanel Hosting
      • Click cPanel
      • Go to Domains → Domains
      • Create a New Domain
      • Go to Domains → Zone Editor
      • Create a new CNAME record with
        Nametwilio.kiwicodes-support.com.
        TTL14400
        TypeCNAME
        Recordlsct.ashburn.us1.twilio.com
      • Step 4: Generating a TLS Certificate
        • Add a SSL certificate to your domain. This was the time consuming part, waiting...
        • Generate and add a Key in PEM format
  • Step 5: Uploading TLS Certificate

    curl -X POST https://messaging.twilio.com/v1/LinkShortening/Domains/"$TWILIO_DOMAIN_SID"/Certificate --data-urlencode "TlsCert="$CERTIFICATE""$PRIVATE_KEY"" -u "$TWILIO_ACCOUNT_SID":"$TWILIO_AUTH_TOKEN"


  • Step 6: Setting Up Domain Configurations

    curl -X POST https://messaging.twilio.com/v1/LinkShortening/Domains/"$TWILIO_DOMAIN_SID"/Config --data-urlencode "FallbackUrl="$FALLBACK_URL"" --data-urlencode "CallbackUrl="$CALLBACK_URL"" --data-urlencode "ContinueOnFailure=true" --data-urlencode "DisableHttps=false" -u "$TWILIO_ACCOUNT_SID":"$TWILIO_AUTH_TOKEN"


  • Associating a Domain Configuration to a Messaging Service

    curl -X POST https://messaging.twilio.com/v1/LinkShortening/Domains/"$TWILIO_DOMAIN_SID"/MessagingServices/"$TWILIO_MESSAGING_SERVICE_SID" -u "$TWILIO_ACCOUNT_SID":"$TWILIO_AUTH_TOKEN"