# crm.opportunities_list

Oportunidades de um contato. Todas as oportunidades do contato, da mais recente para a mais antiga.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `contactId` | string (uuid) | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contactId": {
      "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": [
    "contactId"
  ]
}
```

</details>

## Exemplo

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

CLI:

```bash
node cli/atomiks.mjs crm.opportunities_list --json '{"contactId":"00000000-0000-0000-0000-000000000000"}'
```

MCP: ferramenta `crm_opportunities_list` 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": {
    "items": {
      "type": "array",
      "items": {
        "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
      }
    }
  },
  "required": [
    "items"
  ],
  "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).
