MyInfo API (3.1.0)

Download OpenAPI specification:Download

MyInfo REST APIs for retrieving Person data.

Note - this specification is subject to changes based on evolution of the APIs.

Release Notes

  • 3.1.0 (16 September 2019)

    • New data items available:
      • cpfemployers
      • partialuinfin
    • New 'subentity' parameter in person API that allows traceability to platform's client who will be receiving the person data.
    • Provide clarity on the handling of housingtype & hdbtype
  • 3.0.2 (10 May 2019)

    • Upper case all desc values for:
      • Driving Licence : Comstatus, PDL and QDL Validity
      • Children Birth Records: Sex
      • Sponsored Children Records: Sex, Residential Status
      • Person: Sex, Residential Status
  • 3.0.0 (31 Mar 2019)

    IMPORTANT NOTE: response format for person API has substantial changes from the previous version. Please refer to Understanding the Data Structure for details.

    • APIs updated to v3:
      • Test:
        • /com/v3/authorise
        • /com/v3/token
        • /com/v3/person/{uinfin}/
        • /com/v3/person-sample/{uinfin}/
      • Production:
        • /com/v3/authorise
        • /com/v3/token
        • /com/v3/person/{uinfin}/
    • Response changes from JWE to JWE wrapping JWS
    • Security header (changes in Authorization header parameters)
      • Streamline header parameters to app_id, nonce, signature_method (RS256), signature, timestamp
    • Standardisation of 'code', 'desc' and 'value' of all data items.
    • New data items available:
      • employmentsector
      • passtype
      • hdbownership
      • sponsoredchildrenrecords
      • vehicles
      • drivinglicence
    • Rename data items:
      • workpassstatus -> passstatus
      • workpassexpirydate -> passexpirydate
    • Changes to the following data item to include "type" discriminator to discriminate local and foreign address. Format is significantly different between the two.
      • regadd
      • billadd
      • mailadd
    • Deprecated vehno attribute
    • Updated scheduled downtimes: sandbox and test enviroments will no longer have any scheduled downtimes.
  • 2.2.1 (28 Dec 2018)

    • QR only login:
      • changes to support QR only login. login_type parameter must be provided in the authorise API call.
  • 2.2.0 (05 Dec 2018)

    • Base URL changes:

      • Production Environment: from myinfosg.api.gov.sg to api.myinfo.gov.sg
      • Test Environment: from myinfosgstg.api.gov.sg/test to test.api.myinfo.gov.sg
      • Sandbox Environment: from myinfosgstg.api.gov.sg/dev to sandbox.api.myinfo.gov.sg
    • Security header (.e. no longer needed in basestring)

      • Before v2.2.0, when crafting the basestring of the security header, an additional .e. is required in the domain name: e.g. myinfosgstg.api.gov.sg -> myinfosgstg.e.api.gov.sg.
        Note: This is no longer required
      • In v2.2.0, when crafting the basestring of the security header, the url in the basestring is the same as the one you call; e.g. api.myinfo.gov.sg
      • For more details, please refer to Security > Request Signing section for updated instructions.
    • Data items deprecated:

      • assessyear
      • assessableincome
    • New data items available:

      • noa(basic)
      • noa
      • noahistory(basic)
      • noahistory
    • Added link to MyInfo demo app under Support section for easy reference.

  • 2.1.1 (21 September 2018)

    • updated error codes and descriptions for token and person APIs for better clarity when troubleshooting.
  • 2.1.0 (01 July 2018)

    • "relationship" data item is deprecated
    • New data items available:
      • childrenbirthrecords
      • marriagecertno
      • countryofmarriage
      • workpassstatus
      • workpassexpirydate
  • 2.0.0 (20 April 2018)

    • Base URL changed from:
      • myinfo.api.gov.sg to myinfosg.api.gov.sg (Production) and myinfosgstg.api.gov.sg (Staging)
    • APIs updated to v2:
      • Staging:
        • /test/v2/authorise
        • /test/v2/token
        • /test/v2/person/{uinfin}/
      • Production:
        • /v2/authorise
        • /v2/token
        • /v2/person/{uinfin}/
    • Updated responses for v2 Person APIs:
      • Response format will be JSON Web Encryption (JWE) instead of JSON Web Signature (JWS).

Releases and Compatibility

The RESTful API adopts Semantic Versioning 2.0.0 for releases, and every new release of the API increments the version numbers in the following format:

{MAJOR}.{MINOR}.{PATCH}
  1. {MAJOR} number introduces incompatible API changes with previous {MAJOR} number also resets {MINOR} to 0,
  2. {MINOR} number introduces new functionalities or information that are backward compatible also resets {PATCH} to 0, and
  3. {PATCH} number introduces bug fixes and remains backward compatible.

Pre-release or draft versions, when provided, are denoted by appended hypen - with a series of separate identifiers {LABEL}-{VERSION} following the {PATCH} number. Such releases are unstable and may not provide the intended compatibility with the specification in draft status.

Serving as notice, the RESTful API in version 2.X.X are incompatible with version 1.X.X releases.

Despite backward compatibility in {MINOR} or {PATCH} releases, API consumers are best to evaluate and determine their implementation does not disrupt use-case requirements.

Overview

The following diagram illustrates how the integration with MyInfo APIs work: Overview

As shown above, your application will be interfacing with our API Gateway to integrate successfully with MyInfo.

Environments

The RESTful APIs are provided in both testing and live environments, and are accessible over the Internet via HTTPS.

Consumers are to ensure firewall clearance on their edge network nodes for connecting to the APIs.

The convention used by API endpoints' URLs is in the following format:

https://{ENV_DOMAIN_NAME}/{CONTEXT}/{VERSION}/{RESOURCE}
  • {ENV_DOMAIN_NAME} indicates MyInfo's API domain names - respectively:

    • sandbox.api.myinfo.gov.sg, or
    • test.api.myinfo.gov.sg, or
    • api.myinfo.gov.sg, following
  • /{CONTEXT}, indicates the context of the API call = /com

  • /{VERSION} indicates the endpoint's release {MAJOR} version number path - for this release = /v3

  • /{RESOURCE} indicates the API resource path name. Any additional query string parameters are appended as needed.

