22.10. KyCH OAuth2 Gateway RESTful API#

The KyCH OAuth2 Gateway provides OAuth 2.0 authorization backed by electronic identification. It allows OAuth 2.0 clients (such as a Taler exchange) to verify a person’s identity with an EU Digital Identity Wallet, the German identity card’s online function, another member state’s eID through the eIDAS network, or the Swiss e-ID in the swiyu wallet.

Each source of identity KyCH can use is a vocabulary with its own native claim names (eupid and eupid-mdoc for the EU PID, npa for the German card, eidas, swiyu for the Swiss e-ID), and each vocabulary is served by a helper that does the protocol and cryptographic work (the Swiyu Verifier for swiyu, one of three OpenID4VP verifiers for the EU PID, an eID server for npa). Which vocabularies a client may use, and which named profiles – sets of claims per vocabulary – it may ask for, is part of its registration.

The high-level flow is:

  1. An OAuth 2.0 client is registered with KyCH (via configuration file or CLI tool).

  2. When the client needs to verify a user’s identity, it calls /setup/$CLIENT_ID with its client secret to obtain a nonce.

  3. The client redirects the user-agent to /authorize/$NONCE with OAuth 2.0 parameters (response_type, client_id, redirect_uri, state, scope).

  4. KyCH initiates a verification request with the helper of the session’s vocabulary. For a wallet vocabulary (oid4vp) it returns a verification_url (QR code URL) for the user to scan with their wallet; for the German eID card (eid-server) or another member state’s eID (eidas-saml) it sends the browser to the helper instead.

  5. The user presents their credential to the helper: the wallet does so in the background, the eID card or eIDAS route in the browser, which the helper then sends back to KyCH’s /return/$VERIFICATION_ID.

  6. KyCH learns of the outcome from the helper’s webhook to /notification (the Swiyu Verifier), from asking the helper itself while the browser polls /status (helpers without a webhook), or when the browser returns; in each case it fetches the result from the helper.

  7. The client polls /status/$VERIFICATION_ID or the user calls /finalize/$VERIFICATION_ID to be redirected back to the client with an authorization code – or, if the identification failed or the session expired, with error=access_denied (RFC 6749, section 4.1.2.1).

  8. The client exchanges the authorization code for an access token via /token.

  9. The client retrieves the verified identity claims via /info.

22.10.1. Receiving Configuration#

GET /config#

Returns the public configuration of the KyCH service, including supported verifiable credential types and available claims. Clients can use this endpoint to discover which claims they can request during authorization.

This endpoint does not require authentication and can be used for health checks and service discovery.

Response:

200 OK:

The service is operational. Returns a KyCHConfigResponse containing the service configuration.

interface KyCHConfigResponse {
  // Service identifier. Always "KyCH OAuth2 Gateway".
  name: "kych-oauth2-gateway";

  // Semantic version of the KyCH service (e.g., "1.0.0").
  version: string;

  // Health status indicator. "healthy" indicates the service is
  // ready to accept requests.
  status: "healthy";

  // The vc_* members describe the first SD-JWT VC vocabulary the
  // instance enables, which for a Swiss e-ID installation is the
  // "swiyu" vocabulary; they are empty strings and lists if there is
  // none.
  //
  // Verifiable credential type identifier: the first accepted vct of
  // that vocabulary. For Swiss Beta ID, this is "betaid-sdjwt".
  vc_type: string;

  // Credential format. SD-JWT credentials use "dc+sd-jwt".
  vc_format: string;

  // List of cryptographic signature algorithms accepted for
  // credential verification (e.g., ["ES256"]).
  vc_algorithms: string[];

  // List of claim names that clients can request via the scope
  // parameter, for that vocabulary.
  // Examples: "family_name", "given_name", "birth_date", "age_over_18".
  vc_claims: string[];

  // Every vocabulary the instance enables, in the order of its
  // VOCABULARIES option.
  vocabularies: KyCHVocabulary[];

  // Every profile with a line for at least one enabled vocabulary.
  profiles: KyCHProfile[];
}
interface KyCHVocabulary {
  // Its name, as /setup, the picker and /info's "vocabulary" use it,
  // e.g. "swiyu", "eupid", "eupid-mdoc", "npa", "eidas".
  name: string;

  // How the person identifies: with a wallet over OpenID4VP, with
  // the German eID card's online function, or through eIDAS.
  kind: "oid4vp" | "eid-server" | "eidas-saml";

  // For "oid4vp": "dc+sd-jwt", "vc+sd-jwt" or "mso_mdoc".
  format?: string;

  // For SD-JWT VC: the accepted vct values.
  vct?: string[];

  // For mdoc: the document type.
  doctype?: string;

  // Every claim it delivers, under its native name. For SD-JWT VC a
  // name is a path: "address.locality" is a member of the "address"
  // object, "nationalities[]" every element of that array. In /info a
  // claim appears under its first path component.
  claims: string[];
}
interface KyCHProfile {
  // The name a client puts into its scope, e.g. "kyc".
  name: string;

