Updated on 2024-12-30 GMT+08:00

Obtaining the Country Codes

Function

This API is used to obtain the supported country codes.

URI

GET /api/v2/sdk/country-codes

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-operating-sys-version

Yes

String

Caller OS version, for example, Android 10.

X-device-fingerprint

Yes

String

Caller device fingerprint, for example, 156aysdna213sc50.

X-device-ip

No

String

Caller IP address, for example, 10.10.10.1

X-agent

Yes

String

User agent information, for example, Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36

X-L

No

String

Language type, for example, en.

X-client-id

Yes

String

Application ID, which is a ClientId allocated to an application after registration.

X-tenant-id

No

String

Tenant ID. This parameter is mandatory when calling an ISV application. Replace "{domain_name}" with the ISV common domain name "{common_domain}". In the request header, specify tenant_id of the corresponding tenant and replace X-client-id with client_id of the ISV application template.

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

phoneAreaCodeDefinitions

Array of PhoneAreaCodeDefinitionsResult objects

Details about supported country codes.

preferredAreaCode

String

Preferred country codes configured on the administrator portal.

Table 3 PhoneAreaCodeDefinitionsResult

Parameter

Type

Description

areaCode

String

Country code.

displayMapping

DisplayMapping object

Multi-language display name mapping.

countryCode

String

Country code.

mobileRegex

String

Regular expression of the mobile phone number format.

areaCodeSuffixes

String

Country code suffix.

Table 4 DisplayMapping

Parameter

Type

Description

zh-TW

String

Traditional Chinese description.

en

String

English description.

zh-CN

String

Simplified Chinese description.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error details.

Example Requests

Obtain the supported country codes.

GET https://{domain_name}/api/v2/sdk/country-codes

X-operating-sys-version: Android 10
X-device-fingerprint: 156aysdna213sac
X-device-ip: 10.10.10.1
X-agent: Mozilla/5.0 (Linux; Android 10; Redmi K30 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36
X-L: zh
X-client-id: DRrYIqauawN0I8myTMoDTPys6ezGZxnm
X-tenant-id: 08f770f51f80d2f40f38c00cb199fd21

Example Responses

Status code: 200

Request successful.

{
  "phoneAreaCodeDefinitions" : [ {
    "areaCode" : "86",
    "displayMapping" : {
      "zh-TW" : "Chinese mainland (traditional)",
      "en" : "China",
      "zh-CN" : "Chinese mainland (simplified)"
    },
    "countryCode" : "CN",
    "mobileRegex" : "^(\\+86){0,1}\\-?1\\d{10}$",
    "areaCodeSuffixes" : [ ]
  }, {
    "areaCode" : "852",
    "displayMapping" : {
      "zh-TW" : "Hong Kong, China (traditional)",
      "en" : "Hong Kong",
      "zh-CN" : "Hong Kong, China (simplified)"
    },
    "countryCode" : "HK",
    "mobileRegex" : "^(\\+852){1}\\-?0{0,1}[1,4,5,6,7,8,9](?:\\d{7}|\\d{8}|\\d{12})$",
    "areaCodeSuffixes" : [ ]
  }, {
    "areaCode" : "886",
    "displayMapping" : {
      "zh-TW" : "Taiwan, China (traditional)",
      "en" : "Taiwan",
      "zh-CN" : "Taiwan, China (simplified)"
    },
    "countryCode" : "TW",
    "mobileRegex" : "^(\\+886){1}\\-?[6,7,9](?:\\d{7}|\\d{8})$",
    "areaCodeSuffixes" : [ ]
  }, {
    "areaCode" : "853",
    "displayMapping" : {
      "zh-TW" : "Macao, China (traditional)",
      "en" : "Macau",
      "zh-CN" : "Macao, China (simplified)"
    },
    "countryCode" : "MO",
    "mobileRegex" : "^(\\+853){1}\\-?0{0,1}[1,4,5,6,7,8,9](?:\\d{7}|\\d{8}|\\d{12})$",
    "areaCodeSuffixes" : [ ]
  }, {
    "areaCode" : "93",
    "displayMapping" : {
      "zh-TW" : "Afghanistan",
      "en" : "Afghanistan",
      "zh-CN" : "Afghanistan"
    },
    "countryCode" : "AF",
    "mobileRegex" : "^(\\+93){1}\\-\\d{6,11}",
    "areaCodeSuffixes" : [ ]
  } ],
  "preferredAreaCode" : "CN"
}

Status Codes

Status Code

Description

200

Request successful.

400

Invalid parameter.

Error Codes

See Error Codes.