> ## Documentation Index
> Fetch the complete documentation index at: https://teardowns.aero/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Documents

> Upload, set audience, and remove documents on a sales / lease / exchange listing.

The document endpoints for a listing your org owns. Same shape as the
teardown document endpoints file goes up, URL gets appended to the
listing's `documents[]`, optional `audience` form field updates the
listing's visibility in the same transaction.

## Upload

```http theme={null}
POST /public/v1/sales-lease-exchange/documents/{listing_id}
```

### Headers

<ParamField header="Authorization" type="string" required>
  `Bearer tdao_live_…`
</ParamField>

<ParamField header="X-Organization-Id" type="string" required />

<ParamField header="Content-Type" type="string" required>
  `multipart/form-data`
</ParamField>

### Form fields

<ParamField body="file" type="file" required />

<ParamField body="audience" type="string (CSV)">
  Optional. Comma-separated list of company types. See
  [audience](/concepts/audience).
</ParamField>

### File rules

Same as teardown documents max 50 MB, PDF / XLSX / XLS / DOCX / DOC
/ CSV / images.

### Storage path

```
{SUPABASE_URL}/storage/v1/object/public/teardowns-media/listings/<listing_id>/documents/<8-hex>_<filename>
```

### Response

`200 OK`:

```jsonc theme={null}
{
  "url": "https://.../teardowns-media/listings/<id>/documents/abcd1234_traceability.pdf",
  "filename": "traceability.pdf",
  "size": 123456,
  "content_type": "application/pdf"
}
```

<RequestExample>
  ```bash upload only theme={null}
  curl -X POST "$base_url/public/v1/sales-lease-exchange/documents/$listing_id" \
    -H "Authorization: Bearer $api_key" \
    -H "X-Organization-Id: $org_id" \
    -F "file=@/absolute/path/to/traceability.pdf"
  ```

  ```bash upload + audience theme={null}
  curl -X POST "$base_url/public/v1/sales-lease-exchange/documents/$listing_id" \
    -H "Authorization: Bearer $api_key" \
    -H "X-Organization-Id: $org_id" \
    -F "file=@/absolute/path/to/traceability.pdf" \
    -F "audience=Airline, MRO"
  ```
</RequestExample>

## Delete by URL

```http theme={null}
DELETE /public/v1/sales-lease-exchange/documents/{listing_id}/by-url?url=<encoded-url>
```

Removes a single document URL from the listing's `documents[]`.
Best-effort deletes the underlying storage file. Idempotent.

### Query parameters

<ParamField query="url" type="string" required>
  URL-encoded.
</ParamField>

### Response

`200 OK`:

```jsonc theme={null}
{ "status": "ok" }
```

<RequestExample>
  ```bash curl theme={null}
  encoded_url=$(python3 -c "import urllib.parse,sys;print(urllib.parse.quote(sys.argv[1]))" "$DOC_URL")

  curl -X DELETE "$base_url/public/v1/sales-lease-exchange/documents/$listing_id/by-url?url=$encoded_url" \
    -H "Authorization: Bearer $api_key" \
    -H "X-Organization-Id: $org_id"
  ```
</RequestExample>

## See also

* [Listing images](/api-reference/uploads/listing-images).
* [Audience](/concepts/audience) for visibility rules.
* [Get a listing](/api-reference/listings/get) to read the
  `documents[]` array back.