  // Whether the client keeps what it receives; sent to mdoc wallets
  // as intent_to_retain.
  retain: boolean;

  // Per enabled vocabulary the profile covers: the claims asked for.
  // A credential lacking an optional one is still accepted, and /info
  // lists it in "missing".
  vocabularies: { [vocabulary: string]: KyCHProfileLine };
}
interface KyCHProfileLine {
  required: string[];
  optional: string[];
}

22.10.2. Setup#

POST /setup/$CLIENT_ID#

Initiates a new KYC verification session for the specified client. This is the first step in the verification flow and must be called by the client (e.g., Taler exchange) before redirecting the user to the authorization endpoint.

The client authenticates using HTTP Bearer authentication with its client secret. Upon success, KyCH creates a new session in pending status and returns a cryptographically random nonce that identifies this session.

The client may fix the session’s vocabulary, its profile or both in the request body. A session whose vocabulary is fixed this way shows the person no choice of vocabulary at /authorize, and its scope may then name native claims of that vocabulary even if the client may use several.

Request:

Request Headers:
  • Authorization – Required. Must be Bearer $CLIENT_SECRET where $CLIENT_SECRET is the secret registered for this client.

  • Content-Encoding – Optional. deflate for a body compressed in the zlib format (RFC 1950), as the Taler exchange sends it; raw deflate data (RFC 1951) is accepted as well. Any other encoding but identity is refused.

The body is optional. If present, it is a KyCHSetupRequest. Members KyCH does not know are ignored, so a Taler exchange that sends its measure’s initial_address here, as it does today, opens a session with no preselection. The body is checked only after the client secret has been.

interface KyCHSetupRequest {
  // Fixes the session's vocabulary. Must be one the client is
  // registered for and the instance enables. Case-insensitive.
  vocabulary?: string;

  // The profile the session asks for. Must be one the client is
  // registered for, with a line for the vocabulary given, or for at
  // least one of the client's vocabularies. With a profile fixed here,
  // the scope at /authorize may be empty; if it is not, it must name
  // this profile.
  profile?: string;
}

Response:

200 OK:

Session created successfully. Returns a KyCHSetupResponse containing the session nonce.

400 Bad Request:

The body is not a JSON object, or a member has the wrong type (invalid_request); it names a vocabulary the client may not use (invalid_vocabulary), or a profile the client may not use or that covers none of the session’s possible vocabularies (invalid_profile).

401 Unauthorized:

Authentication failed. Either the Authorization header is missing, malformed, or contains an invalid client secret. The client should verify that it is using the correct secret for the specified $CLIENT_ID.

404 Not found:

The $CLIENT_ID in the URL path does not match any registered client. The client must be registered via configuration file or CLI before use.

413 Request entity too large:

The body is larger than 64 KiB, before or after decompression (request_too_large).

415 Unsupported media type:

The body uses a Content-Encoding other than identity or deflate (unsupported_content_encoding).

interface KyCHSetupResponse {
  // Cryptographically random nonce (base64-encoded) that identifies
  // this verification session. The client must include this nonce
  // in the URL when redirecting the user to /authorize/$NONCE.
  // The nonce is single-use and expires after a configured timeout.
  nonce: string;

  // When the session expires, 15 minutes after its creation: the
  // person has to have identified by then.
  expires: Timestamp;
}

22.10.3. Authorize#

GET /authorize/$NONCE#

The OAuth 2.0 authorization endpoint. The client redirects the user’s browser to this endpoint to begin the credential verification process.

When called, KyCH performs the following steps:

  1. Validates the session identified by $NONCE exists and is in pending status.

  2. Validates the OAuth 2.0 parameters (response_type, client_id, redirect_uri, scope), and resolves the scope to the claims of the session’s vocabulary. If that vocabulary is not fixed yet – by /setup, or by the client being registered for only one – and the scope’s profile covers several of the client’s vocabularies, the person picks one first: KyCH answers with a page offering them (or, for a JSON client, a KyCHAuthorizeChoiceResponse), and the choice is posted back to the same URL; see POST /authorize/$NONCE. Vocabularies that one wallet request can offer together – the EU PID as an SD-JWT VC (eupid) and as an mdoc (eupid-mdoc) on one EUDI verifier – are a single choice, and if that leaves one choice, there is no picker at all.

  3. Creates a verification request with the helper of that vocabulary (the Swiyu Verifier, for instance). For a choice that stands for several vocabularies, one request offers the wallet all of them, of which it presents one; which one it was is the session’s vocabulary from then on, as /info reports. A vocabulary fixed by /setup is that one alone.

  4. Stores the verification details, including which vocabulary and helper the session is bound to from now on, and transitions the session to authorized status.

  5. Returns either HTML or a JSON response, depending on the Accept header. The HTML depends on the kind of the vocabulary: for a wallet (oid4vp) it is a page with a QR code that polls /status; for the eID card or eIDAS (eid-server, eidas-saml) it is a 302 to the helper, which sends the browser back to /return/$VERIFICATION_ID.

