# scheduling.availability_preview

Pré-visualizar os horários de uma agenda. Horários livres de uma agenda ainda não salva, para a prévia do formulário. `scheduleDraft`: `durationMinutes` e os limites (`bufferMinutes`, `minNoticeMinutes`, `maxAdvanceDays`, `maxBookingsPerDay`, `maxBookingsPerMemberPerDay`) e quem atende: `memberIds` (o roster), ou `attendantId`, ou `teamId` (todo o time). Para `schedulingType` `group`, `sessionRules` são as sessões. `from` e `to` (AAAA-MM-DD, no máximo 62 dias, no fuso do negócio). Devolve `days` (dias com horário livre) e `slots` (`startAt`/`endAt` ISO e `memberIds` livres), no mesmo cálculo de `scheduling.available_slots`: horário semanal e exceções de `attendants.availability_*`, menos as reuniões já marcadas (tarefas `meeting`), com folga de `bufferMinutes`.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `scheduleDraft` | object | sim |  |
| `from` | string | sim |  |
| `to` | string | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "scheduleDraft": {
      "type": "object",
      "properties": {
        "durationMinutes": {
          "type": "integer",
          "minimum": 5,
          "maximum": 480
        },
        "bufferMinutes": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 1440
            },
            {
              "type": "null"
            }
          ]
        },
        "minNoticeMinutes": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 525600
            },
            {
              "type": "null"
            }
          ]
        },
        "maxAdvanceDays": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 365
            },
            {
              "type": "null"
            }
          ]
        },
        "maxBookingsPerDay": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000
            },
            {
              "type": "null"
            }
          ]
        },
        "maxBookingsPerMemberPerDay": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000
            },
            {
              "type": "null"
            }
          ]
        },
        "schedulingType": {
          "type": "string",
          "enum": [
            "individual",
            "group",
            "round_robin"
          ]
        },
        "memberIds": {
          "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)$"
          }
        },
        "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)$"
        },
        "teamId": {
          "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)$"
        },
        "sessionRules": {
          "maxItems": 100,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "dayOfWeek": {
                "type": "integer",
                "minimum": 0,
                "maximum": 6
              },
              "startTime": {
                "type": "string",
                "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
              }
            },
            "required": [
              "dayOfWeek",
              "startTime"
            ]
          }
        }
      },
      "required": [
        "durationMinutes"
      ]
    },
    "from": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "to": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    }
  },
  "required": [
    "scheduleDraft",
    "from",
    "to"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/scheduling.availability_preview \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scheduleDraft":{"durationMinutes":30,"bufferMinutes":10,"attendantId":"00000000-0000-0000-0000-000000000000"},"from":"2026-11-01","to":"2026-11-30"}'
```

CLI:

```bash
node cli/atomiks.mjs scheduling.availability_preview --json '{"scheduleDraft":{"durationMinutes":30,"bufferMinutes":10,"attendantId":"00000000-0000-0000-0000-000000000000"},"from":"2026-11-01","to":"2026-11-30"}'
```

MCP: ferramenta `scheduling_availability_preview` 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": {
    "timezone": {
      "type": "string"
    },
    "days": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "slots": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "startAt": {
            "type": "string"
          },
          "endAt": {
            "type": "string"
          },
          "memberIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "startAt",
          "endAt",
          "memberIds"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "timezone",
    "days",
    "slots"
  ],
  "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).
