XreplyAIDevelopers
Guides

Media

Uploading images, video, and documents, and attaching them to posts.

All upload endpoints require the publish:write scope. Uploads happen before post creation: each upload returns a reference (r2_key, media_id, asset_urn, or document_urn) that you place in the matching post_contents entry's metadata object.

Two upload patterns

Direct upload: send base64-encoded bytes in the request body, get a storage reference back. POST /media/uploads covers nine platforms in one endpoint (facebook, instagram, pinterest, tiktok, threads, discord, slack, telegram, tumblr); platform selects the size and type limits:

curl -X POST https://api.xreplyai.com/api/v1/media/uploads \
  -H "Authorization: Bearer $XREPLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "platform": "instagram", "content_type": "image/jpeg", "media": "<base64>" }'
{ "url": "https://media.xreplyai.com/instagram/4021/uuid.jpg", "r2_key": "instagram/4021/uuid.jpg" }

Delete an upload later with DELETE /media/uploads and its r2_key.

Presigned upload: for large files (video), first request a presigned URL, then PUT the bytes directly to storage, then reference the returned r2_key. Presign endpoints exist for X, LinkedIn, YouTube, TikTok, Pinterest, Tumblr, Instagram, and Facebook; see the API Reference for each.

Platform-specific references

UploadReturnsGoes in metadata as
POST /media/uploads (9 platforms, base64)r2_keyr2_key
POST /twitter/media_uploads (base64 image)media_idmedia_id
LinkedIn image uploadasset_urnasset_urn
LinkedIn document upload (PDF)document_urndocument_urn
Presigned video uploads (X, LinkedIn, YouTube, …)r2_keyr2_key

Video limits worth knowing

  • X: presigned PUT, max 500 MB video/mp4; at publish time the video is uploaded to X via the v2 chunked flow, and X enforces a 140-second duration cap.
  • LinkedIn: direct multipart/form-data upload (video field, max 100 MB video/mp4, rate-limited to 10/hour) returning an asset_urn, or a presigned PUT returning an r2_key.
  • YouTube: presigned PUT, max 4 GB; the presign is a POST carrying content_type and file_size.
  • Pinterest: video pins additionally need a cover image.

Attaching to a post

A complete image post on Instagram:

{
  "social_account_ids": [456],
  "post_contents": [
    {
      "platform": "instagram",
      "body": "Caption text",
      "content_type": "single_image",
      "metadata": { "r2_key": "instagram/4021/uuid.jpg" }
    }
  ],
  "use_next_slot": true
}

Run it with dry_run: true first to validate the media reference against the platform's limits without publishing.

On this page