> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.tradeguardins.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.tradeguardins.com/_mcp/server.

# Sandbox Guide

> Test your integration safely — sample documents with known outcomes, simulated broker verification, and a full environment that never contacts a real broker.

# The TradeGuard Sandbox

TradeGuard runs two environments on the same API: **production**, where real compliance work happens, and **sandbox**, a fully isolated environment for building and testing your integration. The sandbox never makes real phone calls and never sends real emails — broker verification is simulated — and it ships with sample documents that produce every compliance outcome on demand, so you can exercise your entire integration without a single real certificate of insurance.

|                       | Production           | Sandbox                           |
| --------------------- | -------------------- | --------------------------------- |
| Purpose               | Real compliance data | Integration testing & development |
| Broker calls / emails | Real                 | **Simulated — never sent**        |
| Data                  | Yours, persistent    | Disposable test data              |
| API keys              | Production keys      | Sandbox keys                      |

## Environments and API keys

Every organization has a sandbox; there is nothing to request or enable. Your dashboard login works in both environments — the **Sandbox mode** switch on **Settings → API Keys** moves the whole dashboard between them (an orange banner shows while you're in sandbox), and the first switch creates your sandbox.

Both environments are served by the **same base URL**. The API key decides which one a request reaches:

* Keys created while in **sandbox** are sandbox keys: they only ever see and change sandbox data.
* Keys created while in **production** are production keys: they only ever see and change production data.
* Sandbox data is stored separately from production data. Object ids are per environment — your sandbox organization, subcontractors and documents have their own ids, and a sandbox key asking for a production id gets a `404`.

Each environment's Settings page lists only its own keys. Key responses include an `environment` field so your tooling can tell them apart. Webhook endpoints are per environment too: register your test endpoint while in sandbox and it receives sandbox events only.

## Sample documents — every outcome, on demand

The sandbox doesn't read real documents. It reads **sample documents** instead: realistic test files with known outcomes, made for the subcontractor you download them for. Think of them as test credit card numbers, but for certificates and paperwork.

* **Built for your sub.** Each sample prints that subcontractor's name and business address (a dummy address if none is on file) and dates counted from the day you download it. An "expired" sample is always expired, and an "expiring in about 20 days" sample always is.
* **Everything else is dummy.** Agents, insurers, policy numbers, tax ID numbers and people on the samples are made up. Your organization's name is printed as the certificate holder.
* **Same checks as production.** When you upload a sample, the sandbox skips the AI reading step and uses the reading the sample was made with. Everything after that (coverage records, compliance checks, verification calls, webhooks) runs the same code as production.

### Download a sample

**In the dashboard:** switch to Sandbox, open a subcontractor, and click **Sample documents**. Pick a sample to download it, then upload it on the same page.

**With the API:** list the samples, then download one for a subcontractor with your sandbox key:

```bash
curl -s "$TG/v1/sandbox/fixtures" -H "Authorization: Bearer $TG_KEY" \
  | jq -r '.data[] | "\(.key)\t\(.title)"'

curl -s "$TG/v1/sandbox/fixtures/coi-compliant/file?subcontractorId=$SUB_ID" \
  -H "Authorization: Bearer $TG_KEY" -o coi-compliant.pdf
```

Upload it with the sample's `documentCategory` (and `documentType`, when it has one), both listed by `GET /v1/sandbox/fixtures`. Without `subcontractorId`, the sample is made for a dummy subcontractor named *Sandbox Demo Roofing LLC*.

A download made for a subcontractor is named after them, for example *Example Tile & Stone LLC - coi-compliant.pdf*, so a sample made for one sub is easy to tell from another's. The name is in the `Content-Disposition` header (use `curl -OJ` to keep it).

### Certificates of insurance

Each one is a filled-in ACORD 25 certificate. Results are against *Sandbox Standard Requirements*, the default profile every new sandbox starts with: General Liability with **$1M each occurrence / $2M aggregate** and an **additional-insured** endorsement. Upload with `documentCategory=insurance`.

| Sample                     | What's on it                                                                                                                                         | What happens                                                                                                                           |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `coi-compliant`            | GL, auto, umbrella and workers comp with standard limits, additional insured and waiver; broker phone (202) 555-0100 confirms on the simulated call. | Passes the default profile and typical $1M/$2M requirements; the simulated broker call verifies it, so the requirement ends compliant. |
| `coi-gl-only`              | A certificate with only a GL policy ($1M / $2M, additional insured).                                                                                 | Meets the default GL requirement; any auto, umbrella or workers comp requirement stays missing.                                        |
| `coi-low-limits`           | GL each occurrence $500,000 and aggregate $1,000,000, under a $1M / $2M requirement.                                                                 | Fails the GL limits check: non-compliant.                                                                                              |
| `coi-low-auto-limit`       | All lines present but the auto combined single limit is \$500,000.                                                                                   | Passes the default GL profile; fails any \$1M auto liability requirement.                                                              |
| `coi-expired`              | Every policy ended 30 days before the download date.                                                                                                 | Coverage is recorded as expired and the requirement reads expired.                                                                     |
| `coi-expiring-20-days`     | Every policy expires 20 days after the download date.                                                                                                | Compliant for now, with an "expiring soon" warning and renewal reminders.                                                              |
| `coi-expiring-45-days`     | Every policy expires 45 days after the download date.                                                                                                | Compliant, inside the 60-day "expiring soon" window.                                                                                   |
| `coi-missing-endorsements` | All lines, but the ADDL INSD and SUBR WVD columns are blank and the remarks don't mention either.                                                    | Fails the additional-insured endorsement check: non-compliant.                                                                         |
| `coi-endorsement-page`     | GL and auto, with a second page carrying an additional-insured endorsement form (CG 20 10) naming the certificate holder.                            | Additional insured is proven by the attached endorsement page: compliant.                                                              |
| `coi-name-mismatch`        | The insured printed is "Northgate Sample Mechanical Inc", not this subcontractor.                                                                    | The insured-name check flags the mismatch; with "require name match" on, the coverage goes to review.                                  |
| `coi-renewal`              | Same lines and limits as "Compliant, all lines" with new policy numbers and a new one-year term.                                                     | Upload after the compliant sample: the new policies replace the old ones and the sub stays compliant.                                  |
| `coi-auto-only`            | A certificate with only an auto policy.                                                                                                              | Adds auto coverage only; it doesn't replace an existing GL certificate, and a GL requirement stays as it was.                          |
| `coi-canceled-on-call`     | A clean all-lines certificate whose broker phone is (202) 555-0101.                                                                                  | Document checks pass, then the simulated broker call reports the policy canceled: non-compliant.                                       |
| `coi-broker-unreachable`   | A clean all-lines certificate whose broker phone is (202) 555-0102.                                                                                  | Compliant pending verification; after the call attempts, producer outreach is needed.                                                  |

### Other documents

| Sample                      | Upload as                                         | What's on it                                                                                      | What happens                                                                                               |
| --------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `w9-good`                   | `tax_form` / `w9`                                 | An IRS Form W-9 in the sub's name, classification checked, EIN, signed and dated.                 | Every W-9 check passes and the name matches the sub: compliant.                                            |
| `w9-unsigned`               | `tax_form` / `w9`                                 | A filled-in W-9 with a blank signature and date.                                                  | The "Signed" and "Dated" checks fail: non-compliant.                                                       |
| `w9-state-form`             | `tax_form` / `w9`                                 | A state vendor substitute form instead of the IRS W-9.                                            | The reader can't say it is the official IRS form, so it goes to TradeGuard review.                         |
| `osha-10`                   | `training_cert` / `osha_card`                     | An OSHA 10-hour construction card for a worker at the sub.                                        | Passes an OSHA 10 requirement; fails one that requires OSHA 30.                                            |
| `osha-30`                   | `training_cert` / `osha_card`                     | An OSHA 30-hour construction card for a worker at the sub.                                        | Passes OSHA 10 and OSHA 30 requirements.                                                                   |
| `first-aid-current`         | `training_cert` / `first_aid_cpr`                 | A First Aid / CPR / AED certificate issued about 4 months ago, valid 2 years.                     | Compliant, with its printed expiration tracked.                                                            |
| `first-aid-expired`         | `training_cert` / `first_aid_cpr`                 | A First Aid / CPR / AED certificate whose printed expiration passed about 70 days ago.            | The "Not expired" check fails: expired.                                                                    |
| `lift-card`                 | `training_cert` / `lift_safety`                   | A MEWP / aerial lift operator qualification for scissor and boom lifts.                           | Every lift check passes: compliant.                                                                        |
| `safety-policy`             | `safety_policy` / `safety_policy`                 | A two-page written safety program in the sub's name, signed by the owner.                         | Compliant.                                                                                                 |
| `safety-policy-template`    | `safety_policy` / `safety_policy`                 | A safety program template with "\[COMPANY NAME]" placeholders and no signature.                   | The "Company named" check fails and no name can be matched: non-compliant until a real policy is uploaded. |
| `wc-exemption-fl`           | `workers_compensation_exemption` / `wc_exemption` | A Florida certificate of election to be exempt, state-stamped, valid 2 years.                     | Compliant, with its printed expiration tracked.                                                            |
| `wc-exemption-ks-affidavit` | `workers_compensation_exemption` / `wc_exemption` | A notarized owner affidavit of exemption (Kansas has no state certificate).                       | The reader can't call it an official state document, so it goes to TradeGuard review.                      |
| `agreement`                 | `agreement` / `agreement`                         | A master subcontract agreement between your organization and the sub, signed by both.             | Compliant.                                                                                                 |
| `agreement-unsigned`        | `agreement` / `agreement`                         | The same agreement with both signature lines blank.                                               | The "Signed by the sub" check fails: non-compliant.                                                        |
| `wrong-type-w9-as-osha`     | `training_cert` / `osha_card`                     | A W-9 meant to be uploaded as an OSHA card, to show what happens with the wrong kind of document. | The reader says it isn't an OSHA card, so it goes to TradeGuard review.                                    |
| `license`                   | `license`                                         | A contractor license file in the sub's name.                                                      | Stored for your records; not read. Licenses are checked against state records by the license report.       |
| `background-check`          | `background_check`                                | A clear background check report for the sub's owner.                                              | Stored for your records; not read.                                                                         |

"Goes to TradeGuard review" means the document waits for a person to look at it, as it would in production. "Stored only" files are kept for your records and never read.

### Uploading anything else

Any other file uploaded in the sandbox fails with the message *"Sandbox only reads sample documents. Download one from Sample documents on this sub's page."* The same message is on the document as `metadata.statusReason`, so your integration can show it.

The six original fixture COI files (recognized by their exact contents) still work, so older test scripts keep passing.

> **Note**
>
> Uploading the *same* file twice for the *same* subcontractor returns the existing document — TradeGuard deduplicates identical file content per subcontractor. A sample downloaded twice on the same day for the same subcontractor is the same file. This is real API behavior worth handling in your integration; use another sample, another day's download, or another subcontractor to create a fresh record.

## License and Secretary of State test values

The license and Secretary of State checks read the subcontractor record, not a document, so they have their own test values. In the sandbox these checks never call the real services and are never charged. Set a value on the subcontractor (in the dashboard with **Edit**, or with `PATCH /v1/subcontractors/{subcontractorId}`), then run the check (**Run report** on the sub page, or `POST /v1/subcontractors/{subcontractorId}/reports`). `GET /v1/sandbox/fixtures` returns the same list as `testValues`, and the dashboard shows it in **Sample documents**.

**License number** (any state; any ending works, e.g. `SANDBOX-VALID-42`):

| License number           | What the sandbox answers                                                   |
| ------------------------ | -------------------------------------------------------------------------- |
| `SANDBOX-VALID-1`        | Active license, expires in about a year, no discipline. Passes.            |
| `SANDBOX-EXPIRED-1`      | Expired license (ended about 90 days ago). Fails.                          |
| `SANDBOX-SUSPENDED-1`    | Suspended license. Fails.                                                  |
| `SANDBOX-DISCIPLINARY-1` | Active license with two past disciplinary actions on record.               |
| `SANDBOX-NOTFOUND-1`     | Not found in the state's license records. Fails.                           |
| `SANDBOX-UNSUPPORTED-1`  | The state can't be checked automatically, so it needs manual verification. |
| anything else            | Treated as an active, valid license.                                       |

**Secretary of State:** put one of these words anywhere in the subcontractor's legal (company) name, e.g. *Acme INACTIVE Roofing LLC*:

| Word in the name | What the sandbox answers                                                           |
| ---------------- | ---------------------------------------------------------------------------------- |
| `INACTIVE`       | The business is found but is no longer active (dissolved). Fails.                  |
| `NOMATCH`        | No business with that name is registered in the state. Fails.                      |
| `MISMATCH`       | A business is found, but under a different legal name, so the name check flags it. |
| none of these    | Found as an active business with exactly that name.                                |

Sandbox answers say so: the run's `adapterMode` is `fixture`, license results have no source link (`sourceUrl` is `null`), and the dashboard labels them *Sandbox test answer* instead of linking anywhere.

## Magic phone numbers — simulated broker verification

A passing COI is `compliant_pending_verification` until the broker confirms the policy — in production, that's a real phone call. In sandbox, the **producer phone number on the certificate** decides the simulated call's outcome:

| Producer phone   | Simulated outcome                                                                  |
| ---------------- | ---------------------------------------------------------------------------------- |
| `(202) 555-0100` | Broker verifies all policies → coverage `active` → **`compliant`**                 |
| `(202) 555-0101` | Broker reports the policy **canceled** → coverage `canceled` → **`non_compliant`** |
| `(202) 555-0102` | No answer → retries, then `compliance.producer_outreach_needed`                    |

The sample certificates already carry these numbers, so the lifecycle plays out on its own.

> **Note**
>
> In the sandbox the first simulated verification runs as soon as the document is processed, at any hour. Automated *retries* after a no-answer follow the broker's business hours, as in production: 9am–5pm Monday–Friday in the broker's local time (taken from the phone's area code), skipping major US holidays. The magic phones are (202) Washington, DC numbers, so in the sandbox that is 9am–5pm ET. To re-run a verification immediately, use `POST /v1/subcontractors/:subId/documents/:docId/verify-coverage`.

## Simulating verification outcomes directly

For scripted control — or to reset a scenario — set a coverage's verification status explicitly:

```bash
POST /v1/sandbox/coverages/:coverageId/verification
```

```json
{ "status": "active" }
```

Accepted statuses: `unverified`, `active`, `inactive`, `expired`, `canceled`. This records a coverage event, emits a `coverage.updated` webhook with `"source": "sandbox_simulation"` and `"simulated": true`, and queues compliance re-checks — the same downstream behavior as a real verification.

## Simulating email replies and bounces

Sandbox never sends or receives real email. To see what happens when a subcontractor or its broker writes back, simulate it on the sub's email conversation:

```bash
# The conversation id
curl -s "$TG/v1/sandbox/conversations?subcontractorId=$SUB_ID" -H "Authorization: Bearer $TG_KEY" | jq '.data[0].id'

# The broker replies with a sample certificate (verified with no call once that broker is on file)
curl -s -X POST "$TG/v1/sandbox/conversations/$CONVERSATION_ID/simulate-reply" \
  -H "Authorization: Bearer $TG_KEY" -H "Content-Type: application/json" \
  -d '{"from": "broker", "attachmentSampleKey": "coi-compliant"}'

# Our email bounced
curl -s -X POST "$TG/v1/sandbox/conversations/$CONVERSATION_ID/simulate-bounce" -H "Authorization: Bearer $TG_KEY"
```

The response's `intake.status` says what TradeGuard did: `documents` (the attachment was read like any emailed document), `reply` (queued for a person to read), `bounce`, or `auto_reply`. In the web app, the same tools are under **Simulate email** on a sub's page while you're in Sandbox. See [Broker-sent certificates](/getting-started/broker-sent-certificates).

## The end-to-end journey to build against

1. Create a subcontractor and enroll it in a compliance profile.
2. Register a webhook endpoint in the webhook portal (`POST /v1/webhooks/portal` returns a link to it; needs `webhooks:write`) — the sandbox delivers real webhooks.
3. Download the `coi-compliant` sample for the subcontractor and upload it (category `insurance`).
4. Watch the webhook sequence: `document.validated` → `document.extracted` → `coverage.updated` → `compliance.status_changed` (`compliant_pending_verification`) → after the simulated broker call, `coverage.updated` + `compliance.status_changed` (**`compliant`**).
5. Repeat with the other samples until your integration handles every branch.

When you're ready to go live, create a production API key from the production side of the dashboard and swap it in — same base URL, identical API surface.