---
title: "Run an agent (async; read its status from /v1/agent-runs/{id})"
method: POST
path: "/v1/agents/{slug}/runs"
tags: ["agents"]
---

# Run an agent (async; read its status from /v1/agent-runs/{id})

`POST /v1/agents/{slug}/runs`

## Request

- Base URL: `https://barchin.net/api`
- URL: `https://barchin.net/api/v1/agents/{slug}/runs`
- Auth: HTTP bearer

## Path parameters

- `slug` string, required

## Query parameters

- `wait` integer: 0 = async. N > 0 = wait up to N seconds for the result.

## Request body

- AgentRunCreateIn
  - `input` object, required: ورودی ایجنت؛ شکل آن در input_schema همان ایجنت آمده است.
  - `webhook_url` string, uri, nullable: فقط برای برنامه‌های متصل (OAuth): آدرس https روی یکی از دامنه‌های ثبت‌شده‌ی برنامه؛ پایان اجرا (موفق یا ناموفق) با امضای HMAC به آن POST می‌شود.

## Response `202`

Successful Response

- AgentRunOut
  - `id` string, uuid, required
  - `agent_slug` string, required
  - `status` string, required
  - `input` object, required
  - `credits_held` integer, required
  - `credits_charged` integer, nullable, required
  - `refunded_credits` integer, required
  - `children_credits` integer, required
  - `model` string, nullable, required
  - `tokens_in` integer, nullable, required
  - `tokens_out` integer, nullable, required
  - `cost_breakdown` object, nullable
  - `error_code` string, nullable, required
  - `error_message` string, nullable, required
  - `created_at` string, date-time, required
  - `started_at` string, date-time, nullable, required
  - `finished_at` string, date-time, nullable, required
  - `children` AgentRunChildOut[], required
    - `position` integer, required
    - `kind` string, required
    - `label` string, required
    - `id` string, uuid, nullable, required
    - `status` string, nullable, required
    - `credits_charged` integer, nullable, required
    - `url` string, nullable, required
    - `actor_slug` string, nullable, required
    - `agent_slug` string, nullable
    - `error_code` string, nullable, required
  - `output` object, nullable, required
  - `webhook_url` string, nullable
  - `webhook_status` string, nullable

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `422`: Unprocessable Entity
- `429`: Too Many Requests

---

[API](https://skmtc.dev/barchin/apis/barchin-scraping-api.md) · [All operations](https://skmtc.dev/barchin/apis/barchin-scraping-api/llms.txt) · [OpenAPI document](https://skmtc.dev/barchin/apis/barchin-scraping-api/revisions/fe97e4690cc3?raw)
