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.

4 min readSume
All posts

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.

Expected status for POST /v1/images, from Sume's image docs and the Postman assertion form, read 2026-10-05.
RequestExpected statusWhat the body holds
Default mode, finishes in 30 s200data[].url, usage.cost
Default mode, still running at 30 s202Job envelope with status_url and result_url
mode: "async"202Job envelope
Terminal failure in the wait window502error 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

All Developers posts

Written by Sume