Files API

our files api is designed to store and retrieve any files in our system for example, we use this for order file attachments you can use this api to retrieve the files attached to your orders more details later technical details important note the urls returned by the api to download/upload files have a expiry time of 15 minutes uploading a file to create a file, use the post endpoint /api/v1/files this takes a file path in the body, and will return a url, some headers and some other information you can then upload a file to this url, using the headers provided you must include these headers, or the file upload will fail for example, to upload the file using curl curl upload file '\<file name>' h 'header 1' h 'header 2' '\<upload url>' this endpoint will also return an id for the file, which can be used for the other endpoints you can update the file by using the patch endpoint /api/v1/files/{id} , using the id returned when creating the file downloading a file to download a file, use the get endpoint /api/v1/files/{id} when the file upload has successfully completed, this will return a download url, along with some file metadata as with the upload endpoint, it will return a list of headers you must include you can then download the file from the provided url failed uploads if the mime type of the file you upload does not match the file extension, the file will be deleted, and the get endpoint /api/v1/files/{id} will return a 410 gone status code downloading order file attachments if you would like to download any files attached to one of your b2b orders, you can use the get endpoint /api/v1/files/{id} we store the ids of attached files in the note attributes of the order, under the name you provide in your checkoutcustomelements in your theme (by default this is file upload ) they are stored as a json array like the following \[ "gid //sparklayer/file/fdc70d92 fcdf 4719 af2b 9d319a5035d2", "gid //sparklayer/file/a7a3ee08 c6d0 49ee 89b4 bcdaf780d553", "gid //sparklayer/file/15be5381 0b50 459f 9643 af236b9f29f7" ] you must extract the uuids from these gid strings, removing the gid //sparklayer/file prefix this is what the uuid should look like fdc70d92 fcdf 4719 af2b 9d319a5035d2