Skip to navigation

Quickstart

From a sandbox API key to a compliance verdict and a webhook, in about 15 minutes, with nothing but curl.

This guide runs entirely in the sandbox. Nothing is emailed, no one is called, and nothing is charged. Every step is a plain HTTP request; copy them in order. You need curl and, for readability, jq.

What you’ll build: a subcontractor, a certificate of insurance (COI) uploaded for it, TradeGuard’s verdict on that COI, and a webhook delivered to your endpoint when the verdict changes.

1. Get a sandbox API key

  1. Sign in to the TradeGuard dashboard and open Settings → API Keys.
  2. Turn on Sandbox mode. An orange banner confirms you’re in the sandbox. The first time, this creates your organization’s sandbox, with its own data and a default compliance profile.
  3. Click Create API key and give it a name. For this guide, select every scope. Copy the secret (ak_…); it is shown once.

Set it and the base URL in your shell:

export TG_KEY="ak_..." # the sandbox key you just created
export TG="https://api.tradeguardins.com"

There is one host for production and sandbox. The key decides which environment you reach.

Check the key works and that you’re in the sandbox:

curl -s "$TG/v1/organizations" -H "Authorization: Bearer $TG_KEY" | jq '.data[0] | {id, name, environment}'
{ "id": "5b1e…", "name": "Acme Builders (Sandbox)", "environment": "sandbox" }

If you see "environment": "production", the key was created outside Sandbox mode. Create a new one with Sandbox mode on.

2. Point a webhook at a URL you can watch

TradeGuard pushes results to you as webhooks. Webhook endpoints are set up in the dashboard, not through the API. With Sandbox mode still on, open Settings → Webhooks, then:

  1. Click Add Endpoint.
  2. For Endpoint URL, paste a URL you can watch. For a first run a free request inspector works: open webhook.site and copy “Your unique URL”.
  3. Under events, subscribe to compliance.status_changed (or leave all selected) and create the endpoint.

Prefer the terminal? POST /v1/webhooks/portal returns a short-lived link to the same portal (the key needs the webhooks:write scope): curl -s -X POST "$TG/v1/webhooks/portal" -H "Authorization: Bearer $TG_KEY" | jq -r '.data.url // .error' (without that scope it prints the 403 error instead of a link)

3. Create a subcontractor

curl -s -X POST "$TG/v1/subcontractors" \
-H "Authorization: Bearer $TG_KEY" -H "Content-Type: application/json" \
-d '{
"entityType": "llc",
"companyName": "Sandbox Test Subcontractor LLC",
"contactEmail": "quickstart-'"$(date +%s)"'@example.com",
"contactPhone": "+14152'"$(date +%s | tail -c 7)"'"
}' | tee /tmp/tg-sub.json | jq '{id: .data.id, matchedExisting}'
export SUB_ID=$(jq -r '.data.id' /tmp/tg-sub.json)

The subcontractor is enrolled in your organization and attached to your default compliance profile. In a new sandbox that profile is Sandbox Standard Requirements: a General Liability COI with 1Meachoccurrence,1M each occurrence, 2M aggregate, and an additional-insured endorsement. Nothing has been uploaded yet, so its record reads pending with the reason Awaiting document. No issue is opened for a requirement that is still awaiting its first document:

curl -s "$TG/v1/subcontractors/$SUB_ID/compliance" -H "Authorization: Bearer $TG_KEY" \
| jq '.data[] | {requirement: .requirement.title, status, statusReason}'
{ "requirement": "General Liability COI", "status": "pending", "statusReason": "Awaiting document" }

(If statusReason is still empty, the first compliance run hasn’t finished. Wait a second and run it again.)

The email and phone above are made unique with the current time. Subcontractors are matched by email and phone, so reusing them returns 409 subcontractor_match with the existing record’s id in details; send that id as existingSubcontractorId to add it.

4. Upload a certificate of insurance

The sandbox doesn’t read real documents; it reads sample documents, test certificates with known outcomes. Each one is made for the subcontractor you ask for: it prints that sub’s name and address and dates counted from today. Download the one that passes every check:

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

Upload it for your subcontractor:

curl -s -X POST "$TG/v1/subcontractors/$SUB_ID/documents" \
-H "Authorization: Bearer $TG_KEY" \
-F "file=@coi-compliant.pdf;type=application/pdf" \
-F "documentCategory=insurance" \
| jq '.data | {id, status}'

TradeGuard now works in the background:

  1. It validates the document and extracts the policy details.
  2. It checks them against the requirement.
  3. It verifies the policy with the insurance broker. In the sandbox that call is simulated; the sample’s broker phone number, (202) 555-0100, always confirms the policy.

5. Read the verdict

Poll the subcontractor’s compliance until the status settles. It usually takes well under a minute:

for i in $(seq 1 30); do
STATUS=$(curl -s "$TG/v1/subcontractors/$SUB_ID/compliance" -H "Authorization: Bearer $TG_KEY" | jq -r '.data[0].status')
echo "$STATUS"
[ "$STATUS" = "compliant" ] && break
sleep 5
done

You’ll see pending (the document is being processed), then compliant_pending_verification (the document passes, and broker verification is under way), then compliant.

6. See the webhook

Back in your request inspector, you’ll find a compliance.status_changed delivery for each status change on the way to compliant. The last one looks like this:

{
"type": "compliance.status_changed",
"data": {
"complianceRecordId": "…",
"subcontractorId": "…",
"requirementId": "…",
"previousStatus": "compliant_pending_verification",
"newStatus": "compliant"
},
"timestamp": "2026-09-30T15:04:05.000Z"
}

In your own endpoint, verify the signature before trusting a delivery. Every request carries svix-id, svix-timestamp and svix-signature headers; see Verifying signatures.

That’s a working integration. Your system created a subcontractor, submitted its COI, and got the verdict pushed to it.

7. Try the other outcomes

List every sample and what it demonstrates:

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

Repeat steps 3–5 with a new subcontractor for each sample, replacing coi-compliant with its key:

SampleFinal status
coi-low-limitsnon_compliant: each-occurrence limit below 1Mandaggregatebelow1M and aggregate below 2M
coi-missing-endorsementsnon_compliant: no additional-insured endorsement
coi-expiredexpired: the policy has ended
coi-canceled-on-callnon_compliant: the simulated broker reports the policy canceled
coi-broker-unreachablestays compliant_pending_verification: the broker never answers. Automated retries follow business hours; once they’re exhausted, compliance.producer_outreach_needed fires. After 14 days with no broker confirmation the requirement becomes under_review.

Uploading the same file twice for the same subcontractor returns the existing document (TradeGuard deduplicates identical content). Use a new subcontractor per sample.

Next steps

  • Onboarding Guide: the concepts behind what you just did: profiles, requirements, coverages, compliance runs.
  • Sandbox Guide: every sample document (COIs, W-9s, OSHA cards and more), magic broker phone numbers, and simulating verification outcomes directly.
  • Errors & Rate Limits: error codes and the 100 requests/minute limit.
  • API Reference: every endpoint, with a request builder.
  • Going live: turn Sandbox mode off, create a production key, and swap it in. It’s the same host and the same API.