---
title: "Create or wait for a script workflow agent task step"
method: POST
path: "/api/internal/script-runs/{runId}/agent-task"
tags: ["Script Runs"]
---

# Create or wait for a script workflow agent task step

`POST /api/internal/script-runs/{runId}/agent-task`

## Path parameters

- `runId` string, uuid, required

## Request body

- object
  - `stepKey` string, required
  - `template` string
  - `task` string
  - `agentId` string
  - `tags` string[]
  - `priority` integer
  - `offerMode` boolean
  - `dir` string
  - `vcsRepo` string
  - `model` string
  - `parentTaskId` string, uuid
  - `requestedByUserId` string
  - `outputSchema` object

## Response `200`

Agent task completed

- object
  - `taskId` string, required
  - `taskOutput` string, nullable, required

## Other responses

- `202` — Agent task created or still running
- `404` — Script run not found

---

[API](https://skmtc.net/desplega-ai/apis/agent-swarm-api.md) · [All operations](https://skmtc.net/desplega-ai/apis/agent-swarm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/desplega-ai/agent-swarm-api/versions/ef761849166b/schema)
