Api reference
Request Verification
Initiate a MitID age verification for a user.
Request Verification
Creates a new age verification session and returns a URL to redirect the user to.
Endpoint
POST /api/customer/v1/request-event
POST /api/test/customer/v1/request-event (test, never billed)Headers
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Your API key (pk_live_ or pk_test_) |
Content-Type | Yes | Must be application/json |
Origin | Recommended | Validated against your whitelisted domains for production keys |
Request body
{
"seqId": "550e8400-e29b-41d4-a716-446655440000",
"minAge": 18,
"returnUrl": "https://yourshop.dk/checkout/age-verified"
}| Field | Type | Required | Description |
|---|---|---|---|
seqId | string (UUID v4) | Yes | Idempotency key — must be unique per verification request. |
minAge | number | Yes | Minimum age the user must be. Typically 18. |
returnUrl | string | No | URL to redirect the user to after verification completes. Defaults to the Aldersverificering result page. |
Response
{
"verificationUrl": "https://mitid.dk/...",
"eventId": "abc123"
}| Field | Type | Description |
|---|---|---|
verificationUrl | string | Redirect the user to this URL to start MitID verification |
eventId | string | Internal event ID for tracking |
Example (TypeScript)
const response = await fetch(
'https://www.aldersverificering.dk/api/customer/v1/request-event',
{
method: 'POST',
headers: {
'x-api-key': process.env.ALDERSVERIFICERING_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({
seqId: crypto.randomUUID(),
minAge: 18,
returnUrl: `${process.env.NEXT_PUBLIC_URL}/checkout/verified`,
}),
}
)
if (!response.ok) {
const { error } = await response.json()
throw new Error(error)
}
const { verificationUrl } = await response.json()
// Redirect the user:
window.location.href = verificationUrlNotes
seqIdis an idempotency key. Reusing the same value for a new verification may cause the second request to be silently ignored. Always generate a fresh UUID per request.- Verification sessions expire after a short window. Do not cache
verificationUrl.