Skip to content

Commit 9c36400

Browse files
feat(api): POST /api/v2/workflows/[id]/execute
Thin route over executeWorkflowService: X-API-Key or anonymous public-API auth (sync/stream only for anonymous), strict body with body-flag async (no mode headers on v2), SSE passthrough for stream, and the execution resource response — executionId always present, in-band run failures are status:'failed' with the structured {message, code, blockId, blockName, blockType} error, sync timeout is status:'failed' + TIMEOUT instead of v1's 408, and a Response block's payload stays inside output (authors never control response status/headers on this origin). Async debits the async bucket and the 202 statusUrl points at the v2 executions resource. Adds CLIENT_CLOSED_REQUEST/SERVICE_UNAVAILABLE to the v2 error codes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CiHhAk2R1NryaS3R8n2yFz
1 parent 4320fed commit 9c36400

5 files changed

Lines changed: 979 additions & 1 deletion

File tree

apps/sim/app/api/v2/lib/response.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export type V2ErrorCode =
2222
| 'USAGE_LIMIT_EXCEEDED'
2323
| 'LOCKED'
2424
| 'RATE_LIMITED'
25+
| 'CLIENT_CLOSED_REQUEST'
2526
| 'INTERNAL_ERROR'
27+
| 'SERVICE_UNAVAILABLE'
2628

2729
const STATUS_BY_CODE: Record<V2ErrorCode, number> = {
2830
BAD_REQUEST: 400,
@@ -35,7 +37,9 @@ const STATUS_BY_CODE: Record<V2ErrorCode, number> = {
3537
UNSUPPORTED_MEDIA_TYPE: 415,
3638
LOCKED: 423,
3739
RATE_LIMITED: 429,
40+
CLIENT_CLOSED_REQUEST: 499,
3841
INTERNAL_ERROR: 500,
42+
SERVICE_UNAVAILABLE: 503,
3943
}
4044

4145
/**

0 commit comments

Comments
 (0)