SDK reference · Resources
client.approvals
client.approvals.{ list, get, approve, reject, watch }A job pauses in waiting_approval when it wants to write somewhere or pay. Deciding needs a key with approvals:decide; keep it separate from the key that submits jobs.
list
list(options?: ListOptions & { status?: string }): Promise<Page>Approvals the key may see.
Parameters
options{ after?: number; limit?: number }optional- Pagination: pass the previous page's next_cursor as after; limit is 1–200 (default 100).
options.statusstringoptional- Only approvals in this state, such as pending.
Returns Promise<Page>
get
get(id: string): Promise<Resource>One approval and what it would do.
Parameters
idstring- The approval's ID.
Returns Promise<Resource>
approve
approve(id: string, input?: Record<string, unknown>): Promise<Resource>Lets the job go ahead; it resumes where it stopped.
Parameters
idstring- The approval's ID.
inputRecord<string, unknown>optional- Details some approvals take, such as a payment's amount.
Returns Promise<Resource>
reject
reject(id: string, input?: Record<string, unknown>): Promise<Resource>Refuses the action; the job carries on without it.
Parameters
idstring- The approval's ID.
inputRecord<string, unknown>optional- A reason, where the approval takes one.
Returns Promise<Resource>
watch
watch(handle: (approval: Resource) => void | Promise<void>, options: WatchOptions): { check(): void; done: Promise<void> }Calls handle with each pending approval every pollMs, until signal aborts. Call check() to look at once, for example when jobs.progress reports an approval. An approval is handed over on every pass until it is decided, so remember which ones you have shown.
Parameters
handle(approval: Resource) => void | Promise<void>- Shows the approval. One that throws doesn't stop the rest.
options.signalAbortSignal- Stops watching.
options.pollMsnumberoptional- Time between looks (default 3 s).
options.onError(error: unknown) => voidoptional- A failed read or handler; watching carries on.
Returns { check(): void; done: Promise<void> }