Skip to main content
All CollectionsDesignDesigning Enrolment Forms
Changing the default telephone country code using the API
Changing the default telephone country code using the API

Using Postman to change the default country code on your Data Collection form

Danny Allen avatar
Written by Danny Allen
Updated over a year ago

Note: The default country code can also be changed from the data collection form design page. See how HERE

When collecting the users telephone number using the enrolment form (data collection form), you may want to set the default telephone country code to your locale. This will make the process quicker for the user as they won't have to scroll and find their particular country code.

Currently this can only be done via the API and this article will show how to do this using a platform called Postman.

Pre-requisites

  • A Membership/Loyalty card or Coupon design created

  • Data Collection form enabled with a telephone number field

  • Postman - web version or app here, This article does not explain the set up required in Postman, for more details regarding using Postman, please see here

  • Your API key and secret

First let's see how my form looks, you can see that the country code is defaulted to USA, so if I need a different country code I need to scroll through the countries to find mine.

Steps

The default country code is set in the template, so first we need to find the template ID. The template ID can be found in the tier record.

The first step is to retrieve the tier record using the endpoint below.

GET https://api.pub1.passkit.io/members/tier/{programId}/{tierId}

We need to find the program ID and Tier ID.

Then add these into the endpoint URL in Postman and make the call.

You can find the template ID here - passTemplateId

"passTemplateId": "7cTwXIzup0LFFoe1QiUsSt"

Now we can retrieve the template record using the endpoint below and the template ID you retrieved

https://api.pub1.passkit.io/template/data/{id}

Copy and paste the JSON into a text editor and find the section that holds the telephone number data.

I'm using the default 'Mobile Phone' field which has the field key 'person.mobileNumber'. If you are using a custom field to hold the phone number, you will need to look for that field key.

{
"uniqueName": "person.mobileNumber",
"templateId": "",
"fieldType": "PII",
"isRequired": false,
"label": "Mobile",
"localizedLabel": null,
"dataType": "TEL",
"defaultValue": "",
"localizedDefaultValue": null,
"validation": "",
"userCanSetValue": true,
"currencyCode": "",
"appleWalletFieldRenderOptions": {
"textAlignment": "LEFT",
"positionSettings": {
"section": "AUXILIARY_FIELDS",
"priority": 0
},
"changeMessage": "",
"localizedChangeMessage": null,
"dateStyle": "DATE_TIME_STYLE_DO_NOT_USE",
"timeStyle": "DATE_TIME_STYLE_DO_NOT_USE",
"numberStyle": "NUMBER_STYLE_DO_NOT_USE",
"suppressLinkDetection": [],
"ignoreTimezone": false,
"isRelativeDate": false
},
"dataCollectionFieldRenderOptions": {
"helpText": "",
"localizedHelpText": null,
"displayOrder": 0,
"placeholder": "",
"selectOptions": [],
"localizedPlaceholder": null,
"autocomplete": false,
"addressRenderOptions": null,
"localizedYearPlaceholder": "",
"localizedMonthPlaceholder": "",
"localizedDayPlaceholder": ""
},
"usage": [
"USAGE_GOOGLE_PAY",
"USAGE_APPLE_WALLET",
"USAGE_DATA_COLLECTION_PAGE"
],
"googlePayFieldRenderOptions": {
"googlePayPosition": "GOOGLE_PAY_TEXT_MODULE",
"textModulePriority": 3
},
"defaultTelCountryCode": ""
}

At the bottom of the section you will see

"defaultTelCountryCode": ""

This is the parameter you need to edit.

I want my default country code to be set for Hong Kong, so I need to add the country code +852

"defaultTelCountryCode": "+852"

When done, copy the updated JSON and paste it into a new tab in Postman set up to use the update template endpoint.

PUT https://api.pub1.passkit.io/template

Now we need to run the call, but before we do we need to remove the nesting at the top.

Remove this from the top of the JSON.

{
"template":

Now the template is updated, let's check the enrolment form (data collection form).

Did this answer your question?