> 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.

# Onboarding Guide

> Learn how TradeGuard works — the core concepts, the compliance flow, and how to integrate using API keys and webhooks.

# Welcome to TradeGuard

TradeGuard is a compliance management platform for companies that work with subcontractors. It collects the documents that prove a subcontractor is compliant — certificates of insurance (COIs), W-9s, licenses, training certificates — automatically extracts the relevant details, verifies insurance coverage directly with the broker, and continuously evaluates everything against the requirements you define.

You interact with TradeGuard in two ways: the **dashboard**, where you configure your requirements, API keys, and webhooks, and the **API**, which your systems use to manage subcontractors, upload documents, and run compliance checks. This guide introduces the product's building blocks and vocabulary first, walks through the intended flow, and then covers the integration mechanics — authentication, webhooks, and a step-by-step walkthrough.

---

## Core Concepts

### Organization

Your workspace in TradeGuard. Every resource — subcontractors, documents, profiles, compliance results — belongs to your organization, and your API keys are scoped to it automatically. Some requests take an `organizationId`; you can find yours on the **Settings** page in the TradeGuard application.

> **Note**
>
> Your sandbox is a separate organization with **its own organization ID**. The ID on the Settings page is for whichever mode the dashboard is in, so switch on Sandbox mode before copying it for sandbox work. Using a production ID with a sandbox key (or the other way round) returns `404 Organization not found in this environment`. The simplest way to get the right ID is to ask the API: `GET /v1/organizations` returns the organization your key belongs to.

### Subcontractor

The business (or individual) you track for compliance. A subcontractor record holds identity and contact details — entity type (`llc`, `sole_proprietor`, `s_corp`, `c_corp`, `partnership`, `other`), company or personal name, email and phone, and preferences for how TradeGuard communicates with them (email/SMS, English/Spanish). You can also set a `tradeCategory` describing their discipline (`electrical`, `plumbing`, `hvac`, `roofing`, `concrete`, and so on) and an `externalId` to link the record to your own systems.

