task API:
GET /api/v1/task/{workspaceId}/{taskId} with a Beam bearer token. Obtain the workspace ID from /api/v1/workspace/current. The workspace and api.beam.cloud/v2 responses are different representations; do not assume their fields are interchangeable. See workspace REST.
Getting the Task ID
- Task queues return the ID when you submit a task, as
{"task_id": "edbcf7ff-e8ce-4199-8661-8e15ed880481"}. See Running Tasks. - Endpoints and ASGI apps return it in the
X-Task-Idresponse header. beam task listshows the IDs of recent tasks, and inside your handler the ID is available ascontext.task_id.
Task Statuses
Your payload will return the status of the task. These are the possible statuses for a task:Request
Response
The response to/task returns the following data:
Here’s what the response payload looks like as JSON:
The per-task cost shown in the dashboard isn’t returned by this API. See Task
Cost for how to estimate
it.
Waiting for a Task to Finish
Poll the API until the status is no longerPENDING, RUNNING, or RETRY:
Client.get_task_by_id() returns a task object that can wait for the result:
Cancelling Tasks
Tasks can be cancelled through theapi.beam.cloud/v2/task/cancel/ endpoint.
Request
Response
200