Postman tests for the Sume image API: pass on 200 or on 202
Two pm.test checks for POST /v1/images: one expects 200 with data[].url, the other expects 202 with a job envelope. Know which one a slow request should hit.

Write two small tests and run the one that matches the request you sent. Postman's test script docs show the pattern: pm.test(name, function) wrapping an assertion such as pm.response.to.have.status(200). A Sume image call has two valid success shapes, so one hard-coded 200 assertion will fail on slow jobs that are working fine.
The image API blocks up to 30 seconds. A job that finishes in that window returns 200 with data[].url. A job that does not, or any request sent with mode: "async", returns 202 with the job envelope.
Which status should each request expect?
Pick the assertion by the request, not by hope. A small draft with quality: "low" should land on 200. A request with mode: "async" should always land on 202, because the job is the answer in that mode. Heavy settings such as 4K, high quality and large n are the ones the docs name as likely to fall through to 202.
| Request | Expected status | What the body holds |
|---|---|---|
| Default mode, finishes in 30 s | 200 | data[].url, usage.cost |
| Default mode, still running at 30 s | 202 | Job envelope with status_url and result_url |
mode: "async" | 202 | Job envelope |
| Terminal failure in the wait window | 502 | error envelope with code and next_action |
The two tests
Put one of these in the Tests tab of the request. The second block also checks that the job envelope names a poll URL.
// Use for a fast, small request (expect an immediate image)
pm.test("image is ready", function () {
pm.response.to.have.status(200);
const body = pm.response.json();
pm.expect(body.data[0].url).to.be.a("string");
});
// Use for mode: "async" or a heavy request (expect a job)
pm.test("job accepted", function () {
pm.response.to.have.status(202);
const body = pm.response.json();
pm.expect(body.data.status_url).to.be.a("string");
});Keep the key out of the collection
Send Authorization: Bearer {{SUME_API_KEY}} from an environment variable, not a literal. Then add a second request that polls the status_url from the 202 body, and stop on a terminal status. The jobs guide says to back off between polls and never to resend the paid create request when a local timer expires.
The terminal statuses are completed, failed and canceled, so the polling test should pass on completed and fail loudly on the other two. Fetch GET /v1/jobs/{id}/result only after completed; before that the API returns a conflict response, not an empty result. Check that the request timeout in Postman's settings is above 30 seconds, because Sume can hold a sync call open for its full wait, and a client limit shorter than that looks like an API failure.
Sources
Related posts
More in Developers
- PowerShell: call Sume's image API with -StatusCodeVariable
-StatusCodeVariable and -SkipHttpErrorCheck let a PowerShell 7 script read the 200, 202 or 502 from Sume's /v1/images, then save the file with -OutFile.
- PowerShell: submit a Kling 3 video job, poll it and download clip.mp4
Invoke-RestMethod posts a silent 5-second kling-3 job to /v1/videos, polls until completed and saves clip.mp4; the 720p test costs $0.70 on Sume.
- Preflight a 90-second voiceover timeline free before the render
Sume's Timeline 1.0 plan endpoint compiles your request, returns duration and billable minutes, and charges nothing. Use it before the $0.20 render.
- Check durations, frames and references against the Sume video catalog
Read supported_durations, supported_resolutions, supported_frame_images and supported_input_references from /v1/videos/models and refuse bad requests early.
Written by Sume