The returned verification_url should be rendered as a QR code for the user to scan with their wallet. On mobile devices, the verification_deeplink can be used to launch the wallet app directly. Both are only ever handed out with the scheme https or one of the vocabulary’s WALLET_SCHEMES (kych.conf(5)), and a browser_url only with https.

Calling /authorize again for an authorized session replays the same answer, without a second request to the helper; this holds for concurrent calls as well.

The HTML pages are in English, German or French, as the Accept-Language header asks; English for any other language.

Request:

Parameters:
  • NONCE – The session nonce obtained from /setup. This is a URL path parameter, not a query parameter.

Query Parameters:
  • response_type – Required. Must be code for the authorization code grant flow. Other values are rejected with 400 Bad Request.

  • client_id – Required. The client identifier. Must match the client that created this session via /setup. Mismatches are rejected.

  • redirect_uri – Required. The URI where the user will be redirected after verification completes. Must exactly match the redirect URI registered for this client in KyCH’s configuration. Mismatches are rejected for security.

  • state – Required. An opaque value generated by the client for CSRF protection. KyCH stores this value and includes it in all subsequent responses and redirects. The client must verify the state matches when receiving the callback to prevent cross-site request forgery attacks.

  • scope – Required unless /setup fixed a profile, in which case it may be empty or must name that profile. Either the name of one profile the client is registered for, such as kyc, which requests that profile’s claims of the session’s vocabulary; or a space-delimited list of native claim names of the session’s vocabulary, each of them in the list returned by /config. Example: family_name given_name age_over_18. Claim names can only be used when the session’s vocabulary is fixed, which it is for a client registered for a single vocabulary. A scope that mixes a profile with claim names, or names two profiles, is rejected. The user will be asked to consent to disclosing these specific claims.

Response:

200 OK:

Verification request created successfully. If the Accept header includes text/html, returns an HTML page containing a QR code and JavaScript that polls the status endpoint. Otherwise, returns a KyCHAuthorizeResponse JSON object containing the verification URL, or the browser URL.

Or the person has to choose a vocabulary first: then the page offers the choices, as buttons that post back to this URL and need no script, or the JSON is a KyCHAuthorizeChoiceResponse. Nothing has been started yet, and the session stays pending.

302 Found:

For an eid-server or eidas-saml vocabulary and an Accept header including text/html: the helper’s page, in Location.

400 Bad Request:

One or more request parameters are invalid:

  • response_type is not code

  • redirect_uri does not match the registered URI for this client

  • scope contains claims not in the allowed list (invalid_scope, or invalid claim in scope: $CLAIM for a name the vocabulary does not define)

  • scope names a profile the client is not registered for, mixes a profile with claim names, or names several profiles (invalid_scope)

  • the scope names claims, the client is registered for several vocabularies, and /setup fixed none (vocabulary_not_selected); only a profile lets the person choose

  • Required parameters are missing

404 Not found:

No session exists for the provided $NONCE. The nonce may have never existed, or it may have already been used (nonces are single-use).

409 Conflict:

The session exists but is not in pending status. This occurs if /authorize is called multiple times for the same nonce, or if the session has already progressed to a later state.

410 Gone:

The session has expired. Sessions have a limited lifetime configured on the server. The client should call /setup to create a new session.

500 Internal Server Error:

Among other internal failures: the client’s registration lists no vocabulary that the instance enables (no_vocabulary). The operator has to synchronize the client registrations with the configuration.

502 Bad Gateway:

KyCH failed to communicate with the helper when creating the verification request (verifier_unavailable, verifier_error, verifier_invalid_response). This may indicate network issues or verifier unavailability. The client may retry after a delay. Also when the helper handed out a URL with a scheme KyCH does not render (invalid_verification_url, invalid_verification_deeplink, invalid_browser_url); the session then stays pending.

interface KyCHAuthorizeChoiceResponse {
  // Where to post the choice: this /authorize URL, query and all,
  // relative to KyCH's base URL. The body is
  // application/x-www-form-urlencoded, vocabulary=$VOCABULARY.
  choose_url: string;

  // The vocabularies the person may choose from: those of the client's
  // that the scope's profile covers, in the order of the client's
  // registration.
  choices: KyCHVocabularyChoice[];

  // The state parameter, echoed back unchanged.
  state: string;
}
interface KyCHVocabularyChoice {
  // The vocabulary, the value to post.
  vocabulary: string;

  // What the person knows it as, such as "EU Digital Identity Wallet",
  // in the language Accept-Language asks for (English, German or
  // French). A vocabulary not shipped with KyCH is named by its
  // section name.
  name: string;

  // How the person identifies with it: a wallet ("oid4vp"), the
  // German eID card ("eid-server") or eIDAS ("eidas-saml").
  kind: "oid4vp" | "eid-server" | "eidas-saml";

  // The further vocabularies this one choice stands for, if any: the
  // wallet is offered vocabulary and these alike and presents
  // whichever it holds -- e.g. ["eupid-mdoc"] for vocabulary "eupid".
  // Posting any of them picks the choice. Absent for a choice of one.
  alternatives?: string[];
}
interface KyCHAuthorizeResponse {
  // UUID assigned by KyCH to identify this verification request.
  // Used in the /status and /finalize endpoint URLs. (Earlier versions
  // passed on the Swiyu Verifier's own identifier; either way it is
  // opaque to the client.)
  verificationId: string;