Available Environments

1. Sandbox Environment

The sandbox environment is used for your testing when developing your prototype. The Person-Sample and Person API will return test data described in https://api.singpass.gov.sg/library/myinfo/developers/resources-personas.

Note:

  • Domain Name: sandbox.api.myinfo.gov.sg
  • PKI digital signature is not required for all APIs.
  • Authorization Bearer access token is not required in Person-Sample API.
  • Authorization Bearer access token is required in Person API.

2. Test Environment

The test enviroment is used for testing your application with the full security measures required in production. The Person API will return test data described in https://api.singpass.gov.sg/library/myinfo/developers/resources-personas.

Note:

  • Domain Name: test.api.myinfo.gov.sg
  • PKI digital signature is required for Token and Person APIs.
    Refer to Security > Request Signing for the steps to sign your request.
  • Authorization Bearer access token is required in Person API.

3. Production Environment

The production enviroment is the actual live environment with full security measures and live data.

Note:

  • Domain Name: api.myinfo.gov.sg
  • PKI digital signature is required for Token and Person APIs.
    Refer to Security > Request Signing for the steps to sign your request.
  • Authorization Bearer access token is required in Person API.

Scheduled Downtimes

The following are the scheduled downtimes for the various environments:

Production Environment

  • CPFB data - Everyday 5:00am to 5:30am
  • IRAS data - Every Wed, 2:00am to 6:00am, Every Sun, 2:00am to 8:30am
  • Once a month, Sunday 12:00 am to 8:00 am (date to be advised)

Test Environment

  • none

Sandbox Environment

  • none

Security

HTTPS Interface

MyInfo's API gateway supports accessing of APIs via the following interfaces:

  • HTTP version 1.1 connection over TLS (Transport Layer Security) version 1.1 or 1.2 standards, and ciphersuites:

    • using AES (Advanced Encryption Standard) and SHA (Secure Hash Algorithm),
    • on either GCM (Galois/Counter Mode) or CBC (Cipher Block Chaining) mode.
  • Below is the list of recommended cipher suites that you may use:

    • TLS_RSA_WITH_AES_256_GCM_SHA384
    • TLS_RSA_WITH_AES_128_GCM_SHA256
    • TLS_RSA_WITH_AES_256_CBC_SHA256
    • TLS_RSA_WITH_AES_256_CBC_SHA
    • TLS_RSA_WITH_AES_128_CBC_SHA256
    • TLS_RSA_WITH_AES_128_CBC_SHA

IMPORTANT: ensure your server supports TLS 1.1 or 1.2 and supports a cipher suite in the list above.

Accessing the RESTful APIs using prior versions of TLS and/or unsupported ciphersuites will result in connectivity errors. MyInfo's API gateway does not support 2-way TLS client nor mutual authentication.

API HTTP interface features:

  1. JSON (JavaScript Object Notation) is the supported data media format and indicated in Content-Type header application/json, also
  2. Content-Length header is omitted by having Transfer-Encoding header chunked emitted for streaming data, and
  3. GZip (GNU Zip) response compression is supported by opt-in Accept-Encoding: gzip and indicated in Content-Encoding header gzip.

OAuth2.0

MyInfo APIs use OAuth2.0 authorisation code flow to perform authentication & authorisation.

The sequence diagram below illustrates the steps involved in integrating your application with our APIs:

OAuth

The flow consists of 3 APIs:

  1. Authorise

    • This will trigger the SingPass login and consent page. Once successful, your application will receive the authorisation code via your callback url.
  2. Token

    • Call this server-to-server API with a valid authorisation code to get the access token.
  3. Protected Resource (Person)

    • Call this server-to-server API with a valid access token to get the person data.

Application Authentication

Access to all server-to-server APIs will be authenticated by MyInfo's API gateway. Prior to calling the APIs, respective consumers are required to have:

  • approval of access, onboarding process for the required API resources will be provisioned, and
  • authentication credentials are then supplied and exchanged.

Authentication methods provided by MyInfo's API gateway on internet:

  • OAuth 2.0 using RS256 digital signature (see "Request Signing" section below)
  • Digital signature should be produced using a RSA private key with corresponding public certificate issued by one of the following compatible CAs:
    • digiCert
    • Entrust
    • Comodo
    • VeriSign
    • GlobalSign
    • GeoTrust
    • Thawte

Request Signing

NOTE: Test and Production Environments only

All server-to-server API requests are to be digitally signed, by including the following parameters and values in the Authorization header:

PKI_SIGN app_id="{app_id}",
nonce="{random_nonce}",
signature_method="RS256",
signature="{base64_url_percent_encoded_signature}",
timestamp="{unix_epoch_in_milliseconds}"

Note: Above sample is separated by lines for ease-of-reading, and new-line denotations are to be omitted in the actual request.

  • {app_id} is the APP ID credential supplied upon onboarding,

  • {random_nonce} is an unique randomly generated text used for replay prevention,

  • {signature_method} is the signature algorithm of the authenticating gateway.

    • Value of signature_method = RS256
  • {base64_url_percent_encoded_signature} is the binary of the generated signature encoded in Base64 URL-safe format,

  • {unix_epoch_in_milliseconds} is the UNIX epoch time in milliseconds

Sample header with authorization parameters

Below is an example of an Authorization header for the sample application. Make sure you list the parameters in the sequence shown below.

  Authorization: PKI_SIGN
  app_id="STG2-MYINFO-SELF-TEST",
  nonce="150590021034800",
  signature_method="RS256",
  signature="EEm+HEcNQajb5FkVd82zjojk+daYZXxSGPCOR2GHZeoyjZY1PK+aFMzHfWu7eJZYMa5WaEwWxdOdq5hjNbl8kHD7bMaOks7FgEPdjE++TNomfv7SMktDnIvZmPYAxhjb/C9POU2KT6tSlZT/Si/qMgD1cryaPwSeMoM59UZa1GzYmqlkveba7rma58uGwb3wZFH0n57UnouR6LYXDOOLkqi8uMZBuvRUvSJRXETAj2N0hT+4QJiN96Ct6IEQh/woZh0o74K5Ol9PpDSM08qC7Lj6N/k694J+hbBQVVviGn7/6mDkfbwdMDuoKs4t7NpqmAnwT+xaQSIZcexfrAVQYA==",
  timestamp="1505900210349"

