# Transport documents

> Markdown edition of https://api.fiz.co/docs/api/transport-documents. Português: https://api.fiz.co/docs/api/transport-documents.md?lang=pt. Index: https://api.fiz.co/llms.txt

Guias de transporte for goods in transit: drafts, issuing before the goods move, cancellation and PDFs. 8 operations.

## List transport documents

GET `/transport-documents`

Returns a paginated, filterable list of transport documents. By default returns 20 documents starting at offset 0.

Authentication: an API key (`x-api-key`) or an OAuth access token.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `offset` | query | number | Number of records to skip (offset) |
| `limit` | query | number | Maximum number of records to return |
| `sort` | query | string | Sort field and order (e.g. movementDate:desc) |
| `search` | query | string | Global search term (number, recipient, etc.) |
| `movementType` | query | string | Filter by movement type — One of: `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO`, `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE` |
| `issueStatus` | query | string | Filter by issue status — One of: `CANCELED`, `DRAFT`, `ISSUED` |

**curl**

```shell
curl 'https://api.fiz.co/transport-documents' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.transportDocuments.list();
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.transport_documents.list()
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->transportDocuments->list();
```

### Response `200`

List of transport documents returned successfully

| Field | Type | Description |
| --- | --- | --- |
| `[].id` | string |  |
| `[].documentNumber` | string | Document number. On a draft, a provisional number. |
| `[].atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `[].atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `[].atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `[].movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `[].movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `[].issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `[].movementDate` | string (date-time) |  |
| `[].movementStartTime` | string (date-time) | Start of transport |
| `[].movementEndTime` | string (date-time) · can be null |  |
| `[].vehicleID` | string · can be null | Vehicle license plate |
| `[].isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `[].unitId` | string · can be null |  |
| `[].createdAt` | string (date-time) |  |
| `[].updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `[].canceledAt` | string (date-time) · can be null |  |
| `[].syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `[].syncWithAt.status` | string |  |
| `[].syncWithAt.action` | string |  |
| `[].syncWithAt.atCode` | string · can be null |  |
| `[].syncWithAt.atMessage` | string · can be null |  |
| `[].syncWithAt.systemError` | string · can be null |  |
| `[].syncWithAt.isRetriable` | boolean · can be null |  |
| `[].syncWithAt.updatedAt` | string (date-time) |  |
| `[].issuer` | object |  |
| `[].issuer.ref` | string |  |
| `[].issuer.data` | object |  |
| `[].issuer.data.name` | string |  |
| `[].issuer.data.taxPayerNumber` | string |  |
| `[].issuer.data.address` | string |  |
| `[].issuer.data.postalCode` | string |  |
| `[].issuer.data.city` | string |  |
| `[].issuer.data.country` | string |  |
| `[].customer` | object · can be null |  |
| `[].customer.ref` | string · can be null |  |
| `[].customer.data` | object |  |
| `[].customer.data.name` | string |  |
| `[].customer.data.taxpayerNumber` | string · can be null |  |
| `[].customer.data.address` | string · can be null |  |
| `[].customer.data.postalCode` | string · can be null |  |
| `[].customer.data.city` | string · can be null |  |
| `[].customer.data.country` | string · can be null |  |
| `[].addressFrom` | object |  |
| `[].addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `[].addressFrom.name` | string |  |
| `[].addressFrom.addressDetail` | string |  |
| `[].addressFrom.postalCode` | string |  |
| `[].addressFrom.city` | string |  |
| `[].addressFrom.country` | string |  |
| `[].addressTo` | object · can be null |  |
| `[].addressTo.ref` | string · can be null | Saved address this one was copied from |
| `[].addressTo.name` | string |  |
| `[].addressTo.addressDetail` | string |  |
| `[].addressTo.postalCode` | string |  |
| `[].addressTo.city` | string |  |
| `[].addressTo.country` | string |  |
| `[].items` | object\[\] · can be null |  |
| `[].items[].ref` | string · can be null | Catalogue item sent on the line |
| `[].items[].meta` | object · can be null |  |
| `[].items[].meta.quantity` | number · can be null |  |
| `[].items[].meta.amountWithoutTax` | number · can be null |  |
| `[].items[].meta.amountWithTax` | number · can be null |  |
| `[].items[].meta.taxAmount` | number · can be null |  |
| `[].items[].data` | object · can be null |  |
| `[].items[].data.name` | string · can be null |  |
| `[].items[].data.description` | string · can be null |  |
| `[].items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `[].items[].data.unitPrice` | number · can be null |  |
| `[].items[].data.unitType` | string · can be null |  |
| `[].items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `[].items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `400` Invalid parameters
-   `401` Unauthorized - API key missing or invalid
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Create draft transport document

POST `/transport-documents`

Creates a draft transport document without issuing it or reporting it to the AT. Use POST /transport-documents/{id}/issue to issue and report it to the AT.

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Request body

Data required to create the draft transport document

| Field | Type | Description |
| --- | --- | --- |
| `movementType` **required** | string | Movement type. GUIA\_DE\_REMESSA (delivery to a customer), GUIA\_DE\_DEVOLUCAO (return), GUIA\_DE\_TRANSPORTE (generic transport), GUIA\_DE\_ATIVOS\_PROPRIOS (transfer between own facilities), GUIA\_DE\_CONSIGNACAO (consignment). — One of: `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO`, `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE` |
| `movementDate` **required** | string | Movement date (ISO 8601 with timezone). Cannot be earlier than today — the transport document must be reported to the AT before the transport starts. |
| `movementStartTime` **required** | string | Loading date/time (ISO 8601 with timezone). Must be in the future: the transport document is issued before the goods leave, and the AT refuses it after that time. |
| `movementEndTime` | string | Expected unloading date/time (optional, ISO 8601 with timezone) |
| `addressFrom` **required** | object | Loading location |
| `addressFrom.name` **required** | string | Location name (e.g. warehouse, store, facility) |
| `addressFrom.addressDetail` **required** | string | Address (street, number, floor) |
| `addressFrom.postalCode` **required** | string | Postal code |
| `addressFrom.city` **required** | string | Locality |
| `addressFrom.country` **required** | string | Country (ISO 3166-1 alpha-2 code) |
| `addressFrom.ref` | string | Identifier of a saved address (optional). Links this address to an address book record. |
| `addressTo` | object | Unloading location (optional) |
| `addressTo.name` **required** | string | Location name (e.g. warehouse, store, facility) |
| `addressTo.addressDetail` **required** | string | Address (street, number, floor) |
| `addressTo.postalCode` **required** | string | Postal code |
| `addressTo.city` **required** | string | Locality |
| `addressTo.country` **required** | string | Country (ISO 3166-1 alpha-2 code) |
| `addressTo.ref` | string | Identifier of a saved address (optional). Links this address to an address book record. |
| `customer` | object | Recipient of the goods. Required for all movement types except GUIA\_DE\_ATIVOS\_PROPRIOS (movement of own assets). Only Portuguese recipients (country = "PT") are accepted — transport documents are reported to the Portuguese AT. |
| `customer.data` **required** | object | Recipient data |
| `customer.data.name` **required** | string | Recipient name |
| `customer.data.taxpayerNumber` | string | Recipient NIF (tax number) |
| `customer.data.address` | string | Recipient address |
| `customer.data.postalCode` | string | Recipient postal code |
| `customer.data.city` | string | Recipient locality |
| `customer.data.country` | string | Recipient country (ISO 3166-1 alpha-2) |
| `customer.ref` | string | Identifier of an existing customer (optional). Use the "id" returned by GET /customers. |
| `isValued` | boolean | Valued transport document (optional, default true). With false the document is unvalued (guia não valorizada): the PDF shows no prices and every line is reported to the AT with a unit price of 0.00. Use it when goods move without a sale (return, transfer, consignment). The line prices stay stored and apply again if the document is made valued again. |
| `vehicleID` | string | Vehicle license plate (optional) |
| `items` **required** | object\[\] | Transported goods and their quantities |
| `items[].id` **required** | string | Item identifier. Use the "id" returned by GET /items. |
| `items[].quantity` **required** | number | Transported quantity |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request POST 'https://api.fiz.co/transport-documents' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "movementType": "GUIA_DE_REMESSA",
  "movementDate": "2026-11-27T08:00:00.000Z",
  "movementStartTime": "2026-11-27T08:30:00.000Z",
  "addressFrom": {
    "name": "Armazém Lisboa",
    "addressDetail": "Rua da Prata, 12, 2.º",
    "postalCode": "1100-052",
    "city": "Lisboa",
    "country": "PT"
  },
  "items": [
    {
      "id": "68483e978073231c3947077c",
      "quantity": 10
    }
  ],
  "customer": {
    "data": {
      "name": "Padaria Central, Lda"
    }
  }
}'
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.transportDocuments.create({
  movementType: 'GUIA_DE_REMESSA',
  movementDate: '2026-11-27T08:00:00.000Z',
  movementStartTime: '2026-11-27T08:30:00.000Z',
  addressFrom: {
    name: 'Armazém Lisboa',
    addressDetail: 'Rua da Prata, 12, 2.º',
    postalCode: '1100-052',
    city: 'Lisboa',
    country: 'PT',
  },
  items: [
    {
      id: '68483e978073231c3947077c',
      quantity: 10,
    },
  ],
  customer: {
    data: {
      name: 'Padaria Central, Lda',
    },
  },
});
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.transport_documents.create({
    "movementType": "GUIA_DE_REMESSA",
    "movementDate": "2026-11-27T08:00:00.000Z",
    "movementStartTime": "2026-11-27T08:30:00.000Z",
    "addressFrom": {
        "name": "Armazém Lisboa",
        "addressDetail": "Rua da Prata, 12, 2.º",
        "postalCode": "1100-052",
        "city": "Lisboa",
        "country": "PT",
    },
    "items": [
        {
            "id": "68483e978073231c3947077c",
            "quantity": 10,
        },
    ],
    "customer": {
        "data": {
            "name": "Padaria Central, Lda",
        },
    },
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->transportDocuments->create([
    'movementType' => 'GUIA_DE_REMESSA',
    'movementDate' => '2026-11-27T08:00:00.000Z',
    'movementStartTime' => '2026-11-27T08:30:00.000Z',
    'addressFrom' => [
        'name' => 'Armazém Lisboa',
        'addressDetail' => 'Rua da Prata, 12, 2.º',
        'postalCode' => '1100-052',
        'city' => 'Lisboa',
        'country' => 'PT',
    ],
    'items' => [
        [
            'id' => '68483e978073231c3947077c',
            'quantity' => 10,
        ],
    ],
    'customer' => [
        'data' => [
            'name' => 'Padaria Central, Lda',
        ],
    ],
]);
```