  // For a wallet vocabulary (oid4vp): the URL that encodes the OID4VP
  // verification request. This URL should be rendered as a QR code for
  // the user to scan with their wallet. The wallet will retrieve the
  // presentation request from the helper using this URL. https, or a
  // scheme of the vocabulary's WALLET_SCHEMES.
  verification_url?: string;

  // Deep link URL for mobile devices. When opened on a device with
  // the wallet installed, this launches the wallet app directly
  // instead of requiring QR code scanning. Only present if the helper
  // provides it.
  verification_deeplink?: string;

  // For an eid-server or eidas-saml vocabulary: where to send the
  // browser. The helper sends it back to /return/$VERIFICATION_ID.
  // Always https.
  browser_url?: string;

  // The state parameter echoed back unchanged. The client should
  // verify this matches the state it sent to detect CSRF attacks.
  state: string;
}
POST /authorize/$NONCE#

The person’s choice of vocabulary, posted from the page GET /authorize/$NONCE shows, or by a JSON client to the choose_url of a KyCHAuthorizeChoiceResponse. The query is the one of the GET, and is validated the same way.

KyCH fixes the session’s vocabulary and starts the verification at its helper, exactly as GET does for a session whose vocabulary is fixed. Posting the same choice again for an authorized session replays the same verification.

Request:

Request Headers:

The body is vocabulary=$VOCABULARY, one of the choices offered; case-insensitive.

Response:

303 See other:

With an Accept header including text/html: Location is the same /authorize/$NONCE URL, as a relative reference (?QUERY), whose GET shows the QR code page or redirects to the helper. A reload of that page therefore posts nothing again.

200 OK:

For a JSON client: the KyCHAuthorizeResponse of the verification started.

400 Bad Request:

The vocabulary is not one of those offered (invalid_vocabulary), or there is no choice to make for this scope (vocabulary_not_selected, invalid_scope); and otherwise as for GET.

409 Conflict:

The session’s vocabulary is already fixed – by /setup or an earlier choice – to another one (vocabulary_already_chosen).

Every other status as for GET.

22.10.4. Status#

GET /status/$VERIFICATION_ID#

Polls the current status of a verification request. Clients (or the browser JavaScript on the authorize page) use this endpoint to detect when the user has completed the verification process.

The state parameter is required and must match the state from the original authorization request. This prevents unauthorized parties from polling verification status.

For a helper that does not call /notification (the EUDI verifier, for instance), this is also where KyCH asks the helper for the outcome: while the session is authorized, a poll asks the helper, at most once a second per session however often /status is called, and completes the session as the webhook would have. walt.id with a webhook is asked as well, at most every ten seconds, for the outcomes no webhook reports (a session it let expire, or lost in a restart).

Request:

Parameters:
  • VERIFICATION_ID – The verification ID returned by /authorize.

Query Parameters:
  • state – Required. The state parameter from the original authorization request. Must match exactly. This provides CSRF protection and prevents unauthorized status polling.

Response:

200 OK:

Returns a KyCHStatusResponse containing the current verification status.

403 Forbidden:

The state parameter does not match the state associated with this verification. This may indicate a CSRF attack or that the wrong state was provided.

404 Not found:

No verification exists with the given $VERIFICATION_ID. The ID may be invalid or the verification may have been deleted after expiration.

interface KyCHStatusResponse {
  // Current status of the verification. Possible values:
  //
  // - "pending": Session created but /authorize not yet called.
  //   (Normally not seen via /status since /authorize must be
  //   called first to get the verification_id.)
  //
  // - "authorized": User has been shown the QR code but has not
  //   yet scanned it or completed verification in their wallet.
  //   The client should continue polling.
  //
  // - "verified": The user's credential has been successfully
  //   verified by the helper. The client can now redirect
  //   the user to /finalize to obtain the authorization code.
  //
  // - "failed": Verification failed. This may occur if the user
  //   declined consent, presented an invalid credential, or the
  //   credential issuer is not trusted.  With the EUDI verifier also
  //   when it refused what the wallet posted (an undecryptable or
  //   otherwise invalid response), when its transaction expired, or
  //   when it does not know the transaction any more (it was
  //   restarted): the person has to start again.
  //
  // - "expired": The verification session timed out before the
  //   user completed verification, which happens 15 minutes after
  //   /setup. The client should start a new session via /setup.
  //
  //   For "failed" and "expired", the wallet page sends the browser
  //   to /finalize, which redirects to the client with
  //   error=access_denied.
  //
  // - "completed": An access token has already been issued for
  //   this verification. The flow is complete.
  status: "pending" | "authorized" | "verified" | "failed" | "expired" | "completed";
}

22.10.5. Return#

GET /return/$VERIFICATION_ID#

Where a browser-redirect helper – the eID server for the German eID card, the eIDAS connector – sends the person back once they are done there. KyCH takes the browser’s return as the signal to ask the helper for the outcome, at most once a second per session, completes the session as the webhook would have, and continues the way the wallet page does once /status says verified.

