## WorkMarket Integration Guide
##### Learn how to connect WorkMarket work orders to 1099Policy to automate contractor insurance checks, validate COIs, and offer fractional coverage for every assignment.

Connect WorkMarket Work Orders to 1099Policy to ensure every contractor engagement has valid insurance coverage before work begins. This integration automates policy creation, COI validation, and compliance syncing between both platforms.

You can:

- Bind new insurance coverage when a contractor is assigned to a Work Order.
- Automatically validate and store Certificates of Insurance (COIs).
- Keep compliance states in sync through 1099Policy webhooks (`policy.*`, `certificate.*`).
- Map WorkMarket compensation to 1099Policy `job.wage` (integer cents) and `wage_type`.
- Persist Work Order IDs in `custom_metadata.work_order_id` for reconciliation (never as primary IDs).

## 2. Integration Flow

Coverage should be triggered when a contractor is assigned to a Work Order. This ensures insurance binds before work starts or service hours are logged.

- **Primary trigger:** Work Order status changes to `ASSIGNED`.
- **Alternative trigger:** Status updates to `IN_PROGRESS` (if work begins after check-in).
- **Event delivery:** WorkMarket “Integration & Automation” Webhooks.
- **Required data:** Work Order ID, worker ID, compensation, and scheduled dates.

## 3. Core Concepts

Each WorkMarket object maps directly to a 1099Policy resource to ensure every assignment carries active coverage and proper COI tracking.

| WorkMarket Object | 1099Policy Resource | Description |
| --- | --- | --- |
| Work Order | Job + Assignment | Defines work scope, comp, and coverage window |
| Worker | Contractor | Represents the insured individual |
| COI (Certificate) | Certificate | Validates insurance documentation |
| Work Order ID | `custom_metadata.work_order_id` | Used for reconciliation only |

## 4. End-to-End Implementation

Follow these steps to integrate WorkMarket and 1099Policy for automated contractor insurance compliance.

### 4.1 Create Contractor

Each WorkMarket Worker must exist in 1099Policy before quotes or assignments are created. Every Contractor must include a unique `contact.email`. Generate a proxy email if missing (e.g., `<worker_id>@relay.yourdomain.com`).

| WorkMarket Field | 1099Policy Contractor | Notes |
| --- | --- | --- |
| `worker_id` | `custom_metadata.workmarket_worker_id` | Reconciliation key |
| `first_name`, `last_name` | `contact.first_name`, `contact.last_name` | Required |
| `email` | `contact.email` | **Required**; proxy allowed |
| `country` | `address.country` | Optional |
| `region` | `address.region` | Optional |

**Source: WorkMarket (REST)**

```http
GET https://api.workmarket.com/v1/workers/{worker_id}
Authorization: Bearer wm_live_***
```

**Destination: 1099Policy (POST /contractors)**

```http
POST https://api.1099policy.com/api/v1/contractors
Authorization: Bearer t9k_test_***
Content-Type: application/json
Idempotency-Key: workmarket-worker-<WORKER_ID>
```

```json
{
  "contact": {
    "first_name": "Alex",
    "last_name": "Nguyen",
    "email": "wk_421@relay.yourdomain.com"
  },
  "address": {
    "country": "US",
    "region": "CA"
  },
  "custom_metadata": {
    "workmarket_worker_id": "wk_421"
  }
}
```

### 4.2 Create Job

Create a Job in 1099Policy when a Work Order is assigned to a contractor to define scope, compensation, and region.

| 1099Policy Job Field | WorkMarket Source | Notes |
| --- | --- | --- |
| `name` | Work Order title | Human-readable name |
| `description` | Work Order description | Scope or SOW |
| `entity` | Internal client/account ID | Must exist in 1099Policy |
| `category_code` | Work Order category → mapped 1099Policy code | Maintain mapping |
| `wage` (cents) | `budget_amount × 100` or `rate_amount × 100` | Required |
| `wage_type` | "flatfee" or "hourly" | Required |
| `region` | Work location (state) | Defaults to contractor region |
| `custom_metadata.work_order_id` | Work Order ID | Reconciliation |

**Source: WorkMarket (REST)**

```http
GET https://api.workmarket.com/v1/workorders/{work_order_id}
Authorization: Bearer wm_live_***
```

**Destination: 1099Policy (POST /jobs)**

```http
POST https://api.1099policy.com/api/v1/jobs
Authorization: Bearer t9k_test_***
Content-Type: application/json
```

```json
{
  "name": "WO 12345 — Low Voltage Cabling",
  "description": "Install Cat6 and test drops at client site",
  "entity": "en_abc123",
  "category_code": "jc_MTqpkbkp6G",
  "wage": 32500,
  "wage_type": "flatfee",
  "region": "CA",
  "custom_metadata": { "work_order_id": "12345" }
}
```