### Response `201`

Draft transport document created successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `documentNumber` | string | Document number. On a draft, a provisional number. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `movementDate` | string (date-time) |  |
| `movementStartTime` | string (date-time) | Start of transport |
| `movementEndTime` | string (date-time) · can be null |  |
| `vehicleID` | string · can be null | Vehicle license plate |
| `isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `unitId` | string · can be null |  |
| `createdAt` | string (date-time) |  |
| `updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `canceledAt` | string (date-time) · can be null |  |
| `syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `syncWithAt.status` | string |  |
| `syncWithAt.action` | string |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `syncWithAt.systemError` | string · can be null |  |
| `syncWithAt.isRetriable` | boolean · can be null |  |
| `syncWithAt.updatedAt` | string (date-time) |  |
| `issuer` | object |  |
| `issuer.ref` | string |  |
| `issuer.data` | object |  |
| `issuer.data.name` | string |  |
| `issuer.data.taxPayerNumber` | string |  |
| `issuer.data.address` | string |  |
| `issuer.data.postalCode` | string |  |
| `issuer.data.city` | string |  |
| `issuer.data.country` | string |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object |  |
| `customer.data.name` | string |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `addressFrom` | object |  |
| `addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `addressFrom.name` | string |  |
| `addressFrom.addressDetail` | string |  |
| `addressFrom.postalCode` | string |  |
| `addressFrom.city` | string |  |
| `addressFrom.country` | string |  |
| `addressTo` | object · can be null |  |
| `addressTo.ref` | string · can be null | Saved address this one was copied from |
| `addressTo.name` | string |  |
| `addressTo.addressDetail` | string |  |
| `addressTo.postalCode` | string |  |
| `addressTo.city` | string |  |
| `addressTo.country` | string |  |
| `items` | object\[\] · can be null |  |
| `items[].ref` | string · can be null | Catalogue item sent on the line |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.unitType` | string · can be null |  |
| `items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `400` Invalid data
-   `401` Unauthorized - API key missing or invalid
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Get transport document by ID

GET `/transport-documents/{id}`

Returns a transport document, including ATCUD, document number and the AT communication status (syncWithAt).

Authentication: an API key (`x-api-key`) or an OAuth access token.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Transport document identifier |

**curl**

```shell
curl 'https://api.fiz.co/transport-documents/ID' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.transportDocuments.retrieve('ID');
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.transport_documents.retrieve("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->transportDocuments->retrieve('ID');
```

### Response `200`

Transport document found

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `documentNumber` | string | Document number. On a draft, a provisional number. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `movementDate` | string (date-time) |  |
| `movementStartTime` | string (date-time) | Start of transport |
| `movementEndTime` | string (date-time) · can be null |  |
| `vehicleID` | string · can be null | Vehicle license plate |
| `isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `unitId` | string · can be null |  |
| `createdAt` | string (date-time) |  |
| `updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `canceledAt` | string (date-time) · can be null |  |
| `syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `syncWithAt.status` | string |  |
| `syncWithAt.action` | string |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `syncWithAt.systemError` | string · can be null |  |
| `syncWithAt.isRetriable` | boolean · can be null |  |
| `syncWithAt.updatedAt` | string (date-time) |  |
| `issuer` | object |  |
| `issuer.ref` | string |  |
| `issuer.data` | object |  |
| `issuer.data.name` | string |  |
| `issuer.data.taxPayerNumber` | string |  |
| `issuer.data.address` | string |  |
| `issuer.data.postalCode` | string |  |
| `issuer.data.city` | string |  |
| `issuer.data.country` | string |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object |  |
| `customer.data.name` | string |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `addressFrom` | object |  |
| `addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `addressFrom.name` | string |  |
| `addressFrom.addressDetail` | string |  |
| `addressFrom.postalCode` | string |  |
| `addressFrom.city` | string |  |
| `addressFrom.country` | string |  |
| `addressTo` | object · can be null |  |
| `addressTo.ref` | string · can be null | Saved address this one was copied from |
| `addressTo.name` | string |  |
| `addressTo.addressDetail` | string |  |
| `addressTo.postalCode` | string |  |
| `addressTo.city` | string |  |
| `addressTo.country` | string |  |
| `items` | object\[\] · can be null |  |
| `items[].ref` | string · can be null | Catalogue item sent on the line |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.unitType` | string · can be null |  |
| `items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `401` Unauthorized - API key missing or invalid
-   `404` Transport document not found
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Update draft transport document

