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

# Create a presigned upload URL

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

Step 1 of the direct-to-S3 upload path: **presign → PUT the bytes to
`uploadUrl` → [confirm](https://docs.tradeguardins.com/api-reference/documents/confirm-document-upload)**.
Use it for large files or browser uploads that should not stream
through the API.

Creates a placeholder document (`status: inactive`, `fileSize: 0`,
`contentSha256: null`, `metadata.presignPending: true`) and returns it
with a presigned S3 `PUT` URL valid for **15 minutes**. The URL is signed
for the given `mimeType`: send the `PUT` with exactly that
`Content-Type` header or S3 rejects it. Nothing is validated, scanned,
activated or processed until you call confirm; the placeholder is
visible in [List documents](https://docs.tradeguardins.com/api-reference/documents/list-documents)
in the meantime.

`mimeType` is not checked against the upload allowlist here — an
unsupported type is only rejected at confirm. There is no `activate`
or `force` option on this path: a confirmed document is always
activated.

Requires scope `documents:write`.

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

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

- `fileName` (string, required) — File name; becomes the last segment of the S3 object key.
- `mimeType` (string, required) — Content type you will `PUT` with. Must be one of `application/pdf`, `image/png`, `image/jpeg`, `image/jpg`, `image/webp`, `image/heic`, `image/heif`, `image/tiff` or confirm fails with `400`.
- `documentCategory` (enum, required) — 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`
- `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)
- `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

### 201

Placeholder document created, with the presigned upload URL

- `data` (PresignedUpload, optional) — The placeholder document created by presign, plus the S3 upload URL.

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

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

### PresignedUpload

The placeholder document created by presign, plus the S3 upload URL.

- `uploadUrl` (string, required) — Presigned S3 `PUT` URL, valid for 15 minutes. Send the raw file bytes with `Content-Type` equal to the `mimeType` you presigned.
- `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` (PresignedUploadMetadata, optional) — Free-form. May carry `presignPending` (unconfirmed presign placeholder) and `crossOrgDuplicateOfDocumentId`.
- `createdAt` (datetime, optional)
- `updatedAt` (datetime, optional)

### ErrorDetailsItems

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

### PresignedUploadMetadata

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

## Examples

**Request**

```json
{
  "fileName": "string",
  "mimeType": "application/pdf",
  "documentCategory": "insurance"
}
```

**Response**

```json
{
  "data": {
    "uploadUrl": "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"
  }
}
```

**SDK Code**

```python
import requests

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

payload = {
    "fileName": "string",
    "mimeType": "application/pdf",
    "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/presign';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"fileName":"string","mimeType":"application/pdf","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/presign"

	payload := strings.NewReader("{\n  \"fileName\": \"string\",\n  \"mimeType\": \"application/pdf\",\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/presign")

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  \"fileName\": \"string\",\n  \"mimeType\": \"application/pdf\",\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/presign")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"fileName\": \"string\",\n  \"mimeType\": \"application/pdf\",\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/presign', [
  'body' => '{
  "fileName": "string",
  "mimeType": "application/pdf",
  "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/presign");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"fileName\": \"string\",\n  \"mimeType\": \"application/pdf\",\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 = [
  "fileName": "string",
  "mimeType": "application/pdf",
  "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/presign")! 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()
```