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
POST/v1/media

This request acts on your real account.

curl -X POST 'https://api.sofia-post.com/api/v1/media' \
  -H "Authorization: Bearer $SOFIA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"establishmentId":"string","url":"https://cdn.example.com/tarte-tatin.jpg"}'

Authorizations

  • Authorizationstringrequired

    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

201application/json

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

400

Malformed body.

401

The token is missing, unknown, expired or revoked.

402

subscription_required.

403

live_mode_required for a test application, or the media:write scope is missing.

404

Establishment outside the Workspace of the token.

413

payload_too_large: above the size limit of the app.

422

media_import_refused, with its reason: private_address, too_large, unsupported_media, unreachable, timeout, invalid_url, redirect_limit or removed_from_library. media_upload_refused for a file.

4XXapplication/json

Any other error, in the error envelope.