> For the complete documentation index, see [llms.txt](https://docs.tnid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tnid.com/api-reference/002_company/011_documents/002__prepare_document_upload_as_company.md).

# Prepare Document Upload (Company)

GraphQL endpoint: `/company`

Reserves space in the calling company's document repository and returns a presigned POST policy to upload the file with. The reservation holds the declared bytes against the quota but stays invisible until `confirmDocumentUpload` claims it; an upload that never completes is reclaimed by the sweeper.

## Query

```graphql
mutation ($fileName: String!, $contentType: String!, $byteSize: String!) {
  prepareDocumentUpload(fileName: $fileName, contentType: $contentType, byteSize: $byteSize) {
    documentId
    url
    fields
  }
}

```

## Variables

```json
{
  "byteSize": "1024",
  "contentType": "application/pdf",
  "fileName": "invoice.pdf"
}
```

## Response

```json
{
  "data": {
    "prepareDocumentUpload": {
      "documentId": "00000000-0000-4000-8000-000000000001",
      "fields": {
        "Content-Type": "application/pdf",
        "Policy": "eyJjb25kaXRpb25zIjpbeyJYLUFtei1BbGdvcml0aG0iOiJBV1M0LUhNQUMtU0hBMjU2In0seyJYLUFtei1DcmVkZW50aWFsIjoiU09NRV9SQU5ET01fQUNDRVNTX0tFWS8yMDI2MDkwOC91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJYLUFtei1EYXRlIjoiMjAyNjA5MDhUMDkwNDUwWiJ9LHsiYnVja2V0IjoidG5pZC12Mi1kb2N1bWVudHMtbG9jYWwifSx7ImtleSI6ImNvbXBhbnkvOTkyMzQ3ZTctNzEzZS00NWEwLTgyY2EtYmNhYWUyNmMyMWZmLzIwMjYtMDktMDhfTUV4TVhMUTJmV3ZBX2ludm9pY2UucGRmIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDI0XSxbImVxIiwiJENvbnRlbnQtVHlwZSIsImFwcGxpY2F0aW9uL3BkZiJdXSwiZXhwaXJhdGlvbiI6IjIwMjYtMDktMDhUMDk6MDk6NTAuMzEyNjgwWiJ9",
        "X-Amz-Algorithm": "AWS4-HMAC-SHA256",
        "X-Amz-Credential": "SOME_RANDOM_ACCESS_KEY/20260115/us-east-1/s3/aws4_request",
        "X-Amz-Date": "20260115T090000Z",
        "X-Amz-Signature": "8ec8fc9ffba4e01733e9bf2c51c19e768a7cafa1936bbb2e10fed9816bbe9eb6",
        "key": "company/00000000-0000-4000-8000-000000000002/2026-09-08_MExMXLQ2fWvA_invoice.pdf"
      },
      "url": "http://localhost:4566/tnid-v2-documents-local"
    }
  }
}
```
