{"id":6664,"date":"2026-05-15T17:14:38","date_gmt":"2026-05-15T15:14:38","guid":{"rendered":"https:\/\/www.trans.eu\/api\/?p=6664"},"modified":"2026-05-15T17:14:40","modified_gmt":"2026-05-15T15:14:40","slug":"uploading-files-and-adding-files-as-an-attachment-to-an-order","status":"publish","type":"post","link":"https:\/\/www.trans.eu\/api\/use-cases\/integration-scenarios\/uploading-files-and-adding-files-as-an-attachment-to-an-order\/","title":{"rendered":"Uploading files and adding files as an attachment to an order"},"content":{"rendered":"\n<p>Descrip\u00adtion of usage of APIs to upload a file, attach\u00ading it to an order, down\u00adload\u00ading an order attach\u00adment, as well as delet\u00ading an attach\u00adment from an order.&nbsp;<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Scenario<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Car\u00adri\u00ader and ship\u00adper are both present on Trans.eu plat\u00adform <\/li>\n\n\n\n<li>The Ship\u00adper has assigned an Order to a Car\u00adri\u00ader<\/li>\n\n\n\n<li>The Order is not can\u00adcelled nor archived<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Authorize access<\/h2>\n\n\n\n<p>Before it is pos\u00adsi\u00adble to send any request, user needs to&nbsp;<a href=\"https:\/\/www.trans.eu\/api\/general-information\/authorization-process\/\" title>autho\u00adrize access<\/a>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>client app was reg\u00adis\u00adtered using reg\u00adis\u00adtra\u00adtion form<\/li>\n\n\n\n<li>exter\u00adnal app was grant\u00aded api keys (client_id and client_secret)<\/li>\n\n\n\n<li>autho\u00adriza\u00adtion process has been imple\u00adment\u00aded in exter\u00adnal app<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Uploading attachments<\/h2>\n\n\n\n<p>Before a file can be added to an order as an attach\u00adment, it has to be uploaded via the fol\u00adlow\u00ading end\u00adpoint to be iden\u00adti\u00adfied with a media_id.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Endpoint<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>PUT https:\/\/api.platform.trans.eu\/ext\/media-storage-api\/v1\/assets<\/code><\/pre><\/div>\n\n\n\n<p>The endpoint\u2019s con\u00adtent type is mul\u00adti\u00adpart\/\u00adform-data, and the avail\u00adable file types are list\u00aded below:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>JPG, GIF, PNG, BMP, PDF, ODT, DOC, TXT, DOCX, TIFF, ODS, XLS, XLSX, PPT, RTF<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Response:<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    \"id\": \"3e7272cd-e805-42c5-bd55-dd9b9a43bc38\",\n    \"path\": \"https:\/\/api.media-storage.service\/v1\/assets\/3e7272cd-e805-42c5-bd55-dd9b9a43bc38\",\n    \"ttl\": {\n        \"validTime\": \"not specified\",\n        \"expirationDate\": null\n    },\n    \"file\": {\n        \"etag\": \"\\\"1a9f3ffe9b03568b7d65b5436431a38f\\\"\",\n        \"size\": 43543,\n        \"type\": \"image\/jpeg\",\n        \"name\": \"cargo_photo.jpg\",\n        \"hash\": {\n            \"md5\": \"1a9f3ffe9b03568b7d65b5436431a38f\",\n            \"sha256\": \"390e2f4af92946e773fe0cdef6c25f694ae6844290cfb411daea8f677237b072\"\n        },\n        \"permissions\": {\n            \"isPublic\": true,\n            \"acl\": {\n                \"1158167\": \"OWNER\",\n                \"public\": \"READER\",\n                \"guest\": \"READER\"\n            }\n        },\n        \"image\": {\n            \"width\": 363,\n            \"height\": 471\n        }\n    }\n}<\/code><\/pre><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Adding uploaded attachment to order<\/h2>\n\n\n\n<p>The uploaded file can be added as an attach\u00adment to the order via the fol\u00adlow\u00ading end\u00adpoint. The end\u00adpoint has the orderId as a path vari\u00adable \u2014 the orderId can be obtained from the response of the end\u00adpoint <a href=\"https:\/\/www.trans.eu\/api\/orders\/getting-lists-orders\/list-of-created-orders\/\" title>here<\/a> (if ship\u00adper) and <a href=\"https:\/\/www.trans.eu\/api\/orders\/getting-lists-orders\/list-of-received-orders\/\" title>here<\/a> (if car\u00adri\u00ader).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Endpoint<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>POST https:\/\/api.platform.trans.eu\/orders-api\/v1\/orders\/{orderId}\/attachments<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Example of use<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>https:\/\/api.platform.trans.eu\/orders-api\/v1\/orders\/{b093cdfe-12cf-4958-a5da-0170141e9c71}\/attachments<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Request example<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n  \"media_id\": \"3e7272cd-e805-42c5-bd55-dd9b9a43bc38\",\n  \"media_name\": \"damaged pallet\",\n  \"type_id\": \"cargo_photo\",\n  \"visible_to_contractor\": true,\n  \"description\": \"goods damaged on pallet due to accident\"\n}<\/code><\/pre><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Downloading attachments<\/h2>\n\n\n\n<p>Any attach\u00adment of an order can be down\u00adloaded by pro\u00advid\u00ading the medi\u00adaId path vari\u00adable with the fol\u00adlow\u00ading end\u00adpoint.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Endpoint<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>GET https:\/\/api.platform.trans.eu\/ext\/media-storage-api\/v1\/assets\/{mediaId}<\/code><\/pre><\/div>\n\n\n\n<p>The file will be pro\u00advid\u00aded in the response.<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Deleting order attachments<\/h2>\n\n\n\n<p>To delete an attach\u00adment of an order, use the fol\u00adlow\u00ading end\u00adpoint. This end\u00adpoint requires two path vari\u00adables \u2014 orderId and attach\u00admen\u00adtId, which is the same val\u00adue as the afore\u00admen\u00adtioned media_id.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Endpoint<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>DELETE https:\/\/api.platform.trans.eu\/orders-api\/v1\/orders\/:orderId\/attachments\/:attachmentId<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Example of use<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>https:\/\/api.platform.trans.eu\/orders-api\/v1\/orders\/{b093cdfe-12cf-4958-a5da-0170141e9c71}\/attachments\/{3e7272cd-e805-42c5-bd55-dd9b9a43bc38}<\/code><\/pre><\/div>\n\n\n\n<p><strong><em>Impor\u00adtant<\/em><\/strong> \u2014 only the user from the author com\u00adpa\u00adny can remove attach\u00adments \u2014 for exam\u00adple, if a ship\u00adper attached a file to an order, the car\u00adri\u00ader is for\u00adbid\u00adden from remov\u00ading the attach\u00adment as well as vice ver\u00adsa. This will result in a 403 error (For\u00adbid\u00adden).<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Getting attachmentId<\/h2>\n\n\n\n<p>If the attach\u00admen\u00adtId is unknown to the user, the infor\u00adma\u00adtion can be found in the response of one of the two end\u00adpoints:<\/p>\n\n\n\n<p>For ship\u00adper:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>GET https:\/\/api.platform.trans.eu\/ext\/orders-api\/v1\/orders-created\/{order-id}<\/code><\/pre><\/div>\n\n\n\n<p>For car\u00adri\u00ader:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>GET https:\/\/api.platform.trans.eu\/ext\/orders-api\/v1\/orders-received\/{order-id}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Response example<\/h2>\n\n\n\n<p>With\u00adin the response for either of these end\u00adpoints, the fol\u00adlow\u00ading infor\u00adma\u00adtion can be found:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>    \"attachments\": [\n        {\n            \"author\": null,\n            \"company\": {\n                \"legal_name\": \"(P3DT) CargoON Test\",\n                \"company_id\": 1079411\n            },\n            \"created_at\": \"2026-05-15T13:55:59.514Z\",\n            \"description\": \"goods damaged on pallet due to accident\",\n            \"media_id\": \"3e7272cd-e805-42c5-bd55-dd9b9a43bc38\",\n            \"media_name\": \"damaged pallet\",\n            \"protected\": false,\n            \"source\": \"orders\",\n            \"source_id\": null,\n            \"type_id\": \"cargo_photo\",\n            \"visible_to_contractor\": true\n        }\n    ],<\/code><\/pre><\/div>\n\n\n\n<p>The media_id val\u00adue cor\u00adre\u00adsponds to the attach\u00admen\u00adtId val\u00adue.<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p class=\"dont-break-out\">Descrip\u00adtion of usage of APIs to upload a file, attach\u00ading it to an order, down\u00adload\u00ading an order attach\u00adment, as well \u2026<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[58],"tags":[],"class_list":["post-6664","post","type-post","status-publish","format-standard","hentry","category-integration-scenarios"],"acf":[],"aioseo_notices":[],"lang":"en","translations":{"en":6664},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts\/6664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/comments?post=6664"}],"version-history":[{"count":1,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts\/6664\/revisions"}],"predecessor-version":[{"id":6665,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/posts\/6664\/revisions\/6665"}],"wp:attachment":[{"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/media?parent=6664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/categories?post=6664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trans.eu\/api\/wp-json\/wp\/v2\/tags?post=6664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}