Skip to navigation

Upload a document from a URL

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.

Authentication

AuthorizationBearer

Session JWT or API key (ak_...)

Path parameters

subcontractorIdstringRequiredformat: "uuid"

Request

This endpoint expects an object.
sourceUrlstringRequiredformat: "uri"
documentCategoryenumRequired

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

documentTypeenumOptional

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.

documentLabelstringOptional<=255 characters
metadatamap from strings to anyOptional
submittedByEmailstringOptionalformat: "email"

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

Byte-identical document already on file; nothing created

dataobject
messagestring

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
413
Content Too Large Error
422
Unprocessable Entity Error
429
Too Many Requests Error
500
Internal Server Error