Format and validate a given number.


We created a new viewing experience for our SMS API documentation. It's now all in one central location. Click here to check it out!


Parameter

Description

Required

msisdnThe number to checkYES
countrycode2 Letter countrycode to validate number againstYES


countrycode values: AU = Australia, SG = Singapore, GB = United Kingdom, NZ = New Zealand, US = United States


Example


curl https://api.transmitsms.com/format-number.json \
  -u 2e24c1cbdd987221e165d543f34b84bf:secret \
  -d 'msisdn=0455667889' \
  -d 'countrycode=AU'


JSON Response

{
  "error": {
    "code": "SUCCESS",
    "description": "OK"
  },
  "number": {
    "countrycode": 61,
     "international": 61455667889,
     "isValid": true,
     "national_leading_zeroes": 455667889,
     "nationalnumber": 455667889,
     "rawinput": null,
     "type": 1
  }
}

XML Response

<?xml version="1.0" encoding="UTF-8"?>
<response>
   <number>
      <countrycode>61</countrycode>
      <nationalnumber>455667889</nationalnumber>
      <national_leading_zeroes>0455667889</national_leading_zeroes>
      <rawinput />
      <international>+61455667889</international>
      <type>1</type>
      <isValid>true</isValid>
   </number>
   <error>
      <code>SUCCESS</code>
      <description>OK</description>
   </error>
</response>


PHP Examples


<?php
 include '../../APIClient2.php';

 $api = new transmitsmsAPI('API_KEY', 'API_SECRET');
 $result = $api->formatNumber('0455667889', 'AU');

 if ($result->error->code == 'SUCCESS') {
   echo 'Number valid and in international: {$result->number->international}';

 } else {
   echo 'Error: {$result->error->description}';
 }