No state is needed: KyCH gives the verification id only to the browser and the helper, and the authorization code /finalize redirects with is of no use without the client secret.

Request:

Parameters:
  • VERIFICATION_ID – The verification ID returned by /authorize.

Response:

302 Found:

The session is verified, failed or expired: Location is /finalize/$VERIFICATION_ID?state=$STATE, which redirects to the client with the code, or with error=access_denied for a session that failed or expired. A failed or expired session is redirected only if its redirect_uri is one the client still has registered.

200 OK:

Anything else. With an Accept header including text/html, a page: while the outcome is pending, one that polls /status and continues to /finalize like the wallet page; for a completed session, and for a failed or expired one without a valid redirect_uri, one that says so, in the language Accept-Language asks for. Otherwise a KyCHStatusResponse.

404 Not found:

No verification exists with the given $VERIFICATION_ID (session_not_found).

22.10.6. Finalize#

GET /finalize/$VERIFICATION_ID#

Completes the authorization flow by redirecting the user back to the client: with an OAuth 2.0 authorization code once /status returns verified, and with an error response (RFC 6749, section 4.1.2.1) once it returns failed or expired. The wallet page and /return send the browser here in all three cases, so that the client learns of a failed identification at once rather than when its own process times out.

For a verified session, KyCH redirects the user’s browser to the redirect_uri of the authorization request with the authorization code (minted when the helper’s outcome arrived) and the state as query parameters. The authorization code is single-use. The client must exchange it for an access token at the /token endpoint before it expires (configurable, default 10 minutes).

Either redirect goes only to a redirect_uri that is still among the client’s registered ones, checked again here.

Request:

Parameters:
  • VERIFICATION_ID – The verification ID returned by /authorize.

Query Parameters:
  • state – Required. The state parameter from the original authorization request. Must match exactly for CSRF protection.

Response:

302 Found:

Redirects to the client’s redirect_uri with query parameters:

  • code: The authorization code to exchange for an access token.

  • state: The state parameter, echoed back unchanged.

Example redirect: https://client.example.com/callback?code=abc123&state=xyz789

For a failed or expired session, the query parameters are instead:

  • error: access_denied.

  • error_description: the identification failed, followed by : $REASON when the helper adapter gave a reason code (such as presentation_expired), or the identification was not completed in time. Printable ASCII; never personal data.

  • state: The state parameter, echoed back unchanged.

Example redirect: https://client.example.com/callback?error=access_denied&error_description=the%20identification%20failed%3A%20presentation_expired&state=xyz789

A Taler exchange maps access_denied to a failed KYC process.

With an Accept header including text/html, a session not decided yet (pending, authorized) is redirected to /return/$VERIFICATION_ID instead, which asks the helper and waits.

200 OK:

The Accept header includes text/html, and the session failed or expired while no valid redirect_uri is known (the client’s registration has changed), or it is completed (a token was already issued, e.g. from a second tab: a same-device wallet opens KyCH’s return URL beside the wallet page): KyCH’s own page saying so, in the language Accept-Language asks for.

400 Bad Request:

not_verified, without text/html in Accept: the user has not completed verification yet (status is authorized), a token was already issued (completed), or the session failed or expired and no valid redirect_uri is known.

403 Forbidden:

The state parameter does not match.

404 Not found:

No verification exists with the given $VERIFICATION_ID.

500 Internal Server Error:

internal_error: a verified session whose redirect_uri the client no longer has registered.

22.10.7. Token#

POST /token#

Exchanges an authorization code for an access token. This is the standard OAuth 2.0 token endpoint implementing the authorization code grant.

The client authenticates by including its client_id and client_secret in the request body (not via HTTP Basic authentication). The redirect_uri must exactly match the one used in the original authorization request.

Authorization codes are single-use. Once exchanged for a token, the code is invalidated and cannot be used again. Codes also expire after a short time (configurable, default 10 minutes).

Request:

Request Headers:
  • Content-Type – Must be application/x-www-form-urlencoded.

The request body contains the following form parameters:

interface KyCHTokenRequest {
  // The OAuth 2.0 grant type. Must be "authorization_code".
  grant_type: "authorization_code";

  // The authorization code received from the /finalize redirect.
  // This code is single-use and expires after a short time.
  code: string;

  // The client identifier. Must match the client that initiated
  // the authorization flow.
  client_id: string;

  // The client secret for authentication. KyCH verifies this
  // against the stored bcrypt hash.
  client_secret: string;

  // The redirect URI. Must exactly match the redirect_uri used
  // in the original /authorize request. This prevents authorization
  // code injection attacks.
  redirect_uri: string;
}

Response:

200 OK:

Token issued successfully. Returns a KyCHTokenResponse containing the access token. The session status is updated to completed.

400 Bad Request:

The request is invalid. Possible causes:

  • grant_type is not authorization_code

  • code is missing, invalid, expired, or already used

  • redirect_uri does not match the original request

  • Required parameters are missing

