Gå til hovedindhold
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

HeaderRequiredDescription
x-api-keyYesYour API key (pk_live_ or pk_test_)
Content-TypeYesMust be application/json
OriginRecommendedValidated against your whitelisted domains for production keys

Request body

{
  "seqId": "550e8400-e29b-41d4-a716-446655440000",
  "minAge": 18,
  "returnUrl": "https://yourshop.dk/checkout/age-verified"
}
FieldTypeRequiredDescription
seqIdstring (UUID v4)YesIdempotency key — must be unique per verification request.
minAgenumberYesMinimum age the user must be. Typically 18.
returnUrlstringNoURL to redirect the user to after verification completes. Defaults to the Aldersverificering result page.

Response

{
  "verificationUrl": "https://mitid.dk/...",
  "eventId": "abc123"
}
FieldTypeDescription
verificationUrlstringRedirect the user to this URL to start MitID verification
eventIdstringInternal 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 = verificationUrl

Notes

  • seqId is 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.

On this page