### 4.3 Create Quote

Create a Quote to define the type of coverage and its effective window.

| 1099Policy Quote Field | WorkMarket Source | Notes |
| --- | --- | --- |
| `contractor` | Mapped Worker ID | Must exist first |
| `job` | Returned Job ID | Required |
| `coverage_type[]` | Policy requirement | e.g., `["general","workers-comp"]` |
| `effective_date` | WO start (epoch UTC) | Recommended |
| `end_date` | WO end (epoch UTC) | Recommended |
| `custom_metadata.work_order_id` | Work Order ID | Reconciliation |

**Destination: 1099Policy (POST /quotes)**

```http
POST https://api.1099policy.com/api/v1/quotes
Authorization: Bearer t9k_test_***
Content-Type: application/json
```

```json
{
  "contractor": "cn_Ehb3bYa",
  "job": "jb_jsb9KEcTpc",
  "coverage_type": ["general","workers-comp"],
  "effective_date": 1761997200,
  "end_date": 1762083600,
  "custom_metadata": { "work_order_id": "12345" }
}
```

### 4.4 Create Insurance Application Session

Redirect contractors to complete their first policy opt-in using the insurance application session endpoint.

**Destination: 1099Policy (POST /apply/sessions)**

```http
POST https://api.1099policy.com/api/v1/apply/sessions
Authorization: Bearer t9k_test_***
Content-Type: application/json
```

```json
{
  "quote": "qt_5DciVga8Kt",
  "success_url": "https://workmarket.com/workorders/12345?coverage=active",
  "cancel_url": "https://workmarket.com/workorders/12345?coverage=canceled",
  "custom_metadata": { "work_order_id": "12345" }
}
```

### 4.5 Create Assignment

Assignments represent active coverage tied to the Work Order’s scheduled period.

**Destination: 1099Policy (POST /assignments)**

```http
POST https://api.1099policy.com/api/v1/assignments
Authorization: Bearer t9k_test_***
Content-Type: application/json
```

```json
{
  "contractor": "cn_Ehb3bYa",
  "job": "jb_jsb9KEcTpc",
  "effective_date": 1761997200,
  "end_date": 1762083600,
  "coverage_type": ["general","workers-comp"],
  "custom_metadata": { "work_order_id": "12345" }
}
```

### 4.6 Upload Certificate (BYO-COI)

If a contractor provides their own COI, upload it for validation and compliance tracking.

**Destination: 1099Policy (POST /files/certificates)**

(multipart upload)

Fields:
- `certificate=@file.pdf`
- `contractor=cn_Ehb3bYa`
- `custom_metadata[work_order_id]=12345`

### 4.7 Record Invoice (Optional)

If the contractor’s final pay differs from the original estimate, record the actual remuneration for reconciliation and audit. This step is optional and does not affect insurance coverage.

**Destination: 1099Policy (POST /invoices)**

```http
POST https://api.1099policy.com/api/v1/invoices
Authorization: Bearer t9k_test_***
Content-Type: application/json
```

```json
{
  "contractor": "cn_ti8eXviE4A",
  "job": "jb_rajdrwMUKi",
  "gross_pay": 1200,
  "paycycle_startdate": 1714419793,
  "paycycle_enddate": 1714419793
}
```

Unix timestamp
Use Unix seconds (UTC) for `paycycle_startdate` and `paycycle_enddate`. See full API reference: [https://docs.1099policy.com/group/endpoint-invoice](https://docs.1099policy.com/group/endpoint-invoice)

## 5. Webhooks

WorkMarket event notifications and 1099Policy webhooks keep coverage synchronized across systems.

| Source | Event | Action |
| --- | --- | --- |
| WorkMarket | Work Order assigned | Trigger Job + Quote creation |
| WorkMarket | Work Order in progress | Create Assignment |
| 1099Policy | `policy.active` | Mark contractor insured |
| 1099Policy | `policy.expired` / `policy.canceled` | Mark unprotected |
| 1099Policy | `certificate.validated` | Mark COI valid |
| 1099Policy | `certificate.flagged` | Flag for manual review |

## 6. Testing Checklist

Ensure coverage is bound automatically when Work Orders are assigned.

- Contractor created (proxy email if missing)
- Job created with wage and metadata mapping
- Quote created with coverage types and dates
- Application Session launched successfully
- Assignment matches Work Order term
- COI uploads validated and webhook verified
- Optional invoice recorded when remuneration differs

## 7. References

- WorkMarket API & Webhook Documentation: [https://developer.workmarket.com/](https://developer.workmarket.com/)
