Skip to main content
The ExecutionsResource on the Figranium Kotlin SDK gives you full visibility and control over every task run. Use it to list past executions, inspect a single run, clean up history, stop active runs, subscribe to a live Server-Sent Events stream of execution updates, and watch a specific execution by polling for status changes.
ExecutionsResource.kt

Methods

  • HTTP endpoint: GET /api/executions/list (default) or GET /api/executions
  • Signature: suspend fun list(apiKeyRoute: Boolean = true, options: RequestOptions = RequestOptions()): List<Execution>
Returns a list of executions. By default it calls GET /api/executions/list, which is the route intended for API-key access. If you pass apiKeyRoute = false, the SDK switches to GET /api/executions instead.
Most callers should leave apiKeyRoute at its default (true). Only override it when your deployment requires the alternate route.
list_executions.kt
  • HTTP endpoint: GET /api/executions/{id}
  • Signature: suspend fun get(id: String, options: RequestOptions = RequestOptions()): Execution
Fetches a single execution by its ID.
get_execution.kt
  • HTTP endpoint: DELETE /api/executions/{id}
  • Signature: suspend fun delete(id: String, options: RequestOptions = RequestOptions()): JsonObject
Removes a single execution record.
delete_execution.kt
  • HTTP endpoint: POST /api/executions/clear
  • Signature: suspend fun clear(options: RequestOptions = RequestOptions()): JsonObject
Deletes all executions in bulk.
clear_executions.kt
  • HTTP endpoint: POST /api/executions/stop
  • Signature: suspend fun stop(runId: String, options: RequestOptions = RequestOptions()): JsonObject
Sends a stop signal to an active run.
stop_execution.kt
  • HTTP endpoint: GET /api/executions/stream
  • Signature: fun stream(options: RequestOptions = RequestOptions()): Flow<StreamEvent<JsonElement>>
Opens a Server-Sent Events connection and yields each event as it arrives. The stream stays open until the server closes the connection, the consumer stops collecting, or the request is cancelled. The stream sends only accept and auth headers, not default or per-call headers, and uses options.timeoutMillis.For details on the StreamEvent shape and how cancellation works, see Streaming. For error handling, see Errors.
stream_executions.kt
Cancelling the collecting coroutine cancels the stream.
  • HTTP endpoint: GET /api/executions/{id} (polled)
  • Signature: fun watch(executionId: String, intervalMillis: Long = 1_000, options: RequestOptions = RequestOptions()): Flow<Execution>
Polls get at the given interval and yields an Execution only when the status changes. The stream finishes automatically when the execution reaches an outcome or status of success, error, stopped, crashed, or anti_bot. Cancelling the collecting coroutine cancels the polling loop.
watch_execution.kt

End-to-end example

This example lists recent executions, inspects the newest one, and stops it if it is still running.
execution_workflow.kt

Tasks

Create and manage the tasks you execute.

Streaming

Collect execution and selector streams with Flow.

Request options

Pass custom headers and per-request timeouts.

Errors

Handle FigraniumException responses.