A product sells out mid-promo: swap one Timeline slot and re-render

When a SKU in a gift-guide video sells out, change that slot's source_url, run the free plan, then re-render with a new idempotency key.

4 min readSume
All posts

Keep the Timeline 1.0 request body you rendered. When a product sells out, change only that slot's source_url to a replacement with the same start and duration, run the free plan, and render again with a new idempotency key. The render is $0.10 per started output minute, and nothing else in the clip needs to change.

Why a stored spec matters

Timeline 1.0 is declarative: one audio spine plus ordered video[] slots, and the server compiles it. That means the whole edit is a JSON file you can keep in version control next to the clip. A sold-out SKU becomes a one-line diff instead of a re-edit in a timeline tool.

The one constraint is timing. Declared slot start values are authoritative and must increase, and the coverage can stop at most 0.5 seconds before the end of the spine. If the replacement slot has the same duration, every later slot keeps its start and the spine stays valid. A different duration means changing the later starts and, probably, audio.duration_seconds.

The swap

The script loads the saved body, asserts exactly one slot matches the sold-out URL, swaps it, runs the plan and submits the render. The idempotency key includes a version and the swap, so the retry logic does not return the previous job. Poll the returned job as described in jobs and results.

import json, os, urllib.request

def call(path, body, key=None):
    h = {"Authorization": "Bearer " + os.environ["SUME_API_KEY"],
         "Content-Type": "application/json"}
    if key:
        h["Idempotency-Key"] = key
    req = urllib.request.Request("https://api.sume.com" + path, json.dumps(body).encode(), h)
    return json.load(urllib.request.urlopen(req))

spec = json.load(open("gift-guide-render.json"))   # the body you rendered before
OLD = "https://media.sume.com/artifacts/artf_demo/candle.png"
NEW = "https://media.sume.com/artifacts/artf_demo/mug.png"
hits = [s for s in spec["video"] if s["source_url"] == OLD]
assert len(hits) == 1, "expected exactly one slot to swap"
hits[0]["source_url"] = NEW            # same start and duration, so the spine stays valid
plan = call("/v1/timeline-1.0/plan", spec)
print(plan["segment_count"], plan["billable_minutes"])
print(call("/v1/timeline-1.0/render", spec, "gift-guide-v2-swap-candle-mug"))

What else the swap touches

  • Price cues or captions burned after the render must be re-run, because the old text names the old product. A caption job is $0.20 per clip up to 60 seconds.
  • A voiceover that names the product needs replacing too. The timeline will not change what the audio says.
  • Any link or page that the clip points to should drop the sold-out product at the same moment.
  • Keep a list of every published copy of the clip, so a swap reaches all of them.

When not to swap

If the product is back in stock in a few days, a swap and a swap-back is two renders and two reviews. A back-in-stock clip is the other option. If the sold-out product is the star of the video, the clip is about something you cannot sell and should come down rather than be patched. Whichever you choose, record the decision with the date and the SKU, so that anyone who finds an old copy of the clip knows why it differs from the current one, and run the plan before the render so a typo in the replacement URL fails for free.

Sources

Related posts

More in Use cases

All Use cases posts

Written by Sume