401 Unauthorized:

Client authentication failed. Either client_id does not exist or client_secret does not match the registered secret.

interface KyCHTokenResponse {
  // The access token. Use this as a Bearer token in the
  // Authorization header when calling /info.
  access_token: string;

  // The token type. Always "Bearer".
  token_type: "Bearer";

  // Token validity period in seconds. The token cannot be used
  // after this time. Typically 3600 (1 hour).
  expires_in: number;
}

22.10.8. Info#

GET /info#

Retrieves the verified identity claims using an access token. This endpoint is analogous to the OAuth 2.0 UserInfo endpoint but returns verified credential claims instead of user profile information.

The response contains only the claims that were:

  1. Requested in the scope parameter during authorization: the profile’s claims for the vocabulary presented, or the native claim names of the scope. KyCH enforces this itself, by each claim’s path: a credential may reveal more than was asked – an issuer can make claims always disclosed, a wallet can disclose a whole object for one of its members – and the rest is neither stored nor returned. A requested object (place_of_birth) is returned whole, a requested member (address.locality) alone within its object. The raw presentation in evidence is the issuer’s signed data and is left as the wallet sent it.

  2. Successfully disclosed by the user from their verifiable credential.

The access token is validated on each request. Expired or revoked tokens are rejected.

Request:

Request Headers:
  • Authorization – Required. Must be Bearer $ACCESS_TOKEN where $ACCESS_TOKEN is the token received from /token.

Response:

200 OK:

Returns a KyCHInfoResponse containing the verified claims.

401 Unauthorized:

The access token is missing, malformed, expired, or has been revoked. The client should obtain a new token by starting a new verification flow.

410 Gone:

The token is valid, but KyCH has deleted the claims and the evidence (claims_purged): they are kept for PURGE_GRACE (an hour by default) after the first successful /info, so that a client can retry a request that failed on its side, and not longer. A client keeps what it needs from the first answer.

The first successful /info is recorded, and the grace runs from there; later calls return the same data until it is deleted. Independently of /info, everything is deleted once the access token expires. See the data retention section of the KyCH manual.

interface KyCHInfoResponse {
  // The verified credential claims as key-value pairs, under the
  // native names of the session's vocabulary. Only claims that were
  // requested and disclosed are included. A claim requested by a path
  // ("address.locality") appears under its first component, holding
  // the value as the credential nests it.
  //
  // Example response for scope "family_name given_name age_over_18":
  // {
  //   "family_name": "Muster",
  //   "given_name": "Max",
  //   "age_over_18": true,
  //   "vocabulary": "swiyu",
  //   "missing": [],
  //   "evidence": { ... }
  // }
  //
  // Claim types vary:
  // - String claims: family_name, given_name, birth_place, nationality, etc.
  // - Boolean claims: age_over_16, age_over_18, age_over_65
  // - Date claims: birth_date, issuance_date, expiry_date (ISO 8601 format)
  // - Binary claims: portrait (base64-encoded image data)
  // - Objects and arrays: address, place_of_birth, nationalities (EU PID)
  [claim: string]: string | boolean | number | object;

  // The keys "vocabulary", "missing" and "evidence" are KyCH's own: no
  // vocabulary may define a claim under one of them. They are absent
  // only for sessions from before KyCH had vocabularies.

  // Which source of identity the person used, e.g. "swiyu", "eupid",
  // "npa"; it decides what the claim names mean.  When the person's
  // choice offered the wallet several vocabularies (the EU PID as
  // "eupid" or "eupid-mdoc"), it is the one the wallet presented.
  vocabulary: string;

  // The optional claims of the requested profile that the credential
  // did not have, by their names in the profile (e.g.
  // "address.country"). Empty for a scope of native claim names, which
  // are all required. The client completes these by other means.
  missing: string[];

  // How the result was obtained and checked.
  evidence: KyCHEvidence;
}
interface KyCHEvidence {
  // KyCH's verification id, the one /status and /finalize used.
  verification_id: string;

  // When KyCH received the outcome from the helper.
  verified_at: Timestamp;

  // The helper that did the verification.
  helper: {
    // Its type, as in kych.conf(5): "swiyu", "eudi-verifier",
    // "waltid-verifier2", "kych-native", "eumw-saml", "eidas-saml".
    type: string;
    // The program, for "kych-native", which several implement:
    // "kych-oid4vp", "kych-eid".
    name?: string;
    // Its version, if it reports one.
    version?: string;
  };

  // The credential format, for a wallet: "dc+sd-jwt" or "mso_mdoc".
  format?: string;

  // What was presented: the vct of an SD-JWT VC, the doctype of an
  // mdoc.
  credential_type?: string;

  // Who issued it.
  issuer?: {
    // The issuer's identifier: a DID for the Swiss e-ID.
    id?: string;
    // The key the credential was signed with, as the credential
    // names it.
    key_id?: string;
    // For an X.509 issuer: the certificate's subject, and the chain
    // as base64 DER, leaf first.
    subject?: string;
    chain?: string[];
  };

