---
title: "Run a command inside a briq"
method: POST
path: "/v1/briqs/{id}/exec"
tags: ["briqs"]
---

# Run a command inside a briq

`POST /v1/briqs/{id}/exec`

## Request

- Base URL: `https://api.briq.cloud`
- URL: `https://api.briq.cloud/v1/briqs/{id}/exec`
- Auth: HTTP bearer

Runs the command and answers with its output, for up to 60 s. With `async: true`, starts it and answers at once (202) with an exec to check, read and stop later: for anything that can take longer. Async needs sh in the image.

## Path parameters

- `id` string, required

## Request body

- object
  - `cmd` string[], required: argv, run without a shell: ["sh", "-c", "…"] for pipes, globs or $VARS
  - `timeoutMs` integer: Without async: 60000 by default and at most. With async: when to stop it, 3600000 (1 h) by default, 86400000 (24 h) at most
  - `stdin` string: Fed to the command's standard input
  - `async` boolean: Start the command and answer at once with an exec to check later (GET /briqs/{id}/execs/{execId}): for anything that can take over a minute. Needs sh in the image

## Response `200`

ok

- object
  - `stdout` string, required
  - `stderr` string, required
  - `exitCode` number, required
  - `timedOut` boolean, required
  - `costLine` string, required
  - `warning` string: Set when timeoutMs was over 60000 without async: it ran with 60000

## Other responses

- `202`: started: check it with GET /briqs/{id}/execs/{execId}
- `400`: validation
- `401`: unauthorized
- `402`: policy_violation or quota_exceeded (the key's policy), or payment_required (no credits: retrying cannot help)
- `403`: forbidden, or plan_limit (the team's plan does not allow it)
- `404`: not found
- `409`: invalid_state: not possible in the briq's current state; the message says why
- `413`: validation: the body, the command or its output is too large
- `429`: rate limited: retry after the `retry-after` header
- `502`: provider_error: the infrastructure refused the change
- `503`: provider_error: the infrastructure did not answer; retry in a moment

---

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