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

# Upload a document from a URL

POST https://api.tradeguardins.com/v1/subcontractors/{subcontractorId}/documents/url
Content-Type: application/json

Upload path 2 of 3: TradeGuard downloads `sourceUrl` server-side and
stores it as a document. The file name is the last segment of the URL
path and the MIME type is the response's `Content-Type`.

The fetch is SSRF-guarded: private, loopback, link-local and cloud
metadata addresses are refused (redirect targets are re-checked), and it
has a timeout and a 25 MiB streaming cap. A refused or failed download or
a non-2xx upstream status is a `400` with `code: bad_request`; a
downloaded file that is empty or of an unsupported type, or a body that
fails schema validation, is a `400` with `code: validation_failed`.

Accepted categories: `insurance`, `license`, `background_check`,
`training_cert`, `tax_form`, `agreement`, `endorsement`,
`workers_compensation_exemption`, `safety_policy` (`business_registration`,
`notice_of_cancellation` and `certificate` are rejected with `400`).

**Other documents (W-9, OSHA card, First Aid, …).** Every category but
`insurance`, `endorsement`, `license` and `background_check` is read by AI, which checks the file really
is that kind of document and reads who it is issued to, its dates and its
key fields (a W-9's TIN is kept as its last 4 digits only). Name the kind
in `documentType` (see `DocumentType`). It is required for
`training_cert` (`osha_card`, `first_aid_cpr`, `lift_safety`) and
defaults for the rest. `license` and `background_check` files are
stored only: kept on file, never read by AI, and the document stays
`lifecycleStatus: uploaded`. Licenses are checked against state records
by a license report requirement (`reportSource: tradesapi_license`);
background checks will run through the background check API. For a
`background_check` file, `documentType` may be left out; the former
values `level_2_screening` and `background_check` are still accepted
and kept as a label. A new document replaces the active one of the same kind only, so an
OSHA card and a First Aid card can both be on file. A document that
doesn't look like the kind it was uploaded as, or that the AI reads with
low confidence, is held for TradeGuard review instead of counting.
Use `endorsement` for endorsement pages sent separately from the
certificate (CG 20 10, CG 24 04, IL 80 01 and so on): they are read like
pages attached to a certificate, count toward the subcontractor's
endorsement and notice-of-cancellation requirements alongside its
certificate, and those requirements are re-checked once the file is read.
Same file types, size limit, content checks and duplicate handling as the
multipart upload. The document is always
activated (there is no `activate` option), replaces the active document
of the same category once it has been read (as the multipart upload
describes), starts the validation + extraction workflow in the
background, and keeps `sourceUrl`.

Requires scope `documents:write`.


Reference: https://docs.tradeguardins.com/api-reference/documents/upload-document-from-url

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

- `sourceUrl` (string, required)
- `documentCategory` (enum, required) — Accepted categories: `insurance`, `license`, `background_check`, `training_cert`, `tax_form`, `agreement`, `endorsement`, `workers_compensation_exemption`, `safety_policy` (`business_registration`, `notice_of_cancellation` and `certificate` are rejected with `400`).
  - Allowed values: `insurance`, `business_registration`, `license`, `background_check`, `training_cert`, `tax_form`, `agreement`, `endorsement`, `notice_of_cancellation`, `workers_compensation_exemption`, `certificate`, `safety_policy`
- `documentType` (enum, optional) — The kind of a non-insurance document, within its category: - `tax_form`: `w9` - `workers_compensation_exemption`: `wc_exemption` - `training_cert`: `osha_card`, `first_aid_cpr`, `lift_safety` (required) - `safety_policy`: `safety_policy` - `agreement`: `agreement` Stored on the document as `metadata.documentType`. A type from another category, or one sent with `insurance`, `endorsement` or `license`, is a `400`. `license` and `background_check` documents are stored only and have no type; a `background_check` upload still accepts the former values `level_2_screening` and `background_check` as a label.
  - Allowed values: `w9`, `wc_exemption`, `osha_card`, `first_aid_cpr`, `lift_safety`, `safety_policy`, `agreement`
- `documentLabel` (string, optional)
- `metadata` (map from string to any, optional)
- `submittedByEmail` (string, optional) — The email address that sent you this document, when it came from someone else (for example the broker who emailed it to you). When it is the subcontractor's broker on file, its policies count as verified by the broker (`verifiedBy: broker_sent_coi`) and no verification call is placed. An address that isn't on file yet (including one that only matches the producer printed on this certificate) goes to TradeGuard staff to confirm.

## Response

### 200

Byte-identical document already on file; nothing created

- `data` (DuplicateDocumentResponseData, required)
- `message` (string, required)

### 201

Document created from URL

- `data` (Document, optional)

## Errors

### 400 Bad Request Error

Body failed validation, or the downloaded file is empty or of an unsupported type (`validation_failed`); the download was refused or failed (`bad_request`); or `subcontractorId` is not a UUID (`invalid_identifier`)

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

### 409 Conflict Error

Conflicts with the resource's current state (`conflict`)

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

### 413 Content Too Large Error

The file exceeds the 25 MiB (26,214,400-byte) limit (`payload_too_large`)

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

### 422 Unprocessable Entity Error

Well-formed but rejected by a business rule (`unprocessable`)

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

### 500 Internal Server Error

Unexpected server error (`internal_error`); safe to retry idempotent requests

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

### DuplicateDocumentResponseData

- `duplicate` (boolean, required)
- `documentId` (string, required, deprecated) — Same as `id`. Kept for older clients.
- `id` (string, optional)
- `subcontractorId` (string, optional)
- `organizationId` (string, optional, nullable)
- `fileName` (string, optional)
- `mimeType` (string, optional)
- `fileSize` (integer, optional) — Bytes. 0 until a presigned upload is confirmed.
- `sourceUrl` (string, optional, nullable)
- `status` (enum, optional)
  - Allowed values: `inactive`, `active`, `superseded`, `archived`
- `lifecycleStatus` (enum, optional) — `needs_review` = held for human review by TradeGuard's operations team (low extraction confidence or a name mismatch; there is no API call to resolve it); `review_rejected` = the review was rejected and processing stopped (the document is archived). An approved document returns to `extracted` and continues.
  - Allowed values: `uploaded`, `validating`, `validation_failed`, `extracting`, `extraction_failed`, `extracted`, `verifying`, `verified`, `verification_failed`, `needs_review`, `review_rejected`
- `documentCategory` (enum, optional) — Category of a document or of the evidence a requirement asks for. The three upload paths accept every value except `business_registration` (used by report requirements), `notice_of_cancellation` and `certificate` (the profile's "Certificate checks" requirement, which reads the insurance certificate).
  - Allowed values: `insurance`, `business_registration`, `license`, `background_check`, `training_cert`, `tax_form`, `agreement`, `endorsement`, `notice_of_cancellation`, `workers_compensation_exemption`, `certificate`, `safety_policy`
- `documentLabel` (string, optional, nullable)
- `uploadedBy` (string, optional, nullable) — Clerk user id or API key subject.
- `insuredName` (string, optional, nullable) — Insured name from the extracted certificate.
- `contentSha256` (string, optional, nullable) — Hex SHA-256 of the file bytes; null on an unconfirmed presign placeholder.
- `scope` (enum, optional) — `baseline`: evidence for the subcontractor's roster compliance. `project`: a project-specific certificate filed to a project slot — never baseline coverage.
  - Allowed values: `baseline`, `project`
- `projectId` (string, optional, nullable) — The project a `project`-scope certificate belongs to; null for baseline documents.
- `metadata` (DuplicateDocumentResponseDataMetadata, optional) — Free-form. May carry `presignPending` (unconfirmed presign placeholder) and `crossOrgDuplicateOfDocumentId`.
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)
- `restored` (boolean, optional) — Present when the existing document had been replaced by uploads that couldn't be read and this re-upload made it `active` again (its requirements are re-checked).
- `rereading` (boolean, optional) — Present when the existing document's last read failed (`validation_failed` or `extraction_failed`) and this re-upload started reading it again. Results land on the document record as with a new upload.

### Document

- `id` (string, optional)
- `subcontractorId` (string, optional)
- `organizationId` (string, optional, nullable)
- `fileName` (string, optional)
- `mimeType` (string, optional)
- `fileSize` (integer, optional) — Bytes. 0 until a presigned upload is confirmed.
- `sourceUrl` (string, optional, nullable)
- `status` (enum, optional)
  - Allowed values: `inactive`, `active`, `superseded`, `archived`
- `lifecycleStatus` (enum, optional) — `needs_review` = held for human review by TradeGuard's operations team (low extraction confidence or a name mismatch; there is no API call to resolve it); `review_rejected` = the review was rejected and processing stopped (the document is archived). An approved document returns to `extracted` and continues.
  - Allowed values: `uploaded`, `validating`, `validation_failed`, `extracting`, `extraction_failed`, `extracted`, `verifying`, `verified`, `verification_failed`, `needs_review`, `review_rejected`
- `documentCategory` (enum, optional) — Category of a document or of the evidence a requirement asks for. The three upload paths accept every value except `business_registration` (used by report requirements), `notice_of_cancellation` and `certificate` (the profile's "Certificate checks" requirement, which reads the insurance certificate).
  - Allowed values: `insurance`, `business_registration`, `license`, `background_check`, `training_cert`, `tax_form`, `agreement`, `endorsement`, `notice_of_cancellation`, `workers_compensation_exemption`, `certificate`, `safety_policy`
- `documentLabel` (string, optional, nullable)
- `uploadedBy` (string, optional, nullable) — Clerk user id or API key subject.
- `insuredName` (string, optional, nullable) — Insured name from the extracted certificate.
- `contentSha256` (string, optional, nullable) — Hex SHA-256 of the file bytes; null on an unconfirmed presign placeholder.
- `scope` (enum, optional) — `baseline`: evidence for the subcontractor's roster compliance. `project`: a project-specific certificate filed to a project slot — never baseline coverage.
  - Allowed values: `baseline`, `project`
- `projectId` (string, optional, nullable) — The project a `project`-scope certificate belongs to; null for baseline documents.
- `metadata` (DocumentMetadata, optional) — Free-form. May carry `presignPending` (unconfirmed presign placeholder) and `crossOrgDuplicateOfDocumentId`.
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)

### ErrorDetailsItems

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

### DuplicateDocumentResponseDataMetadata

Free-form. May carry `presignPending` (unconfirmed presign placeholder) and `crossOrgDuplicateOfDocumentId`.

### DocumentMetadata

Free-form. May carry `presignPending` (unconfirmed presign placeholder) and `crossOrgDuplicateOfDocumentId`.

## Examples

### Example 1

**Request**

```json
{
  "sourceUrl": "string",
  "documentCategory": "insurance"
}
```

**Response**

```json
{
  "data": {
    "duplicate": true,
    "documentId": "string",
    "id": "string",
    "subcontractorId": "string",
    "organizationId": "string",
    "fileName": "string",
    "mimeType": "string",
    "fileSize": 1,
    "sourceUrl": "string",
    "status": "inactive",
    "lifecycleStatus": "uploaded",
    "documentCategory": "insurance",
    "documentLabel": "string",
    "uploadedBy": "string",
    "insuredName": "string",
    "contentSha256": "string",
    "scope": "baseline",
    "projectId": "string",
    "metadata": {},
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z",
    "restored": true,
    "rereading": true
  },
  "message": "This exact document was already uploaded for this subcontractor; the existing document is returned. To re-process it, call POST /v1/subcontractors/{subcontractorId}/documents/{documentId}/extract."
}
```

**SDK Code**

```python
import requests

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

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

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

print(response.json())
```

```javascript
const url = 'https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"sourceUrl":"string","documentCategory":"insurance"}'
};

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/documents/url"

	payload := strings.NewReader("{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}")

	req, _ := http.NewRequest("POST", 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/documents/url")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}"

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.post("https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url', [
  'body' => '{
  "sourceUrl": "string",
  "documentCategory": "insurance"
}',
  '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/documents/url");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```

### Example 2

**Request**

```json
{
  "sourceUrl": "string",
  "documentCategory": "insurance"
}
```

**Response**

```json
{
  "data": {
    "id": "string",
    "subcontractorId": "string",
    "organizationId": "string",
    "fileName": "string",
    "mimeType": "string",
    "fileSize": 1,
    "sourceUrl": "string",
    "status": "inactive",
    "lifecycleStatus": "uploaded",
    "documentCategory": "insurance",
    "documentLabel": "string",
    "uploadedBy": "string",
    "insuredName": "string",
    "contentSha256": "string",
    "scope": "baseline",
    "projectId": "string",
    "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/documents/url"

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

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

print(response.json())
```

```javascript
const url = 'https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"sourceUrl":"string","documentCategory":"insurance"}'
};

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/documents/url"

	payload := strings.NewReader("{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}")

	req, _ := http.NewRequest("POST", 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/documents/url")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}"

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.post("https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url', [
  'body' => '{
  "sourceUrl": "string",
  "documentCategory": "insurance"
}',
  '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/documents/url");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"sourceUrl\": \"string\",\n  \"documentCategory\": \"insurance\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.tradeguardins.com/v1/subcontractors/subcontractorId/documents/url")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```