  // What the issuer was trusted on: the accepted issuer DIDs, a trust
  // list and its issue date, the helper's own evaluation.
  trust?: object;

  // "high" only where the trust configuration establishes it: for an
  // EU PID, an issuer on the PID-provider list plus verified holder
  // binding. Never assumed from the vocabulary.
  level_of_assurance?: string;

  // The revocation check: whether done, against which list, and the
  // result.
  status?: object;

  // The holder-binding check: whether done, the nonce and the
  // audience.
  holder_binding?: object;

  // What was asked for: the DCQL query and the request parameters.
  request?: object;

  // The raw presentation, as the helper hands it out.
  presentation?: any;
}

A member is present only where the helper reports it; an absent member means “not reported”, never “checked and fine”. What each vocabulary’s helper reports:

swiyu (swiyu-verifier)

Always verification_id, verified_at, helper.type, format, trust.accepted_issuer_dids; helper.version when the verifier’s /actuator/info reports its build. request (the DCQL query, response_mode) when the verifier returns the query. Only with the verifier’s ADDITIONAL_AUDIT_INFORMATION_VP_TOKEN_ENABLED: the raw vp_token as presentation, and, read from it, issuer.id (the issuer DID from the credential’s kid, the one the verifier checks against the accepted DIDs), issuer.key_id and credential_type (the presented vct); without it, credential_type is given only when the vocabulary accepts a single vct. Only with ADDITIONAL_AUDIT_INFORMATION_CREDENTIAL_EVALUATION_ENABLED: trust.credential_evaluation, the verifier’s trust-marker and status results. Never level_of_assurance (the Swiss e-ID is not an eIDAS means), status or holder_binding, which the verifier checks but does not report separately.

eupid, eupid-mdoc (eudi-verifier, the EUDI reference verifier)

Always verification_id, verified_at, helper.type, format, credential_type (the presented vct, or the doctype), issuer.chain (the x5c of an SD-JWT VC, the x5chain of an mdoc’s issuerAuth) with issuer.subject of its leaf and, for an SD-JWT VC, issuer.iss; presentation, the raw vp_token object (credential query id to presentations); holder_binding with checked: true – the verifier accepts no presentation without a valid key-binding JWT or deviceSignature – method (kb-jwt or deviceSignature), nonce, audience (the verifier’s client id), for an SD-JWT VC the key-binding JWT’s iat, for an mdoc handover (client_id, nonce, jwk_thumbprint of the response encryption key, response_uri) and session_transcript, the OpenID4VP SessionTranscript, base64url CBOR, which deviceSignature can be checked against again; status: list and index of the credential’s status reference, checked whether the verifier reported checking it, result: "valid" then ({"checked": false} alone for a credential without one); request: dcql_query, client_id, nonce, response_mode, response_uri, profile (haip or openid4vp) and the signed request_object the wallet fetched. trust is kych-trust’s record of the decision on issuer.chain: context (PID), trusted, anchor (the listed certificate, base64 DER), entity, service, list, list_issued and the whole snapshot (its serial, sequence number, issue date and hash), or an error if kych-trust could not be asked. level_of_assurance only when the trust section sets LEVEL_OF_ASSURANCE and kych-trust trusts the issuer: never for a simulated list. helper.version when the verifier’s /actuator/info reports its build (the package exposes it).

eupid, eupid-mdoc (waltid-verifier2, walt.id verifier-api2)

