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

# Activate/deactivate a subcontractor, set its condition flags, or defer endorsements or missing policies to renewal

PATCH https://api.tradeguardins.com/v1/subcontractors/{subcontractorId}/enrollment
Content-Type: application/json

Updates your organization's enrollment of the subcontractor. Send
`status`, `conditionFlags`, `enforceEndorsementsAtRenewal`,
`missingPoliciesAtRenewal`, or any mix.

* Changing `status` is recorded in the
  [enrollment status history](https://docs.tradeguardins.com/api-reference/subcontractors/get-subcontractor-enrollment-history).
* Changing `conditionFlags` re-evaluates compliance for every active
  profile the subcontractor is enrolled in for your organization.
* Record the subcontractor's answer on business vehicles with
  `company_vehicles` (yes) or `no_company_vehicles` (no); sending both
  is a `400`. Auto requirements that apply "only when the sub operates
  company vehicles" read "Waiting on the sub" until one is set (see
  [List condition keys](https://docs.tradeguardins.com/api-reference/compliance/list-condition-keys)).
* Add `no_owned_vehicles` when the subcontractor confirms it owns no
  company vehicles: auto requirements with `policyRules.noOwnedVehiclesException`
  then accept hired + non-owned autos only (see `PolicyRules`).
* `enforceEndorsementsAtRenewal: true` defers the endorsement checks on the
  policies the subcontractor has now until each one renews (see
  [Create a subcontractor](https://docs.tradeguardins.com/api-reference/subcontractors/create-subcontractor)); `false` checks
  them now. Changing it re-evaluates compliance the same way.
* `missingPoliciesAtRenewal` replaces the missing policy types that wait
  until the subcontractor's next renewal (`[]` for none). A type kept from
  before keeps its original start; a newly added one starts now. Changing
  it re-evaluates compliance the same way.
* When nothing actually changes, the enrollment is returned unchanged and
  nothing is recorded.

Returns `404` when the subcontractor has no enrollment with your
organization. Requires scope `subcontractors:write`.

Reference: https://docs.tradeguardins.com/api-reference/subcontractors/update-subcontractor-enrollment

## Authentication

- `Authorization` header (bearer token, required) — Session JWT or API key (`ak_...`)

## Request

### Path parameters

- `subcontractorId` (string, required)

### Body (application/json)

This endpoint expects an object.

- `enforceEndorsementsAtRenewal` (boolean, optional) — Existing sub, endorsement checks wait for each policy's renewal.
- `missingPoliciesAtRenewal` (list of enum, optional) — Existing sub, these missing policy types wait until the subcontractor's next renewal (the earliest expiration date among its policies on file). Replaces the current set; `[]` for none.
  - Allowed values: `general_liability`, `workers_comp`, `automobile_liability`, `umbrella`, `professional_liability`, `medical_malpractice`, `directors_and_officers`, `employment_practices_liability`, `fiduciary_liability`, `cyber`, `technology_errors_omissions`, `media_liability`, `pollution_liability`, `liquor_liability`, `products_liability`, `owners_contractors_protective`, `railroad_protective`, `abuse_and_molestation`, `employee_benefits_liability`, `stop_gap_liability`, `foreign_liability`, `garage_liability`, `garagekeepers`, `riggers_liability`, `crime`, `fidelity_bond`, `surety_bond`, `commercial_property`, `builders_risk`, `installation_floater`, `equipment_floater`, `leased_rented_equipment`, `inland_marine`, `ocean_marine`, `motor_truck_cargo`, `cargo`, `warehouse_legal_liability`, `bailees_coverage`, `business_interruption`, `equipment_breakdown`, `flood`, `earthquake`, `physical_damage`, `trailer_interchange`, `non_trucking_liability`, `contingent_liability`, `occupational_accident`, `aviation`, `watercraft`, `uslh`, `maritime_employers_liability`, `disability`, `accident_health`
- `status` (enum, optional)
  - Allowed values: `active`, `inactive`
- `conditionFlags` (list of string, optional) — Condition keys set for this subcontractor in your organization; replaces the current set. Each must be a known key (see GET /v1/meta/condition-keys), otherwise `400 validation_failed`.

## Response

### 200

Enrollment updated

- `data` (Enrollment, optional) — The link between your organization and a subcontractor (one row per organization × subcontractor). Status, condition flags and portal-invite state are organization-scoped; the subcontractor record itself is shared.

## Errors

### 400 Bad Request Error

Request failed schema validation (`validation_failed`)

- `error` (string, required) — Human-readable message. Wording may change; do not parse it.
- `code` (enum, required) — Stable, machine-readable error code. Status-level codes: `bad_request` (400), `unauthenticated` (401), `forbidden` (403), `not_found` (404), `method_not_allowed` (405, with an `Allow` header), `conflict` (409), `gone` (410), `payload_too_large` (413), `unprocessable` (422), `rate_limited` (429), `internal_error` (500), `bad_gateway` (502), `service_unavailable` (503). Specific codes: `validation_failed` and `invalid_identifier` (400); `reextraction_limit_reached` and `llm_budget_exhausted` (429, document re-extraction only); `sandbox_unavailable` (503, a sandbox key used where the sandbox is not provisioned); `assignment_exists` (409, a live assignment for this subcontractor and project already exists — its id is in `details`), `project_not_ready` (409, the project's setup is not Ready), `project_document` (409, a baseline-only action on a project certificate) and `subcontractor_match` (409, a new subcontractor's email or phone matches one already on TradeGuard — its id is in `details`); `portal_link_expired` and `portal_link_used` (410, sub portal links only).
  - Allowed values: `bad_request`, `unauthenticated`, `forbidden`, `not_found`, `method_not_allowed`, `conflict`, `gone`, `payload_too_large`, `unprocessable`, `rate_limited`, `internal_error`, `bad_gateway`, `service_unavailable`, `validation_failed`, `invalid_identifier`, `reextraction_limit_reached`, `llm_budget_exhausted`, `sandbox_unavailable`, `assignment_exists`, `project_not_ready`, `project_document`, `subcontractor_match`, `portal_link_expired`, `portal_link_used`
- `requestId` (string, optional) — Same value as the `x-request-id` response header.
- `details` (list of ErrorDetailsItems, optional) — Present when `code` is `validation_failed`.

### 401 Unauthorized Error

Missing, malformed, expired or revoked credential (`unauthenticated`)

- `error` (string, required) — Human-readable message. Wording may change; do not parse it.
- `code` (enum, required) — Stable, machine-readable error code. Status-level codes: `bad_request` (400), `unauthenticated` (401), `forbidden` (403), `not_found` (404), `method_not_allowed` (405, with an `Allow` header), `conflict` (409), `gone` (410), `payload_too_large` (413), `unprocessable` (422), `rate_limited` (429), `internal_error` (500), `bad_gateway` (502), `service_unavailable` (503). Specific codes: `validation_failed` and `invalid_identifier` (400); `reextraction_limit_reached` and `llm_budget_exhausted` (429, document re-extraction only); `sandbox_unavailable` (503, a sandbox key used where the sandbox is not provisioned); `assignment_exists` (409, a live assignment for this subcontractor and project already exists — its id is in `details`), `project_not_ready` (409, the project's setup is not Ready), `project_document` (409, a baseline-only action on a project certificate) and `subcontractor_match` (409, a new subcontractor's email or phone matches one already on TradeGuard — its id is in `details`); `portal_link_expired` and `portal_link_used` (410, sub portal links only).
  - Allowed values: `bad_request`, `unauthenticated`, `forbidden`, `not_found`, `method_not_allowed`, `conflict`, `gone`, `payload_too_large`, `unprocessable`, `rate_limited`, `internal_error`, `bad_gateway`, `service_unavailable`, `validation_failed`, `invalid_identifier`, `reextraction_limit_reached`, `llm_budget_exhausted`, `sandbox_unavailable`, `assignment_exists`, `project_not_ready`, `project_document`, `subcontractor_match`, `portal_link_expired`, `portal_link_used`
- `requestId` (string, optional) — Same value as the `x-request-id` response header.
- `details` (list of ErrorDetailsItems, optional) — Present when `code` is `validation_failed`.

### 403 Forbidden Error

The credential lacks the scope or role for this action (`forbidden`)

- `error` (string, required) — Human-readable message. Wording may change; do not parse it.
- `code` (enum, required) — Stable, machine-readable error code. Status-level codes: `bad_request` (400), `unauthenticated` (401), `forbidden` (403), `not_found` (404), `method_not_allowed` (405, with an `Allow` header), `conflict` (409), `gone` (410), `payload_too_large` (413), `unprocessable` (422), `rate_limited` (429), `internal_error` (500), `bad_gateway` (502), `service_unavailable` (503). Specific codes: `validation_failed` and `invalid_identifier` (400); `reextraction_limit_reached` and `llm_budget_exhausted` (429, document re-extraction only); `sandbox_unavailable` (503, a sandbox key used where the sandbox is not provisioned); `assignment_exists` (409, a live assignment for this subcontractor and project already exists — its id is in `details`), `project_not_ready` (409, the project's setup is not Ready), `project_document` (409, a baseline-only action on a project certificate) and `subcontractor_match` (409, a new subcontractor's email or phone matches one already on TradeGuard — its id is in `details`); `portal_link_expired` and `portal_link_used` (410, sub portal links only).
  - Allowed values: `bad_request`, `unauthenticated`, `forbidden`, `not_found`, `method_not_allowed`, `conflict`, `gone`, `payload_too_large`, `unprocessable`, `rate_limited`, `internal_error`, `bad_gateway`, `service_unavailable`, `validation_failed`, `invalid_identifier`, `reextraction_limit_reached`, `llm_budget_exhausted`, `sandbox_unavailable`, `assignment_exists`, `project_not_ready`, `project_document`, `subcontractor_match`, `portal_link_expired`, `portal_link_used`
- `requestId` (string, optional) — Same value as the `x-request-id` response header.
- `details` (list of ErrorDetailsItems, optional) — Present when `code` is `validation_failed`.

### 404 Not Found Error

Resource not found, or not visible to the caller's organization (`not_found`)

- `error` (string, required) — Human-readable message. Wording may change; do not parse it.
- `code` (enum, required) — Stable, machine-readable error code. Status-level codes: `bad_request` (400), `unauthenticated` (401), `forbidden` (403), `not_found` (404), `method_not_allowed` (405, with an `Allow` header), `conflict` (409), `gone` (410), `payload_too_large` (413), `unprocessable` (422), `rate_limited` (429), `internal_error` (500), `bad_gateway` (502), `service_unavailable` (503). Specific codes: `validation_failed` and `invalid_identifier` (400); `reextraction_limit_reached` and `llm_budget_exhausted` (429, document re-extraction only); `sandbox_unavailable` (503, a sandbox key used where the sandbox is not provisioned); `assignment_exists` (409, a live assignment for this subcontractor and project already exists — its id is in `details`), `project_not_ready` (409, the project's setup is not Ready), `project_document` (409, a baseline-only action on a project certificate) and `subcontractor_match` (409, a new subcontractor's email or phone matches one already on TradeGuard — its id is in `details`); `portal_link_expired` and `portal_link_used` (410, sub portal links only).
  - Allowed values: `bad_request`, `unauthenticated`, `forbidden`, `not_found`, `method_not_allowed`, `conflict`, `gone`, `payload_too_large`, `unprocessable`, `rate_limited`, `internal_error`, `bad_gateway`, `service_unavailable`, `validation_failed`, `invalid_identifier`, `reextraction_limit_reached`, `llm_budget_exhausted`, `sandbox_unavailable`, `assignment_exists`, `project_not_ready`, `project_document`, `subcontractor_match`, `portal_link_expired`, `portal_link_used`
- `requestId` (string, optional) — Same value as the `x-request-id` response header.
- `details` (list of ErrorDetailsItems, optional) — Present when `code` is `validation_failed`.

### 429 Too Many Requests Error

Rate limit exceeded (`rate_limited`); retry after `Retry-After` seconds

- `error` (string, required) — Human-readable message. Wording may change; do not parse it.
- `code` (enum, required) — Stable, machine-readable error code. Status-level codes: `bad_request` (400), `unauthenticated` (401), `forbidden` (403), `not_found` (404), `method_not_allowed` (405, with an `Allow` header), `conflict` (409), `gone` (410), `payload_too_large` (413), `unprocessable` (422), `rate_limited` (429), `internal_error` (500), `bad_gateway` (502), `service_unavailable` (503). Specific codes: `validation_failed` and `invalid_identifier` (400); `reextraction_limit_reached` and `llm_budget_exhausted` (429, document re-extraction only); `sandbox_unavailable` (503, a sandbox key used where the sandbox is not provisioned); `assignment_exists` (409, a live assignment for this subcontractor and project already exists — its id is in `details`), `project_not_ready` (409, the project's setup is not Ready), `project_document` (409, a baseline-only action on a project certificate) and `subcontractor_match` (409, a new subcontractor's email or phone matches one already on TradeGuard — its id is in `details`); `portal_link_expired` and `portal_link_used` (410, sub portal links only).
  - Allowed values: `bad_request`, `unauthenticated`, `forbidden`, `not_found`, `method_not_allowed`, `conflict`, `gone`, `payload_too_large`, `unprocessable`, `rate_limited`, `internal_error`, `bad_gateway`, `service_unavailable`, `validation_failed`, `invalid_identifier`, `reextraction_limit_reached`, `llm_budget_exhausted`, `sandbox_unavailable`, `assignment_exists`, `project_not_ready`, `project_document`, `subcontractor_match`, `portal_link_expired`, `portal_link_used`
- `requestId` (string, optional) — Same value as the `x-request-id` response header.
- `details` (list of ErrorDetailsItems, optional) — Present when `code` is `validation_failed`.

## Types

### Enrollment

The link between your organization and a subcontractor (one row per organization × subcontractor). Status, condition flags and portal-invite state are organization-scoped; the subcontractor record itself is shared.

- `id` (string, optional)
- `organizationId` (string, optional)
- `subcontractorId` (string, optional)
- `status` (enum, optional)
  - Allowed values: `active`, `inactive`
- `origin` (string, optional) — Relationship origin from your side — `new` (onboarding tone) or `existing` (continuity tone). Open-ended; other values may appear.
- `invitedAt` (datetime, optional) — When the latest portal invite was sent (defaults to the enrollment's creation time).
- `invitedBy` (string, optional, nullable) — Clerk user id (or API key subject) that sent the latest invite.
- `onboardedAt` (datetime, optional, nullable)
- `inviteToken` (string, optional, nullable) — The current single-use portal invite token.
- `conditionFlags` (list of string, optional) — Condition keys your organization has set for this subcontractor (see GET /v1/meta/condition-keys).
- `enforceEndorsementsAtRenewal` (boolean, optional) — Existing sub, endorsement checks wait for each policy's renewal (see `enforceEndorsementsAtRenewal` on [Create a subcontractor](https://docs.tradeguardins.com/api-reference/subcontractors/create-subcontractor)). A policy that took effect after `endorsementsAtRenewalSince` is a renewal, and its endorsements are checked as normal.
- `endorsementsAtRenewalSince` (datetime, optional, nullable) — When `enforceEndorsementsAtRenewal` was turned on.
- `missingPoliciesAtRenewal` (list of enum, optional) — Existing sub, these missing policy types wait until the subcontractor's next renewal (see `missingPoliciesAtRenewal` on [Create a subcontractor](https://docs.tradeguardins.com/api-reference/subcontractors/create-subcontractor)). Empty when none.
  - Allowed values: `general_liability`, `workers_comp`, `automobile_liability`, `umbrella`, `professional_liability`, `medical_malpractice`, `directors_and_officers`, `employment_practices_liability`, `fiduciary_liability`, `cyber`, `technology_errors_omissions`, `media_liability`, `pollution_liability`, `liquor_liability`, `products_liability`, `owners_contractors_protective`, `railroad_protective`, `abuse_and_molestation`, `employee_benefits_liability`, `stop_gap_liability`, `foreign_liability`, `garage_liability`, `garagekeepers`, `riggers_liability`, `crime`, `fidelity_bond`, `surety_bond`, `commercial_property`, `builders_risk`, `installation_floater`, `equipment_floater`, `leased_rented_equipment`, `inland_marine`, `ocean_marine`, `motor_truck_cargo`, `cargo`, `warehouse_legal_liability`, `bailees_coverage`, `business_interruption`, `equipment_breakdown`, `flood`, `earthquake`, `physical_damage`, `trailer_interchange`, `non_trucking_liability`, `contingent_liability`, `occupational_accident`, `aviation`, `watercraft`, `uslh`, `maritime_employers_liability`, `disability`, `accident_health`
- `contactName` (string, optional, nullable) — Your organization's contact person (surfaced on the subcontractor as `contactName`).
- `contactEmail` (string, optional, nullable) — Your organization's contact email (surfaced on the subcontractor as `contactEmail`).
- `contactPhone` (string, optional, nullable) — Your organization's contact phone (surfaced on the subcontractor as `contactPhone`).
- `externalId` (string, optional, nullable) — Your organization's own ID (surfaced on the subcontractor as `externalId`).
- `gcMetadata` (EnrollmentGcMetadata, optional) — Your organization's own metadata (surfaced on the subcontractor as `metadata`).
- `metadata` (EnrollmentMetadata, optional) — Internal invite bookkeeping. After an invite, `metadata.subInvite` holds `sentAt`, `sentBy`, `expiresAt`, `acceptedAt`, `acceptedBy`, `recipientEmail`, and `revokedAt` / `revokedReason` when a contact-email change voided it.
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)

### ErrorDetailsItems

- `path` (string, optional)
- `message` (string, optional)

### EnrollmentGcMetadata

Your organization's own metadata (surfaced on the subcontractor as `metadata`).

### EnrollmentMetadata

Internal invite bookkeeping. After an invite, `metadata.subInvite` holds `sentAt`, `sentBy`, `expiresAt`, `acceptedAt`, `acceptedBy`, `recipientEmail`, and `revokedAt` / `revokedReason` when a contact-email change voided it.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "data": {
    "id": "string",
    "organizationId": "string",
    "subcontractorId": "string",
    "status": "active",
    "origin": "new",
    "invitedAt": "2024-01-15T09:30:00Z",
    "invitedBy": "string",
    "onboardedAt": "2024-01-15T09:30:00Z",
    "inviteToken": "string",
    "conditionFlags": [
      "string"
    ],
    "enforceEndorsementsAtRenewal": true,
    "endorsementsAtRenewalSince": "2024-01-15T09:30:00Z",
    "missingPoliciesAtRenewal": [
      "general_liability"
    ],
    "contactName": "string",
    "contactEmail": "string",
    "contactPhone": "string",
    "externalId": "string",
    "gcMetadata": {},
    "metadata": {},
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.tradeguardins.com/v1/subcontractors/subcontractorId/enrollment")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```