---
title: "Add document"
method: POST
path: "/api/files/sales/{saleGuid}/documents"
tags: ["Sale Documents"]
---

# Add document

`POST /api/files/sales/{saleGuid}/documents`

## Request

- Base URL: `https://api.skyslope.com`
- URL: `https://api.skyslope.com/api/files/sales/{saleGuid}/documents`
- Auth: OpenID Connect (`https://example.com/.well-known/openid-configuration`)

Adds a document to a sale. fileName and base64Content are required. Returns 422 for invalid file names, file names longer than 150 characters, or invalid base64 content.

### Validation & Requirements
#### Required Parameters
- `saleGuid` (path, string, format=guid)
- `form` (body, object)

#### Required JSON Body Fields
- `base64Content` (minLength=1)
- `fileName` (minLength=1)

#### Validations
- Invalid GUID values in `*Guid`/`*Guids` fields return `422 Unprocessable Entity`.
- Invalid date values in `*date*` fields return `422 Unprocessable Entity`.
- Missing required request body returns `422 Unprocessable Entity` with `Missing request body.`.
- Additional business-rule validation may return `422` with details in the `errors` array.
- File name is required and cannot exceed 150 characters.
- base64Content must be valid base64.

#### Integration Requirement
- Retrieve the corresponding `...Form` endpoint immediately before write operations to get current dynamic required fields and allowed values.

## Path parameters

- `saleGuid` string, guid, required

## Request body

- AddDocumentToSaleForm
  - `base64Content` string, required: The PDF as base64 encoded.
  - `fileName` string, required: The filename of the pdf, it must include the .pdf extension.

## Response `200`

- LinkedResponseOfAddDocumentToSaleResponse
  - `value` AddDocumentToSaleResponse
    - `saleGuid` string, guid
    - `documentGuid` string, guid
    - `documentName` string, nullable
  - `warnings` string[], nullable
  - `links` Link[], nullable
    - `href` string, nullable
    - `rel` string, nullable
    - `method` string, nullable

## Other responses

- `404`
- `422`

## Changes

- **2026-09-17** `bee689a03e75`: 2 info
  - api tag `Sale Documents` added
  - api tag `Sale documents` removed

[Operation history](https://skmtc.dev/skyslope/apis/skyslope-api/changes/api/files/sales/:saleGuid/documents/post.md)

---

[API](https://skmtc.dev/skyslope/apis/skyslope-api.md) - [All operations](https://skmtc.dev/skyslope/apis/skyslope-api/llms.txt) - [OpenAPI document](https://skmtc.dev/skyslope/apis/skyslope-api/revisions/77341f0c0550?raw)