The same members as for eudi-verifier, with these differences, so that a client comparing the two can tell what each helper vouches for:

  • holder_binding.checked is what walt.id’s presentation policies reported – for an SD-JWT VC the key-binding JWT’s signature, nonce, audience and sd_hash checks all passed, for an mdoc mso_mdoc/device-auth – and false when they are missing from its result; handover.jwk_thumbprint is the one walt.id names for its response key.

  • status.checked is true when walt.id’s credential-status policy passed and found a status reference to check.

  • trust says how walt.id was told whom to trust, in source and policy: kych-trust and x509-trust (the helper’s TRUST = kych-trust), then the rest is kych-trust’s record as for eudi-verifier – context, trusted, anchor, entity, service, list, list_issued, snapshot; or self and etsi-trust-list (TRUST = self), then context, trusted, list (the URL walt.id fetched, or the file:// path of the list KyCH handed it) and, as walt.id reports them, entity, service_type (walt.id names a service by its type only, not by the name kych-trust’s service gives), source_freshness and authenticity – but neither anchor nor snapshot nor list_issued, which walt.id does not report. Both carry helper_result, walt.id’s own result of the policy. level_of_assurance needs trusted and holder_binding.checked.

  • request has no profile, but policies: the policies KyCH asked walt.id to apply to this credential, the trust roots or list included.

  • helper.version is walt.id’s own build version, from its OpenAPI document (info.version), read once per gateway process.

eupid, eupid-mdoc (kych-native: kych-oid4vp, KyCH’s own verifier)

The evidence comes from the helper itself, in this shape (the KyCH-native helper API, KyCH-native Helper RESTful API), and is passed on as it is, with KyCH’s verification_id. The same members as for eudi-verifier, with these differences:

  • helper has name, kych-oid4vp, and its version.

  • trust is kych-trust’s record as for eudi-verifier (context, trusted, anchor, entity, service, list, list_issued, snapshot): the very decision the helper took, not a second one KyCH asked for afterwards.

  • status has format (jwt or cwt: the form the list was fetched in, by Accept per credential format) and signer, kych-trust’s decision on the status list’s signer in the class’s revocation context (PIDStatus); checked is true and result valid whenever the credential names a status list, since kych-oid4vp refuses one whose list it cannot fetch, read or trust.

  • holder_binding of an SD-JWT VC also has sd_hash; checked is true because kych-oid4vp refuses any presentation without a valid key-binding JWT or deviceSignature.

  • request has profile (haip for x509_hash, openid4vp for x509_san_dns) and the signed request_object the wallet fetched; presentation is the vp_token as the wallet sent it, decrypted.

  • level_of_assurance needs the trust section’s LEVEL_OF_ASSURANCE, a trusted issuer and a verified holder binding, as for the others.

npa, eidas (kych-native: kych-eumw-bridge, kych-eid)

npa is served by kych-eumw-bridge in front of the Governikus eIDAS Middleware or by kych-eid, eidas by kych-eumw-bridge in front of the eIDAS-Node Connector. The evidence comes from the helper in KyCH’s shape and is passed on with KyCH’s verification_id; its members per helper are listed under Evidence. In short: helper names the program; issuer is the eID server (and, for kych-eid, the card’s document signer and CSCA) or the citizen’s country and its proxy service; trust says what the eID server or the Connector checked; level_of_assurance is high for npa and the asserted level for eidas; presentation is the eID server’s own signed statement (the middleware’s SAML assertion, or kych-eid’s CMS-signed result) or the proxy service’s signed SAML response with the decrypted assertion. For npa nothing in it can be checked against the card later.

22.10.9. Notification#

POST /notification#

Webhook endpoint for receiving asynchronous notifications from a helper that has a webhook: the Swiyu Verifier, walt.id verifier-api2 with a NOTIFY_URL, and KyCH’s own helpers (kych-native) with one, whose body is {"session_id": ...} (see Notification). The verifier calls this endpoint when a verification request changes state, typically when the user presents their credential. Whichever of the webhook, a /status poll and /return learns of the outcome first completes the session; the others find it done.

When a notification is received, KyCH:

  1. Looks up the verification session by the helper’s verification_id.

  2. Queries that helper’s management API for the verification result, on the helper the session was started with.

  3. If successful, extracts the disclosed claims and updates the session to verified status.

  4. If failed, updates the session to failed status.

This endpoint always returns 200 OK to acknowledge receipt, regardless of whether processing succeeded. Errors are logged internally. This prevents the verifier from retrying notifications that cannot be processed.

Request:

Request Headers:
interface KyCHNotificationRequest {
  // UUID of the verification request as assigned by the Swiyu
  // Verifier (not KyCH's verificationId). KyCH uses this to look up
  // the corresponding session.
  verification_id: string;

  // ISO 8601 timestamp indicating when the verification state
  // changed. Used for logging and debugging.
  timestamp: string;
}

Response:

200 OK:

Notification acknowledged. The response body is empty. This status is returned regardless of processing outcome to prevent retries, including for a body that is not JSON or that names no known verification.

22.10.10. Errors#

All error responses use the following format:

interface KyCHErrorResponse {
  // Error code identifier
  error: string;
}

Common error codes:

  • unauthorized: Missing or invalid authentication credentials.

  • invalid_request: Malformed request parameters.

  • invalid_redirect_uri: The redirect URI does not match the registered value.

  • invalid_scope: Requested scopes are not allowed.

  • invalid_grant: Authorization code is invalid, expired, or already used.

  • invalid_client: Client authentication failed.

  • invalid_token: Access token is invalid, expired, or revoked.

  • invalid_state: The state parameter does not match.

  • session_not_found: The session or verification was not found.

  • session_expired: The session has expired.

  • not_verified: The session has not been verified yet.

  • vocabulary_not_selected: The client may use several vocabularies and the session has none chosen yet.

  • no_vocabulary: The client’s registration lists no vocabulary the instance enables; a configuration problem of the operator’s.

  • verifier_unavailable: Cannot communicate with the helper.

  • verifier_error: The helper returned an error.

  • verifier_invalid_response: The helper’s answer could not be understood.

  • invalid_verification_url, invalid_verification_deeplink, invalid_browser_url: The helper handed out a URL with a scheme KyCH does not show the person.

  • invalid_session_status: The session is not in a state that allows the request.

  • vocabulary_already_chosen: The session’s vocabulary is fixed, to another one than the choice posted.

  • claims_purged: /info after KyCH deleted the claims and the evidence.

  • invalid_vocabulary: A vocabulary the client may not use.

  • invalid_profile: A profile the client may not use, or one that covers none of the session’s possible vocabularies.

  • unsupported_content_encoding: A request body compressed in a way KyCH does not read.

  • request_too_large: A request body over the size limit.

  • internal_error: An internal server error occurred.