Skip to content

OR74 - Upload documents to attach to an order

Request

Description

Documents filenames must be distinct. Only documents of the following types are supported: csv, doc, xls, xlsx, ppt, pdf, odt, ods, odp, txt, rtf, png, jpg, gif, zpl, mov, mp4.
An order can have a maximum of 50 documents. In the API output we include only documents with errors. All other documents are successfully uploaded.

For system document types, there are specific restrictions :

  • SYSTEM_DELIVERY_BILL/SYSTEM_SHIPMENT_DELIVERY_BILL : restricted to operator role.
  • SYSTEM_MESSAGE_ATTACHMENT : cannot be directly uploaded to an order.
Call Frequency
Maximum usage: At each document upload on an order
Read More
Security
Operator-Bearer-Token or OAuth-2
Path
order_idstringrequired

The identifier of the order

Bodymultipart/form-data
filesArray of strings, (binary)required

The files to be uploaded. Use multipart/form-data with name 'files'. The file names must contain only US-ASCII characters.

order_documentsobjectrequired

The list of documents to be uploaded details

/**
 * Requires libcurl
 */

const orderId = "YOUR_order_id_PARAMETER";
$curl = curl_init();

$payload = array(
  "files" => "["string"]",
  "order_documents" => "{"order_documents":[{"entity":{"id":"string","type":"RETURN"},"file_name":"string","type_code":"string"}]}",
);

curl_setopt_array($curl, [
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <YOUR_JWT_HERE>",
    "Content-Type: multipart/form-data"
  ],
  CURLOPT_POSTFIELDS => $payload,
  CURLOPT_URL => "https://your-instance.mirakl.net/api/orders/" . orderId . "/documents",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "cURL Error #:" . $error;
} else {
  echo $response;
}

Responses

OK

Bodyapplication/json
errors_countinteger, (int32)

The number of documents in an error state

order_documentsArray of objectsrequired

Lists of error reports associated to each document in an error state

Response
{ "errors_count": 1, "order_documents": [ { … } ] }