Sample Code in NodeJS

  // generates the security headers for calling API gateway
  function generateAuthorizationHeader(url, params, method, strContentType, authType, appId, keyCertContent, passphrase) {

    if (authType == "L2") {
      return generateRS256Header(url, params, method, strContentType, appId, keyCertContent, passphrase);
    } else {
      return "";
    }
  };

  // Signing Your Requests
  function generateRS256Header(url, params, method, strContentType, appId, keyCertContent, keyCertPassphrase) {
    var nonceValue = nonce();
    var timestamp = (new Date).getTime();

    // A) Construct the Authorisation Token Parameters
    var defaultAuthHeaders = {
      "app_id": appId, // App ID assigned to your application
      "nonce": nonceValue, // secure random number
      "signature_method": "RS256",
      "timestamp": timestamp // Unix epoch time
    };

    // B) Forming the Base String
    // Base String is a representation of the entire request (ensures message integrity)

    // i) Normalize request parameters
    var baseParams = sortJSON(_.merge(defaultAuthHeaders, params));

    var baseParamsStr = qs.stringify(baseParams);
    baseParamsStr = qs.unescape(baseParamsStr); // url safe

    // ii) concatenate request elements (HTTP method + url + base string parameters)
    var baseString = method.toUpperCase() + "&" + url + "&" + baseParamsStr;

    // C) Signing Base String to get Digital Signature
    var signWith = {
      key: fs.readFileSync(keyCertContent, 'utf8')
    }; // Provides private key

    // Load pem file containing the x509 cert & private key & sign the base string with it to produce the Digital Signature
    var signature = crypto.createSign('RSA-SHA256')
      .update(baseString)
      .sign(signWith, 'base64');

    // D) Assembling the Authorization Header
    var strAuthHeader = "PKI_SIGN app_id=\"" + appId + // Defaults to 1st part of incoming request hostname
      "\",timestamp=\"" + timestamp +
      "\",nonce=\"" + nonceValue +
      "\",signature_method=\"RS256\"" +
      ",signature=\"" + signature +
      "\"";

    return strAuthHeader;
  };

Token Validation

NOTE: Person APIs only

