Verification APIs Quickstart
Agent Quick-Start
- Source URL: https://docs.valyd.work/verify#quickstart
- Credentials / env vars needed: VALYD_API_KEY, VALYD_WORKFLOW_ID (Hosted only)
- Files an integrator edits: .env (to store VALYD_API_KEY and VALYD_WORKFLOW_ID), server route handler (to make the API call and, for Hosted, handle the webhook)
- Estimated steps: 6
- Can complete without human input: NO — steps 1-4 require a human to sign in with Valyd SSO, copy the one-time API key, create a Workflow, and configure the webhook in the Developer Portal (https://dev.valyd.work ). The API call itself (steps 5-6) can be automated once credentials exist.
- Prerequisites:
- A Valyd SSO account able to sign in to the Developer Portal
- An App API key copied from the Console (shown once at creation)
- For Hosted: a
workflow_idfrom a created Workflow - For Hosted: a publicly reachable webhook URL and signing secret
Prerequisites
- Access to the Developer Portal at https://dev.valyd.work (sign in with Valyd SSO).
- The App API key, copied at App creation (shown once). Store it server-side only.
- For the Hosted snippet: a
workflow_idfrom a Workflow you created in the Console.
Steps
-
Sign in to the Developer Portal with Valyd SSO and create an app — owned by your individual account or your organization. That ONE app issues your OAuth credentials (client_id / client_secret, used for BOTH login and verification), a project API key for verification-only use, and your workflows. One SDK (@valyd/sdk), one host (the Valyd IdP), no second dashboard. (Human-only step.)
Open https://dev.valyd.work and sign in with Valyd SSO.Expected output: You are signed in and a default App is visible in the Console.
-
Copy the App API key (shown once at creation). Keep it server-side only. (Human-only step.) Then store it in your environment.
export VALYD_API_KEY="paste-the-one-time-app-api-key-here"(Get the API key from the Developer Portal → your App → it is shown once at creation: https://dev.valyd.work )
Expected output:
VALYD_API_KEYis set in your shell/.env. The key cannot be retrieved again after creation — rotate it in the Console if lost. -
(Hosted only) Create a Workflow and copy its
workflow_id. (Human-only step.) Then store it.export VALYD_WORKFLOW_ID="paste-your-workflow-id-here"(Get the
workflow_idfrom the Developer Portal → Workflows → your Workflow: https://dev.valyd.work )Expected output:
VALYD_WORKFLOW_IDis set. Required only for the Hosted session call in step 6. -
(Hosted only) Set your webhook URL and signing secret under Webhooks in the Console. (Human-only step.)
In the Console → Webhooks: set the endpoint URL (e.g. https://your-app.com/api/valyd-webhook) and copy the signing secret.Expected output: Valyd will POST signed events to your URL when a session reaches a terminal state.
-
Run your first Core APIs call (age verification) to confirm your API key works.
curl -X POST https://idp.valyd.work/api/v2/age-verification \ -H "X-API-Key: $VALYD_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "dob": "1995-06-01", "bands": ["is_18_plus"] }'Expected output: HTTP
200with the standard envelope, e.g.{ "success": true, "data": { ... } }. On a bad/missing key expect a4xxwith{ "success": false, "error": { "code": "...", "message": "..." } }. -
(Hosted only) Create a Hosted session from your server, then redirect the user’s browser to the returned URL.
const res = await fetch("https://idp.valyd.work/api/v2/session", { method: "POST", headers: { "X-API-Key": process.env.VALYD_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ workflow_id: process.env.VALYD_WORKFLOW_ID, redirect_url: "https://your-app.com/verify/result", callback: "https://your-app.com/api/valyd-webhook", vendor_data: "user-123", }), }); const { data } = await res.json(); // Redirect the user's browser to data.urlExpected output: HTTP
200with{ "success": true, "data": { "url": "https://..." } }. Redirect the user’s browser todata.url. The verification result arrives later via your configured webhook (step 4).
Verification
-
Core APIs: the curl in step 5 returns HTTP
200and a body wheresuccessistrue.curl -s -o /dev/null -w "%{http_code}\n" -X POST https://idp.valyd.work/api/v2/age-verification \ -H "X-API-Key: $VALYD_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "dob": "1995-06-01", "bands": ["is_18_plus"] }'Expect
200printed. -
Hosted: the step-6 call returns a non-empty
data.url. Confirmecho $VALYD_WORKFLOW_IDis non-empty before calling.
Common errors
-
401 / 403 Unauthorized
- Cause: Missing, wrong, or rotated
X-API-Key, or the key was sent client-side. - Fix: Re-copy the API key from the Console (or rotate it), set
VALYD_API_KEYserver-side, and send it in theX-API-Keyheader. Never expose it in browser code.
- Cause: Missing, wrong, or rotated
-
400 Bad Request on /api/v2/session
- Cause: Missing or invalid
workflow_id(Hosted requires a real Workflow id), or malformed JSON body. - Fix: Create a Workflow in the Console, set
VALYD_WORKFLOW_ID, and verifyecho $VALYD_WORKFLOW_IDis non-empty. EnsureContent-Type: application/jsonand valid JSON.
- Cause: Missing or invalid
-
No webhook received after a Hosted session
- Cause: Webhook URL/signing secret not configured, or your endpoint is not publicly reachable.
- Fix: Set the webhook URL and signing secret in Console → Webhooks (step 4), ensure the URL is publicly reachable, and verify the signature using the signing secret before trusting the event.