Create a hologram
The whole flow, from a video and an image to a printed QR code, in cURL, Node.js and Python.
A hologram takes four calls: create a draft, upload its files, submit it, then get it once it is ready (or wait for the webhook).
POST /v1/experiences ──▶ PUT video (+ image) ──▶ POST /v1/experiences/{id}/submit
│
experience.ready on your webhook ◀┘ or GET /v1/experiences/{id}KEY="msk_live_your_api_key"
API="https://api.meishi.cards"
# 1. Start a hologram: say what you will upload, with the exact sizes in bytes
curl -X POST $API/v1/experiences \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"type": "hologram", "orderReference": "1001",
"image": {"contentType": "image/jpeg", "size": 812345},
"video": {"contentType": "video/mp4", "size": 24000000}}'
# The answer holds experience.experienceId, uploads.image.url and uploads.video.url
# 2. Upload each file to its URL, with the Content-Type it was given
curl -X PUT "<uploads.image.url>" -H "Content-Type: image/jpeg" --data-binary @photo.jpg
curl -X PUT "<uploads.video.url>" -H "Content-Type: video/mp4" --data-binary @message.mp4
# 3. Submit: Meishi prints the QR code onto the image and makes the hologram
curl -X POST $API/v1/experiences/<experienceId>/submit -H "Authorization: Bearer $KEY"
# 4. Once status is ready (or experience.ready reaches your webhook), print it
curl $API/v1/experiences/<experienceId> -H "Authorization: Bearer $KEY"1. Create the draft
POST /v1/experiences takes the type and exact size of each file, plus your own reference and layout options. It answers 201 with the draft and a presigned upload for each file. A draft uses nothing.
2. Upload the files
PUT each file to uploads.<file>.url with exactly the headers in uploads.<file>.headers. The size you declared is signed into the URL, so a file of a different size or type is refused. The URLs stop working at expiresAt, an hour later: create a new draft if you miss it.
3. Submit
POST /v1/experiences/{id}/submit checks the uploads, prints the QR code onto the image, counts one experience and starts processing. The person in the video is cut out of its background, unless you sent "background": "keep".
409 upload_missing: a file is not there yet.details.filesays which.422 video_too_long,image_too_small,file_refused,image_unreadable: fix the file, upload it again to the same draft (with a new draft if the URL expired) and submit again.402 no_experience_credits: the draft stays a draft. Submit it again once you have more experiences.
Submitting again is safe: it answers with where the experience stands.
4. Use it when it is ready
Processing usually takes a few minutes. Then:
experience.readyreaches your key's webhook with the experience indata, orexperience.failedwithprocessingError.- Or poll
GET /v1/experiences/{id}every 10 seconds or so.
Print printPdfUrl on a label printer, or printImageUrl anywhere else. The printed code opens scanUrl.