MediaImport or upload a media

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.

POSThttps://api.sofia-post.com/api/v1/media
POSThttps://api.sofia-post.com/api/v1/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.

Authorizations

Authorizationstringrequired

Your personal key or OAuth access token, sent as Bearer <token>.

Kept in this tab only, and sent only to api.sofia-post.com. Get an API key

Headers

Idempotency-Keystring

Replayed with the same body, the request returns the same response without a second import. It covers the form fields, not the file bytes.

Body

This request acts on your real account.

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 url returned is signed and expires: keep the id, and read the media again with GET /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

  • Authorizationstringheaderrequired

    Your personal key or OAuth access token, sent as Bearer <token>.

Headers

  • Idempotency-Keystring

    Replayed with the same body, the request returns the same response without a second import. It covers the form fields, not the file bytes.

Body

application/json, multipart/form-data
  • establishmentIdstringrequired

    The establishment whose media library receives the media

  • urlstring

    JSON: the https address of the media, which Sofia fetches itself (no file)

  • filestring<binary>

    multipart/form-data: the file (image or video), without url

Response

The media added to the library.

  • idstringrequired

    Identifier of the media, to pass in media[].id of a post

  • typestringrequired

    Kind of the media

    Allowed values: imagevideo

  • urlstringrequired

    Signed address, valid for the current window

Was this page helpful?