Task Agent
API quickstart
Create a key, submit a task, and read execution results.
Use a personal API key to submit tasks from your server and follow progress through events. This guide uses the same public contract as the in-product Task Agent API documentation.
Prepare the URL and key
Create a personal key on the Manage API keys page. Task submission needs prompts:write; sessions and events need sessions:read. Save the full key and set these variables in your terminal:
export HAST_API_BASE='https://backend.hast.so/api/public/v1'
export HAST_API_KEY='<YOUR_PERSONAL_API_KEY>'Submit your first task
curl --fail-with-body --request POST \
--url "$HAST_API_BASE/prompts" \
--header "Authorization: Bearer $HAST_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"request_id":"req_123","prompt":"Summarize the latest workspace files."}'This asks the Agent to summarize workspace files. Replace prompt with your requirements.
Omitting session_id creates a session; sending the same identifier later continues it. request_id provides idempotency; use a new value for each new turn.
The API returns HTTP 202 after acceptance. Save session_id from the response and keep reading events for the outcome. See the API reference for complete fields and responses.
Read execution progress
Set the returned identifier as SESSION_ID:
export SESSION_ID='<SESSION_ID_FROM_RESPONSE>'
curl -N --fail-with-body \
"$HAST_API_BASE/sessions/$SESSION_ID/events/stream?after=0" \
--header "Authorization: Bearer $HAST_API_KEY" \
--header 'Accept: text/event-stream'SSE carries HAST Event v2. Display messages, tool progress, and run results according to event type. message.completed completes a message; use run events to determine whether the whole turn has ended. See event streaming.
Continue integration
The API reference covers sessions, files, Skills, memory, connectors, and secrets. Expand an endpoint for parameters and response schemas, or download OpenAPI JSON for tools supporting Swagger / OpenAPI 2.0.