Scenarios are configuration, not verification data. They live on your account, are shared by every teammate using a sandbox key, and have no effect in production. The endpoints accept sandbox keys only; a production key gets
403 env_not_sandbox.Start from a working sandbox integration. Your Bridge or order flow should already complete a verification with Truv’s built-in test credentials. A scenario changes only the data that comes back.
How it works
1
Create a scenario
POST /v1/sandbox/scenarios/ with the input it answers for, a payload of the data to return, and optionally how the task should behave: status, delay, multi-factor authentication (MFA).2
Run a verification
Start a normal sandbox verification and supply that input: sign in with the scenario’s login, upload the files it names, or order for the applicant it identifies.
3
Get your data back
Truv resolves the scenario and serves your payload as the task result. Tasks, webhooks, and reports behave exactly as they do for any other connection.
Pick a data source
Every scenario belongs to onedata_source. The data source decides which fields select the scenario, what the user does in Truv Bridge to reach it, and the shape of its payload. Two optional fields narrow a scenario further. On a login data source, provider_id restricts the scenario to one provider or carrier. products limits which products can use the scenario. For example, financial_accounts is a data source, truv_bank is a provider, and assets is a product.
Each guide below works through its data source end to end.
is_refresh is accepted on every data source.
Create a scenario [Server-side]
A scenario is one flat object: what it matches on, how it behaves, and what it returns. This request creates a payroll scenario; the other guides show the same call for their data source.Check that it works
Start a sandbox verification, select Truv Payroll Provider in Truv Bridge, and sign in withacme.start / s4ndb0x. The income and employment report lists Jane Roe as a Staff Engineer at Acme Inc. If it shows Truv’s built-in test data instead, no scenario matched the input. Send the same input to the resolve endpoint to see which scenario, if any, answers it.
Identity and routing
Matching fields
These fields decide which input the scenario answers. A field you leave out narrows nothing, so it matches any value. Set at least one field the data source accepts;is_refresh doesn’t count on its own, because a scenario that constrains nothing would answer every input of its data source.
No two of your scenarios on the same data source can have the same matching fields. The API refuses a duplicate and names the scenario that already has them.
enabled and products don’t make two scenarios distinct: change a matching field, or edit the existing scenario instead.
Behavior
payload is required unless behavior_status is a failure status. A scenario that only ever fails carries no data.
Two data sources have no login step, so they accept a subset of this:
See Task lifecycle for what each status means to your integration.
Payload
payload holds the data the scenario returns. Its shape depends on data_source, and the API validates it against that shape: unknown keys are dropped, choice fields and required fields are checked, and money is a decimal string ("4615.38", not 4615.38) so nothing is lost to floating point. Each guide has the full field reference:
- Payroll payload: employments with paystubs, W-2s, bank accounts, and shifts
- Document upload payload: employments with paystubs, W-2s, 1099s, 1040s, and volunteer letters, plus permanent change of station (PCS) orders
- Financial accounts payload: accounts with balances, owners, transactions, holdings, statements, and recurring deposits
- Education payload: National Student Clearinghouse (NSC) outcome, degrees, and enrollments
- Insurance payload: policies with drivers, vehicles, and documents
Which scenario wins
Several scenarios can match the same input. Truv uses the following rules, in order, to choose one:- On
docs, a scenario whosefilenamesare exactly the uploaded files beats one that names only some of them, and among partial matches the one naming more files wins. - The scenario with more matching fields set (
username,password,provider_id,company_domain,ssn_last4,date_of_birth) wins.is_refreshdoesn’t count here. - A scenario that sets
is_refreshwins over one that doesn’t. - The oldest scenario wins.
products is skipped for tasks of any other product. Truv uses its built-in test data when no custom scenario matches.
Check the winner without running a verification
POST /v1/sandbox/scenarios/resolve/ is a dry run: send the input a user would supply and get back the scenario that would answer it.
scenario is abbreviated here; the API returns the full scenario. matched_on lists the fields the winning scenario actually constrained. Here the scenario sets no provider_id, so it answers the ADP connection without listing provider_id. A 404 means no scenario of yours matches and the verification would get Truv’s built-in test data.
Manage scenarios
List and filter
{"results": [...], "next": "..."}. Follow next until it is null. Results come back oldest first. Which scenario wins depends on the input, so use the resolve endpoint to see the actual winner.
Update
PATCH (or PUT, they behave identically) replaces every top-level key you send and leaves the rest untouched. payload is replaced wholesale, so send the complete object, not a fragment.
data_source after creating a scenario. To use another data source, create a new scenario with that source and a compatible payload.
Delete
Document library
Any record a scenario serves as a file comes from your sandbox document library: a paystub or W-2 PDF on a payroll or document upload scenario, a 1099, volunteer letter, or PCS order, a bank statement, or an insurance policy document. Upload the file once, then reference itsid as document_id from as many scenarios as you like. When a task uses an entry, Truv serves a separate copy for that task; the original stays in the library.
Document upload scenarios also use the library for matching: every name in a scenario’s filenames must be an entry, and an entry’s test metadata describes what a document collection finds in the file.
Upload a file
Send the file asmultipart/form-data, or as JSON with the bytes base64-encoded in content. Send exactly one of file or content. filename is a separate field: it is the name the entry is addressed by and does not have to match the name on disk. Filenames are unique per account, compared without regard to case, and Truv’s own test document filenames are reserved.
id: that is the document_id your payloads reference.
Test metadata
status, validations, last_error, and documents are test metadata you configure for the entry, not data Truv extracted from the file. Only document upload scenarios read them, when a document collection receives a file with the entry’s filename. Every other use serves the file bytes and ignores the metadata, so leave it out.
Set them on upload (
documents only) or afterwards with PATCH /v1/sandbox/documents/{id}/, which takes filename and the four fields above. The file itself can’t be replaced; upload a new entry instead.
Manage the library
GET /v1/sandbox/documents/ lists your entries newest first, with a fresh pre-signed file URL on every read. DELETE /v1/sandbox/documents/{id}/ removes one. A delete is refused with 409 resource_in_use while any scenario still references the entry, by document_id or by filenames, so drop the reference first. Renaming an entry a docs scenario matches on is refused the same way.
Limits
These are the default limits for your account as a whole. Each guide lists the per-payload limits for its data source. Contact Truv Support if your test plan needs higher limits.Errors
Sandbox configuration errors use the standard error envelope:Next steps
Payroll
Employments, paystubs, W-2s, bank accounts, and shifts behind a payroll login
Document upload
What Truv returns for the files a user uploads
Financial accounts
Accounts, transactions, holdings, statements, and recurring deposits behind a bank login
Education
Degrees and enrollments for an applicant’s SSN or date of birth
Insurance
Policies, drivers, vehicles, and documents behind a carrier login
Sandbox API reference
Full request and response schemas for every sandbox endpoint