# Change Guide State Changes the state of guide documents (shippings, transports, devolutions). | From | To | Event | | :--- | :--- | :--- | | draft | final | finalized | | draft | deleted | deleted | | final | canceled | canceled | Endpoint: PUT /{guides-type}/{document-id}/change-state.json Version: 2.0.0 Security: apiKeyAuth ## Path parameters: - `guides-type` (string, required) The type of the guide document. Enum: "shippings", "transports", "devolutions" - `document-id` (integer, required) The ID of the document. Example: 1050 ## Query parameters: - `api_key` (string, required) Your API Key. Example: "YOUR_API_KEY" ## Request fields (application/json): - `shipping` (object, required) - `shipping.state` (string, required) Enum: "finalized", "canceled", "deleted" - `shipping.message` (string) No enforced character limit (text column, stored as cancel_message). Example: "Wrong value" ## Response 200 fields (application/json): - `shipping` (object) Wrapper key matches the singular of the requested guide type — shipping, transport or devolution. Shown here as "shipping". - `shipping.id` (integer) Example: 541797 - `shipping.status` (string) Example: "final" - `shipping.archived` (boolean) - `shipping.type` (string) Example: "Shipping" - `shipping.sequence_number` (string) Example: "1/D" - `shipping.inverted_sequence_number` (string) Example: "D/1" - `shipping.atcud` (string) Example: "ABCD1234-1" - `shipping.date` (string) Example: "13/07/2017" - `shipping.due_date` (string) dd/mm/yyyy Example: "27/07/2026" - `shipping.reference` (string,null) - `shipping.observations` (string,null) No enforced character limit (text column). - `shipping.retention` (string,null) - `shipping.loaded_at` (string) dd/mm/yyyy HH:mm:ss. Note the list endpoint returns this same field as date-only (dd/mm/yyyy). Example: "27/07/2026 23:00:00" - `shipping.license_plate` (string,null) 255-character limit is the database column default, not an explicit business rule. Example: "11-AA-22" - `shipping.permalink` (string) Example: "https://web.invoicexpress.com/documents/541797d75bbee48911934cbd4a4294946a324295f52b08" - `shipping.saft_hash` (string) No enforced character limit (text column). Example: "vaDf" - `shipping.sum` (number) Example: 1 - `shipping.discount` (number) - `shipping.before_taxes` (number) Example: 1 - `shipping.taxes` (number) Example: 0.07 - `shipping.total` (number) Example: 1.07 - `shipping.currency` (string) Example: "Euro" - `shipping.address_from` (object) - `shipping.address_from.country` (string) Not stored on the address itself — resolved through a tax-location name lookup, falling back to Portugal. Example: "Portugal" - `shipping.address_from.postal_code` (string) 255-character limit is the database column default on the Address model, not an explicit business rule. Example: "1050-083" - `shipping.address_from.detail` (string) 255-character limit is the database column default on the Address model, not an explicit business rule. Note the API re-inserts line breaks roughly every 35 characters before storing, so an input close to 255 characters can overflow the column — keep well under the limit. Example: "Avenida Duque D'Avila, 46 - 3ºA" - `shipping.address_from.city` (string) 255-character limit is the database column default on the Address model, not an explicit business rule. Example: "Lisboa" - `shipping.address_to` (object) - `shipping.client` (object) - `shipping.client.name` (string) Example: "John" - `shipping.client.country` (string) 255-character limit is the database column default, not an explicit business rule. Example: "Portugal" - `shipping.items` (array) - `shipping.items.name` (string) Maximum 60 characters. V3 rejects a longer name with HTTP 422; V2 accepts the request and silently truncates the stored value to 60 characters. Example: "iPhone" - `shipping.items.description` (string,null) Maximum 200 characters and 20 lines. V3 rejects a longer description with HTTP 422; V2 accepts the request and silently truncates the stored value to 200 characters. - `shipping.items.unit_price` (string) Example: "1.0" - `shipping.items.unit` (string,null) Restricted to a fixed set of unit values rather than length-limited free text. Example: "service" - `shipping.items.quantity` (string) Example: "1.0" - `shipping.items.tax` (object) - `shipping.items.tax.value` (number) Example: 7 - `shipping.items.subtotal` (number) Example: 1 - `shipping.items.tax_amount` (number) Example: 0.07 - `shipping.items.discount_amount` (number) - `shipping.sequence_id` (integer,null) Example: 12345 - `shipping.tax_exemption` (string) Example: "M01" - `shipping.at_doc_code_id` (string,null) Read-only. Written only by the AT gateway and never accepted on input. The 255-character limit is the database column default, not an explicit business rule. Example: "999" ## Response 401 fields (application/json): - `errors` (array) - `errors.error` (string) Example: "Authentication Error" ## Response 404 fields (application/json): - `errors` (array) - `errors.error` (string) Example: "Document not found" ## Response 422 fields (application/json): - `errors` (array) Example: [{"error":"CantHandle: 1 for Invoice"},{"error":"The cancellation reason is a required field"}] - `errors.error` (string)