# pipelines.board

Quadro de oportunidades com filtros. Como `crm.board` (pipeline, cards por etapa em ordem, totais por etapa e próxima ação), com a consulta do quadro: busca `q`, status (`open`, `won`, `lost`, `all`), atendentes, safra (`AAAA-MM` ou `AAAA-Www`, pela criação), filtros simples (prioridade, origem, tags, produtos, empresas, contatos, valor, previsão), ordem dos cards e o filtro avançado `filter`: grupos "todas/qualquer" ligados por E/OU, com os campos de Oportunidade, Datas, Pipeline, Relações, Tarefa e `lead` (filtro de contato). Os totais e as contagens já refletem o filtro.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `q` | string | não |  |
| `attendantId` | string (uuid) | não |  |
| `attendantIds` | string (uuid)[] | não |  |
| `cohort` | string | não |  |
| `status` | "open" \| "won" \| "lost" \| "all" | não |  |
| `filter` | object[] | não |  |
| `priorities` | "low" \| "normal" \| "high" \| "urgent"[] | não |  |
| `origins` | string[] | não |  |
| `tagIds` | string (uuid)[] | não |  |
| `productIds` | string (uuid)[] | não |  |
| `companyIds` | string (uuid)[] | não |  |
| `contactIds` | string (uuid)[] | não |  |
| `valueMinCents` | integer | não |  |
| `valueMaxCents` | integer | não |  |
| `expectedClosingDateFrom` | string | não |  |
| `expectedClosingDateTo` | string | não |  |
| `cardOrder` | "manual" \| "createdAtDesc" \| "createdAtAsc" \| "stageTimeAsc" \| "stageTimeDesc" | não |  |
| `pipelineId` | string (uuid) | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "q": {
      "type": "string",
      "maxLength": 120
    },
    "attendantId": {
      "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)$"
    },
    "attendantIds": {
      "maxItems": 200,
      "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)$"
      }
    },
    "cohort": {
      "type": "string",
      "maxLength": 64
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "won",
        "lost",
        "all"
      ]
    },
    "filter": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "matcher": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ]
          },
          "connector": {
            "type": "string",
            "enum": [
              "and",
              "or"
            ]
          },
          "conditions": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string",
                  "maxLength": 60
                },
                "operator": {
                  "type": "string",
                  "maxLength": 30
                },
                "value": {
                  "anyOf": [
                    {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 4000
                        },
                        {
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "maxLength": 200
                          }
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "lead": {
                  "maxItems": 200,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "maxLength": 64
                      },
                      "order": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1000
                      },
                      "field": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "operator": {
                        "type": "string",
                        "maxLength": 30
                      },
                      "negation": {
                        "default": false,
                        "type": "boolean"
                      },
                      "parentId": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 64
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "valueString": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 4000
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "valueNumber": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "valueDate": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 40
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "valueBool": {
                        "type": [
                          "boolean",
                          "null"
                        ]
                      },
                      "valueUuid": {
                        "anyOf": [
                          {
                            "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)$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "field",
                      "operator"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "field",
                "operator"
              ]
            }
          }
        },
        "required": [
          "matcher",
          "connector",
          "conditions"
        ]
      }
    },
    "priorities": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "low",
          "normal",
          "high",
          "urgent"
        ]
      }
    },
    "origins": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 120
      }
    },
    "tagIds": {
      "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)$"
      }
    },
    "productIds": {
      "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)$"
      }
    },
    "companyIds": {
      "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)$"
      }
    },
    "contactIds": {
      "maxItems": 500,
      "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)$"
      }
    },
    "valueMinCents": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "valueMaxCents": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "expectedClosingDateFrom": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "expectedClosingDateTo": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "cardOrder": {
      "type": "string",
      "enum": [
        "manual",
        "createdAtDesc",
        "createdAtAsc",
        "stageTimeAsc",
        "stageTimeDesc"
      ]
    },
    "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)$"
    }
  },
  "required": [
    "pipelineId"
  ]
}
```

</details>

## Exemplo

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

CLI:

```bash
node cli/atomiks.mjs pipelines.board --json '{"pipelineId":"00000000-0000-0000-0000-000000000000","status":"open","priorities":["high"]}'
```

MCP: ferramenta `pipelines_board` 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": {
    "pipeline": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "groupName": {
          "type": [
            "string",
            "null"
          ]
        },
        "isDefault": {
          "type": "boolean"
        },
        "stages": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "enum": [
                  "open",
                  "won",
                  "lost"
                ]
              },
              "position": {
                "type": "number"
              },
              "capiEvent": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "name",
              "kind",
              "position",
              "capiEvent"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "id",
        "name",
        "groupName",
        "isDefault",
        "stages"
      ],
      "additionalProperties": false
    },
    "cards": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "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
        }
      }
    },
    "totals": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number"
          },
          "valueCents": {
            "type": "number"
          }
        },
        "required": [
          "count",
          "valueCents"
        ],
        "additionalProperties": false
      }
    },
    "nextTasks": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "dueAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "type": "string"
          },
          "assignee": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "title",
          "dueAt",
          "kind",
          "assignee"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "pipeline",
    "cards",
    "totals"
  ],
  "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).
