> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goyappr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update call time windows

> Atomically replaces the call window configuration. Send any combination
of `inbound_enabled`, `outbound_enabled`, and `windows`. Omitting
`windows` leaves the existing schedule unchanged; including it (even as
an empty array) overwrites the whole schedule.

Window rules:
- `day_of_week` is 0–6 (0=Sunday … 6=Saturday).
- `start_time` and `end_time` are `HH:MM` (24h, workspace timezone).
- `start_time` must be earlier than `end_time` (no overnight wrap-around — use two rows on consecutive days instead).
- Multiple windows per day are allowed but must not overlap.


Atomically replaces the call window configuration. Send any combination of `inbound_enabled`, `outbound_enabled`, and `windows`:

* Omitting `windows` leaves the existing schedule unchanged.
* Including `windows` (even as an empty array) overwrites the entire schedule for every day of the week.

Any authenticated API key for the workspace can call this — no specific scope is required.

## Window rules

* `day_of_week` is `0`–`6` (`0` = Sunday, `6` = Saturday).
* `start_time` and `end_time` are `HH:MM` strings in 24-hour format. They are evaluated in the workspace timezone (`companies.timezone`, editable from the Company settings tab).
* `start_time` must be strictly earlier than `end_time` — there is no overnight wrap-around. To express a window that crosses midnight, use two entries on consecutive days (e.g. `{ day_of_week: 4, start_time: "22:00", end_time: "23:59" }` and `{ day_of_week: 5, start_time: "00:00", end_time: "02:00" }`).
* Multiple windows per day are allowed but they must not overlap.

## Example request

```bash theme={null}
# Switch to a Sun–Thu, 09:00–13:00 + 14:00–18:00 schedule. Friday + Saturday closed.
curl -X PUT "https://api.goyappr.com/call-windows" \
  -H "Authorization: Bearer $YAPPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "outbound_enabled": true,
    "inbound_enabled": false,
    "windows": [
      { "day_of_week": 0, "start_time": "09:00", "end_time": "13:00" },
      { "day_of_week": 0, "start_time": "14:00", "end_time": "18:00" },
      { "day_of_week": 1, "start_time": "09:00", "end_time": "13:00" },
      { "day_of_week": 1, "start_time": "14:00", "end_time": "18:00" },
      { "day_of_week": 2, "start_time": "09:00", "end_time": "13:00" },
      { "day_of_week": 2, "start_time": "14:00", "end_time": "18:00" },
      { "day_of_week": 3, "start_time": "09:00", "end_time": "13:00" },
      { "day_of_week": 3, "start_time": "14:00", "end_time": "18:00" },
      { "day_of_week": 4, "start_time": "09:00", "end_time": "13:00" },
      { "day_of_week": 4, "start_time": "14:00", "end_time": "18:00" }
    ]
  }'
```

## Example response

The response mirrors `GET /call-windows` so clients can update state without a follow-up read:

```json theme={null}
{
  "timezone": "Asia/Jerusalem",
  "inbound_enabled": false,
  "outbound_enabled": true,
  "windows": [
    { "day_of_week": 0, "start_time": "09:00", "end_time": "13:00" },
    { "day_of_week": 0, "start_time": "14:00", "end_time": "18:00" }
  ]
}
```

## Disabling windows entirely

To stop gating outbound calls without losing your schedule, set the toggle off and omit `windows`:

```bash theme={null}
curl -X PUT "https://api.goyappr.com/call-windows" \
  -H "Authorization: Bearer $YAPPR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "outbound_enabled": false }'
```

To make a day fully closed, simply omit any windows for that `day_of_week`. To close every day, pass `"windows": []`.

## Errors

| HTTP | Code                   | When                                                                                   |
| ---- | ---------------------- | -------------------------------------------------------------------------------------- |
| 400  | `INVALID_CALL_WINDOWS` | Two ranges on the same day overlap, or `start_time` is not strictly before `end_time`. |
| 400  | —                      | `day_of_week` is outside `0..6`, or a time is not `HH:MM`.                             |
| 401  | —                      | Missing or invalid API key.                                                            |


## OpenAPI

````yaml PUT /call-windows
openapi: 3.1.0
info:
  title: Yappr API
  description: >
    Create and manage AI voice agents, purchase phone numbers, configure tools,
    and initiate calls — all via REST.
  version: 1.0.0
  contact:
    url: https://goyappr.com
servers:
  - url: https://api.goyappr.com
    description: Production
security:
  - apiKey: []
paths:
  /call-windows:
    put:
      tags:
        - Call Windows
      summary: Replace call time windows
      description: >
        Atomically replaces the call window configuration. Send any combination

        of `inbound_enabled`, `outbound_enabled`, and `windows`. Omitting

        `windows` leaves the existing schedule unchanged; including it (even as

        an empty array) overwrites the whole schedule.


        Window rules:

        - `day_of_week` is 0–6 (0=Sunday … 6=Saturday).

        - `start_time` and `end_time` are `HH:MM` (24h, workspace timezone).

        - `start_time` must be earlier than `end_time` (no overnight wrap-around
        — use two rows on consecutive days instead).

        - Multiple windows per day are allowed but must not overlap.
      operationId: updateCallWindows
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                inbound_enabled:
                  type: boolean
                  description: >-
                    When true, inbound calls outside the window are hung up
                    before answering.
                outbound_enabled:
                  type: boolean
                  description: >-
                    When true, outbound calls outside the window are scheduled
                    for the next opening.
                windows:
                  type: array
                  description: >-
                    Full replacement set of windows. Empty array = no allowed
                    windows on any day.
                  items:
                    $ref: '#/components/schemas/CallWindow'
      responses:
        '200':
          description: Updated configuration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CallWindowConfig'
        '400':
          description: Invalid call windows (overlap or start>=end)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CallWindow:
      type: object
      description: >
        A single allowed time range on one day of the week. All times are in the

        workspace's timezone (see `companies.timezone` /
        `CallWindowConfig.timezone`).

        Multiple ranges per day are allowed but must not overlap.
      required:
        - day_of_week
        - start_time
        - end_time
      properties:
        day_of_week:
          type: integer
          minimum: 0
          maximum: 6
          description: 0=Sunday, 1=Monday, …, 6=Saturday.
        start_time:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          example: '09:00'
        end_time:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          example: '19:00'
    CallWindowConfig:
      type: object
      description: |
        Company-level configuration that gates inbound and outbound calls by
        time-of-day. When `outbound_enabled` is true, outbound API requests
        placed outside any allowed window are deferred — the response is
        `202 Accepted` with `status: "scheduled"` and a `scheduled_for`
        timestamp marking the next window opening. When `inbound_enabled` is
        true, inbound calls received outside any allowed window are hung up
        before being answered (no `call_logs` row is created).

        A day with no windows is a closed day for whichever directions are
        enforced. The default schedule (seeded for every company) is Sunday
        through Thursday 09:00–19:00 plus Friday 09:00–11:30; Saturday is
        closed.
      properties:
        timezone:
          type: string
          description: >-
            IANA timezone identifier. Reflects `companies.timezone`. Edit it in
            the Company settings tab.
          example: Asia/Jerusalem
        inbound_enabled:
          type: boolean
          description: >-
            When true, inbound calls outside the window are hung up before
            answering. Default false.
        outbound_enabled:
          type: boolean
          description: >-
            When true, outbound calls outside the window are scheduled for the
            next opening. Default true.
        windows:
          type: array
          items:
            $ref: '#/components/schemas/CallWindow'
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Your Yappr API key (e.g. `ypr_live_...`). Generate one in the dashboard
        under **Settings → API Keys**.

````