# crm.availability_update

Definir disponibilidade de um atendente. Cada um edita a própria; o admin edita a de qualquer atendente. `weekly` substitui por inteiro (faixas HH:MM, início antes do fim, sem sobreposição, até 8 por dia). `slotMinutes` em 5, 10, 15, 20, 30, 45 ou 60. `timezone` é um fuso IANA.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `userId` | string (uuid) \| "me" | não |  |
| `weekly` | object | sim |  |
| `slotMinutes` | number | não |  |
| `timezone` | string | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "userId": {
      "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"
        }
      ]
    },
    "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
    },
    "slotMinutes": {
      "type": "number"
    },
    "timezone": {
      "type": "string",
      "maxLength": 64
    }
  },
  "required": [
    "weekly"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/crm.availability_update \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"weekly":{"mon":[["09:00","12:00"],["14:00","18:00"]]}}'
```

CLI:

```bash
node cli/atomiks.mjs crm.availability_update --json '{"weekly":{"mon":[["09:00","12:00"],["14:00","18:00"]]}}'
```

MCP: ferramenta `crm_availability_update` 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": {
    "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
}
```

## 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).
