Attachments
Shoppers can attach pictures and videos to each unit they return, offer or send to repair, and some reasons require them (requireCustomerImage, minPicsRequired, minVideosRequired on the reason). Files are uploaded straight to the storage of Drelife through a signed form, confirmed, and then referenced when the return, offer or repair is created. The three flows share the same two endpoints under their own prefix: /returns/..., /purchases/... and /repairs/....
1. Ask for an upload form
POST /returns/upload-url/{marketplaceId}
Content-Type: application/json
{ "filename": "front.jpg", "mimetype": "image/jpeg" }{
"url": "https://storage.googleapis.com/drelife-...",
"fields": {
"key": "production/temp/5798222299429/6f1c2e3d-....jpg",
"Content-Type": "image/jpeg",
"Cache-Control": "no-store",
"policy": "...",
"x-goog-signature": "..."
}
}marketplaceId must be the marketplace of your session: POST /returns/confirm-upload looks the order up with it (404 Order Not found otherwise); the other endpoints ignore it. The key is <environment>/temp/<order id>/<uuid>.<ext> for returns and <environment>/temp/<shopper email>/<uuid>.<ext> for offers and repairs. Accepted types are image/jpeg, image/jpg, image/png, image/webp, image/jfif, video/mp4, video/mpeg, video/ogg, video/webm, video/quicktime, video/x-m4v and video/x-msvideo; anything else answers 400 Invalid file type. The form is valid for ten minutes.
2. Upload the file
POST a multipart/form-data to url with every entry of fields as a form field, in that order, and the file last in a field named file. The storage rejects a file over the limit (100 MB for images, 400 MB for videos) or with a different content type.
3. Confirm the upload
POST /returns/confirm-upload/{marketplaceId}
Content-Type: application/json
{ "path": "production/temp/5798222299429/6f1c2e3d-....jpg", "mimetype": "image/jpeg", "size": 348211, "filename": "front.jpg" }{ "id": "c0ffee00-1111-4a4a-9c9c-bbbbbbbbbbbb", "path": "https://storage.googleapis.com/.../temp/5798222299429/6f1c2e3d-....jpg" }path is the key of the form. The API checks that the object exists and is not empty (400 Uploaded file is empty), that the path belongs to your session (400 Upload path does not belong to this user) and that the declared size respects the limits (413 PayloadTooLarge), and registers it. Keep the id.
4. Reference it when creating
Put the id values in customerImageNames of the unit, in the creation body (/returns/create, /returns/request, /purchases/create, /repairs/create...):
{ "fulfillmentId": "5294120468773", "reasonId": "9e09f0f3-...", "customerImageNames": ["c0ffee00-1111-4a4a-9c9c-bbbbbbbbbbbb"] }Despite its name, the field takes the identifiers returned by the confirmation, not file names. Offers and repairs accept up to ten files per unit; returns have no limit in the API. Once the return, offer or repair is created, the files are attached to it and appear in its detail as items[].customerImageUrls.
Uploads are temporary: every creation call of the session deletes the pending uploads of that shopper, so upload and confirm right before the creation that uses them, and do not share confirmed uploads across two creations.
Reasons and attachments
When a reason requires attachments, the creation fails with a 400 whose message names the rule (errorCode is BadRequest):
| Message | Meaning |
|---|---|
Reason {id} requires the items to have customer info | requireCustomerInfo: customerInfo is mandatory |
Reason {id} requires the items to have customer image | requireCustomerImage: at least one attachment |
Reason {id} requires all images to be uploaded | An id in customerImageNames was never confirmed |
Reason {id} requires items to have at least {n} image(s) | minPicsRequired not met (pictures are told from videos by the mime type or the file extension) |
Reason {id} requires the items to have at least {n} video(s) | minVideosRequired not met |
Only 10 files per item allowed | More than ten ids on one unit (offers and repairs) |
Check the reason flags on the order or the catalog before asking the shopper for files: allowCustomerImage says whether attachments are accepted at all.
Updated about 2 months ago
