# crm.agenda_get

Agenda de um responsável (blocos ocupados). Tarefas e reuniões do responsável com horário entre `from` e `to` (até 14 dias), para desenhar a linha do dia e achar conflitos. Conta tudo da conta, inclusive de contatos que o chamador não vê: nesses, `title` e `contactId` vêm `null` (só o bloco ocupado). Sem `durationMinutes` o bloco conta 30 min; `allDay` ocupa o dia. Traz também a disponibilidade.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/crm.agenda_get` (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_agenda_get`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `crm.agenda_get`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `assigneeId` | string (uuid) \| "me" | não |  |
| `from` | string (date-time) | sim |  |
| `to` | string (date-time) | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "assigneeId": {
      "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": "string",
          "const": "me"
        }
      ]
    },
    "from": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "to": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    }
  },
  "required": [
    "from",
    "to"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.agenda_get \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"assigneeId":"me","from":"2026-10-24T00:00:00-03:00","to":"2026-10-25T00:00:00-03:00"}'
```

CLI:

```bash
node cli/atomiks.mjs crm.agenda_get --json '{"assigneeId":"me","from":"2026-10-24T00:00:00-03:00","to":"2026-10-25T00:00:00-03:00"}'
```

MCP: ferramenta `crm_agenda_get` 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": {
    "availability": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string"
        },
        "configured": {
          "type": "boolean"
        },
        "timezone": {
          "type": "string"
        },
        "slotMinutes": {
          "type": "number"
        },
        "weekly": {
          "type": "object",
          "properties": {
            "mon": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            },
            "tue": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            },
            "wed": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            },
            "thu": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            },
            "fri": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            },
            "sat": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            },
            "sun": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "array",
                "prefixItems": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string"
                  }
                ],
                "items": false,
                "minItems": 2,
                "maxItems": 2
              }
            }
          },
          "additionalProperties": false
        }
      },
      "required": [
        "userId",
        "configured",
        "timezone",
        "slotMinutes",
        "weekly"
      ],
      "additionalProperties": false
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "taskId": {
            "type": "string"
          },
          "dueAt": {
            "type": "string"
          },
          "durationMinutes": {
            "type": "number"
          },
          "allDay": {
            "type": "boolean"
          },
          "kind": {
            "type": "string",
            "enum": [
              "todo",
              "call",
              "message",
              "meeting"
            ]
          },
          "done": {
            "type": "boolean"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "contactId": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "taskId",
          "dueAt",
          "durationMinutes",
          "allDay",
          "kind",
          "done",
          "title",
          "contactId"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "availability",
    "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).
