> 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": "eyJjb25kaXRpb25zIjpbeyJYLUFtei1BbGdvcml0aG0iOiJBV1M0LUhNQUMtU0hBMjU2In0seyJYLUFtei1DcmVkZW50aWFsIjoiU09NRV9SQU5ET01fQUNDRVNTX0tFWS8yMDI2MDkyMy91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJYLUFtei1EYXRlIjoiMjAyNjA5MjNUMDMyMDM5WiJ9LHsiYnVja2V0IjoidG5pZC12Mi1kb2N1bWVudHMtbG9jYWwifSx7ImtleSI6ImNvbXBhbnkvZjdlZmNiYTctNjk1MS00NDg1LThkZDYtOGZmM2RhMjc1NGQ4LzIwMjYtMDktMjNfS082REhQajlFdGMyX2ludm9pY2UucGRmIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDI0XSxbImVxIiwiJENvbnRlbnQtVHlwZSIsImFwcGxpY2F0aW9uL3BkZiJdXSwiZXhwaXJhdGlvbiI6IjIwMjYtMDktMjNUMDM6MjU6MzkuNDcyOTE4WiJ9",
        "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": "fc1137efc3701e1473792eacc6a50e1fe746c2afbda733a41bffd5578f1a2336",
        "key": "company/00000000-0000-4000-8000-000000000002/2026-09-23_KO6DHPj9Etc2_invoice.pdf"
      },
      "url": "http://localhost:4566/tnid-v2-documents-local"
    }
  }
}
```
