# crm.opportunity_move

Mover oportunidade de etapa. Move o card para uma etapa da mesma pipeline, antes do card `beforeId` (ou no fim). Ganho/Perdido ajustam `status`, `wonAt`/`lostAt`; `lostReason` só vale ao mover para Perdido.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `id` | string (uuid) | sim |  |
| `stageId` | string (uuid) | sim |  |
| `beforeId` | string (uuid) | não |  |
| `lostReason` | string | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "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)$"
    },
    "stageId": {
      "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)$"
    },
    "beforeId": {
      "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)$"
    },
    "lostReason": {
      "type": "string",
      "maxLength": 200
    }
  },
  "required": [
    "id",
    "stageId"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.opportunity_move \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id":"00000000-0000-0000-0000-000000000000","stageId":"00000000-0000-0000-0000-000000000000"}'
```

CLI:

```bash
node cli/atomiks.mjs crm.opportunity_move --json '{"id":"00000000-0000-0000-0000-000000000000","stageId":"00000000-0000-0000-0000-000000000000"}'
```

MCP: ferramenta `crm_opportunity_move` 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": {
    "id": {
      "type": "string"
    },
    "pipelineId": {
      "type": "string"
    },
    "stageId": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "won",
        "lost"
      ]
    },
    "title": {
      "type": "string"
    },
    "valueCents": {
      "type": [
        "number",
        "null"
      ]
    },
    "product": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "contact": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "phone": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "phone"
      ],
      "additionalProperties": false
    },
    "owner": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "openTasks": {
      "type": "number"
    },
    "updatedAt": {
      "type": "string"
    },
    "priority": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "low",
            "normal",
            "high",
            "urgent"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "expectedCloseDate": {
      "type": [
        "string",
        "null"
      ]
    },
    "probability": {
      "type": [
        "number",
        "null"
      ]
    },
    "origin": {
      "type": [
        "string",
        "null"
      ]
    },
    "lostReason": {
      "type": [
        "string",
        "null"
      ]
    },
    "company": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "pipelineId",
    "stageId",
    "status",
    "title",
    "valueCents",
    "product",
    "contact",
    "owner",
    "openTasks",
    "updatedAt",
    "priority",
    "expectedCloseDate",
    "probability",
    "origin",
    "lostReason",
    "company"
  ],
  "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).
