# pipelines.stages_reorder

Reordenar as etapas abertas de um pipeline. Define a ordem das etapas abertas (`stageIds`, todas as abertas do pipeline, sem repetir); Ganho e Perdido ficam sempre no fim.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/pipelines.stages_reorder` (corpo JSON)
- Quem pode chamar: administrador da conta
- Escopo da chave: `crm:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `pipelines_stages_reorder`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `pipelines.stages_reorder`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `pipelineId` | string (uuid) | sim |  |
| `stageIds` | string (uuid)[] | sim |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "pipelineId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "stageIds": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
      }
    }
  },
  "required": [
    "pipelineId",
    "stageIds"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/pipelines.stages_reorder \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pipelineId":"00000000-0000-0000-0000-000000000000","stageIds":["00000000-0000-0000-0000-000000000000"]}'
```

CLI:

```bash
node cli/atomiks.mjs pipelines.stages_reorder --json '{"pipelineId":"00000000-0000-0000-0000-000000000000","stageIds":["00000000-0000-0000-0000-000000000000"]}'
```

MCP: ferramenta `pipelines_stages_reorder` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "pipelineId": {
      "type": "string"
    },
    "stageIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "pipelineId",
    "stageIds"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