PATCH `/transport-documents/{id}`

Updates a draft transport document. Only the sent fields are changed. Only draft (DRAFT) transport documents can be updated.

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Transport document identifier |

### Request body

Fields to update

| Field | Type | Description |
| --- | --- | --- |
| `movementType` | string | Movement type — One of: `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO`, `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE` |
| `movementDate` | string | Movement date (ISO 8601 with timezone). Cannot be earlier than today. |
| `movementStartTime` | string | Loading date/time (ISO 8601 with timezone). Must be in the future: the transport document is issued before the goods leave, and the AT refuses it after that time. |
| `movementEndTime` | string | Expected unloading date/time (ISO 8601 with timezone) |
| `addressFrom` | object | Loading location |
| `addressFrom.name` **required** | string | Location name (e.g. warehouse, store, facility) |
| `addressFrom.addressDetail` **required** | string | Address (street, number, floor) |
| `addressFrom.postalCode` **required** | string | Postal code |
| `addressFrom.city` **required** | string | Locality |
| `addressFrom.country` **required** | string | Country (ISO 3166-1 alpha-2 code) |
| `addressFrom.ref` | string | Identifier of a saved address (optional). Links this address to an address book record. |
| `addressTo` | object | Unloading location |
| `addressTo.name` **required** | string | Location name (e.g. warehouse, store, facility) |
| `addressTo.addressDetail` **required** | string | Address (street, number, floor) |
| `addressTo.postalCode` **required** | string | Postal code |
| `addressTo.city` **required** | string | Locality |
| `addressTo.country` **required** | string | Country (ISO 3166-1 alpha-2 code) |
| `addressTo.ref` | string | Identifier of a saved address (optional). Links this address to an address book record. |
| `customer` | object | Recipient of the goods |
| `customer.data` **required** | object | Recipient data |
| `customer.data.name` **required** | string | Recipient name |
| `customer.data.taxpayerNumber` | string | Recipient NIF (tax number) |
| `customer.data.address` | string | Recipient address |
| `customer.data.postalCode` | string | Recipient postal code |
| `customer.data.city` | string | Recipient locality |
| `customer.data.country` | string | Recipient country (ISO 3166-1 alpha-2) |
| `customer.ref` | string | Identifier of an existing customer (optional). Use the "id" returned by GET /customers. |
| `isValued` | boolean | Valued transport document (optional, default true). With false the document is unvalued (guia não valorizada): the PDF shows no prices and every line is reported to the AT with a unit price of 0.00. Use it when goods move without a sale (return, transfer, consignment). The line prices stay stored and apply again if the document is made valued again. |
| `vehicleID` | string | Vehicle license plate |
| `items` | object\[\] | Transported goods and their quantities |
| `items[].id` **required** | string | Item identifier. Use the "id" returned by GET /items. |
| `items[].quantity` **required** | number | Transported quantity |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request PATCH 'https://api.fiz.co/transport-documents/ID' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "movementType": "GUIA_DE_REMESSA",
  "movementDate": "2026-11-27T08:00:00.000Z",
  "movementStartTime": "2026-11-27T08:30:00.000Z"
}'
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.transportDocuments.update('ID', {
  movementType: 'GUIA_DE_REMESSA',
  movementDate: '2026-11-27T08:00:00.000Z',
  movementStartTime: '2026-11-27T08:30:00.000Z',
});
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.transport_documents.update("ID", {
    "movementType": "GUIA_DE_REMESSA",
    "movementDate": "2026-11-27T08:00:00.000Z",
    "movementStartTime": "2026-11-27T08:30:00.000Z",
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->transportDocuments->update('ID', [
    'movementType' => 'GUIA_DE_REMESSA',
    'movementDate' => '2026-11-27T08:00:00.000Z',
    'movementStartTime' => '2026-11-27T08:30:00.000Z',
]);
```

### Response `200`

Transport document updated successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `documentNumber` | string | Document number. On a draft, a provisional number. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `movementDate` | string (date-time) |  |
| `movementStartTime` | string (date-time) | Start of transport |
| `movementEndTime` | string (date-time) · can be null |  |
| `vehicleID` | string · can be null | Vehicle license plate |
| `isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `unitId` | string · can be null |  |
| `createdAt` | string (date-time) |  |
| `updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `canceledAt` | string (date-time) · can be null |  |
| `syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `syncWithAt.status` | string |  |
| `syncWithAt.action` | string |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `syncWithAt.systemError` | string · can be null |  |
| `syncWithAt.isRetriable` | boolean · can be null |  |
| `syncWithAt.updatedAt` | string (date-time) |  |
| `issuer` | object |  |
| `issuer.ref` | string |  |
| `issuer.data` | object |  |
| `issuer.data.name` | string |  |
| `issuer.data.taxPayerNumber` | string |  |
| `issuer.data.address` | string |  |
| `issuer.data.postalCode` | string |  |
| `issuer.data.city` | string |  |
| `issuer.data.country` | string |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object |  |
| `customer.data.name` | string |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `addressFrom` | object |  |
| `addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `addressFrom.name` | string |  |
| `addressFrom.addressDetail` | string |  |
| `addressFrom.postalCode` | string |  |
| `addressFrom.city` | string |  |
| `addressFrom.country` | string |  |
| `addressTo` | object · can be null |  |
| `addressTo.ref` | string · can be null | Saved address this one was copied from |
| `addressTo.name` | string |  |
| `addressTo.addressDetail` | string |  |
| `addressTo.postalCode` | string |  |
| `addressTo.city` | string |  |
| `addressTo.country` | string |  |
| `items` | object\[\] · can be null |  |
| `items[].ref` | string · can be null | Catalogue item sent on the line |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.unitType` | string · can be null |  |
| `items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `400` Invalid data or transport document already issued
-   `401` Unauthorized - API key missing or invalid
-   `404` Transport document not found
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Delete draft transport document

DELETE `/transport-documents/{id}`

Deletes a draft transport document. Already issued documents cannot be deleted — use POST /transport-documents/{id}/cancel to cancel them.

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Transport document identifier |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request DELETE 'https://api.fiz.co/transport-documents/ID' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.transportDocuments.delete('ID');
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.transport_documents.delete("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->transportDocuments->delete('ID');
```

### Response `200`

Transport document deleted successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `documentNumber` | string | Document number. On a draft, a provisional number. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `movementDate` | string (date-time) |  |
| `movementStartTime` | string (date-time) | Start of transport |
| `movementEndTime` | string (date-time) · can be null |  |
| `vehicleID` | string · can be null | Vehicle license plate |
| `isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `unitId` | string · can be null |  |
| `createdAt` | string (date-time) |  |
| `updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `canceledAt` | string (date-time) · can be null |  |
| `syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `syncWithAt.status` | string |  |
| `syncWithAt.action` | string |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `syncWithAt.systemError` | string · can be null |  |
| `syncWithAt.isRetriable` | boolean · can be null |  |
| `syncWithAt.updatedAt` | string (date-time) |  |
| `issuer` | object |  |
| `issuer.ref` | string |  |
| `issuer.data` | object |  |
| `issuer.data.name` | string |  |
| `issuer.data.taxPayerNumber` | string |  |
| `issuer.data.address` | string |  |
| `issuer.data.postalCode` | string |  |
| `issuer.data.city` | string |  |
| `issuer.data.country` | string |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object |  |
| `customer.data.name` | string |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `addressFrom` | object |  |
| `addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `addressFrom.name` | string |  |
| `addressFrom.addressDetail` | string |  |
| `addressFrom.postalCode` | string |  |
| `addressFrom.city` | string |  |
| `addressFrom.country` | string |  |
| `addressTo` | object · can be null |  |
| `addressTo.ref` | string · can be null | Saved address this one was copied from |
| `addressTo.name` | string |  |
| `addressTo.addressDetail` | string |  |
| `addressTo.postalCode` | string |  |
| `addressTo.city` | string |  |
| `addressTo.country` | string |  |
| `items` | object\[\] · can be null |  |
| `items[].ref` | string · can be null | Catalogue item sent on the line |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.unitType` | string · can be null |  |
| `items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `400` Transport document already issued — cannot be deleted
-   `401` Unauthorized - API key missing or invalid
-   `404` Transport document not found
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Issue transport document

POST `/transport-documents/{id}/issue`

Issues the transport document and reports it to the AT. The document becomes ISSUED and receives a document number and ATCUD. The AT communication status is returned in "syncWithAt" (PROCESSING, SYNCED or FAILED). Reporting to the AT requires the account to have AT synchronization enabled and validated credentials. The document must be issued before the loading time (movementStartTime): after it, issuing is refused with 400 and the document has to be corrected with PATCH /transport-documents/{id}. Portuguese postal codes must be in the NNNN-NNN format. Issuing is a fiscal act and cannot be undone; an issued document can only be cancelled (POST /transport-documents/{id}/cancel) before the transport starts.

> Fiscal act: this call creates, settles or cancels fiscal documents, and it cannot be undone. Rehearse it in the sandbox first (`fiz_test_` keys).

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Transport document identifier |

### Request body

| Field | Type | Description |
| --- | --- | --- |
| `expectedUpdatedAt` | string (date-time) | The transport document version you verified (updatedAt, or createdAt if it was never changed). Issuing is refused with 409 if the document changed in the meantime. |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request POST 'https://api.fiz.co/transport-documents/ID/issue' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "expectedUpdatedAt": "2026-01-31T10:00:00.000Z"
}'
```

**TypeScript**

```shell
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
```

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const idempotencyKey = process.env.IDEMPOTENCY_KEY; // from the step above, the same on every retry
if (!idempotencyKey) throw new Error('Set IDEMPOTENCY_KEY first, in the step above');
const result = await fiz.transportDocuments.issue('ID', {
  expectedUpdatedAt: '2026-01-31T10:00:00.000Z',
}, { idempotencyKey });
```

**Python**

```shell
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
```

```python
import os

from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
idempotency_key = os.environ["IDEMPOTENCY_KEY"]  # from the step above, the same on every retry
result = fiz.transport_documents.issue("ID", {
    "expectedUpdatedAt": "2026-01-31T10:00:00.000Z",
}, idempotency_key=idempotency_key)
```

**PHP**

```shell
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
```

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
// from the step above, the same on every retry
$idempotencyKey = getenv('IDEMPOTENCY_KEY') ?: throw new RuntimeException('Set IDEMPOTENCY_KEY first, in the step above');
$result = $fiz->transportDocuments->issue('ID', [
    'expectedUpdatedAt' => '2026-01-31T10:00:00.000Z',
], ['idempotencyKey' => $idempotencyKey]);
```

### Response `200`

Transport document issued successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `documentNumber` | string | Document number. On a draft, a provisional number. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `movementDate` | string (date-time) |  |
| `movementStartTime` | string (date-time) | Start of transport |
| `movementEndTime` | string (date-time) · can be null |  |
| `vehicleID` | string · can be null | Vehicle license plate |
| `isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `unitId` | string · can be null |  |
| `createdAt` | string (date-time) |  |
| `updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `canceledAt` | string (date-time) · can be null |  |
| `syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `syncWithAt.status` | string |  |
| `syncWithAt.action` | string |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `syncWithAt.systemError` | string · can be null |  |
| `syncWithAt.isRetriable` | boolean · can be null |  |
| `syncWithAt.updatedAt` | string (date-time) |  |
| `issuer` | object |  |
| `issuer.ref` | string |  |
| `issuer.data` | object |  |
| `issuer.data.name` | string |  |
| `issuer.data.taxPayerNumber` | string |  |
| `issuer.data.address` | string |  |
| `issuer.data.postalCode` | string |  |
| `issuer.data.city` | string |  |
| `issuer.data.country` | string |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object |  |
| `customer.data.name` | string |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `addressFrom` | object |  |
| `addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `addressFrom.name` | string |  |
| `addressFrom.addressDetail` | string |  |
| `addressFrom.postalCode` | string |  |
| `addressFrom.city` | string |  |
| `addressFrom.country` | string |  |
| `addressTo` | object · can be null |  |
| `addressTo.ref` | string · can be null | Saved address this one was copied from |
| `addressTo.name` | string |  |
| `addressTo.addressDetail` | string |  |
| `addressTo.postalCode` | string |  |
| `addressTo.city` | string |  |
| `addressTo.country` | string |  |
| `items` | object\[\] · can be null |  |
| `items[].ref` | string · can be null | Catalogue item sent on the line |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.unitType` | string · can be null |  |
| `items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `400` Transport document invalid, already issued, loading time already passed or postal code invalid
-   `401` Unauthorized - API key missing or invalid
-   `404` Transport document not found
-   `409` The transport document changed since the version given in expectedUpdatedAt; nothing was reported to the AT
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Cancel transport document

POST `/transport-documents/{id}/cancel`

Cancels an already issued transport document and reports the cancellation to the AT. The document becomes CANCELED. Only issued (ISSUED) transport documents can be cancelled, and only before the loading time: the AT does not accept a cancellation after the transport has started.

> Fiscal act: this call creates, settles or cancels fiscal documents, and it cannot be undone. Rehearse it in the sandbox first (`fiz_test_` keys).

Authentication: an API key (`x-api-key`) or an OAuth access token. Send an `Idempotency-Key` to retry this call safely.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Transport document identifier |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
curl --request POST 'https://api.fiz.co/transport-documents/ID/cancel' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}"
```

**TypeScript**

```shell
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
```

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const idempotencyKey = process.env.IDEMPOTENCY_KEY; // from the step above, the same on every retry
if (!idempotencyKey) throw new Error('Set IDEMPOTENCY_KEY first, in the step above');
const result = await fiz.transportDocuments.cancel('ID', { idempotencyKey });
```

**Python**

```shell
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
```

```python
import os

from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
idempotency_key = os.environ["IDEMPOTENCY_KEY"]  # from the step above, the same on every retry
result = fiz.transport_documents.cancel("ID", idempotency_key=idempotency_key)
```

**PHP**

```shell
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
```

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
// from the step above, the same on every retry
$idempotencyKey = getenv('IDEMPOTENCY_KEY') ?: throw new RuntimeException('Set IDEMPOTENCY_KEY first, in the step above');
$result = $fiz->transportDocuments->cancel('ID', ['idempotencyKey' => $idempotencyKey]);
```

### Response `200`

Transport document cancelled successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `documentNumber` | string | Document number. On a draft, a provisional number. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null until issued. |
| `atDocCodeID` | string · can be null | Identification code the AT assigns when the document is reported. Null until issued. |
| `atWarning` | string · can be null | Warning the AT returned when the document was reported, if any. |
| `movementType` | string | Transport document type (GR, GT, GA, GC, GD) — One of: `GUIA_DE_REMESSA`, `GUIA_DE_TRANSPORTE`, `GUIA_DE_ATIVOS_PROPRIOS`, `GUIA_DE_CONSIGNACAO`, `GUIA_DE_DEVOLUCAO` |
| `movementStatus` | string | SAF-T status: N normal, T invoiced, A cancelled — One of: `N`, `T`, `A` |
| `issueStatus` | string | Draft, issued (reported to the AT) or cancelled — One of: `DRAFT`, `ISSUED`, `CANCELED` |
| `movementDate` | string (date-time) |  |
| `movementStartTime` | string (date-time) | Start of transport |
| `movementEndTime` | string (date-time) · can be null |  |
| `vehicleID` | string · can be null | Vehicle license plate |
| `isValued` | boolean | false on an unvalued transport document: the PDF shows no prices and the AT receives 0.00. The line prices stay stored. |
| `unitId` | string · can be null |  |
| `createdAt` | string (date-time) |  |
| `updatedAt` | string (date-time) · can be null | Draft revision. Send it as expectedUpdatedAt when issuing. |
| `canceledAt` | string (date-time) · can be null |  |
| `syncWithAt` | object · can be null | Reporting to the AT. Null on a draft. |
| `syncWithAt.status` | string |  |
| `syncWithAt.action` | string |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `syncWithAt.systemError` | string · can be null |  |
| `syncWithAt.isRetriable` | boolean · can be null |  |
| `syncWithAt.updatedAt` | string (date-time) |  |
| `issuer` | object |  |
| `issuer.ref` | string |  |
| `issuer.data` | object |  |
| `issuer.data.name` | string |  |
| `issuer.data.taxPayerNumber` | string |  |
| `issuer.data.address` | string |  |
| `issuer.data.postalCode` | string |  |
| `issuer.data.city` | string |  |
| `issuer.data.country` | string |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object |  |
| `customer.data.name` | string |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `addressFrom` | object |  |
| `addressFrom.ref` | string · can be null | Saved address this one was copied from |
| `addressFrom.name` | string |  |
| `addressFrom.addressDetail` | string |  |
| `addressFrom.postalCode` | string |  |
| `addressFrom.city` | string |  |
| `addressFrom.country` | string |  |
| `addressTo` | object · can be null |  |
| `addressTo.ref` | string · can be null | Saved address this one was copied from |
| `addressTo.name` | string |  |
| `addressTo.addressDetail` | string |  |
| `addressTo.postalCode` | string |  |
| `addressTo.city` | string |  |
| `addressTo.country` | string |  |
| `items` | object\[\] · can be null |  |
| `items[].ref` | string · can be null | Catalogue item sent on the line |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string | One of: `PRODUCT`, `SERVICE` |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.unitType` | string · can be null |  |
| `items[].data.vatRate` | string · can be null | One of: `NORMAL`, `INTERMEDIATE`, `REDUCED`, `EXEMPT` |
| `items[].data.vatExemptionReason` | string · can be null |  |

### Errors

-   `400` Transport document not issued or already cancelled
-   `401` Unauthorized - API key missing or invalid
-   `404` Transport document not found
-   `409` A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
-   `422` The idempotency key was already used with a different request body
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Download transport document PDF

GET `/transport-documents/{id}/pdf`

Generates and returns the download link for a transport document PDF. The PDF includes the QR code and the ATCUD, as required by the AT.

Authentication: an API key (`x-api-key`) or an OAuth access token.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Transport document identifier |
| `isDuplicate` | query | boolean | Mark PDF as duplicate |

**curl**

```shell
curl 'https://api.fiz.co/transport-documents/ID/pdf' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.transportDocuments.pdf('ID');
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.transport_documents.pdf("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->transportDocuments->pdf('ID');
```

### Response `200`

PDF generated successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | PDF file ID |
| `name` | string · can be null | PDF file name |
| `url` | string · can be null | PDF download URL |

### Errors

-   `401` Unauthorized - API key missing or invalid
-   `404` Transport document not found
-   `429` The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

## Errors

Errors share one shape: `statusCode`, `message`, `code` and `error`, with the request id in the `X-Request-Id` header.

## All resources

-   [Company](https://api.fiz.co/docs/api/company) ([Markdown](https://api.fiz.co/docs/api/company.md))
-   [Customers](https://api.fiz.co/docs/api/customers) ([Markdown](https://api.fiz.co/docs/api/customers.md))
-   [Items](https://api.fiz.co/docs/api/items) ([Markdown](https://api.fiz.co/docs/api/items.md))
-   [Invoices](https://api.fiz.co/docs/api/invoices) ([Markdown](https://api.fiz.co/docs/api/invoices.md))
-   [Recurring invoices](https://api.fiz.co/docs/api/recurring-invoices) ([Markdown](https://api.fiz.co/docs/api/recurring-invoices.md))
-   [Pro formas](https://api.fiz.co/docs/api/pro-formas) ([Markdown](https://api.fiz.co/docs/api/pro-formas.md))
-   [Transport documents](https://api.fiz.co/docs/api/transport-documents) ([Markdown](https://api.fiz.co/docs/api/transport-documents.md))
-   [Series](https://api.fiz.co/docs/api/series) ([Markdown](https://api.fiz.co/docs/api/series.md))
-   [PDF templates](https://api.fiz.co/docs/api/pdf-templates) ([Markdown](https://api.fiz.co/docs/api/pdf-templates.md))
-   [Exports](https://api.fiz.co/docs/api/exports) ([Markdown](https://api.fiz.co/docs/api/exports.md))
-   [Expenses](https://api.fiz.co/docs/api/expenses) ([Markdown](https://api.fiz.co/docs/api/expenses.md))
-   [VAT](https://api.fiz.co/docs/api/vat) ([Markdown](https://api.fiz.co/docs/api/vat.md))
-   [Bank](https://api.fiz.co/docs/api/bank) ([Markdown](https://api.fiz.co/docs/api/bank.md))
