> 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 file to a slot

POST https://api.tradeguardins.com/v1/assignments/{assignmentId}/slots/{slotId}/documents
Content-Type: multipart/form-data

Files a document to this slot (multipart, same file rules as
[Upload a document](https://docs.tradeguardins.com/api-reference/documents/upload-document)).
The slot moves to `received_pending_review`; a file it already held
moves to a `superseded` history row. A `waived` slot refuses files
(`409` — re-open it first). A project certificate is evidence for this
job only: it never becomes the subcontractor's baseline coverage. The
assignment re-checks once the file has been read. Requires
`documents:write`.

Reference: https://docs.tradeguardins.com/api-reference/assignments/upload-assignment-slot-document

## Authentication

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

## Request

### Path parameters

- `assignmentId` (string, required) — The assignment (project membership) id returned when the subcontractor was attached to the project.
- `slotId` (string, required)

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required)
- `documentLabel` (string, optional)
- `metadata` (string, optional) — JSON object of at most 16 KB, as a string.

## Response

### 200

Byte-identical certificate already filed for this project; nothing created

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

### 201

Filed

- `data` (Document, optional)

## Errors

### 400 Bad Request Error

Malformed request (`bad_request`, `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`.

## 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
{
  "documentLabel": {
    "type": "json"
  },
  "file": "<file: [object Object]>",
  "metadata": {
    "type": "json"
  }
}
```

**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/assignments/assignmentId/slots/slotId/documents"

files = { "file": "open('[object Object]', 'rb')" }
payload = {
    "documentLabel": "{
  \"type\": \"json\"
}",
    "metadata": "{
  \"type\": \"json\"
}"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents';
const form = new FormData();
form.append('documentLabel', '{
  "type": "json"
}');
form.append('file', '[object Object]');
form.append('metadata', '{
  "type": "json"
}');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

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/assignments/assignmentId/slots/slotId/documents"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n")

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

	req.Header.Add("Authorization", "Bearer <token>")

	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/assignments/assignmentId/slots/slotId/documents")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\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/assignments/assignmentId/slots/slotId/documents")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents', [
  'multipart' => [
    [
        'name' => 'documentLabel',
        'contents' => '{
  "type": "json"
}'
    ],
    [
        'name' => 'file',
        'filename' => '[object Object]',
        'contents' => null
    ],
    [
        'name' => 'metadata',
        'contents' => '{
  "type": "json"
}'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "documentLabel",
    "value": "{
  \"type\": \"json\"
}"
  ],
  [
    "name": "file",
    "fileName": "[object Object]"
  ],
  [
    "name": "metadata",
    "value": "{
  \"type\": \"json\"
}"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents")! 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
{
  "documentLabel": {
    "type": "json"
  },
  "file": "<file: [object Object]>",
  "metadata": {
    "type": "json"
  }
}
```

**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/assignments/assignmentId/slots/slotId/documents"

files = { "file": "open('[object Object]', 'rb')" }
payload = {
    "documentLabel": "{
  \"type\": \"json\"
}",
    "metadata": "{
  \"type\": \"json\"
}"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents';
const form = new FormData();
form.append('documentLabel', '{
  "type": "json"
}');
form.append('file', '[object Object]');
form.append('metadata', '{
  "type": "json"
}');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

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/assignments/assignmentId/slots/slotId/documents"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n")

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

	req.Header.Add("Authorization", "Bearer <token>")

	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/assignments/assignmentId/slots/slotId/documents")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\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/assignments/assignmentId/slots/slotId/documents")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents', [
  'multipart' => [
    [
        'name' => 'documentLabel',
        'contents' => '{
  "type": "json"
}'
    ],
    [
        'name' => 'file',
        'filename' => '[object Object]',
        'contents' => null
    ],
    [
        'name' => 'metadata',
        'contents' => '{
  "type": "json"
}'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documentLabel\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"metadata\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "documentLabel",
    "value": "{
  \"type\": \"json\"
}"
  ],
  [
    "name": "file",
    "fileName": "[object Object]"
  ],
  [
    "name": "metadata",
    "value": "{
  \"type\": \"json\"
}"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.tradeguardins.com/v1/assignments/assignmentId/slots/slotId/documents")! 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()
```