docs: recommend Jobs API instead of history/queue endpoints#742
docs: recommend Jobs API instead of history/queue endpoints#742christian-byrne wants to merge 4 commits intomainfrom
Conversation
|
Is this PR good to merge now? |
- Add Jobs API section with list/get endpoints documentation
- Update complete example to use /api/jobs/{id} instead of /api/history_v2
- Add note about legacy endpoints being maintained for compatibility
- Update both English and Chinese examples
Amp-Thread-ID: https://ampcode.com/threads/T-019c0c6f-94c9-70a9-90c7-dee4048a242d
Co-authored-by: Amp <amp@ampcode.com>
- Add /api/jobs and /api/jobs/{job_id} to routes table with (recommended) label
- Mark /history and /queue GET endpoints as (legacy)
- Add detailed Jobs API section with parameters, response examples
- Update both English and Chinese translations
Amp-Thread-ID: https://ampcode.com/threads/T-019c0c6f-94c9-70a9-90c7-dee4048a242d
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c0cd7-4eea-71d7-91d1-6b7288070d65 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c0cd7-4eea-71d7-91d1-6b7288070d65 Co-authored-by: Amp <amp@ampcode.com>
1ae3a27 to
6960c75
Compare
|
Just rebased onto latest |
There was a problem hiding this comment.
Inline anchors below. Highest-signal:
comms_routes.mdxandapi-reference.mdxdisagree onsort_byfield names. The cloud API accepts[create_time, execution_time];comms_routes.mdxinventedcreated_atandexecution_duration. One side returns 400 / silent ignore.output_typeTypeScript signature drops a fourth value (3d) that the cloud API actually accepts.create_timeexample is shown as 10-digit seconds whileexecution_*_timein the same payload is 13-digit ms — internally inconsistent regardless of which is right.- The
workflowfield has a[REDACTED]round-trip footgun that's undocumented here — a real surprise for anyone reusing returned workflows in/api/prompt.
Broader gaps not anchored to a single line:
- The
comms_routes.mdxJobs API subsection mixes cloud-only fields/filters (e.g.workflow_idresponse field, the cloudstatusenum) with OSS-shared behavior, without distinguishing them. A self-hoster following the example response will see fields their server doesn't return. - The cloud Jobs API also supports cancellation (
POST /api/jobs/{job_id}/cancel), not documented here. The legacy Note inapi-reference.mdxclaims the Jobs API replaces/api/queue(the cloud cancel surface), so cancellation belongs in the cloud reference. - The cloud list/detail responses include a structured error object for failed jobs that's not in the TS interfaces or examples.
- No 401/403/404 documentation. The cloud API distinguishes "wrong id" from "not yours" via different status codes — readers can't tell which is which without the docs covering it.
- Chinese mirrors (
zh/development/cloud/api-reference.mdx,zh/development/comfyui-server/comms_routes.mdx,snippets/zh/cloud/complete-example.mdx) replicate every issue above. Localization is also half-done:console.log/printstring literals stayed English. - The PR body's
Related: COM-13971leaks an internal-only Notion ticket on a public docs PR.
| |-----------|------|-------------| | ||
| | `status` | string | Filter by status (comma-separated): `pending`, `in_progress`, `completed`, `failed`, `cancelled` | | ||
| | `workflow_id` | string | Filter by workflow ID | | ||
| | `sort_by` | string | Sort field: `created_at` (default), `execution_duration` | |
There was a problem hiding this comment.
sort_by values contradict api-reference.mdx in this same PR (and the actual API).
The live cloud API accepts sort_by values create_time (default) and execution_time — api-reference.mdx (lines 472, 501, 540) uses those values. This row says created_at and execution_duration, neither of which is accepted server-side.
A reader following this table will send sort_by=created_at and get either a 400 or a silently-ignored sort. Should be:
| `sort_by` | string | Sort field: `create_time` (default), `execution_time` |
| "create_time": 1706540000, | ||
| "workflow_id": "workflow-uuid", | ||
| "outputs_count": 2, | ||
| "preview_output": {"filename": "output.png", "type": "output"}, | ||
| "execution_start_time": 1706540001000, |
There was a problem hiding this comment.
Timestamp units mismatched in the same payload, and create_time is the wrong unit.
The API actually returns create_time in milliseconds (consistent with execution_start_time and execution_end_time). The example here shows 1706540000 (10 digits = seconds), while execution_start_time in the same object shows 1706540001000 (13 digits = milliseconds).
Clients parsing this as an example will either:
- Treat both fields the same and be off by 1000×, or
- Treat
create_timeas ms (matching the actual response) and display 1970 dates.
Fix the example to use 13-digit ms throughout: "create_time": 1706540000000.
|
|
||
| async function listJobs(options: { | ||
| status?: string; | ||
| output_type?: "image" | "video" | "audio"; |
There was a problem hiding this comment.
output_type enum is missing "3d".
The live API accepts a fourth value, "3d", in addition to image | video | audio. The TypeScript signature here drops it, so anyone copy-pasting this type into their own SDK will get a compile error the moment they try to filter for 3D outputs.
- output_type?: "image" | "video" | "audio";
+ output_type?: "image" | "video" | "audio" | "3d";The Python docstring on line 539 has the same issue.
| if (options.limit !== undefined) params.set("limit", String(options.limit)); | ||
|
|
||
| const response = await fetch(`${BASE_URL}/api/jobs?${params}`, { | ||
| headers: getHeaders(), |
There was a problem hiding this comment.
getHeaders() / get_headers() are referenced but never defined.
The TypeScript example on this line calls getHeaders(); the Python equivalent on line 561 calls get_headers(); the curl block above (line 465) uses -H "X-API-Key: $COMFY_CLOUD_API_KEY". Three different auth conventions in one section, and the two helper-function ones are phantom — nothing in the diff (or earlier on the page) introduces them.
A developer copy-pasting these snippets gets a ReferenceError/NameError. Either define the helpers up front in the page (a one-liner that returns { "X-API-Key": ... }) or inline the header inside each snippet so it matches the curl block.
Same issue at line 600 (getJobDetails) and line 625 (get_job_details).
| interface JobDetailResponse { | ||
| id: string; | ||
| status: "pending" | "in_progress" | "completed" | "failed" | "cancelled"; | ||
| workflow?: Record<string, any>; |
There was a problem hiding this comment.
workflow is typed as Record<string, any> and hides a real footgun.
When the API returns a workflow, sensitive credentials inside extra_data are redacted before the response is sent. Specifically: if the original submission contained extra_data.api_key_comfy_org, the returned value of that field is replaced with the literal string "[REDACTED]". The field is preserved (not removed), so existence checks still pass, but the value is not usable.
A developer reading these docs and round-tripping a returned workflow back into /api/prompt will silently submit "[REDACTED]" as their API key and then debug a confusing auth failure. This is exactly the case where the type comment matters more than the type itself.
At minimum, add a short callout above this interface: "Returned workflows have extra_data.api_key_comfy_org replaced with "[REDACTED]" — strip or replace this field before resubmitting."
| } | ||
|
|
||
| // Get full job details including outputs | ||
| const job = await getJobDetails(promptId); |
There was a problem hiding this comment.
promptId is undefined, and the example silently equates prompt-id with job-id.
promptId (here) and prompt_id (Python, line 631) aren't introduced anywhere on the page. The endpoint is /api/jobs/{job_id} and the path parameter is job_id, but the example passes a variable called promptId — the only reason this works is that the cloud platform happens to use the same UUID for both.
This page never says they're the same value. A developer who got their prompt id from /api/prompt will reasonably assume they need to do a separate lookup to get a job id. Either:
- Rename the variable to
jobId/job_idand show how to obtain it (e.g.const jobId = (await fetch('/api/prompt'…)).prompt_id), or - Add a one-line callout: "The
prompt_idreturned by/api/promptis the same asjob_id."
(The JSON example response above also uses "id": "prompt-uuid" rather than a real UUID, which compounds the confusion — the id field is a UUID in the actual response.)
| </CodeGroup> | ||
|
|
||
| <Note> | ||
| **Legacy Endpoints:** The `/api/history`, `/api/history_v2`, and `/api/queue` endpoints are maintained for compatibility with local ComfyUI but the Jobs API is recommended for new integrations. |
There was a problem hiding this comment.
The compatibility justification is factually wrong, and undersells the actual deprecation status.
Two issues:
-
"maintained for compatibility with local ComfyUI" — local ComfyUI's API surface is
/history,/history/{prompt_id},/queue. There is no/api/prefix and no_v2variant./api/history_v2is a cloud-only endpoint that has no analog in local ComfyUI. So the stated reason for keeping the legacy surface doesn't hold. -
"maintained" is softer than reality. These endpoints are deprecated, and some of them already return 404 redirecting callers to
/api/jobs/{prompt_id}rather than serving the legacy response. A reader of this Note may build new integrations on endpoints that already 404.
Suggested rewrite:
Legacy Endpoints:
/api/history,/api/history_v2, and/api/queueare deprecated and may already return 404 — new integrations must use the Jobs API. Existing integrations should migrate; see migration mapping for field equivalences.
Summary
Updates cloud API documentation to recommend the Jobs API (
/api/jobs) instead of legacy/history,/history_v2, and/queueendpoints.Changes
GET /api/jobs- List jobs with filtering (status, output_type, workflow_id, sorting, pagination)GET /api/jobs/{job_id}- Get full job details including workflow and outputs/api/jobs/{id}instead of/api/history_v2/{id}Related
Notion ticket: COM-13971