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

# Update Transport Route Attachment

> Attach a document to a transport route, or remove it, without recalculating the route

Attach a supporting document to a transport route (e.g. the carrier's invoice or the delivery note), replace it, or
remove it. Only the attachment changes: a document changes no emissions, so the route keeps its sections, status and
results and is not recalculated. To change anything else, use [Update Transport Route](https://code.dcycle.io/api-reference/transport/update.md),
which also takes `attachment_file_id`.

The attachment is not the file the route was read from (`file_id`, a spreadsheet upload or a freight invoice). Deleting
the attached file or moving it to the trash unlinks the route, which stays.

## Request

### Headers

**x-api-key** `string` *required*

Your API key for authentication

**Example:** `sk_live_1234567890abcdef`

**x-organization-id** `string` *required*

Your organization UUID

**Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`

### Path Parameters

**transport\_route\_id** `string` *required*

The unique identifier (UUID) of the transport route

**Example:** `010ed3b6-b513-40f3-b9fe-0f0a338d9274`

### Body

**attachment\_file\_id** `string | null` *required*

UUID of an `uploaded` file of your [files](https://code.dcycle.io/api-reference/files/upload.md) to attach to the route: upload it first
(`POST /v1/files/presigned-urls` with `skip_processing: true`, the upload, then `PATCH /v1/files/batch-update` to
`uploaded`). The file must belong to your organization or one you can write to, and a private file only to the
route's organization. `null` removes the attachment. Any other field is rejected (`422`).

**Example:** `"7c9e6679-7425-40de-944b-e07fc1f90ae7"`

## Response

Returns the route as [Get Transport Route](https://code.dcycle.io/api-reference/transport/get.md) does (HTTP 200), with its `attachment`:

**attachment** `object | null`

The document attached to the route, or `null` when it was removed.

**properties**

**file\_id** `uuid`

The file of your [files](https://code.dcycle.io/api-reference/files/upload.md).

**file\_name** `string`

Its name, with its extension.

**file\_url** `string`

Where to download it: a presigned URL, valid for an hour.

## Example

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X PATCH "https://api.dcycle.io/v1/transports/010ed3b6-b513-40f3-b9fe-0f0a338d9274" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{"attachment_file_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7"}'
```

```json Response (200) theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
  "name": "Pallets to Valencia",
  "status": "active",
  "attachment": {
    "file_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "file_name": "carrier-invoice.pdf",
    "file_url": "https://media.dcycle.io/files/file-7c9e6679.pdf?X-Amz-Signature=..."
  }
}
```

The response is abridged: it carries every field of [Get Transport Route](https://code.dcycle.io/api-reference/transport/get.md).

## Common Errors

### 404 Not Found

**Cause:** The route does not exist or belongs to another organization (`TRANSPORT_ROUTE_NOT_FOUND`), or
`attachment_file_id` is not a file you can attach: unknown, outside your perimeter, pending, in the trash or private to
another organization all answer the same `NOT_FOUND` naming `File`.

### 422 Unprocessable Entity

**Cause:** The body has no `attachment_file_id`, it is not a UUID, or it carries another field.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.