Download OpenAPI specification:Download
API Specifications for implementing Webhook for SG-Verify service.
Note - this specification is subject to changes based on evolution of the APIs.
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}
{MAJOR}
number introduces incompatible API changes with previous {MAJOR}
number also resets {MINOR}
to 0
,{MINOR}
number introduces new functionalities or information that are backward compatible also resets {PATCH}
to 0
, and{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.
SG-Verify is a service provided by SingPass Mobile that allows easy sharing of customer basic personal information to an organization. Some example uses of SG-Verify can be:
The following diagram illustrates how the SG-Verify work:
NOTE: As a partner, in order to use SG-Verify, you will need to implement your webhook according to this specification.
Ensure that your webhook implements the following HTTPS channel encryption:
HTTP version 1.1 connection over TLS (Transport Layer Security) version 1.1 or 1.2 standards, and ciphersuites:
Below is the list of recommended cipher suites that you may use:
IMPORTANT: ensure your server supports TLS 1.1 or 1.2 and supports a cipher suite in the list above.
Access to your wehbook should be protected with the following minimum criteria:
Prior to implementing your webhook, respective consumers are required to have:
NOTE: it is important that your webhook implements the correct authentication mechanism (by checking for the correct API Key provided to you during the onboarding process) to prevent unauthorised access to your webhook.
The payload for the personal information pushed to your webhook 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:
After doing the above steps, your application will be able to extract the payload in JSON format.
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";
})
}
The decrypted payload will be signed according to JWS (JSON Web Signature) format, similar to the access token.
RS256
.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");
}
}
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:
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) The source
property indicates the source of data. Possible values are:
Note: All Government-verified fields must be non-editable on your digital service form (some exceptions apply - see individual field descriptions).
In each data item, there can be multiple data properties or arrays of data properties.
Each data property will contain either:
value
property, orcode
and desc
properties, orNote:
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
.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:
classification
, source
, lastupdated
, and unavailable
type
in address formatsSometimes, a requested data item is not applicable to the person. Examples include:
regadd
data item.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.
When a requested data item is not applicable to the entity:
source
property will be 3In such cases, please ignore the data item completely.
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.
This webhook allows SG-Verify to push personal data to the partner.
Authorization required | any Authorization credentials. Use API Key for authentication. |
state | object (State) Returns the same value as the 'state' parameter sent during QR login process, which allows application to restore application states in a stateless transaction. |
timestamp | object (Timestamp) 'Last updated date of data field. See "date-time" in http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14' |
txnNo | object (Transaction No) Transaction No for traceability |
identity | object Person's details. Properties shown below are after decryption and decoded from verified JWS. |
OK. successful push of personal data.
Unauthorized. Invalid credentials.
Forbidden
Not Found.
Unexpected error. Check response body for actual error.