Media

Files in the Media library are what your posts refer to with media_ids. This page covers adding files, the rules for them, and how to check a file before you post it.

Two ways to add a file

POST /media (reference) takes either a file upload or a URL. Send exactly one of them (otherwise 422). The scope is media.write.

Multipart upload URL import
Request multipart/form-data with a file field JSON {"url": "https://..."}
Answer 201 with status: "ready" 201 with status: "pending"
Then Use the id in a post. Wait until ready: poll GET /media/{id}, or listen for the media.ready and media.failed events.

Both accept the optional fields name, collection (a collection id) and tags.

curl
# Upload a file
curl -X POST "https://iqcore.ai/api/public/v1/media" \
  -H "Authorization: Bearer $IQCORE_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F "file=@./launch.jpg" -F "name=Launch picture"

# Import from a URL
curl -X POST "https://iqcore.ai/api/public/v1/media" \
  -H "Authorization: Bearer $IQCORE_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/images/launch.jpg"}'
JavaScript
import { openAsBlob } from "node:fs";

const headers = { Authorization: `Bearer ${process.env.IQCORE_KEY}` };

// Upload a file (Node 20+: openAsBlob)
const form = new FormData();
form.append("file", await openAsBlob("./launch.jpg"), "launch.jpg");
form.append("name", "Launch picture");
const uploaded = await fetch("https://iqcore.ai/api/public/v1/media", {
  method: "POST",
  headers: { ...headers, "Idempotency-Key": crypto.randomUUID() },
  body: form,
});

// Import from a URL
const imported = await fetch("https://iqcore.ai/api/public/v1/media", {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({ url: "https://example.com/images/launch.jpg" }),
});
Python
import os
import uuid
import requests

headers = {"Authorization": f"Bearer {os.environ['IQCORE_KEY']}"}

# Upload a file
with open("launch.jpg", "rb") as f:
    uploaded = requests.post(
        "https://iqcore.ai/api/public/v1/media",
        headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
        files={"file": f},
        data={"name": "Launch picture"},
        timeout=120,
    )

# Import from a URL
imported = requests.post(
    "https://iqcore.ai/api/public/v1/media",
    headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
    json={"url": "https://example.com/images/launch.jpg"},
    timeout=30,
)

Do not set the Content-Type header yourself for a multipart upload: the library adds it with the boundary.

Reading a file

GET /media/{id} (reference) returns the file's status (ready, pending or failed; a failed import has error with a code and message), kind, mime_type, size_bytes, width, height, duration_ms, has_audio, tags and collection. For a file imported from a URL, source_url shows that URL without its query string. A pending or failed import answers under its id with kind: null.

On the API the answer also has url, thumb_url and poster_url and urls_expire_at. See Signed links.

GET /media lists files with q, kind, source, collection, updated_since and a cursor. A pending import is not listed until it is a file. See Pagination.

File types and sizes

IQCore reads the type of a file from its bytes, never from its name, its extension or the Content-Type your client or the other server sends.

Kind Types
Pictures JPEG, PNG, WebP, GIF. Never SVG or HTML.
Videos MP4, MOV, WebM
Audio MP3, WAV, M4A, AAC, OGG

Refusals:

Code Meaning
unsupported_file_type The bytes are not an allowed type.
file_too_large (413) The file is over the size limit for its kind.
empty The file has no content.
storage_full (403) The organization's storage quota is used up. A full storage is refused before any download.
file_rejected The file failed a safety check (for example a virus scan or the pixel limit).

URL import rules

IQCore downloads the file from your URL on its own servers, so it protects itself and you.

  • Only public http and https addresses. The host must be a public DNS name: no IP addresses, no user:password@, and no private, local or internal hosts. https uses port 443 and http port 80. Any other port is refused.
  • IQCore resolves the name once and connects to that address, so a name cannot change to an internal address halfway.
  • It follows at most 3 redirects, and checks every hop the same way. A redirect from https to http is refused.
  • The download stops at the size limit, and takes at most about a minute.
  • It sends no cookies and no credentials. Do not use a URL that needs a login. A signed link (one that carries a token in its query string) works, and IQCore does not keep the query string after the import.
  • Errors name the problem (url_invalid, url_scheme, url_credentials, url_port, url_host) but never an internal address or the other server's answer.

Limits: 10 URL imports a minute and 10 open imports per organization (429 rate_limited). See Rate limits.

Files are private. In an API answer, url, thumb_url and poster_url are signed links:

  • They are valid for 15 minutes (a link lives 15 to 22.5 minutes, see urls_expire_at).
  • They are bound to the API key. If the key is revoked or expired, or loses the organization, its links answer 404 at once.
  • Ask again with GET /media/{id} when a link has expired. Do not store links.

