Skip to content

Requesting fields

launchMdlVerification() takes a namespace object that specifies which fields to request from the user’s wallet under the org.iso.18013.5.1 namespace.

Available fields are defined by two standards:

Pass any object mapping namespace strings to arrays of field names:

const namespaces = {
'org.iso.18013.5.1': ['family_name', 'given_name', 'portrait', 'age_over_18']
};
await session.launchMdlVerification('container', namespaces);

Wallet behavior: Not every field you request is guaranteed to appear in the response. If a requested element doesn’t exist in the holder’s mDL (e.g., a field defined by a newer standard version), wallets silently omit it — no error is returned. Users can also decline individual fields at the wallet consent prompt; declined fields are likewise omitted. Always check for the presence of each field in the response rather than assuming all requested fields will be returned.

Data minimization: Request only the fields you need. Fewer fields means higher user trust and a simpler consent prompt in the wallet.

The SDK exports three preset namespace objects for common use cases:

import {
NAMESPACES_MDL_AGE_OVER_18_ONLY,
NAMESPACES_MDL_NAME_ONLY,
NAMESPACES_MDL_ALL_MANDATORY,
} from '@spruceid/verify-sdk';
PresetElements
NAMESPACES_MDL_AGE_OVER_18_ONLYage_over_18
NAMESPACES_MDL_NAME_ONLYfamily_name, given_name
NAMESPACES_MDL_ALL_MANDATORYbirth_date, document_number, driving_privileges, expiry_date, family_name, given_name, issue_date, issuing_authority, issuing_country, portrait, un_distinguishing_sign