Creating a subcontractor needs both a `contactEmail` and a `contactPhone`. The phone must be a real, dialable number: numbers without a country code are read as US numbers, formatted input like `(415) 555-1234` is accepted and stored as `+14155551234`, and made-up numbers (for example `+15551234567`, whose area code doesn't exist) are rejected with `400 validation_failed`.

Subcontractor records are shared across general contractors. Before adding one, you can find it with `GET /v1/subcontractors/lookup?q=Acme` (name, DBA, email, phone or EIN; contacts come back partly hidden) and add it by sending its id as `existingSubcontractorId`. If you create a subcontractor whose email or phone matches one already on TradeGuard, nothing is linked automatically: you get `409 subcontractor_match` naming it, and you resend with its `existingSubcontractorId` to join that record, or with `createNew: true` if it's a different company. Company details (name, EIN, owner, address, licenses) are shared and any GC can update them; each change shows in the subcontractor's activity. Your contact person, email and phone, your `externalId` and your `metadata` are your own: other GCs never see or change them, and notices you trigger go to your contact. When TradeGuard collects documents for you, adding a subcontractor also invites it by email; see [Subcontractor invites and reminders](/getting-started/subcontractor-invites-and-reminders).

### Compliance Profile

A reusable template that defines what "compliant" means — for example, *"Standard Subcontractor Requirements: GL coverage of at least \$1M, plus a signed W-9."* Create and manage profiles in the dashboard or through the API ([Set up a compliance profile by API](/getting-started/set-up-a-compliance-profile-by-api)); both see the same profiles. Every new subcontractor is enrolled in your **default profile** automatically. You list profiles to find their IDs if you want to enroll a subcontractor in another one.

### Requirement

A single rule inside a compliance profile. Each requirement names a document category it applies to (and a policy type, for insurance), plus the criteria that must be met — coverage limits, expiration tracking, name matching, signatures, and [policy rules](/getting-started/policy-rules) such as occurrence basis, covered autos or umbrella follow form. Compliance checks evaluate a subcontractor against every requirement in their enrolled profile.

Every new profile also has one **Certificate checks** requirement for the checks that apply to the whole certificate: certificate holder, insured name (the subcontractor's legal name or DBA), signature, and every listed policy in force. See [Certificate Checks](/getting-started/certificate-checks).

### Document

A file uploaded as proof — a COI, tax form, license, or agreement. Every document is tagged with a category:

| Category                         | Examples                                            |
| -------------------------------- | --------------------------------------------------- |
| `insurance`                      | Certificates of insurance (COIs)                    |
| `tax_form`                       | W-9s                                                |
| `license`                        | Trade and business licenses (stored only, not read) |
| `background_check`               | Background check results (stored only, not read)    |
| `training_cert`                  | Safety and training certificates                    |
| `agreement`                      | Signed contracts and agreements                     |
| `endorsement`                    | Policy endorsements                                 |
| `workers_compensation_exemption` | Workers' comp exemption forms                       |

After upload, TradeGuard processes the file automatically: it is validated, then its contents are extracted (`uploaded → validating → extracting → extracted`). `license` and `background_check` files are stored only: they stay `uploaded` and are never read. Uploads are **activated automatically** and replace the previously active document of the same type once they have been read successfully — only active documents count toward compliance. A file that can't be read (wrong or unreadable document) never replaces the one you already have: it becomes `inactive` and the earlier document keeps counting. If you want to stage a document for review without making it live, pass `activate: "false"` on upload.

### Coverage

The insurance facts TradeGuard extracts from a COI: policy type, policy number, carrier, effective and expiration dates, and limits. Policy types are `general_liability`, `workers_comp`, `automobile_liability` and `umbrella`, plus about 50 others brokers type into the certificate's blank rows, such as `professional_liability`, `pollution_liability` and `builders_risk` (see [Other policy types](/getting-started/other-policy-types)).

A coverage starts as `unverified`. TradeGuard then verifies the policy directly with the insurance broker, and the coverage moves to `active` (confirmed in force), `expired`, `canceled`, or `inactive` (superseded by a newer policy). Verification status feeds into compliance results — a requirement can be satisfied on paper but still pending broker confirmation.

### Compliance Record & Compliance Run

A **compliance record** tracks one subcontractor's status against one requirement. Records are created when a subcontractor is enrolled in a profile (which happens automatically for the default profile when you create the subcontractor), and updated every time a check runs:

| Status                           | Meaning                                                                                                                                                                |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pending`                        | Not yet evaluated                                                                                                                                                      |
| `compliant`                      | Requirement satisfied                                                                                                                                                  |
| `compliant_pending_verification` | Documents satisfy the requirement; broker verification still pending. If the broker hasn't confirmed the policy within 14 days, the requirement becomes `under_review` |
| `non_compliant`                  | Requirement not satisfied                                                                                                                                              |
| `expired`                        | The satisfying document or coverage has expired                                                                                                                        |
| `under_review`                   | Being reviewed (e.g. extraction in progress)                                                                                                                           |

A **compliance run** is one execution of a check — an asynchronous evaluation of a subcontractor against their profile. Runs move through `queued → processing → completed`, and the finished run contains the overall outcome plus a per-requirement breakdown.

### API Keys & Webhooks

The two halves of your integration surface. **API keys** authenticate your requests and are created in the dashboard. **Webhooks** push events to your systems — compliance results, status changes, expirations — so you never have to poll. Both are introduced in depth below, in [Authentication & API Keys](#authentication--api-keys) and [Webhooks](#webhooks).

### Where things are managed

| In the dashboard only                              | In the dashboard or via the API              |
| -------------------------------------------------- | -------------------------------------------- |
| API keys                                           | Compliance profiles & requirements           |
| Webhook endpoints                                  | Subcontractors (create, update, enroll)      |
| Organization settings (incl. your organization ID) | Document uploads                             |
|                                                    | Compliance checks, results, records and runs |

---

## How It Works

The intended end-to-end flow:

1. **Define your requirements** — create a compliance profile with the requirements subcontractors must satisfy, in the dashboard or with one API call ([Set up a compliance profile by API](/getting-started/set-up-a-compliance-profile-by-api)), or use your default profile.
2. **Add subcontractors** — create a record for each business you work with, via the API or the dashboard. Each new subcontractor is enrolled in your default profile right away, which creates a compliance record for every requirement and starts a first compliance run.
3. **Enroll them in other profiles (optional)** — only if a subcontractor needs a profile other than your default.
4. **Collect documents** — upload COIs, W-9s, and licenses. TradeGuard validates each file and extracts its contents; insurance documents produce coverage records.
5. **TradeGuard verifies coverage** — extracted insurance coverage is confirmed directly with the broker, moving it from `unverified` to its true status.
6. **Compliance is evaluated** — checks run when you trigger them (and as documents and coverages change), comparing active documents and verified coverages against every requirement. Checks are asynchronous: you get an immediate acknowledgment, then results.
7. **Your systems stay in sync via webhooks** — run results, status changes, and upcoming expirations are pushed to your endpoint as they happen.

Steps 2–7 are the recurring loop of an integration: onboard a subcontractor, collect their documents, and let TradeGuard keep their compliance status current.

---

## Base URL

Every request goes to one host:

```
https://api.tradeguardins.com
```

Production and the sandbox share this host. **Your API key decides which environment you reach**: a key created while the dashboard is in Sandbox mode only ever sees sandbox data. All endpoints are under `/v1`, for example `https://api.tradeguardins.com/v1/organizations`.

### Formats

* **Dates and times** are ISO 8601 date-times in UTC, such as `2026-12-01T00:00:00Z`. Query filters like `from` and `to` on `GET /v1/issues` need the full date-time; a bare date such as `2026-12-01` is rejected with `400`.
* **Phone numbers** are returned in E.164 format (`+14155551234`). See [Subcontractor](#subcontractor) for what's accepted on input.
* **IDs** are UUIDs. A malformed ID returns `400 invalid_identifier`.

---

## Authentication & API Keys

Every API request is authenticated with an **API key** — a secret token scoped to your organization. Keys are created in the dashboard, not through the API, so provisioning credentials stays an explicit, auditable action:

1. Log in to the dashboard and open **Settings → API Keys**.
2. Click **Create API Key** and give it a name (e.g. `Production Integration`).
3. Copy the generated secret and store it somewhere safe.

The secret is shown **only once**, right after creation. If you lose it, revoke the key and create a new one.

> **Note**
>
> The API Reference also lists `/v1/api-keys` endpoints. Those are used by the dashboard itself: they need the `api_keys:manage` scope, which can't be granted to an API key, so calling them with an API key returns `403`.

Requests carry the key as a bearer token:

```
Authorization: Bearer <your-api-key>
```

If you're exploring from these docs, you don't need to construct headers at all — open any endpoint in the [API Reference](/api-reference) and paste your key into the playground's authorization field. The examples in this guide omit the header for brevity.

Where a request needs your `organizationId`, find it on the **Settings** page in the application, or call `GET /v1/organizations` with your key. Remember that the sandbox has its own organization ID.

---

## Webhooks

Much of what TradeGuard does happens asynchronously — compliance checks run in the background, coverages get verified with brokers over time, and documents expire on their own schedule. Webhooks are how those outcomes reach you: TradeGuard POSTs an event to your endpoint the moment something changes, so your systems react in real time instead of polling.

### Events

| Event                                               | Fires when                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `compliance.status_changed`                         | A requirement's compliance status changes for a subcontractor                                                                                                                                                                                                                                                                                                                                                    |
| `compliance.run_completed`                          | A compliance run (e.g. onboarding, or a triggered check) finishes                                                                                                                                                                                                                                                                                                                                                |
| `compliance.expiring_soon`                          | A coverage, or a document with a printed expiration (see [Other Documents](/getting-started/other-documents)), is 30, 14, 7 or 1 days from expiring (sent once at each of those marks)                                                                                                                                                                                                                           |
| `compliance.expired`                                | A document or coverage has expired                                                                                                                                                                                                                                                                                                                                                                               |
| `compliance.producer_outreach_needed`               | Broker verification could not be completed and needs follow-up                                                                                                                                                                                                                                                                                                                                                   |
| `coverage.updated`                                  | A coverage changed: read from a document, confirmed or reported canceled by the broker, expired, or resolved by review. One event per coverage, with `coverageId`, `subcontractorId`, `policyType`, `previousStatus`, `status` and `source`. When the broker sent the certificate, also `verifiedBy: "broker_sent_coi"` and `verifiedAt` ([Broker-sent certificates](/getting-started/broker-sent-certificates)) |
| `document.validated` / `document.validation_failed` | An uploaded document passed or failed validation                                                                                                                                                                                                                                                                                                                                                                 |
| `document.extracted` / `document.extraction_failed` | Extraction of a document finished or failed                                                                                                                                                                                                                                                                                                                                                                      |
| `document.extraction_warning`                       | Extraction finished with fields worth a second look                                                                                                                                                                                                                                                                                                                                                              |
| `document.needs_review`                             | A document was held for human review by TradeGuard (see [Documents Held for Review](/getting-started/documents-held-for-review))                                                                                                                                                                                                                                                                                 |
| `issue.created` / `issue.updated`                   | A compliance issue opened or changed (for example, acknowledged)                                                                                                                                                                                                                                                                                                                                                 |
| `issue.resolved`                                    | Someone resolved an issue with a note; its status is `resolved`                                                                                                                                                                                                                                                                                                                                                  |
| `issue.closed`                                      | An issue closed: a later check passed, a review cleared it, or you closed it without a fix; its status is `closed`                                                                                                                                                                                                                                                                                               |
| `report.completed` / `report.finding_flagged`       | A business report finished, or flagged a finding                                                                                                                                                                                                                                                                                                                                                                 |
| `assignment.status_changed`                         | A subcontractor's job status on a project changed (Cleared / On Watch / Blocked / Pending Review)                                                                                                                                                                                                                                                                                                                |
| `assignment.slot_verdict`                           | A project document slot (e.g. the project-specific COI) got a new verdict                                                                                                                                                                                                                                                                                                                                        |
| `requirement.updated`                               | A requirement is modified                                                                                                                                                                                                                                                                                                                                                                                        |
| `compliance_profile.updated`                        | A compliance profile is modified                                                                                                                                                                                                                                                                                                                                                                                 |

Every payload has the shape `{ type, data, timestamp }`.

### Setting up an endpoint

Webhook endpoints are set up **in the dashboard**, not through the API. There are no API calls to create, list, change, delete or test an endpoint, and you don't need any: the dashboard is where you add endpoints, pick events, get signing secrets and send test events. Under the hood, delivery, signing, retries, and logs are handled by [Svix](https://www.svix.com), embedded directly in the dashboard.

1. In the dashboard, open **Settings → Webhooks**. (Turn on Sandbox mode first to set up sandbox endpoints; each environment has its own.)
2. Click **Add Endpoint** and enter the URL where you want to receive events (e.g. `https://your-app.com/webhooks/tradeguard`).
3. Select the event types you want to subscribe to.
4. After creating the endpoint, open it to reveal its **Signing Secret** (starts with `whsec_`). Use this to verify incoming signatures.

From the same page you can inspect delivery logs, replay failed deliveries, and send test events — no code required.

If you need to open the same portal outside the dashboard, `POST /v1/webhooks/portal` returns a short-lived link to it. It needs the `webhooks:write` scope: organization admins have it, and an API key has it only if you grant it.

### Verifying signatures

Deliveries are signed by Svix. Each request includes `svix-id`, `svix-timestamp`, and `svix-signature` headers. The simplest and safest way to verify them is with the official [Svix libraries](https://docs.svix.com/receiving/verifying-payloads/how), using the endpoint's signing secret (`whsec_...`) from the webhook portal:

```javascript
import { Webhook } from 'svix';

const wh = new Webhook(process.env.TRADEGUARD_WEBHOOK_SECRET); // whsec_...

// `payload` must be the raw request body string (not parsed JSON)
const event = wh.verify(payload, {
  'svix-id': req.headers['svix-id'],
  'svix-timestamp': req.headers['svix-timestamp'],
  'svix-signature': req.headers['svix-signature'],
});
// `event` is the verified JSON body — throws if the signature is invalid.
```

---

## Step-by-Step Walkthrough

> **Tip**
>
> Want copy-paste requests you can run right now? The [Quickstart](/getting-started/quickstart) goes from a sandbox key to a verdict and a webhook with nothing but curl.

With an API key and a webhook endpoint in place, here is the core integration loop. Each step links to its section of the [API Reference](/api-reference) for full request and response details.

### 1. Look up your compliance profile

Profiles are created in the dashboard or through the API ([Set up a compliance profile by API](/getting-started/set-up-a-compliance-profile-by-api)); fetch their IDs via the API. Your `organizationId` is on the **Settings** page, or in the response of `GET /v1/organizations` (use the sandbox organization's ID with a sandbox key).

```
GET /v1/organizations/:orgId/compliance-profiles
```

```json
{
  "data": [
    {
      "id": "e5f6g7h8-...",
      "name": "Standard Subcontractor Requirements",
      "isDefault": true
    }
  ]
}
```

See the [Compliance Profiles reference](/api-reference/compliance-profiles) — including listing the individual [requirements](/api-reference/requirements) inside a profile.

### 2. Create a subcontractor

```
POST /v1/subcontractors
```

```json
{
  "organizationId": "<your-organization-id>",
  "entityType": "llc",
  "companyName": "ABC Electrical",
  "contactEmail": "john@abcelectrical.com",
  "contactPhone": "+14155550123",
  "tradeCategory": "electrical"
}
```

**Response (201):** the subcontractor record, including its `id`. If the business is insured under a trade name, send it as `dba` too (e.g. `"dba": "ABC Lighting"`): a certificate in either name matches.

The new subcontractor is already enrolled in your **default profile**: a compliance record exists for each of its requirements and a first compliance run has started. To use a different profile from the start, include `complianceProfileId` in this request. See the [Subcontractors reference](/api-reference/subcontractors).

### 3. (Optional) Enroll the subcontractor in another profile

Skip this step if the default profile is all you need. To add another profile:

```
POST /v1/subcontractors/:subId/compliance-profiles
```

```json
{
  "complianceProfileId": "e5f6g7h8-..."
}
```

This creates a compliance record for each requirement in the profile and starts a compliance run. Attaching a profile that is already attached is safe: it returns `201` with `alreadyAttached: true` and changes nothing. The default profile can't be detached (`DELETE` returns `400`).

### 4. Upload documents

Upload files as `multipart/form-data`:

```
POST /v1/subcontractors/:subId/documents
Content-Type: multipart/form-data
```

| Field              | Value                                                  |
| ------------------ | ------------------------------------------------------ |
| `file`             | The file itself (required)                             |
| `documentCategory` | e.g. `insurance` (required)                            |
| `documentLabel`    | e.g. `2026 General Liability COI`                      |
| `activate`         | `"false"` to stage the document without making it live |

**Response (201):** the new document, wrapped in `data` like every other response:

```json
{
  "data": {
    "id": "m3n4o5p6-...",
    "subcontractorId": "i9j0k1l2-...",
    "documentCategory": "insurance",
    "status": "active",
    "lifecycleStatus": "uploaded"
  }
}
```

If the exact same file is already on file for this subcontractor, nothing new is created: you get `200` with the existing document instead. If that document had been knocked out by an upload that couldn't be read, it becomes active again and the response also carries `restored: true`. If that document's last read failed (`validation_failed` or `extraction_failed`), the re-upload reads it again and the response carries `rereading: true`.

The document is activated automatically and replaces the previously active document of the same type once it has been read; processing continues in the background (`validating → extracting → extracted`). Insurance documents produce coverage records that TradeGuard verifies with the broker.

If the file is already hosted somewhere, `POST /v1/subcontractors/:subId/documents/url` accepts a JSON body with a `sourceUrl` instead. See the [Documents reference](/api-reference/documents).

### 5. Trigger a compliance check

```
POST /v1/subcontractors/:subId/compliance/check
```

```json
{
  "complianceProfileId": "e5f6g7h8-..."
}
```

**Response (202):**

```json
{
  "data": {
    "id": "u1v2w3x4-...",
    "status": "queued",
    "message": "Compliance check queued. Results will be delivered via webhook."
  }
}
```

Checks run asynchronously. You can poll the run with `GET /v1/compliance/runs/:runId`, but the intended pattern is to wait for the `compliance.run_completed` webhook:

```json
{
  "type": "compliance.run_completed",
  "data": {
    "runId": "u1v2w3x4-...",
    "subcontractorId": "i9j0k1l2-...",
    "complianceProfileId": "e5f6g7h8-...",
    "overallStatus": "pending",
    "summary": {
      "total": 2,
      "passed": 1,
      "failed": 0,
      "pending": 1,
      "pendingVerification": 0,
      "expired": 0
    },
    "requirements": [
      {
        "requirementId": "...",
        "title": "General Liability COI",
        "documentCategory": "insurance",
        "policyType": "general_liability",
        "status": "compliant",
        "documentId": "m3n4o5p6-...",
        "reason": "All criteria met",
        "details": {}
      },
      {
        "requirementId": "...",
        "title": "W-9 Tax Form",
        "documentCategory": "tax_form",
        "policyType": null,
        "status": "pending",
        "documentId": null,
        "reason": "Awaiting document",
        "details": {}
      }
    ],
    "completedAt": "2026-07-13T..."
  },
  "timestamp": "2026-07-13T..."
}
```

See the [Compliance reference](/api-reference/compliance).

### 6. Monitor ongoing compliance

Compliance isn't a one-time gate — documents expire and policies get canceled. To stay current:

* `GET /v1/subcontractors/:subId/compliance` — the current status of every requirement.
* `GET /v1/subcontractors/:subId/compliance/runs` — the run history.
* `GET /v1/subcontractors/:subId` — the full picture: record, documents, coverages, and compliance summary.
* Subscribe to `compliance.expiring_soon`, `compliance.expired`, and `coverage.updated` webhooks to hear about changes the moment they happen.

That's the loop: onboard subcontractors, collect their documents, and let TradeGuard — and your webhook endpoint — keep their compliance status current.