# calendars.create

Criar calendário de atendimento. Cria um calendário. O primeiro da conta vira o principal; `isDefault: true` troca o principal.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `name` | string | sim |  |
| `timezone` | string | não |  |
| `isDefault` | boolean | não |  |
| `weekly` | object | não |  |
| `exceptions` | object[] | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "timezone": {
      "type": "string",
      "maxLength": 64
    },
    "isDefault": {
      "type": "boolean"
    },
    "weekly": {
      "type": "object",
      "properties": {
        "mon": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "tue": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "wed": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "thu": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "fri": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "sat": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "sun": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        }
      },
      "additionalProperties": false
    },
    "exceptions": {
      "maxItems": 366,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "mode": {
            "type": "string",
            "enum": [
              "closed",
              "open",
              "range"
            ]
          },
          "start": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          },
          "end": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          }
        },
        "required": [
          "date",
          "mode"
        ]
      }
    }
  },
  "required": [
    "name"
  ]
}
```

</details>

## Exemplo

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

CLI:

```bash
node cli/atomiks.mjs calendars.create --json '{"name":"Comercial","weekly":{"mon":[["09:00","18:00"]]}}'
```

MCP: ferramenta `calendars_create` 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": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "timezone": {
      "type": "string"
    },
    "isDefault": {
      "type": "boolean"
    },
    "weekly": {
      "type": "object",
      "properties": {
        "mon": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "tue": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "wed": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "thu": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "fri": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "sat": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        },
        "sun": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              },
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        }
      },
      "additionalProperties": false
    },
    "exceptions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "mode": {
            "type": "string",
            "enum": [
              "closed",
              "open",
              "range"
            ]
          },
          "start": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          },
          "end": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
          }
        },
        "required": [
          "date",
          "mode"
        ],
        "additionalProperties": false
      }
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "timezone",
    "isDefault",
    "weekly",
    "exceptions",
    "createdAt",
    "updatedAt"
  ],
  "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).