Deleting files

POST /media/delete (up to 100 ids), DELETE /images/{id} and DELETE /voice-overs/{id} need the scope media.delete. media.write never deletes.

  • media.delete deletes any file, picture or voice-over of the organization, not only the ones your key added.
  • Only keys of an owner or admin can use it (the scope's lowest role is admin). A member's key answers 403 missing_scope.
  • There is no dashboard step and no undo over the API. Give media.delete only to tools that must delete, and keep it off keys you share.
  • A test key cannot hold media.delete.
  • On MCP, a connected app needs the same permission, and every delete still waits for a person to approve it in IQCore.

Check a file before you post: media_validate

GET /media/{id}/validate?platform=instagram&format=reel (reference) checks a ready file against a platform and a format. platform is instagram, facebook, threads or tiktok. format is post, reel or carousel (default: reel for a video, post for a picture).

curl
curl "https://iqcore.ai/api/public/v1/media/$MEDIA_ID/validate?platform=tiktok&format=reel" \
  -H "Authorization: Bearer $IQCORE_KEY"
JavaScript
const url = `https://iqcore.ai/api/public/v1/media/${mediaId}/validate?platform=tiktok&format=reel`;
const check = await (await fetch(url, {
  headers: { Authorization: `Bearer ${process.env.IQCORE_KEY}` },
})).json();
console.log(check.ok, check.checks);
Python
import os
import requests

check = requests.get(
    f"https://iqcore.ai/api/public/v1/media/{media_id}/validate",
    params={"platform": "tiktok", "format": "reel"},
    headers={"Authorization": f"Bearer {os.environ['IQCORE_KEY']}"},
    timeout=30,
).json()
print(check["ok"], check["checks"])

The answer has ok (no check has the severity error), checks[] with code, severity and message, the spec it used and the facts read from the file. An error means the platform refuses the file or IQCore cannot prepare it. A warning means it may be refused or is changed on the way (padded or scaled, for example).

A file that is not ready (pending or failed) answers 422 media_not_ready. format=story answers 422 unsupported_format: stories are not supported.

The same checks run per channel when you call POST /posts/{id}/publish with dry_run. See Test keys and dry run.

Requirements per platform

This is the table media_validate uses. Platform rules change. If a platform stops accepting a file IQCore passed, the post fails with a clear error code instead of a silent loss.

Platform Format Takes Pictures Videos
Instagram post, carousel pictures Sent as is: JPEG up to 1440 px wide, ratio 4:5 to 1.91:1, up to 8 MB. Other pictures become a fresh JPEG. Outside 4:5 to 1.91:1 the picture is padded (warning). Under 320 px wide it is scaled up (warning). -
Instagram reel videos - MP4 or MOV. H.264 or HEVC. AAC audio (warning). 23 to 60 fps (warning). Up to 1920 px wide (warning). Ratio 0.01 to 10. 3 seconds to 15 minutes. Up to 300 MB. Up to 25 Mbps (warning).
Facebook post pictures, videos JPEG and PNG sent as is, up to 10 MB. WebP and GIF become JPEG. MP4 or MOV. No length or size limit is published.
Facebook carousel pictures As post. -
Facebook reel videos - MP4 or MOV.
Threads post pictures, videos Ratio up to 10:1 either way (error). Under 320 px wide it is scaled up (warning). Every picture is re-encoded to JPEG up to 1440 px. MP4 or MOV. H.264 or HEVC. AAC audio (warning). 23 to 60 fps (warning). Up to 1920 px wide (warning). Ratio 0.01 to 10. Up to 5 minutes. Up to 1 GB. Up to 100 Mbps (warning).
Threads carousel pictures As post. -
Threads reel videos - As post.
TikTok post pictures (photo mode), videos Always a fresh JPEG up to 1080 x 1920. MP4, WebM or MOV. H.264, HEVC, VP8 or VP9. 23 to 60 fps (warning). 360 to 4096 px on both sides. Up to 10 minutes (over 3 minutes is a warning, because the creator's own limit may be lower). Up to 4 GB.
TikTok reel videos - As post.
Any story - Not supported (422 unsupported_format).

Other checks for every platform: a file that is not ready gives media_not_ready, audio gives media_kind, a picture over 40 megapixels gives image_too_large, a video that was never analyzed gives video_not_probed (warning), and an unknown length gives video_duration_unknown (warning). Other post rules, such as the caption length (Threads 500 characters, Instagram and TikTok 2,200) and the number of carousel items (2 to 10), are checked when you create or publish the post.

Next: Events, Platform permissions, Quickstart.