Extending HYPR Affirm with Code Customizations
This playbook is the running order for adding custom code to a HYPR Affirm verification flow. Each step says what you decide or do, then links to the page that describes it in detail. Follow the link, complete the step, and come back here for the next one.
Who this is for: developers and administrators who need a verification flow to read profile data from a system other than Okta or Entra ID, to act on a verification decision in an external system, or to send notifications through their own gateway.
Before you start: you need a verification flow you can edit, and access to HYPR Affirm → Advanced Settings → Code Customizations in the Control Center.
Step 1 — Confirm you need a customization
Standard integrations cover most deployments. Reach for custom code only where they fall short.
What you'll decide:
- Whether your identity provider already supplies every profile field your flow requires
- Whether your system of record keys users on an identifier that needs mapping
- Whether the verification decision must drive an action in another system
Go to Choose a customization type →
If a standard integration covers you, stop here — no customization is needed.
Step 2 — Decide which verification steps the flow uses
The steps you choose determine which profile fields the flow needs, which in turn determines what a User Directory customization has to return.
What you'll decide:
- Which steps meet your assurance requirement
- Which profile fields those steps compare against
- Whether your system of record actually holds those fields
Go to Profile data each step requires →
For the wider flow-design decisions around this — the identifier users type on the first screen, outcomes, and branding — see Identity Verification and Assurance Strategies.
Step 3 — Pick the customization type
Each type has its own input and output contract. Pick the one that matches the job before you write anything.
| If you need to… | Use |
|---|---|
| Read the user profile from your own system | User Directory |
| Act on the verification decision in another system | Outcome API Call |
| Send SMS through your own gateway | SMS Sending and SMS Verifying |
| Send email through your own gateway | |
| Write verification images to an external directory | Image Writeback |
| Insert your own verification step into the flow | Custom Verification Step |
Go to the full contract reference →
Step 4 — Register the customization and its attributes
Create the customization in the Control Center first, so you have somewhere to put the code and the environment values it reads.
What you'll do:
- Create the customization and choose its type
- Add the attributes your script will read — API URLs, tenant identifiers, credentials
- Save
Keep environment values in attributes rather than in the script, so the same customization can move between environments unchanged.
Go to Create a Customization →
Step 5 — Write the script
The script runs in an ES2022 runtime with no browser or Node.js APIs, so every call to the outside world goes through the ctx object.
What you'll learn:
- The
handleentry point and how the input arrives - The
ctxobject — HTTP methods, JWT helpers, hashing, and the short-lived value store - The design pattern for your customization type
- A worked User Directory customization, built up in stages
Go to Writing Affirm Code Customizations →
Jump straight to a part: the entry point · the ctx object · design patterns · worked example
Step 6 — Decide what the script returns when it cannot finish
How you signal a missing record or an unreachable API is part of the design, not an afterthought — an uncaught exception is not a failure signal.
What you'll learn:
- What to return when the record is not found
- How to surface your own error condition
- What the flow does when the script throws
Step 7 — Test before you attach it to a live flow
Test mode runs the script against values you supply and surfaces errors instead of swallowing them.
What you'll do:
- Turn on Edit Mode to change code or attributes, then switch to Test
- Exercise every outcome the flow can produce, approved and denied
- Confirm every attribute your code reads is configured, with names matching exactly
Go to Edit and test a customization →
For end-to-end validation of the whole deployment, see Affirm Test Cases.
Step 8 — Attach the customization to a verification flow
A registered customization does nothing until a flow uses it. Assignment happens in the flow's step configuration, not on the customization itself.
What you'll do:
- Open the verification flow and the step the customization belongs to
- Select your customization from that step's drop-down
- Save the flow
Go to Configure Verification Steps →
For a worked assignment example, see Liveness-Only (Anchor Image).
Step 9 — Confirm it in production
Customization results are recorded as part of the verification flow, so you can confirm behavior without instrumenting anything yourself.
Where to look:
- Activity Log — the customization's result alongside the flow's other step results
- Affirm Helpdesk — the same history for service-desk operators
- Audit Trail — administrative changes, including attribute updates and code edits
Optional — related configuration
These are not part of the main sequence. Come back to them if your deployment needs them.
- Send an authentication parameter to your IdP — pass
acr_values,prompt, or any other authorization-request parameter through OIDC Settings. - Start Enterprise Passkey registration from an Affirm outcome — see Affirm to Enterprise Passkey Seamless Integration.
- Customize screen content and branding — see Affirm Studio (Admin).
- Write verification images to a directory — see Directory Image Writeback.
Related
- Writing Affirm Code Customizations — the developer guide this playbook sequences
- Affirm Customizations (Code Customization API) — contract reference for every customization type
- Identity Verification and Assurance Strategies — designing the verification flow this customization plugs into
- Playbooks overview