---
title: "Executar um comando no workspace"
description: "Execute um comando de shell em uma cópia de trabalho do rascunho do site, em seu próprio contêiner."
canonical: "https://atelier201.com/docs/pt/api/workspace/run"
updated: "2026-11-06"
---

# Executar um comando no workspace

Requer `sites:write`. Não custa créditos. O caminho termina em `/workspace:run`.

O workspace é um shell em uma cópia de trabalho do rascunho do site, dentro do próprio contêiner do site e sem conexão com a internet. Use-o para tarefas que um shell executa bem: `rg`, `grep`, `find`, `cat`, `sed -i`, `node` e `npx astro build` para testar uma compilação em segundos. O comando é executado na raiz do projeto como um usuário sem privilégios, e não há acesso à rede.

As alterações feitas pelo comando permanecem sem commit. A resposta lista essas alterações em `uncommitted`, uma por linha, no estilo de `git status` (`M src/pages/index.astro`). Nada é adicionado ao histórico até você [fazer commit do workspace](/docs/api/workspace/commit), e os visitantes não veem nada até você publicar.

`command` pode ter no máximo 8000 caracteres. `timeout_ms` deve estar entre 1000 e 300000 e, por padrão, é 60000: se o comando ainda estiver em execução nesse momento, ele será interrompido e `timed_out` será `true`. Uma falha no comando não é um erro da API: a chamada é bem-sucedida e `exit_code` não é 0. `output` reúne stdout e stderr; acima de 8 KB, mantém o início e o fim, e `truncated` será `true`.

O workspace acompanha o rascunho. Se outra alteração tiver modificado o rascunho desde seu último comando, suas edições sem commit serão preservadas e `note` informará isso. O mesmo vale quando o workspace precisa ser recriado.

Um site que ainda está sendo criado responde com `result_not_ready`; um site suspenso ou em processo de exclusão responde com `conflict`.

```http
POST https://api.atelier201.com/v1/sites/{site_id}/workspace:run
```

## Authorizations

- `Authorization` (bearer, in header, required)

## Path parameters

- `site_id` (`string`, required): O id do site ou seu slug (o endereço antes de .atelier201.page).

## Body

`application/json`, required

- `command` (`string`, required, length: `1–8000 chars`): Um comando bash executado na raiz do projeto, em uma cópia de trabalho do rascunho: rg, grep, sed, find, cat, node... Sem rede. Os arquivos alterados permanecem sem commit até `workspace:commit`, que os compila e informa qualquer erro de compilação. A compilação do projeto é recusada aqui: levou 30 s e duplicou essa compilação.
- `timeout_ms` (`integer`, range: `1000–300000`): Padrão: 60000. O comando é interrompido ao ultrapassar esse limite.

## Response

**200**: Execute um comando shell no workspace do site

- `data` (`object`, required)
- `data.revision` (`string`, required, length: `40–40 chars`): A revisão do rascunho a partir da qual o workspace foi iniciado.
- `data.exit_code` (`integer`, required, range: `-9007199254740991–9007199254740991`)
- `data.timed_out` (`boolean`, required)
- `data.output` (`string`, required): stdout e stderr juntos; acima de 8 KB, mostra o início e o fim.
- `data.truncated` (`boolean`, required)
- `data.uncommitted` (`string[]`, required): As alterações sem commit do workspace após o comando, no estilo de git status ("M src/pages/index.astro").
- `data.note` (`string,null`, required): Informado quando o workspace foi recriado ou atualizado para um rascunho mais recente antes do comando.
- `request_id` (`string`, required)

```json
{
  "data": {
    "revision": "<string>",
    "exit_code": 123,
    "timed_out": true,
    "output": "<string>",
    "truncated": true,
    "uncommitted": [
      "<string>"
    ],
    "note": null
  },
  "request_id": "<string>"
}
```

**400**: Códigos possíveis: invalid_request, unknown_field, invalid_parameter, invalid_cursor

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**401**: Códigos possíveis: authentication_required, invalid_api_key, api_key_expired, api_key_revoked

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**402**: Códigos possíveis: insufficient_credits

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**403**: Códigos possíveis: insufficient_scope, feature_not_available, admin_required

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**404**: Códigos possíveis: resource_not_found

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**409**: Códigos possíveis: conflict, result_not_ready, idempotency_key_reused

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**410**: Códigos possíveis: result_expired

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**413**: Códigos possíveis: request_too_large

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**422**: Códigos possíveis: request_too_large_for_plan

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**429**: Códigos possíveis: rate_limited

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**500**: Códigos possíveis: internal_error

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**503**: Códigos possíveis: service_unavailable

- `error` (`object`, required)
- `error.type` (`string`, required)
- `error.code` (`string`, required)
- `error.message` (`string`, required)
- `error.param` (`string`)
- `error.docs_url` (`string`, required)
- `error.action_url` (`string<uri>`)
- `error.details` (`Record<string, object>`)
- `request_id` (`string`, required)

```json
{
  "error": {
    "type": "<string>",
    "code": "<string>",
    "message": "<string>",
    "param": "<string>",
    "docs_url": "<string>",
    "action_url": "<string>",
    "details": {}
  },
  "request_id": "<string>"
}
```

**Example request**

```bash
curl --request POST \
  --url 'https://api.atelier201.com/v1/sites/<site_id>/workspace:run' \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "command": "<string>"
}'
```