Access Tokens are in JWT format. This JWT complies to the standard 'JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants' (https://tools.ietf.org/html/rfc7523). You will need to verify the token with our public cert (provided during application onboarding).

Sample Code in NodeJS

  // Sample Code for Verifying & Decoding JWS or JWT
  function verifyJWS(jws, publicCert) {
    // verify token
    // ignore notbefore check because it gives errors sometimes if the call is too fast.
    try {
      var jwspayload = jwt.verify(jws, fs.readFileSync(publicCert, 'utf8'), {
        algorithms: ['RS256'],
        ignoreNotBefore: true
      });
      return jwspayload;
    }
    catch(error) {
      throw("Error with verifying and decoding JWS");
    }
  }

Payload Signing and Encryption (Person)

NOTE: Person APIs in Test and Production environments only

The response payload for the Person API (for test and production environments) is first signed, then encrypted:

Encryption protects the data at rest while a signed payload means, if necessary, you will be able to pass this signed payload to a 3rd party where they can verify the payload's integrity with our public certificate.

In order to read the payload, you have to perform the following steps in order:

  1. Decrypt the payload with your application's private key.
  2. Validate the decrypted payload signature with our public key.

After doing the above steps, your application will be able to extract the payload in JSON format.

STEP 1: Decryption

  • Encryption is done using your application's public key that you provided during onboarding. Decryption of the payload should be using the private key of that key-pair.
  • Current encryption algorithms used:
    • RSA-OAEP (for content key wrapping)
    • AES256GCM (for content encrytion)

Sample Code in NodeJS

  // Sample Code for decrypting JWE
  // Decrypt JWE using private key
  function decryptJWE(header, encryptedKey, iv, cipherText, tag, privateKey) {

    return new Promise((resolve, reject) => {

      var keystore = jose.JWK.createKeyStore();

      var data = {
        "type": "compact",
        "ciphertext": cipherText,
        "protected": header,
        "encrypted_key": encryptedKey,
        "tag": tag,
        "iv": iv,
        "header": JSON.parse(jose.util.base64url.decode(header).toString())
      };
      keystore.add(fs.readFileSync(privateKey, 'utf8'), "pem")
        .then(function(jweKey) {
          // {result} is a jose.JWK.Key
          jose.JWE.createDecrypt(jweKey)
            .decrypt(data)
            .then(function(result) {
              resolve(JSON.parse(result.payload.toString()));
            })
            .catch(function(error) {
              reject(error);
            });
        });

    })
    .catch (error => {
      throw "Error with decrypting JWE";
    })
  }

STEP 2: Verification of Signature

The decrypted payload is signed according to JWS (JSON Web Signature) format, similar to the access token.

  • signature algorithm used is RS256.

Sample Code in NodeJS

  // Sample Code for Verifying & Decoding JWS or JWT
  function verifyJWS(jws, publicCert) {
    // verify payload
    // ignore notbefore check because it gives errors sometimes if the call is too fast.
    try {
      var jwspayload = jwt.verify(jws, fs.readFileSync(publicCert, 'utf8'), {
        algorithms: ['RS256'],
        ignoreNotBefore: true
      });
      return jwspayload;
    }
    catch(error) {
      throw("Error with verifying and decoding JWS");
    }
  }

Understanding the Data Structure (NEW in v3)

MyInfo Person data follows a specific structure that you need to understand to traverse the data effectively. This section will explain the structure in detail.

The diagram below illustrates how the data is represented logically:
MyInfo Person Data Structure

Data Items (Top-Level)

Each top-level data item can either be a data item object or an array of data item objects. Each data item object will consist of the following properties:

  • classification (Data classification of data field. Default 'C' - Confidential)
  • source (see below)
  • lastupdated (Last updated date of data field. See "full-date" here)
  • unavailable (in certain situations - see below)
  • additional data properties containing data values or arrays

Data Source

The source property indicates the source of data. Possible values are:

  • '1' - Government-verified
  • '2' - User provided
  • '3' - Field is Not Applicable to Person
  • '4' - Verified by SingPass

Note: All Government-verified fields must be non-editable on your digital service form (some exceptions apply - see individual field descriptions).

Data Properties

In each data item, there can be multiple data properties or arrays of data properties.

Each data property will contain either:

  • a value property, or
  • a pair of code and desc properties, or
  • an array of data properties, or
  • other data properties

Note:

  • value property can be strings, numbers, or dates.
  • code and desc pairs will contain the code and its matching description.
  • value is mutually exclusive from (code + desc); i.e. if there is a value, there will not be any code or desc.
  • Where there is code, there will always be a desc - no value will be present.

Exceptions: For these cases, the values will be directly in the property and not in a value, code or desc subproperty:

  • for data item metadata properties; e.g. classification, source, lastupdated, and unavailable
  • for discriminator properties; e.g. type in address formats

Data Not Applicable

Sometimes, a requested data item is not applicable to the person. Examples include:

  • a foreigner will never have a regadd data item.
  • a singapore citizen or permanent resident will never have passtype data item.

For a full list, refer to the "Data Catalog" section of MyInfo API Data in our portal.

Note: When a requested data item is not applicable to the person, the source property will be 3. In such cases, please ignore the data item completely.

Data Item Not Applicable

When a requested data item is not applicable to the entity:

  • for data item objects, the source property will be 3
  • for data item arrays, an empty array will be returned

In such cases, please ignore the data item completely.

Data Property Not Applicable

  • When a data property is not applicable to the person, it will not appear in the schema of that particular entity type.
  • Please check the Person schema to identify which data properties are not applicable to the person type.

Data Unavailable

In other situations, a requested data item might not have any data for that data item from the data source; i.e. data is unavailable. Examples include:

  • when a person does not have any CPF contributions in the last 15 months
  • when a person does not have any IRAS Notice of Assessments in the last 3 years
  • when a person does not have any vehicles registered under them

Note: When a requested data item is unavailable:

  • for data item objects, the data item will have the property unavailable with value true.
    In such cases, no additional properties (other than classification, source, and lastupdated) will be provided for the data item.
  • for arrays of data items, an empty array will be returned.

Please display as "Not Available" in your form.

Data Item Unavailable

  • for data item objects, the data item will have the property unavailable with value true.
    In such cases, no additional properties (other than classification, source, lastupdated) will be provided for the data item.
  • for data item arrays, an empty array will be returned.

Please display as "Not Available" in your form.

Data Property Unavailable

  • for data property objects, the value or code/desc will be empty value ("") or NaN.
  • for arrays of data properties, an empty array will be returned.

Error Handling

The RESTful APIs used HTTP specification standard status codes to indicate the success or failure of each request. Except gateway errors, the response content will be in the following JSON format:

{
    "code": "integer (int32)",
    "message": "string"
}

Refer to the individual API definitions for the error codes you might encounter for each API.

Support

Please refer to the NDI {api} Portal for the following supporting materials where relevant:

For technical queries, contact support@myinfo.gov.sg.

For business queries, contact partner@myinfo.gov.sg.

Authentication

PKISign

PKI digital signature for server to server calls. See Request Signing for more details.

Security scheme type: HTTP
HTTP Authorization Scheme Mutual authentication via PKI digital signature in Authorization header

OAuth2

The following are the available OAuth2 scopes for MyInfo APIs

Security scheme type: OAuth2
authorizationCode OAuth Flow
Authorization URL: /com/v3/authorise
Token URL: /com/v3/token
Scopes:
  • uinfin -

    NRIC/FIN

  • partialuinfin -

    Partial NRIC/FIN

  • name -

    Principal Name

  • aliasname -

    Alias Name

  • hanyupinyinname -

    Hanyu Pinyin Name

  • hanyupinyinaliasname -

    Hanyu Pinyin Alias Name

  • marriedname -

    Married Name

  • sex -

    Sex

  • race -

    Race

  • secondaryrace -

    Secondary Race

  • dialect -

    Dialect

  • dob -

    Date of Birth

  • residentialstatus -

    Residential Status

  • nationality -

    Nationality

  • birthcountry -

    Country of Birth

  • passportnumber -

    Passport Number

  • passportexpirydate -

    Passport Expiry Date

  • passtype -

    Pass Type

  • passstatus -

    Pass Status

  • passexpirydate -

    Pass Expiry Date

  • employmentsector -

    Employment Sector

  • mobileno -

    Mobile Number

  • homeno -

    Home Contact Number

  • email -

    Email Address

  • regadd -

    Registered Address

  • hdbtype -

    Type of HDB

  • housingtype -

    Type of Housing

  • mailadd -

    Mailing Address

  • billadd -

    Billing Address

  • cpfbalances -

    CPF Account Balance

  • cpfcontributions -

    CPF Contribution History (up to 15 months)

  • cpfemployers -

    Employers who paid CPF Contribution (up to 15 months)

  • noa-basic -

    Notice of Assessment (Basic, Latest Year)

  • noahistory-basic -

    Notice of Assessment (Basic, Last 2 Years)

  • noa -

    Notice of Assessment (Detailed, Latest Year)

  • noahistory -

    Notice of Assessment (Detailed, Last 2 Years)

  • ownerprivate -

    Ownership of Private Residential Property

  • householdincome -

    Monthly Household Income

  • employment -

    Name of Employer

  • occupation -

    Occupation

  • edulevel -

    Highest Education Level

  • schoolname -

    Name of School Attended

  • gradyear -

    Year of Graduation

  • marital -

    Marital Status

  • marriagedate -

    Marriage Date

  • marriagecertno -

    Marriage Certificate Number

  • countryofmarriage -

    Country of Marriage

  • divorcedate -

    Divorce Date

  • childrenbirthrecords.birthcertno -

    Children Birth Records - Birth Cert Number

  • childrenbirthrecords.name -

    Children Birth Records - Name

  • childrenbirthrecords.aliasname -

    Children Birth Records - Alias Name

  • childrenbirthrecords.hanyupinyinname -

    Children Birth Records - Hanyu Pinyin Name

  • childrenbirthrecords.hanyupinyinaliasname -

    Children Birth Records - Hanyu Pinyin Alias Name

  • childrenbirthrecords.marriedname -

    Children Birth Records - Married Name

  • childrenbirthrecords.sex -

    Children Birth Records - Sex

  • childrenbirthrecords.race -

    Children Birth Records - Race

  • childrenbirthrecords.secondaryrace -

    Children Birth Records - Secondary Race

  • childrenbirthrecords.dob -

    Children Birth Records - Date of Birth

  • childrenbirthrecords.tob -

    Children Birth Records - Time of Birth

  • childrenbirthrecords.dialect -

    Children Birth Records - Dialect

  • childrenbirthrecords.lifestatus -

    Children Birth Records - Life Status

  • sponsoredchildrenrecords.nric -

    Sponsored Children Records - NRIC

  • sponsoredchildrenrecords.name -

    Sponsored Children Records - Name

  • sponsoredchildrenrecords.aliasname -

    Sponsored Children Records - Alias Name

  • sponsoredchildrenrecords.hanyupinyinname -

    Sponsored Children Records - Hanyu Pinyin Name

  • sponsoredchildrenrecords.hanyupinyinaliasname -

    Sponsored Children Records - Hanyu Pinyin Alias Name

  • sponsoredchildrenrecords.marriedname -

    Sponsored Children Records - Married Name

  • sponsoredchildrenrecords.sex -

    Sponsored Children Records - Sex

  • sponsoredchildrenrecords.race -

    Sponsored Children Records - Race

  • sponsoredchildrenrecords.secondaryrace -

    Sponsored Children Records - Secondary Race

  • sponsoredchildrenrecords.dialect -

    Sponsored Children Records - Dialect

  • sponsoredchildrenrecords.dob -

    Sponsored Children Records - Date of Birth

  • sponsoredchildrenrecords.birthcountry -

    Sponsored Children Records - Country of Birth

  • sponsoredchildrenrecords.lifestatus -

    Sponsored Children Records - Life Status

  • sponsoredchildrenrecords.residentialstatus -

    Sponsored Children Records - Residential Status

  • sponsoredchildrenrecords.nationality -

    Sponsored Children Records - Nationality

  • sponsoredchildrenrecords.scprgrantdate -

    Sponsored Children Records - SC PR Grant Date

  • vehicles.vehicleno -

    Vehicles - Vehicle Number

  • vehicles.type -

    Vehicles - Vehicle Type

  • vehicles.iulabelno -

    Vehicles - IU Label Number

  • vehicles.make -

    Vehicles - Vehicle Make

  • vehicles.model -

    Vehicles - Vehicle Model

  • vehicles.chassisno -

    Vehicles - Chassis Number

  • vehicles.engineno -

    Vehicles - Engine Number

  • vehicles.motorno -

    Vehicles - Motor Number

  • vehicles.yearofmanufacture -

    Vehicles - Year of Manufacture

  • vehicles.firstregistrationdate -

    Vehicles - First Registration Date

  • vehicles.originalregistrationdate -

    Vehicles - Original Registration Date

  • vehicles.coecategory -

    Vehicles - COE Category

  • vehicles.coeexpirydate -

    Vehicles - COE Expiry Date

  • vehicles.roadtaxexpirydate -

    Vehicles - Road Tax Expiry Date

  • vehicles.quotapremium -

    Vehicles - Quota Premium

  • vehicles.openmarketvalue -

    Vehicles - Open Market Value

  • vehicles.co2emission -

    Vehicles - CO2 Emission Rate

  • vehicles.status -

    Vehicles - Vehicle Status

  • vehicles.primarycolour -

    Vehicles - Primary Colour

  • vehicles.secondarycolour -

    Vehicles - Secondary Colour

  • vehicles.attachment1 -

    Vehicles - Attachment 1

  • vehicles.attachment2 -

    Vehicles - Attachment 2

  • vehicles.attachment3 -

    Vehicles - Attachment 3

  • vehicles.scheme -

    Vehicles - Vehicle Scheme

  • vehicles.thcemission -

    Vehicles - THC Emission Rate

  • vehicles.coemission -

    Vehicles - CO Emission Rate

  • vehicles.noxemission -

    Vehicles - NOx Emission Rate

  • vehicles.pmemission -

    Vehicles - PM Emission Rate

  • vehicles.enginecapacity -

    Vehicles - Engine Capacity

  • vehicles.powerrate -

    Vehicles - Power Rate

  • vehicles.effectiveownership -

    Vehicles - Effective Date/Time of Ownership

  • vehicles.propellant -

    Vehicles - Propellant

  • vehicles.maximumunladenweight -

    Vehicles - Max Unladen Weight

  • vehicles.maximumladenweight -

    Vehicles - Max Laden Weight

  • vehicles.minimumparfbenefit -

    Vehicles - Minimum PARF Benefit

  • vehicles.nooftransfers -

    Vehicles - No. of Transfers

  • vehicles.vpc -

    Vehicles - Vehicle Parking Certificate

  • drivinglicence.comstatus -

    Driving Licence - Certificate of Merit Status

  • drivinglicence.totaldemeritpoints -

    Driving Licence - Total Demerit Points

  • drivinglicence.suspension.startdate -

    Driving Licence - Suspension Start Date

  • drivinglicence.suspension.enddate -

    Driving Licence - Suspension End Date

  • drivinglicence.disqualification.startdate -

    Driving Licence - Disqualification Start Date

  • drivinglicence.disqualification.enddate -

    Driving Licence - Disqualification End Date

  • drivinglicence.revocation.startdate -

    Driving Licence - Revocation Start Date

  • drivinglicence.revocation.enddate -

    Driving Licence - Revocation End Date

  • drivinglicence.pdl.validity -

    Driving Licence - Provisional Driving Licence Validity

  • drivinglicence.pdl.expirydate -

    Driving Licence - Provisional Driving Licence Expiry Date

  • drivinglicence.pdl.classes -

    Driving Licence - Provisional Driving Licence Class

  • drivinglicence.qdl.validity -

    Driving Licence - Qualified Driving Licence Validity

  • drivinglicence.qdl.expirydate -

    Driving Licence - Qualified Driving Licence Expiry Date

  • drivinglicence.qdl.classes -

    Driving Licence - Qualified Driving Licence Class

  • drivinglicence.photocardserialno -

    Driving Licence - Photo Card Serial Number

  • hdbownership.noofowners -

    HDB Ownership - Number of Owners

  • hdbownership.address -

    HDB Ownership - Address

  • hdbownership.hdbtype -

    HDB Ownership - Type of HDB Dwelling

  • hdbownership.leasecommencementdate -

    HDB Ownership - Lease Commencement Date

  • hdbownership.termoflease -

    HDB Ownership - Term of Lease

  • hdbownership.dateofpurchase -

    HDB Ownership - Date of Purchase

  • hdbownership.dateofownershiptransfer -

    HDB Ownership - Date of Transfer of Ownership

  • hdbownership.loangranted -

    HDB Ownership - Loan Granted

  • hdbownership.originalloanrepayment -

    HDB Ownership - Original Loan Repayment Period

  • hdbownership.balanceloanrepayment -

    HDB Ownership - Balance Loan Repayment Period

  • hdbownership.outstandingloanbalance -

    HDB Ownership - Outstanding HDB Loan Balance

  • hdbownership.monthlyloaninstalment -

    HDB Ownership - Monthly Loan Instalment

MyInfo

RESTful API Definitions

Person-Sample

Retrieves a sample Person data from MyInfo based on UIN/FIN.

This API does not use OAuth2.0 to perform authentication or authorisation, and does not require authorisation token and digital signature.

Note: Null value indicates that an attribute is unavailable.

path Parameters
uinfin
required
string
Example: "S9812381D"
query Parameters
attributes
Array of string
Example: "name,hanyupinyinname"

Comma separated list of attributes requested. Possible attributes are listed in the scopes of the OAuth2 Security Schema above.

Responses

200

OK.

Note:

  • Response will be a JSON object.
get /com/v3/person-sample/{uinfin}/
Sandbox
https://sandbox.api.myinfo.gov.sg/com/v3/person-sample/{uinfin}/

Request samples

Copy
curl https://sandbox.api.myinfo.gov.sg/com/v3/person-sample/S9812381D

Response samples

application/json
Copy
Expand all Collapse all
{
  • "uinfin":
    {
    },
  • "partialuinfin":
    {
    },
  • "name":
    {
    },
  • "hanyupinyinname":
    {
    },
  • "aliasname":
    {
    },
  • "hanyupinyinaliasname":
    {
    },
  • "marriedname":
    {
    },
  • "sex":
    {
    },
  • "race":
    {
    },
  • "secondaryrace":
    {
    },
  • "dialect":
    {
    },
  • "nationality":
    {
    },
  • "dob":
    {
    },
  • "birthcountry":
    {
    },
  • "residentialstatus":
    {
    },
  • "passportnumber":
    {
    },
  • "passportexpirydate":
    {
    },
  • "regadd":
    {
    },
  • "mailadd":
    {
    },
  • "billadd":
    {
    },
  • "housingtype":
    {
    },
  • "hdbtype":
    {
    },
  • "hdbownership":
    [
    ],
  • "ownerprivate":
    {
    },
  • "email":
    {
    },
  • "homeno":
    {
    },
  • "mobileno":
    {
    },
  • "marital":
    {
    },
  • "marriagecertno":
    {
    },
  • "countryofmarriage":
    {
    },
  • "marriagedate":
    {
    },
  • "divorcedate":
    {
    },
  • "childrenbirthrecords":
    [
    ],
  • "sponsoredchildrenrecords":
    [
    ],
  • "edulevel":
    {
    },
  • "gradyear":
    {
    },
  • "schoolname":
    {
    },
  • "occupation":
    {
    },
  • "employment":
    {
    },
  • "passtype":
    {
    },
  • "passstatus":
    {
    },
  • "passexpirydate":
    {
    },
  • "employmentsector":
    {
    },
  • "householdincome":
    {
    },
  • "noa-basic":
    {
    },
  • "noa":
    {
    },
  • "noahistory-basic":
    {
    },
  • "noahistory":
    {
    },
  • "cpfcontributions":
    {
    },
  • "cpfemployers":
    {
    },
  • "cpfbalances":
    {
    },
  • "vehicles":
    [
    ],
  • "drivinglicence":
    {
    }
}

Authorise

This API triggers SingPass login and obtain consent for the user to retrieve user's data from MyInfo. Once the user has authenticated and consented, an authorisation code (authcode) will be returned together with the state for verification via the callback URL defined. The authcode can then be used to retrieve an access token via the Token API.

Note: This API is public and should be implemented as a link or button on your online webpage.

query Parameters
authmode
string
Default: "SINGPASS"
Enum:"SINGPASS" "MOBILEID"

Mode of authentication used to obtain user consent. Default is "SINGPASS".

purpose
required
string

State the purpose for requesting the data. This will be shown to the user for his consent.

response_type
string
Default: "code"

Response type for authorisation code flow - must be "code".

attributes
required
Array of string
Example: "name,hanyupinyinname"

Comma separated list of attributes requested. Possible attributes are listed in the scopes of the OAuth2 Security Schema above.

state
required
string

Identifier that represents the user's session/transaction with the client for reconciling query and response. The same value will be sent back via the callback URL. Use a unique system generated number for each user/transaction.

redirect_uri
required
string

Your callback URL for MyInfo to return with the authorisation code.

client_id
required
string
Example: "STG-180099999K-TEST01"

Unique ID for your application.

login_type
string
Default: "SINGPASS"
Enum:"SINGPASS" "QR"

Pilot for SingPass-QR-only-login using SingPass Mobile. SingPass-QR-only-login is enabled by specifying this parameter with value set to QR.

Note that this only applies to digital service on-boarded to perform SingPass-QR-only-login.

Responses

302

Service will redirect all responses to 'redirect_uri' with additional parameters added as response results. Expected parameters include:

  • code: this is the authorisation code you will use when calling the token endpoint
  • state: this should be the same state passed in your initial URL.
  • error: if there are any errors encountered, the error code will be given in this parameter.
    • '500' - Unknown or other server side errors.
    • '503' - MyInfo under maintenance. Error description will also be given in error_description parameter.
    • 'access_denied' - When user did not give consent, refer to error_description parameter for the reason.
  • error_description: if error is 'access_denied' i.e. user did not give consent, the description will be 'Resource Owner did not authorize the request'.

Note: If user closes the browser window prematurely, there will be no callback to the 'redirect_uri'. Therefore it is important for you to check the 'state' to verify that the transaction is the same.

get /com/v3/authorise
Sandbox
https://sandbox.api.myinfo.gov.sg/com/v3/authorise
Test
https://test.api.myinfo.gov.sg/com/v3/authorise
Production
https://api.myinfo.gov.sg/com/v3/authorise

Request samples

Copy
function callAuthoriseApi() {
  var authoriseUrl = authApiUrl + "?client_id=" + clientId +
    "&attributes=" + attributes +
    "&purpose=" + purpose +
    "&state=" + state +
    "&redirect_uri=" + redirectUrl;

  window.location = authoriseUrl;
}

Token

This API generates an access token when presented with a valid authcode obtained from the Authorise API. This token can then be used to request for the user's data that were consented.

Authorizations:
header Parameters
Authorization
required
string

Add authorization token constructed containing the RSA digital signature of the base string. Refer to https://api.singpass.gov.sg/library/myinfo/developers/tutorial3 on how this token should be generated.

Note: This header is not required when calling Sandbox API.

Request Body schema: application/x-www-form-urlencoded
code
required
string

The authcode given by the authorise API.

grant_type
string
Default: "authorization_code"

Grant type for getting token (default "authorization_code")

client_secret
required
string

Secret key given to your application during onboarding.

client_id
required
string

Unique ID for your application.

redirect_uri
required
string

Application's callback URL.

state
string

Identifier that represents the user's session with the client, provided earlier during the authorise API call.

Responses

200

OK.

Returning a JSON object which contains the authorization access token (JWT) that will be used to retrieve the data from MyInfo.

400

Possible scenarios:

  • Same authcode in the body is being re-used. We do not allow same authcode being used in multiple calls. Ensure that authcode is not repeated.
  • AuthCode error - missing, invalid, expired, revoked
401

Unauthorized.

Possible scenarios:

  • No security header given (HTTP 'Authorization' header)
  • Invalid App ID used. Digital service is not registered with MyInfo
  • The timestamp of server is not synchronised. Check timestamp of server.
  • The value of the nonce in the authorisation header was deemed to be repeated. Check that the nonce is not re-used
  • Ensure HTTP 'Authorization' header to be 'PKI_SIGN'
  • Signature incorrect - Verify your signature by using our signature verifier tool and ensure correct key is used to sign the base string.
    • Ensure that base string contains all parameters required
    • Ensure attributes in base string are separate by comma(,), and not %2C
    • Ensure that correct key is used to sign the base string
    • Ensure that HTTP call is made with the same query/body parameters used to formulate the base string.
    • Ensure the base string contains the following:
      1. HTTP GET method(in uppercase)
      2. API (e.g. https://..)
      3. These parameters:
        • app_id
        • nonce
        • signature
        • signature_method
        • timestamp
403

Forbidden

Possible scenarios:

  • Incorrect API URL used. Refer to tutorial for the correct API URL(test/production)
500

Unexpected error. Check response body for actual error.

post /com/v3/token
Sandbox
https://sandbox.api.myinfo.gov.sg/com/v3/token
Test
https://test.api.myinfo.gov.sg/com/v3/token
Production
https://api.myinfo.gov.sg/com/v3/token

Request samples

Copy
// function to prepare request for TOKEN API
function createTokenRequest(code) {
  var cacheCtl = "no-cache";
  var contentType = "application/x-www-form-urlencoded";
  var method = "POST";
  var request = null;

  // preparing the request with header and parameters
  // assemble params for Token API
  var strParams = "grant_type=authorization_code" +
    "&code=" + code +
    "&redirect_uri=" + _redirectUrl +
    "&client_id=" + _clientId +
    "&client_secret=" + _clientSecret;
  var params = querystring.parse(strParams);


  // assemble headers for Token API
  var strHeaders = "Content-Type=" + contentType + "&Cache-Control=" + cacheCtl;
  var headers = querystring.parse(strHeaders);

  // Sign request and add Authorization Headers
  var authHeaders = generateAuthorizationHeader(
    _tokenApiUrl,
    params,
    method,
    contentType,
    _authLevel,
    _clientId,
    _privateKeyContent,
    _clientSecret
  );

  if (!_.isEmpty(authHeaders)) {
    _.set(headers, "Authorization", authHeaders);
  }

  var request = restClient.post(_tokenApiUrl);

  // Set headers
  if (!_.isUndefined(headers) && !_.isEmpty(headers))
    request.set(headers);

  // Set Params
  if (!_.isUndefined(params) && !_.isEmpty(params))
    request.send(params);

  return request;
}

Response samples

application/json
Copy
Expand all Collapse all
{
  • "token_type": "Bearer",
  • "id_token": "string",
  • "access_token":
    {
    }
}

Person

This API returns user's data from MyInfo when presented with a valid access token obtained from the Token API.

Note: Null value indicates that an attribute is unavailable.

Authorizations:
path Parameters
uinfin
required
string
Example: "S9812381D"

UIN/FIN of user

query Parameters
txnNo
string

Transaction ID from requesting digital services for cross referencing.

attributes
required
Array of string
Example: "name,hanyupinyinname"

Comma separated list of attributes requested. Possible attributes are listed in the scopes of the OAuth2 Security Schema above.

client_id
required
string
Example: "STG-180099999K-TEST01"

Unique ID for your application.

subentity
string <= 10 characters
Example: "PARTNER001"

Field that allows traceability to platform's client who will be receiving the person data. Only applicable to

header Parameters
Authorization
required
any

Add authorization token constructed containing the RSA digital signature of the base string. Refer to https://api.singpass.gov.sg/library/myinfo/developers/tutorial3 on how this token should be generated. Also include the access token (JWT) from /token API in your header prefixed with 'Bearer'.

Note: Only the Bearer token is required when calling Sandbox API.

Responses

200

OK.

Note:

  • Response Content-Type will be 'application/jose', which is a JSON object conforming to the JWE standard (https://tools.ietf.org/html/rfc7516).
  • Response contents are first signed, then encrypted. In order to access the data, your application should do the following steps in order:
    1. Decrypt the payload with your application's private key.
    2. Validate the decrypted payload signature with our public key.
  • After doing the above steps, your application will be able to extract the payload in JSON format.
401

Unauthorized.

Possible scenarios:

  • No security header given (HTTP 'Authorization' header)
  • Invalid App ID used. Digital service is not registered with MyInfo
  • The timestamp of server is not synchronised. Check timestamp of server.
  • The value of the nonce in the authorisation header was deemed to be repeated. Check that the nonce is not re-used
  • Ensure HTTP 'Authorization' header to be 'PKI_SIGN'
  • Signature incorrect - Verify your signature by using our signature verifier tool and ensure correct key is used to sign the base string.
    • Ensure that base string contains all parameters required
    • Ensure attributes in base string are separate by comma(,), and not %2C
    • Ensure that correct key is used to sign the base string
    • Ensure that HTTP call is made with the same query/body parameters used to formulate the base string.
    • Ensure the base string contains the following:
      1. HTTP GET method(in uppercase)
      2. API (e.g. https://..)
      3. These parameters:
        • app_id
        • nonce
        • signature
        • signature_method
        • timestamp
    • The requested UIN/FIN does not match the UIN/FIN of the person who logged in
    • Requested attributes do not match the attributes consented by person. This happens if the list of attributes in your request are different from the attributes specified when calling the token API.

Details will be given in the error object returned.

403

Forbidden

Possible scenarios:

  • Incorrect API URL used. Refer to tutorial for the correct API URL(test/production)
  • Digital service is not registered with MyInfo.
  • Request contains attributes not allowable for the digital service.
404

Not Found.

Possible scenarios.

  • Missing MyInfo profile due to UIN/FIN accessing his MyInfo account less than a day after SingPass account activation.
500

Unexpected error. Check response body for actual error.

get /com/v3/person/{uinfin}/
Sandbox
https://sandbox.api.myinfo.gov.sg/com/v3/person/{uinfin}/
Test
https://test.api.myinfo.gov.sg/com/v3/person/{uinfin}/
Production
https://api.myinfo.gov.sg/com/v3/person/{uinfin}/

Request samples

Copy
// function to prepare request for PERSON API
function createPersonRequest(uinfin, validToken) {
  var url = _personApiUrl + "/" + uinfin + "/";
  var cacheCtl = "no-cache";
  var method = "GET";
  var request = null;
  // assemble params for Person API
  var strParams = "client_id=" + _clientId +
    "&attributes=" + _attributes;
  var params = querystring.parse(strParams);

  // assemble headers for Person API
  var strHeaders = "Cache-Control=" + cacheCtl;
  var headers = querystring.parse(strHeaders);
  var authHeaders;

  // Sign request and add Authorization Headers
  authHeaders = generateAuthorizationHeader(
    url,
    params,
    method,
    "", // no content type needed for GET
    _authLevel,
    _clientId,
    _privateKeyContent,
    _clientSecret
  );

  if (!_.isEmpty(authHeaders)) {
    _.set(headers, "Authorization", authHeaders + ",Bearer " + validToken);
  }
  else {
    // NOTE: include access token in Authorization header as "Bearer " (with space behind)
      _.set(headers, "Authorization", "Bearer " + validToken);
  }

  // invoke token API
  var request = restClient.get(url);

  // Set headers
  if (!_.isUndefined(headers) && !_.isEmpty(headers))
    request.set(headers);

  // Set Params
  if (!_.isUndefined(params) && !_.isEmpty(params))
    request.query(params);

  return request;
}

Response samples

application/json
Copy
Expand all Collapse all
{
  • "uinfin":
    {
    },
  • "partialuinfin":
    {
    },
  • "name":
    {
    },
  • "hanyupinyinname":
    {
    },
  • "aliasname":
    {
    },
  • "hanyupinyinaliasname":
    {
    },
  • "marriedname":
    {
    },
  • "sex":
    {
    },
  • "race":
    {
    },
  • "secondaryrace":
    {
    },
  • "dialect":
    {
    },
  • "nationality":
    {
    },
  • "dob":
    {
    },
  • "birthcountry":
    {
    },
  • "residentialstatus":
    {
    },
  • "passportnumber":
    {
    },
  • "passportexpirydate":
    {
    },
  • "regadd":
    {
    },
  • "mailadd":
    {
    },
  • "billadd":
    {
    },
  • "housingtype":
    {
    },
  • "hdbtype":
    {
    },
  • "hdbownership":
    [
    ],
  • "ownerprivate":
    {
    },
  • "email":
    {
    },
  • "homeno":
    {
    },
  • "mobileno":
    {
    },
  • "marital":
    {
    },
  • "marriagecertno":
    {
    },
  • "countryofmarriage":
    {
    },
  • "marriagedate":
    {
    },
  • "divorcedate":
    {
    },
  • "childrenbirthrecords":
    [
    ],
  • "sponsoredchildrenrecords":
    [
    ],
  • "edulevel":
    {
    },
  • "gradyear":
    {
    },
  • "schoolname":
    {
    },
  • "occupation":
    {
    },
  • "employment":
    {
    },
  • "passtype":
    {
    },
  • "passstatus":
    {
    },
  • "passexpirydate":
    {
    },
  • "employmentsector":
    {
    },
  • "householdincome":
    {
    },
  • "noa-basic":
    {
    },
  • "noa":
    {
    },
  • "noahistory-basic":
    {
    },
  • "noahistory":
    {
    },
  • "cpfcontributions":
    {
    },
  • "cpfemployers":
    {
    },
  • "cpfbalances":
    {
    },
  • "vehicles":
    [
    ],
  • "drivinglicence":
    {
    }
}