Media
Import or upload a media
Adds a file (multipart) or an https URL that Sofia fetches to the media library of an establishment. Needs a live application and an active subscription.
Import from a URL
Send JSON with the establishmentId and a public https url. Sofia downloads the file herself, checks it and files it in the library.
curl -X POST https://api.sofia-post.com/api/v1/media \
-H "Authorization: Bearer $SOFIA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"establishmentId":"'$ESTABLISHMENT_ID'","url":"https://images.example.com/tatin.jpg"}'Upload a file
Or send the file itself as multipart/form-data, with a file field.
curl -X POST https://api.sofia-post.com/api/v1/media \
-H "Authorization: Bearer $SOFIA_API_KEY" \
-F establishmentId=$ESTABLISHMENT_ID \
-F file=@tatin.jpg{
"id": "393d5aa4-16f1-430f-b1d8-1fb1473076ef",
"type": "image",
"url": "https://…/393d5aa4-16f1-430f-b1d8-1fb1473076ef.jpg?X-Amz-…"
}What is accepted
- Images and videos, up to 200 MB.
- A URL must be public https: a private address, more than 3 redirects or more than 30 seconds of download are refused.
- The
urlreturned is signed and expires: keep theid, and read the media again withGET /v1/media/{id}when you need a fresh URL.
A rejected file answers 422 media_import_refused or media_upload_refused, with the reason in details and the steps to follow in message.
Authorizations
AuthorizationstringheaderrequiredYour personal key or OAuth access token, sent as
Bearer <token>.
Headers
Idempotency-KeystringReplayed with the same body, the request returns the same response without a second import. It covers the form fields, not the file bytes.
Body
establishmentIdstringrequiredThe establishment whose media library receives the media
urlstringJSON: the
httpsaddress of the media, which Sofia fetches itself (no file)filestring<binary>multipart/form-data: the file (image or video), withouturl
Response
The media added to the library.
idstringrequiredIdentifier of the media, to pass in
media[].idof a posttypestringrequiredKind of the media
Allowed values:
imagevideourlstringrequiredSigned address, valid for the current window