List your Sume Formats in Python and keep the video ones

Page through GET /v1/formats with next_cursor, keep io.output_kind video, and print each vanity_invoke_url. A runnable snippet with field caveats.

3 min readSume
All posts

GET /v1/formats returns the Formats your key's workspace owns plus the first-party catalog, in keyset pages: while has_more is true, send next_cursor back as cursor (Format API). The snippet below walks every page and keeps those whose io.output_kind is video.

The snippet

The key needs the formats:read scope. limit is passed as 50.

import os, requests

H = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"]}
url = "https://api.sume.com/v1/formats"
params = {"limit": 50}
formats = []
while True:
    r = requests.get(url, headers=H, params=params, timeout=30)
    r.raise_for_status()
    body = r.json()
    formats += body["data"]
    if not body["has_more"]:
        break
    params["cursor"] = body["next_cursor"]

for f in formats:
    kind = (f.get("io") or {}).get("output_kind")
    if kind == "video":
        print(f["handle"], f["slug"], f["vanity_invoke_url"])

Fields to read

Selected fields from the Format list
FieldUse
handle, slug, vanity_invoke_urlThe address to POST runs to
invoke_urlThe opaque skl_ path that survives renames; persist it if stored URLs must stay valid
ioinput_kind and output_kind; null on older Formats
generation_spend_cap_usd_microsThe cap a run inherits when it names none ($400 for a Format that never set one)
versionBumped on every edit; the receipt shows which version ran

Two traps

A Format you never ran over the API can show status: inactive and api_trigger_enabled: false until its first run, and it still runs. Do not gate your integration on those two values being true.

A personal key lists personal Formats and a team key lists that workspace's; neither lists the other's. If an expected Format is missing, you probably hold the other key.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume