openapi: 3.0.3
info:
  title: AppToMe API
  version: '1'
  description: The public API of an AppToMe organization. Every organization has its
    own address, `https://1<id>.backends.apptome.it/api/v1/`, shown in the app next
    to the keys. Dates and times are ISO 8601, in the organization's time zone.
paths:
  /api/v1/availabilities/:
    get:
      operationId: availabilities_list
      description: |-
        The approved availabilities of the shifts starting in the range: what
        Statistics -> Availabilities lists. With the organization's setting, the
        shifts not covered are left out, as in the app.

        Scope: `calendar:read`.
      parameters:
      - in: query
        name: calendar
        schema:
          type: array
          items:
            type: integer
        description: Calendar ids (see /organization/). Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: group
        schema:
          type: array
          items:
            type: integer
        description: 'Group ids (see /organization/): people in at least one of them.
          Repeat for more than one.'
        explode: true
        style: form
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: person
        schema:
          type: array
          items:
            type: integer
        description: Person ids. Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: shift_type
        schema:
          type: array
          items:
            type: integer
        description: Shift type ids (see /organization/). Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: start
        schema:
          type: string
          format: date
        description: First day of the range, YYYY-MM-DD, included. Shifts are matched
          by their start.
        required: true
      - in: query
        name: stop
        schema:
          type: string
          format: date
        description: Last day of the range, YYYY-MM-DD, included. At most 366 days
          after `start`.
        required: true
      - in: query
        name: task
        schema:
          type: array
          items:
            type: integer
        description: Task ids (see /organization/). Without it, every task not excluded
          from the statistics. Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: type
        schema:
          type: array
          items:
            type: string
            enum:
            - available
            - no_answer
            - to_call_back
            - unavailable
        description: |-
          Availability types. Repeat for more than one; all of them when absent.

          * `available` - available
          * `unavailable` - unavailable
          * `to_call_back` - to_call_back
          * `no_answer` - no_answer
        explode: true
        style: form
      - in: query
        name: updated_since
        schema:
          type: string
          format: date-time
        description: Only the rows changed at or after this moment (ISO 8601, e.g.
          2026-03-01T08:00:00+01:00). Pass the largest `updated_at` you received.
          Rows not changed since the change history exists have no `updated_at` and
          are left out.
      tags:
      - availabilities
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAvailabilityList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/availabilities/{id}/:
    delete:
      operationId: availabilities_destroy
      description: |-
        Takes the person off the shift, as the staff do in the app: the
        availability stays, as unavailable (200, with it). The person is
        told, as in the app.

        Scope: `calendar:write`.
      parameters:
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      - in: path
        name: id
        schema:
          type: integer
        description: Availability id.
        required: true
      tags:
      - availabilities
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailabilityOrDryRun'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/availabilities/deleted/:
    get:
      operationId: availabilities_deleted_list
      description: |-
        Availabilities deleted since `updated_since`, or no longer listed (not
        approved any more, their shift or calendar deleted or left out).

        Scope: `calendar:read`.
      parameters:
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: updated_since
        schema:
          type: string
          format: date-time
        description: Only the rows changed at or after this moment (ISO 8601, e.g.
          2026-03-01T08:00:00+01:00). Pass the largest `updated_at` you received.
          Rows not changed since the change history exists have no `updated_at` and
          are left out.
        required: true
      tags:
      - availabilities
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedDeletedList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/availabilities/summary/:
    get:
      operationId: availabilities_summary_list
      description: |-
        Shifts and minutes of the available people, from the same rows as
        `/availabilities/`, added up by person, calendar, shift type or task.

        Scope: `statistics:read`.
      parameters:
      - in: query
        name: calendar
        schema:
          type: array
          items:
            type: integer
        description: Calendar ids (see /organization/). Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: group
        schema:
          type: array
          items:
            type: integer
        description: 'Group ids (see /organization/): people in at least one of them.
          Repeat for more than one.'
        explode: true
        style: form
      - in: query
        name: group_by
        schema:
          type: array
          items:
            type: string
            enum:
            - calendar
            - person
            - shift_type
            - task
        description: |-
          What a row adds up: any of person, calendar, shift_type, task. Repeat for more than one; by person when absent.

          * `person` - person
          * `calendar` - calendar
          * `shift_type` - shift_type
          * `task` - task
        explode: true
        style: form
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: person
        schema:
          type: array
          items:
            type: integer
        description: Person ids. Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: shift_type
        schema:
          type: array
          items:
            type: integer
        description: Shift type ids (see /organization/). Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: start
        schema:
          type: string
          format: date
        description: First day of the range, YYYY-MM-DD, included. Shifts are matched
          by their start.
        required: true
      - in: query
        name: stop
        schema:
          type: string
          format: date
        description: Last day of the range, YYYY-MM-DD, included. At most 366 days
          after `start`.
        required: true
      - in: query
        name: task
        schema:
          type: array
          items:
            type: integer
        description: Task ids (see /organization/). Without it, every task not excluded
          from the statistics. Repeat for more than one.
        explode: true
        style: form
      tags:
      - availabilities
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSummaryList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/availabilities/xlsx/:
    get:
      operationId: availabilities_xlsx_retrieve
      description: |-
        The Excel of Statistics -> Availabilities, the same file the app
        downloads for the same filters (a sheet per calendar, the parameters
        last). An export: it counts against the export limits.

        Scope: `statistics:read`.
      tags:
      - availabilities
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
          description: The Excel file.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/me/:
    get:
      operationId: me_retrieve
      description: |-
        Who the key acts for, its scopes and the organization's active modules.

        Any valid key.
      tags:
      - me
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Me'
          description: ''
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/organization/:
    get:
      operationId: organization_retrieve
      description: |-
        The organization's time zone and the ids the filters take: calendars,
        shift types, tasks and groups.

        Scope: `calendar:read`.
      tags:
      - organization
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Organization'
          description: ''
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/people/:
    get:
      operationId: people_list
      description: |-
        The people of the registry, by last name.

        Scope: `people:read`.
      parameters:
      - in: query
        name: group
        schema:
          type: array
          items:
            type: integer
        description: 'Group ids (see /organization/): people in at least one of them.
          Repeat for more than one.'
        explode: true
        style: form
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: search
        schema:
          type: string
        description: Words that must all appear in the first or the last name.
      - in: query
        name: task
        schema:
          type: array
          items:
            type: integer
        description: 'Task ids (see /organization/): people who can cover at least
          one of them. Repeat for more than one.'
        explode: true
        style: form
      - in: query
        name: updated_since
        schema:
          type: string
          format: date-time
        description: Only the rows changed at or after this moment (ISO 8601, e.g.
          2026-03-01T08:00:00+01:00). Pass the largest `updated_at` you received.
          Rows not changed since the change history exists have no `updated_at` and
          are left out.
      tags:
      - people
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedPersonList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/people/deleted/:
    get:
      operationId: people_deleted_list
      description: |-
        People deleted or removed from the registry since `updated_since`.

        Scope: `people:read`.
      parameters:
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: updated_since
        schema:
          type: string
          format: date-time
        description: Only the rows changed at or after this moment (ISO 8601, e.g.
          2026-03-01T08:00:00+01:00). Pass the largest `updated_at` you received.
          Rows not changed since the change history exists have no `updated_at` and
          are left out.
        required: true
      tags:
      - people
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedDeletedList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/shifts/:
    get:
      operationId: shifts_list
      description: |-
        The shifts starting in the range, on the calendars that are not
        deleted, by start.

        Scope: `calendar:read`.
      parameters:
      - in: query
        name: calendar
        schema:
          type: array
          items:
            type: integer
        description: Calendar ids (see /organization/). Repeat for more than one.
        explode: true
        style: form
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: shift_type
        schema:
          type: array
          items:
            type: integer
        description: Shift type ids (see /organization/). Repeat for more than one.
        explode: true
        style: form
      - in: query
        name: start
        schema:
          type: string
          format: date
        description: First day of the range, YYYY-MM-DD, included. Shifts are matched
          by their start.
        required: true
      - in: query
        name: stop
        schema:
          type: string
          format: date
        description: Last day of the range, YYYY-MM-DD, included. At most 366 days
          after `start`.
        required: true
      - in: query
        name: updated_since
        schema:
          type: string
          format: date-time
        description: Only the rows changed at or after this moment (ISO 8601, e.g.
          2026-03-01T08:00:00+01:00). Pass the largest `updated_at` you received.
          Rows not changed since the change history exists have no `updated_at` and
          are left out.
      tags:
      - shifts
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedShiftList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
    post:
      operationId: shifts_create
      description: |-
        Creates a shift, as the app's new-shift form does, or a series of
        them with `repeat`: 201 with the shift (the first of a series). Who
        the app would tell is told: with `notify_candidates`, everyone who
        can take part. With dry_run, 200 and what it would do.

        Scope: `calendar:write`.
      parameters:
      - in: header
        name: Idempotency-Key
        schema:
          type: string
        description: 'Any string of 1 to 255 printable characters, new for each write:
          the same request sent again with it within 24 hours gets the first response
          (with `Idempotent-Replayed: true`) and is not done twice. Ignored on a dry
          run.'
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      tags:
      - shifts
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ShiftCreate'
        required: true
      security:
      - ApiKey: []
      responses:
        '201':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
            Idempotent-Replayed:
              schema:
                type: string
              description: '`true` on a response replayed for an Idempotency-Key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Shift'
          description: ''
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
            Idempotent-Replayed:
              schema:
                type: string
              description: '`true` on a response replayed for an Idempotency-Key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShiftDryRun'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The Idempotency-Key was used for a different request (`idempotency_key_reused`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/shifts/{id}/:
    get:
      operationId: shifts_retrieve
      description: |-
        One shift.

        Scope: `calendar:read`.
      parameters:
      - in: path
        name: id
        schema:
          type: integer
        description: Shift id.
        required: true
      tags:
      - shifts
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Shift'
          description: ''
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
    patch:
      operationId: shifts_partial_update
      description: |-
        Changes the fields sent, as the app's shift form does: 200 with
        the shift. Moving it tells the people on it, as in the app. With
        dry_run, 200 with `dry_run` and the warnings.

        Scope: `calendar:write`.
      parameters:
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      - in: path
        name: id
        schema:
          type: integer
        description: Shift id.
        required: true
      - in: query
        name: scope
        schema:
          type: string
          enum:
          - following
          - single
        description: 'single (default): this shift; if it is in a series, it leaves
          it, as in the app. following: it and the following ones of its series (name,
          type, times, note, vehicles; not the days nor the calendar).'
      tags:
      - shifts
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchedShiftUpdate'
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShiftOrDryRun'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
    delete:
      operationId: shifts_destroy
      description: |-
        Deletes the shift, or the following ones of its series: 200 with
        their ids. The people on them are told, as in the app.

        Scope: `calendar:write`.
      parameters:
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      - in: path
        name: id
        schema:
          type: integer
        description: Shift id.
        required: true
      - in: query
        name: scope
        schema:
          type: string
          enum:
          - following
          - single
        description: 'single (default): this shift. following: it and the following
          ones of its series. The whole series cannot be deleted from here.'
      tags:
      - shifts
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeletedShiftsResult'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/shifts/{id}/assignments/:
    post:
      operationId: shifts_assignments_create
      description: |-
        Puts a person on the shift with a task, as the staff do in the
        app: approves a pending availability, or changes its task. The task
        is a requirement of the shift that the person has (a 400 on `task`
        otherwise); a pending availability is approved with its own task.
        200 with the availability. The person is told, as in the app; their
        overlapping shifts lose them. With dry_run, 200 with `dry_run`, the
        availability and the warnings.

        Scope: `calendar:write`.
      parameters:
      - in: header
        name: Idempotency-Key
        schema:
          type: string
        description: 'Any string of 1 to 255 printable characters, new for each write:
          the same request sent again with it within 24 hours gets the first response
          (with `Idempotent-Replayed: true`) and is not done twice. Ignored on a dry
          run.'
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      - in: path
        name: id
        schema:
          type: integer
        description: Shift id.
        required: true
      tags:
      - shifts
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Assignment'
        required: true
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
            Idempotent-Replayed:
              schema:
                type: string
              description: '`true` on a response replayed for an Idempotency-Key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailabilityOrDryRun'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The Idempotency-Key was used for a different request (`idempotency_key_reused`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/shifts/{id}/signup/:
    post:
      operationId: shifts_signup_create
      description: |-
        Signs the key's user up for the shift with a task, as the app's
        «I'm available»: 200 with the availability. The task is one the app
        offers the user: a requirement of the shift, not hidden, that they
        have, with room left; another is a 400 on `task`. It may wait for the
        staff's approval, as in the app; the people on overlapping shifts
        leave them. The calendar's notification rules tell the staff. With
        dry_run, 200 with `dry_run`, the availability and the warnings.

        Scope: `calendar:write`.
      parameters:
      - in: header
        name: Idempotency-Key
        schema:
          type: string
        description: 'Any string of 1 to 255 printable characters, new for each write:
          the same request sent again with it within 24 hours gets the first response
          (with `Idempotent-Replayed: true`) and is not done twice. Ignored on a dry
          run.'
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      - in: path
        name: id
        schema:
          type: integer
        description: Shift id.
        required: true
      tags:
      - shifts
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SignUp'
        required: true
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
            Idempotent-Replayed:
              schema:
                type: string
              description: '`true` on a response replayed for an Idempotency-Key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailabilityOrDryRun'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The Idempotency-Key was used for a different request (`idempotency_key_reused`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
    delete:
      operationId: shifts_signup_destroy
      description: |-
        The key's user withdraws from the shift: 200 with the availability,
        now unavailable. The calendar's notification rules tell the staff.

        Scope: `calendar:write`.
      parameters:
      - in: query
        name: dry_run
        schema:
          type: boolean
        description: 'true: check the write as the real one and answer what it would
          do, without saving anything or telling anyone.'
      - in: path
        name: id
        schema:
          type: integer
        description: Shift id.
        required: true
      tags:
      - shifts
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailabilityOrDryRun'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter or a field is not valid (`invalid_request`, with
            `fields`).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No such object.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The calendar refuses the change now (`not_allowed`, with `reason`),
            the key's user has no person (`no_person`), or a request with the same
            Idempotency-Key is still running (`idempotency_in_progress`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
  /api/v1/shifts/deleted/:
    get:
      operationId: shifts_deleted_list
      description: |-
        Shifts deleted since `updated_since`, or on a calendar deleted since.
        Drop them from a copy kept with `/shifts/?updated_since=`.

        Scope: `calendar:read`.
      parameters:
      - name: page
        required: false
        in: query
        description: Page number, from 1.
        schema:
          type: integer
      - name: per_page
        required: false
        in: query
        description: 'Rows per page: 50 by default, at most 100.'
        schema:
          type: integer
      - in: query
        name: updated_since
        schema:
          type: string
          format: date-time
        description: Only the rows changed at or after this moment (ISO 8601, e.g.
          2026-03-01T08:00:00+01:00). Pass the largest `updated_at` you received.
          Rows not changed since the change history exists have no `updated_at` and
          are left out.
        required: true
      tags:
      - shifts
      security:
      - ApiKey: []
      responses:
        '200':
          headers:
            X-RateLimit-Limit:
              schema:
                type: integer
              description: Requests allowed in the tightest window.
            X-RateLimit-Remaining:
              schema:
                type: integer
              description: Requests left in that window.
            X-RateLimit-Reset:
              schema:
                type: integer
              description: Unix time when that window ends.
            X-Quota-Limit:
              schema:
                type: integer
              description: Requests included this month.
            X-Quota-Remaining:
              schema:
                type: integer
              description: Included requests left this month.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedDeletedList'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: A parameter is not valid (`invalid_request`, `invalid_range`).
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: No key, or a key that is not valid, expired, or of an inactive
            user.
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The organization is on the lite plan.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: The scope is missing, the author is no longer a superuser,
            or the module is not active.
        '429':
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before the next request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'A limit or the included usage is reached: wait for Retry-After.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'The organization settings cannot be read right now: retry
            in a minute.'
components:
  schemas:
    Assignment:
      type: object
      properties:
        start:
          type: string
          format: date-time
          description: 'Partial availability: from when, within the shift. Only on
            calendars that take partial availabilities, and on shifts shorter than
            24 hours.'
        end:
          type: string
          format: date-time
          description: 'Partial availability: until when, as start.'
        note:
          type: string
          description: Note on the availability. Left as it is when absent. At most
            2000 characters.
          maxLength: 2000
        person:
          type: integer
          description: The person to put on the shift (see /people/).
        task:
          type: integer
          description: The task the person covers (see /organization/).
        employee:
          type: boolean
          description: On the shift as an employee. Left as it is when absent, false
            for a new availability.
      required:
      - person
      - task
    Availability:
      type: object
      properties:
        id:
          type: integer
          description: Availability id.
        shift:
          type: integer
          description: Shift id.
        person:
          allOf:
          - $ref: '#/components/schemas/PersonRef'
          description: The person.
        task:
          type: integer
          nullable: true
          description: Task the person covers, null if none.
        type:
          allOf:
          - $ref: '#/components/schemas/TypeEnum'
          description: |-
            Kind of availability.

            * `available` - available
            * `no_answer` - no_answer
            * `to_call_back` - to_call_back
            * `unavailable` - unavailable
        start:
          type: string
          format: date-time
          description: 'Actual start: the shift''s, or the person''s own for a partial
            availability.'
        end:
          type: string
          format: date-time
          description: Actual end, as start.
        duration_minutes:
          type: integer
          readOnly: true
          description: From start to end, in minutes.
        employee:
          type: boolean
          description: Covered as an employee.
        certified:
          type: boolean
          description: Certified by the staff.
        created_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row was created; null for rows older than the change
            history.
        updated_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row last changed; null when it has not changed since
            the change history exists. The value to pass as updated_since.
      required:
      - certified
      - created_at
      - duration_minutes
      - employee
      - end
      - id
      - person
      - shift
      - start
      - task
      - type
      - updated_at
    AvailabilityDryRun:
      type: object
      properties:
        dry_run:
          type: boolean
          description: 'Always true: nothing was saved and nobody was told.'
        availability:
          allOf:
          - $ref: '#/components/schemas/AvailabilityPreview'
          description: The availability as the write would leave it.
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/Warning'
          description: What the write would do that is worth knowing.
      required:
      - availability
      - dry_run
      - warnings
    AvailabilityOrDryRun:
      oneOf:
      - $ref: '#/components/schemas/Availability'
      - $ref: '#/components/schemas/AvailabilityDryRun'
    AvailabilityPreview:
      type: object
      properties:
        id:
          type: integer
          nullable: true
          description: 'Availability id: always null in a dry run, which saves no
            row (the write may save the person''s row anew).'
        shift:
          type: integer
          description: Shift id.
        person:
          allOf:
          - $ref: '#/components/schemas/PersonRef'
          description: The person.
        task:
          type: integer
          nullable: true
          description: Task the person covers, null if none.
        type:
          allOf:
          - $ref: '#/components/schemas/TypeEnum'
          description: |-
            Kind of availability.

            * `available` - available
            * `no_answer` - no_answer
            * `to_call_back` - to_call_back
            * `unavailable` - unavailable
        start:
          type: string
          format: date-time
          description: 'Actual start: the shift''s, or the person''s own for a partial
            availability.'
        end:
          type: string
          format: date-time
          description: Actual end, as start.
        duration_minutes:
          type: integer
          readOnly: true
          description: From start to end, in minutes.
        employee:
          type: boolean
          description: Covered as an employee.
        certified:
          type: boolean
          description: Certified by the staff.
        created_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row was created; null for rows older than the change
            history.
        updated_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row last changed; null when it has not changed since
            the change history exists. The value to pass as updated_since.
      required:
      - certified
      - created_at
      - duration_minutes
      - employee
      - end
      - id
      - person
      - shift
      - start
      - task
      - type
      - updated_at
    Deleted:
      type: object
      properties:
        id:
          type: integer
          description: Id of a row to drop.
        deleted_at:
          type: string
          format: date-time
          description: When it was deleted, or when it left the list (a deleted calendar,
            a person removed).
      required:
      - deleted_at
      - id
    DeletedShiftsResult:
      type: object
      properties:
        dry_run:
          type: boolean
          description: 'True when nothing was deleted: the ids are those that would
            be.'
        deleted:
          type: array
          items:
            type: integer
          description: 'Ids of the shifts deleted, by start: one, or the following
            ones of the series with scope=following.'
      required:
      - deleted
      - dry_run
    Error:
      type: object
      properties:
        error:
          allOf:
          - $ref: '#/components/schemas/ErrorDetail'
          description: What went wrong.
      required:
      - error
    ErrorDetail:
      type: object
      properties:
        code:
          type: string
          description: 'Stable code: invalid_key, expired_key, inactive_user, not_superuser,
            missing_scope, module_not_active, plan_required, service_unavailable,
            rate_limited, quota_exceeded, invalid_request, invalid_range, not_found,
            method_not_allowed, forbidden, server_error; on the writes also not_allowed,
            no_person, idempotency_in_progress, idempotency_key_reused.'
        message:
          type: string
          description: Explanation for a person, in the language of the request.
        fields:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: 'Errors by parameter or field, when they are not valid. non_field_errors:
            those of the request as a whole.'
        reason:
          type: string
          description: 'With not_allowed: why, in the calendar''s terms (past_shift,
            current_shift, too_close_to_add, too_close_to_delete, too_far_to_add,
            too_close_to_change, add_not_allowed, delete_not_allowed).'
      required:
      - code
      - message
    ExceptOnEnum:
      enum:
      - monday
      - tuesday
      - wednesday
      - thursday
      - friday
      - saturday
      - sunday
      - working_day
      - day_before_holiday
      - holiday
      type: string
      description: |-
        * `monday` - monday
        * `tuesday` - tuesday
        * `wednesday` - wednesday
        * `thursday` - thursday
        * `friday` - friday
        * `saturday` - saturday
        * `sunday` - sunday
        * `working_day` - working_day
        * `day_before_holiday` - day_before_holiday
        * `holiday` - holiday
    Me:
      type: object
      properties:
        user:
          allOf:
          - $ref: '#/components/schemas/MeUser'
          description: Who the key acts for.
        key:
          allOf:
          - $ref: '#/components/schemas/MeKey'
          description: The key of this request.
        active_modules:
          type: array
          items:
            type: string
          description: Modules active for the organization.
      required:
      - active_modules
      - key
      - user
    MeKey:
      type: object
      properties:
        name:
          type: string
          description: Name given to the key.
        prefix:
          type: string
          description: First characters of the key, the only part shown again.
        scopes:
          type: array
          items:
            type: string
          description: Scopes of the key.
        expires_at:
          type: string
          format: date-time
          description: When the key stops working.
      required:
      - expires_at
      - name
      - prefix
      - scopes
    MeUser:
      type: object
      properties:
        id:
          type: integer
          description: User id.
        email:
          type: string
          format: email
          description: Email of the user the key acts for.
        person:
          allOf:
          - $ref: '#/components/schemas/PersonRef'
          nullable: true
          description: The user's person, null if there is none.
      required:
      - email
      - id
      - person
    Named:
      type: object
      properties:
        id:
          type: integer
          description: 'Id, stable: use it in the filters.'
        name:
          type: string
          description: Name, as the app shows it.
      required:
      - id
      - name
    OnEnum:
      enum:
      - monday
      - tuesday
      - wednesday
      - thursday
      - friday
      - saturday
      - sunday
      - working_day
      - day_before_holiday
      - holiday
      - every_day
      type: string
      description: |-
        * `monday` - monday
        * `tuesday` - tuesday
        * `wednesday` - wednesday
        * `thursday` - thursday
        * `friday` - friday
        * `saturday` - saturday
        * `sunday` - sunday
        * `working_day` - working_day
        * `day_before_holiday` - day_before_holiday
        * `holiday` - holiday
        * `every_day` - every_day
    Organization:
      type: object
      properties:
        timezone:
          type: string
          description: 'IANA time zone of the organization: the dates of the filters
            are read in it.'
        calendars:
          type: array
          items:
            $ref: '#/components/schemas/Named'
          description: Calendars, in the order of the app.
        shift_types:
          type: array
          items:
            $ref: '#/components/schemas/Named'
          description: Shift types, by priority.
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/Named'
          description: Tasks, by name.
        groups:
          type: array
          items:
            $ref: '#/components/schemas/Named'
          description: Groups of people, by name.
      required:
      - calendars
      - groups
      - shift_types
      - tasks
      - timezone
    PaginatedAvailabilityList:
      type: object
      required:
      - count
      - results
      properties:
        count:
          type: integer
          example: 123
          description: Rows in all pages.
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=4
          description: Address of the next page, null on the last one.
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=2
          description: Address of the previous page, null on the first one.
        results:
          type: array
          items:
            $ref: '#/components/schemas/Availability'
          description: The rows of this page.
    PaginatedDeletedList:
      type: object
      required:
      - count
      - results
      properties:
        count:
          type: integer
          example: 123
          description: Rows in all pages.
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=4
          description: Address of the next page, null on the last one.
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=2
          description: Address of the previous page, null on the first one.
        results:
          type: array
          items:
            $ref: '#/components/schemas/Deleted'
          description: The rows of this page.
    PaginatedPersonList:
      type: object
      required:
      - count
      - results
      properties:
        count:
          type: integer
          example: 123
          description: Rows in all pages.
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=4
          description: Address of the next page, null on the last one.
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=2
          description: Address of the previous page, null on the first one.
        results:
          type: array
          items:
            $ref: '#/components/schemas/Person'
          description: The rows of this page.
    PaginatedShiftList:
      type: object
      required:
      - count
      - results
      properties:
        count:
          type: integer
          example: 123
          description: Rows in all pages.
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=4
          description: Address of the next page, null on the last one.
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=2
          description: Address of the previous page, null on the first one.
        results:
          type: array
          items:
            $ref: '#/components/schemas/Shift'
          description: The rows of this page.
    PaginatedSummaryList:
      type: object
      required:
      - count
      - results
      properties:
        count:
          type: integer
          example: 123
          description: Rows in all pages.
        next:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=4
          description: Address of the next page, null on the last one.
        previous:
          type: string
          nullable: true
          format: uri
          example: http://api.example.org/accounts/?page=2
          description: Address of the previous page, null on the first one.
        results:
          type: array
          items:
            $ref: '#/components/schemas/Summary'
          description: The rows of this page.
    PatchedShiftUpdate:
      type: object
      description: |-
        Every field is optional: only the ones sent change. `repeat` and
        `notify_candidates` are of a new shift only: on a change, 400.
      properties:
        name:
          type: string
          description: Name of the shift.
          maxLength: 128
        calendar:
          type: integer
          description: Calendar id (see /organization/).
        shift_type:
          type: integer
          description: Shift type id (see /organization/).
        start:
          type: string
          format: date-time
          description: Start, ISO 8601. With an offset it is converted to the organization's
            time zone, without one it is read in it.
        end:
          type: string
          format: date-time
          description: 'End, as start: after it, at most 60 days later.'
        note:
          type: string
          description: Notes, shown on the shift. At most 2000 characters.
          maxLength: 2000
        vehicles:
          type: array
          items:
            type: integer
          description: Ids of the vehicles on the shift. On a change, the whole list.
    Person:
      type: object
      properties:
        id:
          type: integer
          description: Person id.
        first_name:
          type: string
          description: First name.
        last_name:
          type: string
          description: Last name.
        role:
          allOf:
          - $ref: '#/components/schemas/RoleEnum'
          description: |-
            Role in the organization.

            * `civic_service` - civic_service
            * `community_service` - community_service
            * `employee` - employee
            * `freelancer` - freelancer
            * `member` - member
            * `volunteer` - volunteer
        tasks:
          type: array
          items:
            type: integer
          readOnly: true
          description: Ids of the tasks the person can cover, the inherited ones included.
        groups:
          type: array
          items:
            type: integer
          readOnly: true
          description: Ids of the groups the person belongs to.
        created_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row was created; null for rows older than the change
            history.
        updated_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row last changed; null when it has not changed since
            the change history exists. The value to pass as updated_since.
      required:
      - created_at
      - first_name
      - groups
      - id
      - last_name
      - role
      - tasks
      - updated_at
    PersonRef:
      type: object
      properties:
        id:
          type: integer
          description: Person id.
        first_name:
          type: string
          description: First name.
        last_name:
          type: string
          description: Last name.
        role:
          allOf:
          - $ref: '#/components/schemas/RoleEnum'
          description: |-
            Role in the organization.

            * `civic_service` - civic_service
            * `community_service` - community_service
            * `employee` - employee
            * `freelancer` - freelancer
            * `member` - member
            * `volunteer` - volunteer
      required:
      - first_name
      - id
      - last_name
      - role
    RoleEnum:
      enum:
      - civic_service
      - community_service
      - employee
      - freelancer
      - member
      - volunteer
      type: string
      description: |-
        * `civic_service` - civic_service
        * `community_service` - community_service
        * `employee` - employee
        * `freelancer` - freelancer
        * `member` - member
        * `volunteer` - volunteer
    Shift:
      type: object
      properties:
        id:
          type: integer
          description: Shift id.
        name:
          type: string
          description: Name of the shift.
        start:
          type: string
          format: date-time
          description: Start.
        end:
          type: string
          format: date-time
          description: End.
        calendar:
          type: integer
          description: Calendar id.
        shift_type:
          type: integer
          nullable: true
          description: Shift type id, null if none.
        covered:
          type: boolean
          description: Whether the people signed up meet the requirements of the shift.
        series:
          type: integer
          nullable: true
          description: Id of the series the shift belongs to (a repeated shift), null
            for a shift on its own.
        note:
          type: string
          readOnly: true
          description: Notes of the shift, as the app shows them; empty when there
            are none.
        created_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row was created; null for rows older than the change
            history.
        updated_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: When the row last changed; null when it has not changed since
            the change history exists. The value to pass as updated_since.
      required:
      - calendar
      - covered
      - created_at
      - end
      - id
      - name
      - note
      - series
      - shift_type
      - start
      - updated_at
    ShiftCreate:
      type: object
      description: The fields of a shift as the app's form takes them.
      properties:
        name:
          type: string
          description: Name of the shift.
          maxLength: 128
        calendar:
          type: integer
          description: Calendar id (see /organization/).
        shift_type:
          type: integer
          description: Shift type id (see /organization/).
        start:
          type: string
          format: date-time
          description: Start, ISO 8601. With an offset it is converted to the organization's
            time zone, without one it is read in it.
        end:
          type: string
          format: date-time
          description: 'End, as start: after it, at most 60 days later.'
        note:
          type: string
          description: Notes, shown on the shift. At most 2000 characters.
          maxLength: 2000
        vehicles:
          type: array
          items:
            type: integer
          description: Ids of the vehicles on the shift. On a change, the whole list.
        repeat:
          allOf:
          - $ref: '#/components/schemas/ShiftRepeat'
          description: 'Repeat the shift: a series, from start to `until`. Each shift
            of it is created as the first one.'
        notify_candidates:
          type: boolean
          default: false
          description: Tell everyone who can take part in the shift that it is open,
            as the app's option does. Not with repeat.
      required:
      - calendar
      - end
      - shift_type
      - start
    ShiftDryRun:
      type: object
      properties:
        dry_run:
          type: boolean
          description: 'Always true: nothing was saved and nobody was told.'
        preview:
          allOf:
          - $ref: '#/components/schemas/ShiftPreview'
          description: The shift as the write would leave it.
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/Warning'
          description: What the write would do that is worth knowing.
      required:
      - dry_run
      - preview
      - warnings
    ShiftOrDryRun:
      oneOf:
      - $ref: '#/components/schemas/Shift'
      - $ref: '#/components/schemas/ShiftDryRun'
    ShiftPreview:
      type: object
      description: The shift as the write would leave it, checked as the real write.
      properties:
        id:
          type: integer
          nullable: true
          description: 'Shift id: null when the write would create it.'
        name:
          type: string
          description: Name of the shift.
        start:
          type: string
          format: date-time
          description: Start.
        end:
          type: string
          format: date-time
          description: End.
        calendar:
          type: integer
          description: Calendar id.
        shift_type:
          type: integer
          nullable: true
          description: Shift type id, null if none.
        occurrences:
          type: integer
          description: 'Shifts the write creates or changes: 1, or those of the series.
            For a new series an upper bound: a day whose shift fails the checks (a
            vehicle busy that day) is skipped when saving.'
        dates:
          type: array
          items:
            type: string
            format: date
          description: 'A new series only: the days of its shifts, the first 100 at
            most.'
      required:
      - calendar
      - end
      - id
      - name
      - occurrences
      - shift_type
      - start
    ShiftRepeat:
      type: object
      properties:
        until:
          type: string
          format: date
          description: 'Last day a shift of the series can fall on, YYYY-MM-DD: not
            before the start, not beyond the first of January five years from now.'
        every_days:
          type: integer
          maximum: 3660
          minimum: 1
          default: 1
          description: 'Days from one shift to the next: 1 for every day, 7 for every
            week; at most 3660.'
        'on':
          type: array
          items:
            $ref: '#/components/schemas/OnEnum'
          description: 'The days a shift falls on: week days (monday...sunday), working_day,
            day_before_holiday, holiday, or every_day (the default).'
        except_on:
          type: array
          items:
            $ref: '#/components/schemas/ExceptOnEnum'
          description: The days skipped even when `on` takes them, with the same names.
      required:
      - until
    SignUp:
      type: object
      properties:
        start:
          type: string
          format: date-time
          description: 'Partial availability: from when, within the shift. Only on
            calendars that take partial availabilities, and on shifts shorter than
            24 hours.'
        end:
          type: string
          format: date-time
          description: 'Partial availability: until when, as start.'
        note:
          type: string
          description: Note on the availability. Left as it is when absent. At most
            2000 characters.
          maxLength: 2000
        task:
          type: integer
          description: The task the key's user covers on the shift (see /organization/).
      required:
      - task
    Summary:
      type: object
      properties:
        person:
          allOf:
          - $ref: '#/components/schemas/PersonRef'
          nullable: true
          description: The person; null unless grouped by person.
        calendar:
          type: integer
          nullable: true
          description: Calendar id; null unless grouped by calendar.
        shift_type:
          type: integer
          nullable: true
          description: Shift type id; null unless grouped by shift_type, or for shifts
            without a type.
        task:
          type: integer
          nullable: true
          description: Task id; null unless grouped by task.
        shifts:
          type: integer
          description: Number of distinct shifts.
        minutes:
          type: integer
          description: Total time, in minutes.
      required:
      - calendar
      - minutes
      - person
      - shift_type
      - shifts
      - task
    TypeEnum:
      enum:
      - available
      - no_answer
      - to_call_back
      - unavailable
      type: string
      description: |-
        * `available` - available
        * `no_answer` - no_answer
        * `to_call_back` - to_call_back
        * `unavailable` - unavailable
    Warning:
      type: object
      properties:
        code:
          type: string
          description: past_shift (the shift has started or is over), pending_approval
            (the availability waits for the staff's approval), busy_elsewhere (the
            person leaves the overlapping shifts in `shifts`), leaves_series (the
            shift is taken out of its series).
        message:
          type: string
          description: Explanation for a person, in the language of the request.
        shifts:
          type: array
          items:
            type: integer
          description: 'With busy_elsewhere: the shifts the person is taken off.'
      required:
      - code
      - message
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: atm_…
      description: 'An API key of the organization, created by a superuser in the
        app: `Authorization: Bearer atm_…`. It acts for its author, within its scopes.'
servers:
- url: https://1{organization}.backends.apptome.it
  description: The organization's backend.
  variables:
    organization:
      default: '0'
      description: The organization's id.
