openapi: 3.0.3
info:
  title: Makerble API
  description: |
    The Makerble API enables developers to integrate with the Makerble CRM and impact measurement platform — reading and writing data on contacts, projects, surveys, cases, outcomes, metrics, and more.

    ## Base URL
    ```
    https://makerble.com/api/v2
    ```
    A staging environment is also available at `https://staging.makerble.com/api/v2`.

    ## Authentication
    All endpoints (except `/users/sign_in` and the password reset endpoints) require token-based authentication. Pass both headers on every authenticated request:

    | Header | Value |
    |---|---|
    | `X-User-Email` | The authenticated user's email address |
    | `X-User-Token` | The user's long-lived authentication token |

    Tokens are obtained via `POST /users/sign_in` and **do not expire**. Each user has one fixed token.

    > **Multi-user integrations:** If activity must be attributed to specific users, authenticate separately per user. A single Organisation Admin token is acceptable when attribution to one admin is sufficient.

    ### Organisation API keys
    A custom integration that works for one Organisation should use an **API key** instead of a person's own token. An Organisation Admin creates one in Makerble under **Data In & Out → Integrations → API keys** (or with `POST /api_keys`). Send it on every request as:

    ```
    Authorization: Bearer mk_live_...
    ```

    A key belongs to one Organisation and acts as the colleague chosen when it was created: it can see and do only what they can, in that Organisation only. It can call the same endpoints as a connected app (OAuth), and gets `403` with `not_available_to_connected_apps` from any other. If the colleague leaves the Organisation, or the key is revoked, requests get `401`. Calls made with an Organisation's API keys count towards its monthly API usage.
    ## Connecting an app with OAuth 2.0
    Apps published for other people to use, such as marketplace connectors, connect with OAuth 2.0 instead of asking for a password. The user signs in to Makerble, chooses which of their organisations (Charities) the app may use, and selects **Allow**. The app then calls the API as that user, limited to that organisation.

    1. **Get a client ID and secret.** Makerble registers client applications; email [api-key-request@makerble.com](mailto:api-key-request@makerble.com) with your app's name and its exact redirect URI (https only). There is no self-service registration.
    2. **Send the user to** `GET https://makerble.com/oauth/authorize?response_type=code&client_id=…&redirect_uri=…&scope=api&state=…`. Makerble shows the consent screen, then redirects to your redirect URI with `?code=…&state=…`, or `?error=access_denied` if the user cancels. A redirect URI that isn't registered for your app is refused without redirecting.
    3. **Exchange the code** at `POST https://makerble.com/oauth/token` with `grant_type=authorization_code`. The code works once and expires after 10 minutes.
    4. **Call the API** with `Authorization: Bearer <access_token>`. Don't send `X-User-Email`/`X-User-Token` as well. Tokens are only read from the `Authorization` header.
    5. **Refresh** at `POST https://makerble.com/oauth/token` with `grant_type=refresh_token`. Access tokens last 1 hour. Refresh tokens don't expire, but each refresh returns a new refresh token: always store the latest one.

    | Situation | Response |
    |---|---|
    | Token expired, revoked, or the user is no longer in the connected organisation | `401 {"error":"invalid_token"}` |
    | Endpoint not yet available to connected apps | `403 {"error":"not_available_to_connected_apps"}` |

    A connected app sees only the organisation the user chose, with that user's permissions there. It can call the same endpoints as an Organisation API key (see Organisation API keys above), and gets `403` with `not_available_to_connected_apps` from any other. Users and Organisation Admins can disconnect an app at any time from **Settings → Connected Apps**, and it stops working straight away. The scope is always `api`.

    ## Creating Users via the API
    `POST /users` requires a separate API Key (`auth_code`). Request one at [api-key-request@makerble.com](mailto:api-key-request@makerble.com).

    ## Terminology
    Makerble uses different terms in the UI and the API:

    | Front-end | API |
    |---|---|
    | Organisation | Charity |
    | Contact | Beneficiary |
    | Contact Bio Form | Beneficiary Category |
    | Contact Type | Beneficiary Type |
    | Survey | Story Category |
    | Survey Campaign | Project Story Category |
    | Survey Response / Timeline Update / Instant Update | Story |
    | Activity / Engagement tracker | Change (stage: activity / participation) |
    | Achievement / Choice / Numerical tracker | Indicator (type: binary / scale / value) |
    | Dropdown / List field | Ratio Set |
    | Answer Choice | Sub Ratio |
    | Case Form | Custom Field Category |
    | Case Owner | Case Creator |
    | Case Worker | Case Member |
    | Project Manager | Project Editor |
    | Changemaker | Project Reporter |
    | Analyst | Project Observer |
    | Signup Page | Referral Link Detail |

    ## Story timestamps
    Stories carry three timestamps:

    | API field | Front-end label | Meaning |
    |---|---|---|
    | `actual_created_at` | Date Posted | Real database insertion time |
    | `created_at` | Date Happened | Activity date chosen by the user (can be backdated) |
    | `updated_at` | Date Edited | Most recent modification |

    ## Pagination
    All list endpoints accept:

    | Parameter | Type | Default | Max | Description |
    |---|---|---|---|---|
    | `page` | integer | 1 | — | Page number |
    | `per_page` | integer | 10 | 200 | Records per page |
    | `last_sync_datetime` | string (ISO 8601) | — | — | Return only records updated after this datetime |

    Paginated responses use this envelope:
    ```json
    { "page": 1, "page_size": 10, "page_count": 146, "total_count": 1458, "data": [] }
    ```

    ## Rate limits
    To keep the API fast for every organisation, calls are limited per minute:

    | Who | Limit |
    |---|---|
    | Each API key, connected app token, or person's email and token | 120 requests a minute |
    | All of one Organisation's API keys and connected apps together | 300 requests a minute |

    The minute is a fixed clock minute (it resets at :00 seconds). Every response carries headers so an integration can pace itself:

    | Header | Meaning |
    |---|---|
    | `X-RateLimit-Limit` | Requests allowed per minute for this key or token |
    | `X-RateLimit-Remaining` | Requests left this minute |
    | `X-RateLimit-Reset` | When the minute resets, as a Unix timestamp |

    A call over a limit gets `429 Too Many Requests` with a `Retry-After` header (seconds) and this body:
    ```json
    {
      "error": "Too many requests: this API key or token has made more than 120 requests in a minute. The limit resets at 17:31:00 UTC, in 23 seconds; try again then. ...",
      "scope": "api_key",
      "limit": 120,
      "retry_after": 23,
      "resets_at": "2026-11-25T17:31:00Z",
      "documentation": "https://api-docs.makerble.com/#rate-limits"
    }
    ```
    `scope` is `api_key` for the key or token's own limit and `organisation` for the Organisation's shared one.

    **To stay within the limits:** wait `Retry-After` seconds after a `429` before trying again; space requests out (one every half second keeps a key under its limit); and fetch lists a page at a time with `per_page` up to 200 and `last_synced_datetime` to get only what changed since your last sync, instead of fetching records one by one. For example, 5,000 Survey Responses (Stories) take 25 calls to `GET /stories?per_page=200`, but 5,000 calls to `GET /stories/{id}`.

    ## Webhooks
    Instead of polling, an Organisation's admins can register **webhook endpoints**: HTTPS URLs that Makerble sends a signed JSON `POST` to when records change. Manage them under **Connect > Webhooks** or with the Webhooks endpoints below. An Organisation's admin turns webhooks on by ticking **Turn on Webhooks** in the Organisation's Settings (Preferences) page; until then those endpoints answer `403`.

    | Event | Sent when | `data` |
    |---|---|---|
    | `contact.created` | A Contact is created | Same as `GET /beneficiaries/{id}` |
    | `contact.updated` | A Contact is edited, including its Contact Type or a dropdown answer (not when only counts Makerble keeps up to date change) | Same, plus `changed_fields` on the envelope. A changed dropdown is listed as `custom_fields.<dropdown title>` |
    | `contact.deleted` | A Contact is deleted (archived), or removed for good without being archived first | `id`, `deleted_at`. No name or other personal data |
    | `contact.merged` | A Contact is merged into another Contact. No `contact.deleted` is sent for it | `kept_contact_id`, `merged_contact_ids`, `merged_at` |
    | `contact.restored` | A deleted Contact is restored, or a merge is undone | Same as `GET /beneficiaries/{id}` |
    | `story.created` | A Story is posted, about 30 seconds later so its survey answers are included (not drafts) | Same as `GET /stories/{id}` |
    | `story.updated` | A Story is edited, including a draft being published | Same |
    | `story.deleted` | A Story is deleted (not drafts) | `id`, `project_id`, `contact_ids`, `deleted_at` |
    | `project.created` / `project.updated` | A Project is created / edited. Closing (archiving) or reopening a Project is an edit | Same as `GET /projects/{id}` |
    | `project.deleted` | A Project is deleted | `id`, `name`, `deleted_at` |
    | `project.contact_added` / `project.contact_removed` | A Contact joins / leaves a Project (not when the Contact is being deleted, and not from imports) | `project_id`, `project_name`, `contact_id`, `contact_state` (the Contact's state in the Project, e.g. `Enrolled`) |
    | `import.completed` | A spreadsheet import has processed every row. Rows of an import send no events of their own | `import_id`, `import_type`, `kind`, `status`, `counts`, `charity_id` |
    | `webhook.test` | Someone sends a test event | `{ "test": true, "message": "This is a test event from Makerble." }` |

    `*.updated` events are sent about 10 seconds after the change, so several saves of one change (publishing a draft Story saves it more than once) arrive as one event showing the latest state.

    The `data` of `contact.deleted`, `contact.merged`, `story.deleted`, `project.deleted` and the `project.contact_*` events is recorded when the event happens, as the record may be gone by the time it is sent.

    A webhook created before an event existed doesn't receive it until an admin ticks it under **Send a message when**. New webhooks receive every event unless unticked.

    Bulk actions (merging many Contacts, adding many Contacts to a Project, undoing an import) still send one event per record. Once an endpoint has 100 events waiting, further ones are spaced out at 5 a second, so a bulk action on thousands of records may take some minutes to arrive in full.

    Every request has this body:
    ```json
    {
      "id": "evt_6f0c2a4e-8d1b-4b7e-9a53-2f1d6c3e9b10",
      "event": "contact.updated",
      "occurred_at": "2026-10-04T09:15:00Z",
      "charity_id": 123,
      "changed_fields": ["name", "mobile"],
      "data": { "id": 456, "name": "Ada Lovelace" }
    }
    ```
    `data` shows the record as it is when the request is sent, which can be newer than `occurred_at`. New fields may be added to `data` over time.

    Headers: `X-Makerble-Event` (the event), `X-Makerble-Delivery` (the `id`), `User-Agent: Makerble-Webhooks/1` and `X-Makerble-Signature: t=<unix time>,v1=<signature>`.

    **Verify the signature** before trusting a request. `v1` is the hex HMAC-SHA256 of `"<t>.<raw request body>"`, keyed with the endpoint's secret (shown once, when the endpoint is created or its secret is rotated). Reject old timestamps to stop replays:
    ```ruby
    t, v1 = request.headers['X-Makerble-Signature'].split(',').map { |part| part.split('=', 2).last }
    expected = OpenSSL::HMAC.hexdigest('SHA256', secret, "#{t}.#{request.raw_post}")
    valid = Rack::Utils.secure_compare(expected, v1) && (Time.now.to_i - t.to_i).abs < 300
    ```

    **Respond with any 2xx within 10 seconds.** Anything else, a timeout or a refused connection is retried 8 more times over about 25 hours (after 1 and 5 minutes, then 15 minutes, 1, 2, 4, 8 and 10 hours). Redirects are not followed. After 10 deliveries in a row fail, or 7 days without a success, Makerble switches the endpoint off and emails the Organisation's admins; turn it back on with `PATCH /webhook_endpoints/{id}` and `active: true`.

    Delivery is **at least once** and in no guaranteed order: de-duplicate on `id`, and use `occurred_at` (or fetch the record) where order matters. Delivery logs are kept for 30 days and any delivery can be sent again with its replay endpoint.

  version: "2.0.0"
  contact:
    name: Makerble Support
    url: https://discover.makerble.com
    email: support@makerble.com
  license:
    name: Proprietary

servers:
  - url: https://makerble.com/api/v2
    description: Production
  - url: https://staging.makerble.com/api/v2
    description: Staging
  - url: /mock
    description: Mock server (safe for testing — no real data)

tags:
  - name: Authentication
    description: Obtain and manage authentication tokens
  - name: Users
    description: Platform users with login credentials
  - name: Teams
    description: Teams of colleagues in an Organisation, and the Projects a Team adds the people who join it to
  - name: Charities
    description: Organisations — the top-level entity that owns Projects
  - name: Projects
    description: The primary organisational unit — every Story and Case belongs to a Project
  - name: Welcome Tours
    description: Guided tours of Makerble's own pages for new colleagues; Organisation Admins choose each team's stops, wording and how strict they are, and see who has finished
  - name: Feature Launches
    description: One record per Makerble feature holding its launch content, used by announcements and the feature launch emails; written by Makerble staff
  - name: Weekly Email
    description: The weekly email of feature announcements, prepared and approved by Makerble staff
  - name: Social Posts
    description: A feature launch's posts for Makerble's own LinkedIn company page, Instagram and X, reviewed and approved by Makerble staff
  - name: Feature Tours
    description: Short tours introducing one feature to people who already use Makerble, offered from a page's Intro or an announcement; written by Makerble staff
  - name: Staff Unavailability
    description: When colleagues can't work for an Organisation (leave, sickness, training), as on the Staff availability page
  - name: Staff Capacity
    description: How many appointments and one-to-one Contacts a colleague can take on in an Organisation, as on the Staff availability page
  - name: Staff Matching
    description: When a colleague is free for an appointment, and which colleagues could take on a Contact for one-to-one appointments, best fit first
  - name: Training Materials
    description: An Organisation's links to its own training documents and videos, each shown to the whole Organisation or to chosen Teams and Workspaces
  - name: Training Tours
    description: The guided tours on the Training materials page - the Welcome Tours picked for you, and every feature tour, with how far you have got
  - name: Announcements
    description: '"What''s new in Makerble" popups, written and scheduled by Makerble staff in Site Overview'
  - name: Wishlist
    description: The gift icon's Wishlist - your feature requests and feedback, and what Makerble is building next (Coming soon)
  - name: Saved Filters
    description: Saved Filters for Contacts, Events and Cases, and adding one to a project's toolbar as a shortcut
  - name: Toolkits
    description: Toolkits (Collections) are ready-made sets of Surveys, Contact Forms, Impact Frameworks, metrics and tips on Explore Toolkits
  - name: Albums
    description: Albums (Bundles; being renamed Portfolios on screen) group Projects so their results can be seen together
  - name: Age Bands
    description: |
      Age bands worked out from each Contact's (Beneficiary's) Date of Birth, as of today. An
      Organisation always has age bands (by default 0–12, 13–17, 18–24 and 25 and over); an Album or
      Project can have its own, and otherwise uses its Organisation's. The Demographics tab of
      Manage Contacts and the Snapshot use the same bands.
  - name: Focus
    description: |
      Focus under Today: one list of everything that needs the signed-in user, grouped by when it's
      due (Overdue, Today, This week, Later) and filtered by type. The first source is Checklist
      Actions: the next step on each Contact's Checklist that the user is responsible for.
  - name: My Apps menu
    description: |
      Whether the My Apps button shows in the signed-in user's top menu, as chosen under
      Personal Settings › Preferences. Contacts with a login and Survey Portal users have no My Apps menu.
  - name: Start page
    description: |
      The page the signed-in user lands on after signing in, and whenever they click Home or the
      Makerble logo: one of the Today pages, chosen under Personal Settings › Preferences › Start page.
  - name: Impact Celebrations
    description: |
      Impact Celebrations announce good news for a Workspace (Project) or Portfolio (Album, Bundle in
      the code) automatically. Its editors switch them on and tick the metrics worth celebrating. Every
      hour Makerble checks: when a ticked metric reaches its target, when a ticked Engagement Tracker
      (a participation Change) reaches 10, 100, 1,000 and so on, or when 80% of Contacts judged on
      a ticked Choice tracker (a Scale Indicator with a success direction) have improved, its
      colleagues see a popup announcement for 7 days. Each target, each milestone, and each Choice tracker,
      celebrates once; anything already reached when first checked is recorded without a popup. Only whoever may
      edit the Workspace's or Portfolio's targets can read or change its Impact Celebrations.
  - name: Snapshot
    description: |
      The Snapshot under Today: one Album's (Portfolio's) or Project's headline numbers on one page.
      "Who we're working with" shows how its Contacts (Beneficiaries) split by Ratio Set, by age band
      and, on an Album, by Project; "How the work is going" shows one headline number per Results
      Canvas column; "Workload" shows up to three Workflow, Cohort or Formula Trackers. The Album's or
      Project's editors choose what goes on it on the Snapshot tab of its Preferences.
  - name: Beneficiaries
    description: Contacts — the people your organisation works with
  - name: Beneficiary Categories
    description: Contact Bio Forms — field schemas for creating and editing Beneficiary records
  - name: Beneficiary Types
    description: The four contact types — Person, Organisation, Animal, Object
  - name: Audio Notes
    description: |
      AI AudioNotes (CaseNotes): audio recordings of a conversation with a Contact (Beneficiary) or
      of an Event session, which Makerble transcribes and summarises into a draft survey response.
  - name: Cases
    description: Cases linked to a Beneficiary and a Project
  - name: Stories
    description: Survey responses, timeline updates, and instant updates — the primary content format
  - name: Labels
    description: Story Labels — an organisation's themes for coding Stories and survey responses
  - name: Story Categories
    description: Surveys — form templates used to create Stories
  - name: Project Story Categories
    description: Survey Campaigns — a Survey assigned to a specific Project
  - name: Progress Boards
    description: Progress Boards — pages of charts and cards showing a Project's, Album's or Survey's results
  - name: Story Metrics
    description: Per-story metric records (Story Changes, Story Indicators, Story Beneficiaries)
  - name: Changes
    description: Activity and Participation custom KPIs tracked across Projects
  - name: Versions
    description: Audit trail — who created or edited a Contact, when, and what it looked like at the time
  - name: Access Logs
    description: Audit trail of views — who opened or fetched a Contact, when, and how many times
  - name: Audit Trail
    description: Organisation-wide feed of changes (Versions) and views (Access Logs) across Contacts and Stories
  - name: Indicators
    description: Scale, Binary, and Value progress trackers linked to Outcomes
  - name: Outcomes
    description: Impact outcomes that Indicators are grouped under
  - name: Outcome Indicators
    description: Join table linking Outcomes to Indicators
  - name: Framework Sets
    description: Groups of Impact Frameworks (e.g. the SDGs) that organisations report their contribution towards
  - name: Financial Values
    description: Published money values for outcomes, and the project Metrics they are put against on a project's Financial Value calculator
  - name: Explore
    description: The Makerble® ImpactStore™'s Explore pages, with the same search, filters and counts as the app
  - name: Reports
    description: Makerble® ReportMaker™'s Report Templates (the questions a report answers, and in what shape) and each Report's answers
  - name: Library
    description: Search the organisation's library and the public library of reusable building blocks, read an item in full, and see where it is used
  - name: ImpactStore
    description: Search the Makerble ImpactStore (the Explore pages) for published Surveys, Contact Forms, Case Forms, Impact Frameworks, Report Templates, Toolkits and Project Types to reuse
  - name: Ratio Sets
    description: Dropdown / List field definitions
  - name: Sub Ratios
    description: Individual answer choices within a Ratio Set
  - name: Ratio Set Choiceables
    description: Selection rules governing how many Sub Ratios can be chosen from a Ratio Set
  - name: Custom Tables
    description: |
      Custom Tables (Custom List Views in the database) are saved column layouts for the Contacts list on
      Manage Contacts: one row per Contact (Beneficiary), with columns for basic Contact fields, Bio Form
      questions, survey answers, progress trackers and relationships.
  - name: Custom Field Categories
    description: Case Forms — field schemas for creating Case records
  - name: Media Gallery
    description: Photos, videos, audio and documents attached to Stories and to Contacts' bios
  - name: Events
    description: Events and recurring series of events, with their guests (Contacts) and staff
  - name: Signup Pages
    description: |
      Referral Link Details — public-facing signup forms, including the
      Offline Collector endpoints that let a form be filled in with no
      network connection and synced back later.
  - name: Suggested Merges
    description: |
      Sets of two or more Contacts (Beneficiaries) that Makerble thinks are the same person,
      waiting for someone to merge them or mark them as Not duplicates. They come from Merge Rules
      set to Suggest mode and from contacts with similar names.
  - name: Duplicate Contacts
    description: |
      Scan for duplicate contacts (Contacts > Merge Contacts > Scan for duplicates): sets of
      Contacts (Beneficiaries) whose names are spelt exactly the same or look similar, and the
      "Suggest possible duplicates when contacts are created" setting.
  - name: Merge Rules
    description: |
      An Organisation's custom rules for finding duplicate Contacts: which fields must be
      identical, and whether matches are merged automatically or suggested for review.
  - name: Field Visibility
    description: |
      Who can see each Contact field (Settings > Field Visibility). A field is either visible to
      everyone who can view the Contact (default) or Restricted to users in chosen Teams or on
      chosen Projects. Also sets whether external guest users see the field.
  - name: Checklists
    description: |
      An Organisation's lists of actions it expects to be done for each Contact (Beneficiary),
      e.g. give them a Role, complete a Contact Form, invite them to an induction event. Projects
      offer a Checklist by hand or add it to every Contact automatically, and each Contact's
      profile shows which actions are done.
  - name: Cohort Trackers
    description: |
      Metrics that count the Contacts (Beneficiaries) in a Project or Album who meet a
      set of Contact Filter criteria, e.g. "Children attending 75%+". Placed in an
      Impact Scorecard column like other metrics, and targeted with a number of
      Contacts to reach.
  - name: Workflow Trackers
    description: |
      Metrics that count records Makerble's own features create, e.g. Signpostings made or
      Contacts referred to another Project, rather than Contacts tagged in updates. Placed in an
      Impact Scorecard column like other metrics.
  - name: Automations
    description: |
      Contact Automations (when Contacts in a Project meet a criteria, do actions such as sending a
      Survey), Project Automations (settings copied onto Projects that match a saved project filter)
      and Automation Templates (saved Contact Automations applied to other Projects).
  - name: Filtered Metrics
    description: |
      Filtered versions of standard metrics: a Change (Activity or Engagement tracker) or an
      Indicator (Choice, Achievement or Numerical tracker) counted again for only some responses
      and Contacts, e.g. "Session attendances — Female, under 21". Each has its own row, name,
      column and targets on a Project's or Album's Results Canvas.
  - name: Add Metric To
    description: |
      The Add metric to popup: the places a metric (a Change, Outcome or Indicator) can be added
      to, and adding or removing it there. Projects are the first destination; an Indicator is only
      ever added to a Project through one of its Outcomes.
  - name: Event Formats
    description: Event Categories — templates for an organisation's events (e.g. Workshops, Classes, Meetings)
  - name: Event Catalogues
    description: Public, bookable lists of an organisation's upcoming events, and who can see them on the Contacts' Portal
  - name: Contacts' Portal
    description: Each Contact's own link to the Contacts' Portal, where they book onto events from Event Catalogues
  - name: Formula Trackers
    description: |
      Metrics worked out from other trackers with + − × ÷, numbers and brackets, e.g. Referrals
      completed = External referrals + Internal referrals, or a percentage of one tracker in another.
      Placed in an Impact Scorecard column like other metrics.
  - name: Seats
    description: |
      Seats per Colleague: which seat each colleague holds on each of an Organisation's current
      Contracts, and changing one. A colleague's roles decide the lowest seat (Billing Role) they
      need on Role-based Pricing. Only the Organisation's admins can change seats.
  - name: Onboarding
    description: |
      Setting up an area of work (a programme or service) for an Organisation, as the onboarding
      journey does after an Organisation is created: workspaces with a Toolkit installed, extra
      workspaces such as Referrals or Volunteers, and a Checklist (participant journey) for the
      area's contacts. Charity Editors and Charity Reporters of the Organisation can use it.
  - name: Setup guide
    description: |
      An Organisation's Setup guide: the main things to set up in Makerble, how far each has got,
      and whether it is done. Makerble ticks each item off when it sees it done; an item once done
      stays done. An Organisation Admin can mark an item "Not relevant to us", which takes it out of
      the total. Organisation Admins and Makerble staff can use it, while the Setup guide is switched
      on for the Organisation (it is on for Organisations created since it was released).
  - name: Usage
    description: |
      An Organisation's usage against the allowances in its plan: Contacts, Stories (survey
      responses), automation runs, API and integration runs, file storage uploaded, SMS and email.
      Shows the charge so far this month, the charge expected by the end of the month if usage
      carries on at the same rate, and the 12 months before. Prices are the Organisation's own.
      This is the Usage page under Our Account › Usage. Organisation Admins and Makerble staff can read it.
  - name: Guidance Panels
    description: |
      The Show/Hide Guidance introduction at the top of each Manage page. Makerble staff with System
      Access change the wording and video; every change is kept as a version.
  - name: API keys
    description: |
      Keys an Organisation's admins create for the custom integrations they build. Each key belongs
      to one Organisation and acts as one of its colleagues. See "Organisation API keys" above.
  - name: Webhooks
    description: |
      HTTPS endpoints an Organisation's admins register to receive signed events when
      Contacts, Stories and Projects change and when imports finish. See Webhooks above.
  - name: Eventbrite
    description: |
      An Organisation's connection to Eventbrite, which brings Eventbrite events, ticket holders and
      check-ins into Makerble as Events, Contacts and attendance Stories. Only the Organisation's admins
      can see or change it.
  - name: Health
    description: Whether the service is up, and which build of it is running

paths:

  /users/sign_in:
    post:
      tags: [Authentication]
      summary: Sign in — obtain an authentication token
      description: |
        Authenticates with email and password. Returns a long-lived token for all subsequent requests.
        Tokens **do not expire**. No auth headers needed on this endpoint.
      operationId: signIn
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required: ["user[email]", "user[password]"]
              properties:
                "user[email]":
                  type: string
                  format: email
                  example: user@example.com
                "user[password]":
                  type: string
                  format: password
      responses:
        "200":
          description: Authentication successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthResponse'
              example:
                user_id: 42
                email: user@example.com
                authentication_token: "sJxyz_abc123longtoken"
        "401":
          description: |
            Wrong email address or password (`invalid-credentials`), or the person hasn't accepted
            their invitation yet and so has no password of their own (`invitation-pending`, with a
            `message` to show them: they set their password from their invitation email).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalidCredentials:
                  value:
                    error: invalid-credentials
                invitationPending:
                  value:
                    error: invitation-pending
                    message: "You haven't set a password yet. Open your invitation email to set one."

  /oauth/token:
    servers:
      - url: https://makerble.com
        description: Production (OAuth endpoints are not under /api/v2)
      - url: https://staging.makerble.com
        description: Staging
    post:
      tags: [Authentication]
      summary: Exchange an authorisation code, or refresh an access token (OAuth 2.0)
      description: |
        For apps connected with OAuth 2.0. Exchange the `code` from the consent screen for an
        access token and refresh token, or swap a refresh token for a new pair. Authenticate
        the app with `client_id` and `client_secret` in the body, or with HTTP Basic auth.
        Access tokens last 1 hour (`expires_in: 3600`). Each refresh returns a new refresh
        token; store the latest one.
      operationId: createOauthToken
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required: [grant_type, client_id, client_secret]
              properties:
                grant_type:
                  type: string
                  enum: [authorization_code, refresh_token]
                code:
                  type: string
                  description: Required for `authorization_code`. Works once; expires after 10 minutes.
                redirect_uri:
                  type: string
                  description: Required for `authorization_code`; must match the one used on `/oauth/authorize`.
                refresh_token:
                  type: string
                  description: Required for `refresh_token`.
                client_id:
                  type: string
                client_secret:
                  type: string
            example:
              grant_type: authorization_code
              code: "Zx1...code"
              redirect_uri: https://global.consent.azure-apim.net/redirect
              client_id: "your-client-id"
              client_secret: "your-client-secret"
      responses:
        "200":
          description: Tokens issued
          content:
            application/json:
              example:
                access_token: "kq3...access"
                token_type: Bearer
                expires_in: 3600
                refresh_token: "9Lm...refresh"
                scope: api
                created_at: 1791726153
        "400":
          description: Invalid, expired or already-used code or refresh token (`{"error":"invalid_grant"}`)
        "401":
          description: Unknown client or wrong client secret (`{"error":"invalid_client"}`)

  /oauth/revoke:
    servers:
      - url: https://makerble.com
        description: Production (OAuth endpoints are not under /api/v2)
      - url: https://staging.makerble.com
        description: Staging
    post:
      tags: [Authentication]
      summary: Revoke an access or refresh token (OAuth 2.0)
      description: |
        For apps connected with OAuth 2.0, e.g. when the user disconnects from inside your app.
        Revoking either token of a pair stops both working. Always returns 200, even for an
        unknown token.
      operationId: revokeOauthToken
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required: [token, client_id, client_secret]
              properties:
                token:
                  type: string
                client_id:
                  type: string
                client_secret:
                  type: string
            example:
              token: "9Lm...refresh"
              client_id: "your-client-id"
              client_secret: "your-client-secret"
      responses:
        "200":
          description: Token revoked (or already invalid)

  /users:
    get:
      tags: [Users]
      summary: List all Users
      operationId: listUsers
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Users
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedUsers'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Users]
      summary: Create a new User
      description: |
        Registers a new user. Requires an `auth_code` API Key — request one at [api-key-request@makerble.com](mailto:api-key-request@makerble.com).

        **Password rules:** min 8 chars · at least 1 number · 1 special character · 1 capital letter
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [auth_code, user, charity_id]
              properties:
                auth_code:
                  type: string
                  description: API Key from api-key-request@makerble.com
                user:
                  type: object
                  required: [email, first_name, last_name, password, password_confirmation]
                  properties:
                    email:
                      type: string
                      format: email
                    first_name:
                      type: string
                    last_name:
                      type: string
                    password:
                      type: string
                    password_confirmation:
                      type: string
                charity_id:
                  type: integer
                charity_controlled:
                  type: boolean
                  default: false
                disable_email_notification:
                  type: boolean
                  default: false
            example:
              auth_code: "qspehLnbRlUS0uiA2mN..."
              user:
                email: "jane@charity.org"
                first_name: "Jane"
                last_name: "Smith"
                password: "Secur3!Pass"
                password_confirmation: "Secur3!Pass"
              charity_id: 31
              charity_controlled: true
              disable_email_notification: false
      responses:
        "200":
          description: User created
          content:
            application/json:
              schema:
                type: object
                properties:
                  user:
                    type: object
                    properties:
                      id:
                        type: integer
                      email:
                        type: string
                        format: email
                  message:
                    type: string
                    example: "Sign up successfully!!!"
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /users/notification_settings:
    get:
      tags: [Users]
      summary: Get your notification settings
      operationId: getUserNotificationSettings
      description: |
        Your own email notification settings, as on the **Notifications** tab of **User Settings**:
        each setting's `key`, its `label` as the tab shows it, and whether it is `enabled`. Settings you
        have never changed show their default. There is no user id: you can only see your own.
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Your notification settings
          content:
            application/json:
              schema: { $ref: '#/components/schemas/UserNotificationSettings' }
              example:
                data:
                  - { key: event_guest_cancelled, label: When an event guest cancels, enabled: true }
                  - { key: someone_tags_me, label: Someone tags me, enabled: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
    patch:
      tags: [Users]
      summary: Change your notification settings
      operationId: updateUserNotificationSettings
      description: |
        Turns your own email notifications on or off, as ticking or unticking them on the
        **Notifications** tab of **User Settings** does. Only the settings you send change. For example,
        `event_guest_cancelled: false` stops the email you get when a guest at one of your events
        cancels. An unknown key, or a value that isn't true or false, returns `422` and changes nothing.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [settings]
              properties:
                settings:
                  type: object
                  description: Setting keys (from GET) and true or false
                  additionalProperties: { type: boolean }
            example:
              settings:
                event_guest_cancelled: false
      responses:
        "200":
          description: All your notification settings, after the change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/UserNotificationSettings' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /users/{id}:
    get:
      tags: [Users]
      summary: Get a single User
      operationId: getUser
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: User record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /users/{id}/resend_invitation:
    post:
      tags: [Users]
      summary: Resend a colleague's invitation
      description: |
        Sends a new invitation email to someone who was invited to an Organisation but hasn't yet set
        their password (Manage Colleagues shows them as "Invited, not yet accepted"). The new link stops
        the earlier one working. Makerble never emails a password: the invitation has a link where the
        person sets their own, and this response never contains the link or its token.

        Only an Organisation Admin of an Organisation the person is a colleague in can do this, as on
        the Manage Colleagues page. Pass `organisation_id` to choose the Organisation the invitation is
        for; without it, the first such Organisation is used. An address can be sent at most 3 new links
        an hour.
      operationId: resendInvitation
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                organisation_id:
                  type: integer
                  description: The Organisation (Charity) to invite them into. Optional.
            example:
              organisation_id: 512
      responses:
        "200":
          description: A new invitation is being sent
          content:
            application/json:
              schema:
                type: object
                required: [id, email, organisation_id, invitation_status, message]
                properties:
                  id:
                    type: integer
                  email:
                    type: string
                  organisation_id:
                    type: integer
                  invitation_status:
                    type: string
                    enum: [sent]
                  message:
                    type: string
              example:
                id: 4012
                email: thandi@example.org
                organisation_id: 512
                invitation_status: sent
                message: A new invitation is on its way. The earlier link no longer works.
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
        "429":
          description: The address has been sent 3 new links in the last hour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: This colleague has been sent 3 new links in the last hour. Try again later.

  /users/{id}/specialisms:
    get:
      tags: [Users]
      summary: List a colleague's Specialisms in an organisation
      description: |
        A colleague's Specialisms (Skills) in one organisation, as the Specialisms box on their
        profile shows them. A colleague in several organisations has separate Specialisms in each.
        Any member of the organisation can list them; `can_change` says whether you may change them.
        The organisation must have Specialisms turned on. `charity_id` may be left out when you
        belong to one organisation.
      operationId: listUserSpecialisms
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
      responses:
        "200":
          description: The colleague's Specialisms in the organisation, by name
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ColleagueSpecialisms' }
              example:
                user_id: 237
                charity_id: 12
                can_change: true
                data:
                  - id: 31
                    name: Eating disorders
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Users]
      summary: Add Specialisms to a colleague
      description: |
        Adds some of the organisation's Specialisms (Skills) to a colleague's. The colleague, a Team
        Leader of one of their Teams in the organisation, or an Organisation Editor can do this.
        Specialisms they already have are left as they are.
      operationId: addUserSpecialisms
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [skill_ids]
              properties:
                charity_id:
                  type: integer
                  description: The organisation. May be left out when you belong to one organisation.
                skill_ids:
                  type: array
                  items: { type: integer }
                  description: Specialisms of that organisation, from GET /skills. Others are ignored.
            example:
              charity_id: 12
              skill_ids: [31]
      responses:
        "201":
          description: The colleague's Specialisms in the organisation, after the change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ColleagueSpecialisms' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You aren't allowed to make this change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                error: forbidden
        "404":
          $ref: '#/components/responses/NotFound'
    delete:
      tags: [Users]
      summary: Remove Specialisms from a colleague
      description: |
        Removes some of the organisation's Specialisms (Skills) from a colleague's. The colleague, a
        Team Leader of one of their Teams in the organisation, or an Organisation Editor can do this.
      operationId: removeUserSpecialisms
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [skill_ids]
              properties:
                charity_id:
                  type: integer
                  description: The organisation. May be left out when you belong to one organisation.
                skill_ids:
                  type: array
                  items: { type: integer }
                  description: Specialisms of that organisation, from GET /skills. Others are ignored.
            example:
              charity_id: 12
              skill_ids: [31]
      responses:
        "200":
          description: The colleague's Specialisms in the organisation, after the change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ColleagueSpecialisms' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You aren't allowed to make this change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                error: forbidden
        "404":
          $ref: '#/components/responses/NotFound'
  /users/permissions:
    get:
      tags: [Users]
      summary: Get user permissions
      description: Returns the authenticated user's permissions across all Projects and Organisations.
      operationId: getUserPermissions
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Permissions object
          content:
            application/json:
              schema:
                type: object
        "401":
          $ref: '#/components/responses/Unauthorized'

  /users/request_password_reset_code:
    get:
      tags: [Users]
      summary: Request a password reset code
      description: Sends a reset code to the user's email. No authentication required.
      operationId: requestPasswordResetCode
      parameters:
        - name: email
          in: query
          required: true
          schema:
            type: string
            format: email
      responses:
        "200":
          description: Reset code sent

  /users/check_password_reset_code:
    get:
      tags: [Users]
      summary: Verify a password reset code
      operationId: checkPasswordResetCode
      parameters:
        - name: email
          in: query
          required: true
          schema:
            type: string
            format: email
        - name: reset_code
          in: query
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Validity result
          content:
            application/json:
              schema:
                type: object
                properties:
                  is_reset_code_correct:
                    type: boolean

  /users/reset_password:
    post:
      tags: [Users]
      summary: Reset a user's password
      operationId: resetPassword
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email, reset_code, password]
              properties:
                email:
                  type: string
                  format: email
                reset_code:
                  type: string
                  example: "DD3CB5B7C260"
                password:
                  type: string
      responses:
        "200":
          description: Password reset successful
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /charities/{id}:
    get:
      tags: [Charities]
      summary: Get a single Organisation
      description: Returns a single Charity (Organisation). Each Charity owns one or more Projects.
      operationId: getCharity
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Charity record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Charity'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Charities]
      summary: Change an Organisation's settings
      description: |
        Changes the Organisation's settings that Charity Preferences offers over the API. For now that is
        **Default story level privacy setting on each project**: the Story Privacy Level each new project
        in the Organisation starts with. Existing projects keep their own level, and each project's level
        can still be changed on its Preferences page. Only settings sent are changed. Only an
        Organisation Admin may do this; other colleagues get 403. Returns the Organisation.

        It also sets the Organisation's **Region** and **Industry** (`region_factor_option_id`,
        `industry_factor_option_id`), as on Edit organisation profile. Localised Financial Values, such
        as the TOM System's local employment and local spend Measures, are worked out from them for
        every project that doesn't set its own. Take the ids from `GET /factor_options`; send null to
        clear one, so national amounts apply. An Industry sent as the Region, or the other way round,
        gets 422. Contribution figures update in the background a few minutes later.
      operationId: updateCharity
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                default_project_story_privacy:
                  $ref: '#/components/schemas/DefaultProjectStoryPrivacy'
                participant_pass_sign_in_enabled:
                  type: boolean
                  description: >-
                    "Enable contacts to sign in using a participant pass". When false, a Contact's profile
                    hides the Participating As tab unless the Contact is already linked to a user.
                region_factor_option_id:
                  type: integer
                  nullable: true
                  description: The Organisation's Region, a `dimension` region option from `GET /factor_options`
                industry_factor_option_id:
                  type: integer
                  nullable: true
                  description: The Organisation's Industry, a `dimension` industry option from `GET /factor_options`
            example:
              region_factor_option_id: 7
              industry_factor_option_id: 102
      responses:
        "200":
          description: The Organisation, with the setting changed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Charity'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /announcements:
    get:
      tags: [Announcements]
      summary: List Announcements
      description: |
        Lists popup announcements, newest first, with how many people have seen each one and how
        many clicked its "Learn more" link. Each signed-in user in an announcement's audience sees
        it once, between its start and end dates.

        There are two kinds. Makerble's own "What's new in Makerble" popups (`scope_type` null) are
        written in Site Overview › Announcements. An Organisation, Workspace (Project) or Team's
        announcements (`scope_type` `Charity`, `Project` or `Team`) are written by the people who
        look after it, for the colleagues there, on that place's Announcements page.

        System Access users (Makerble staff) see every announcement. Anyone else sees only those for
        places where they hold the role now: an Organisation Admin sees their Organisation's and its
        Workspaces' and Teams'; a Workspace editor (Project Editor) sees that Workspace's; a Team
        leader sees that Team's. Someone who can make announcements nowhere gets 403.
      operationId: listAnnouncements
      security: [{tokenAuth: []}]
      parameters:
        - name: scope_type
          in: query
          required: false
          description: With `scope_id`, only this place's announcements.
          schema:
            type: string
            enum: [Charity, Project, Team]
        - name: scope_id
          in: query
          required: false
          description: The Organisation, Workspace or Team id, with `scope_type`.
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Announcements
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAnnouncements'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
    post:
      tags: [Announcements]
      summary: Create an Announcement
      description: |
        Creates a popup announcement. It is saved as a draft (seen by nobody) unless `status` is
        `scheduled`, when it shows from `starts_on` to `ends_on` to its audience. Write the headline
        in sentence case, saying plainly what changed, and a message that says what the person
        needs to do, which is often nothing.

        With `scope_type` and `scope_id`, it is that Organisation's, Workspace's or Team's
        announcement. Its audience is always the colleagues there (`audience` is ignored), it can't
        use the name change animation, and its Learn more link can be any https page. The user must
        be an Organisation Admin of that Organisation (or of the Workspace's or Team's
        Organisation), an editor of that Workspace, or a leader of that Team; otherwise 403. A place
        that doesn't exist gets 404.

        Without them, it is one of Makerble's own "What's new in Makerble" popups: System Access
        users only.
      operationId: createAnnouncement
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnnouncementInput'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/AnnouncementInput'
            examples:
              makerble:
                summary: One of Makerble's own (System Access users)
                value:
                  title: Projects are now Workspaces, and Albums are now Portfolios
                  body: Nothing has moved. Only the names have changed.
                  visual_type: name_change
                  name_changes:
                    - old_name: Projects
                      new_name: Workspaces
                    - old_name: Albums
                      new_name: Portfolios
                  learn_more_url: https://makerble.atlassian.net/wiki/spaces/MCPD/pages/123/Workspaces
                  audience: everyone
                  starts_on: "2026-12-01"
                  ends_on: "2026-12-31"
                  status: scheduled
              workspace:
                summary: A Workspace's, for the colleagues on it
                value:
                  scope_type: Project
                  scope_id: 42
                  title: Term dates are out
                  body: Have a look before you book leave.
                  visual_type: none
                  learn_more_url: https://riverside.org.uk/term-dates
                  starts_on: "2026-12-01"
                  ends_on: "2026-12-08"
                  status: scheduled
              image:
                summary: With an image, sent as base64
                value:
                  title: Surveys now have a Duplicate button
                  body: Copy a Survey, with its questions, in one click.
                  visual_type: image
                  image:
                    filename: duplicate-survey.png
                    data: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
                  image_alt: The Duplicate button at the top of a Survey
                  learn_more_url: https://makerble.atlassian.net/wiki/spaces/MCPD/pages/123/Surveys
                  status: draft
      responses:
        "201":
          description: The created Announcement
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Announcement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /announcements/facts:
    get:
      tags: [Announcements]
      summary: List Announcement Facts
      description: |
        The named facts an announcement's `audience_rules` can use, such as
        `distance_travelled_not_set_up` (the person's organisation hasn't set up Distance Travelled), each
        with what it means and the params it takes. A fact about a person's organisations takes `across`:
        for someone in several organisations, whether it must hold for any one of them
        (`any_organisation`, the default), every one (`all_organisations`) or the oldest one they belong
        to (`first_organisation`). Facts are written in Makerble's code, so this list only changes with a
        release. System Access users only; anyone else gets 403.
      operationId: listAnnouncementFacts
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Every fact, on one page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAnnouncementFacts'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
  /deep_links:
    get:
      tags: [Announcements]
      summary: List Deep Links
      description: |
        The pages a link can open in the signed-in person's own organisation, such as Manage Checklists
        (`checklists`) or Create a contact (`create_contact`): every link in Makerble's deep links catalogue, the
        same links the User Guide uses as https://www.makerble.com/deeplink/<name>. Each has its `name`, a readable
        `label` in on-screen words, the `group` it belongs to (Contacts, Events, Surveys, ...) and the `role` the
        person needs: `user` (anyone signed in), `member` (an Editor, Reporter or Observer of the organisation or one
        of its Workspaces) or `editor` (an Editor of the organisation). A `record` link opens one record, such as the
        first Contact the person can see. Use a `name` as an announcement's `button_deep_link`. The list only changes
        with a release, so it comes on one page. System Access users only; anyone else gets 403.
      operationId: listDeepLinks
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Every deep link, on one page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedDeepLinks'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
  /announcements/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Announcements]
      summary: Get an Announcement
      description: |
        One announcement, with its seen and "Learn more" click counts. System Access users can get any;
        anyone else only one for a place where they hold the role (see List Announcements), or 403.
      operationId: getAnnouncement
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Announcement
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Announcement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Announcements]
      summary: Update an Announcement
      description: |
        Changes only the fields sent. Without `status`, a draft stays a draft and a scheduled
        announcement stays scheduled. Editing a live announcement doesn't show it again to people
        who have already seen it. To end one early, set `ends_on` to today. An announcement never
        moves to another place: `scope_type` and `scope_id` are ignored here. System Access users can
        change any; anyone else only one for a place where they hold the role now, or 403.

        To schedule one of Makerble's own on the next free days (people see at most one Makerble
        announcement a day), send `schedule_on_next_free_days: true`.
      operationId: updateAnnouncement
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnnouncementInput'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/AnnouncementInput'
            example:
              ends_on: "2026-12-15"
      responses:
        "200":
          description: The updated Announcement
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Announcement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /whats_new:
    get:
      tags: [Announcements]
      summary: List What's new for the signed-in user
      description: |
        Lists the announcements in the signed-in user's Wishlist › What's new: Makerble's own "What's
        new in Makerble" announcements that have gone live (live now, or ended) for an audience the
        user is in, newest first. Scheduled ones still to start are listed too, by their start date,
        when the popup would show them to the user (its audience or roles, and its behaviour rules),
        so they can be read early; reading one early means the popup skips it on its day. An
        Organisation's, Workspace's or Team's own announcements are not listed. Each says whether the user has seen it, in the popup or by opening it in What's new,
        and which section it is in: `new_since_joined` (it started on or after the day the user's
        account was made) or `before_joined`.

        Listing them records nothing; the user still sees an unseen one in the popup. Use `filter`
        to list only the Unread or only the Read ones, as the page's Unread and Read filters do.
      operationId: listWhatsNew
      security: [{tokenAuth: []}]
      parameters:
        - name: section
          in: query
          required: false
          description: Only this section. Without it, both sections together.
          schema:
            type: string
            enum: [new_since_joined, before_joined]
        - name: filter
          in: query
          required: false
          description: |
            `unread`: only the ones the user hasn't opened yet, in the popup or in What's new (the page's
            Unread filter). `read`: only the ones they have opened (Read). Without it, both.
          schema:
            type: string
            enum: [unread, read]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated What's new announcements
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedWhatsNew'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /wishes:
    get:
      tags: [Wishlist]
      summary: List your Wishlist
      description: |
        Lists your own feature requests and feedback from Wishlist › Your wishlist (the gift icon), newest
        first, with where each one is. You only ever see your own, never a colleague's. A feature request
        also goes to Makerble's Helpdesk; `status` then follows it ("Received", "We are looking at this",
        "Estimate sent to your bill payer", "Being built", "Shipped" and so on). Feedback stays in Makerble
        and reads "Read by the Makerble team".
      operationId: listWishes
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Wishes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedWishes'
        "401":
          $ref: '#/components/responses/Unauthorized'
    post:
      tags: [Wishlist]
      summary: Request a feature or give feedback
      description: |
        Sends a feature request or feedback, as Wishlist › Your wishlist does. A feature request goes to
        Makerble's Helpdesk; if it needs custom work, Makerble sends an estimate to your organisation's
        bill payer, not to you. Feedback stays in Makerble. Don't include details of people you support.
        `charity_id` says which of your organisations it's about. It must be one you belong to; leave it
        out if you belong to only one.
      operationId: createWish
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WishInput'
            example:
              kind: feature_request
              body: Remind me when a register hasn't been filled in by the end of the day.
      responses:
        "201":
          description: The Wish you sent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Wish'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /roadmap_items:
    get:
      tags: [Wishlist]
      summary: List Coming soon
      description: |
        What Makerble has committed to building, as Wishlist › Coming soon shows it: published items,
        Building now before Up next, each in order. There are no dates. System Access users (Makerble
        staff) also see unpublished items, and `stale` flags any unchanged for 60 days.
      operationId: listRoadmapItems
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Coming soon items
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedRoadmapItems'
        "401":
          $ref: '#/components/responses/Unauthorized'
    post:
      tags: [Wishlist]
      summary: Create a Coming soon item
      description: |
        Adds an item to Coming soon, at the end of its stage, as Site Overview › Coming soon does. Write it
        in customer language, with no dates. Nobody but Makerble staff sees it until `published` is true.
        System Access users only.
      operationId: createRoadmapItem
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoadmapItemInput'
            example:
              title: Formula Trackers
              body: Add metrics together to show a combined result.
              stage: up_next
              published: true
      responses:
        "201":
          description: The created item
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoadmapItem'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /roadmap_items/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    patch:
      tags: [Wishlist]
      summary: Update a Coming soon item
      description: |
        Changes only the fields sent. Moving an item to another stage puts it at the end of that stage.
        Set `published` to false to take it out of Coming soon. System Access users only.
      operationId: updateRoadmapItem
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoadmapItemInput'
            example:
              stage: building_now
      responses:
        "200":
          description: The updated item
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoadmapItem'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /saved_filters:
    get:
      tags: [Saved Filters]
      summary: List Saved Filters
      description: |
        The Saved Filters for Contacts, Events and Cases that you can see: your own, the ones colleagues
        have shared, and the ones you can edit (`can_edit`). These are the filters listed on a project's Workflow › Saved filters tab, ready to be
        added to a project's toolbar as a shortcut. `project_ids` are the projects named in the filter's
        criteria; a filter can be added only to one of those projects. `can_add_shortcut` is true when you
        can add it to at least one of them.
      operationId: listSavedFilters
      security: [{tokenAuth: []}]
      parameters:
        - name: type
          in: query
          required: false
          description: Only Saved Filters of this kind.
          schema:
            type: string
            enum: [contacts, events, cases]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Saved Filters, by name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSavedFilters'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Saved Filters]
      summary: Create a Saved Filter
      description: |
        Saves a set of filter criteria for Contacts, Events or Cases as a Saved Filter, as the Save the filter
        button on those pages does. Anyone who can use the page can then apply it in one click from its Saved
        Filters list.

        `criteria` holds the filter settings in the same shape the page's filters send them (for Cases, the
        Manage Cases filters, e.g. `project_ids`, `owner_ids`, `date_created_from`). Read an existing filter's
        `criteria` (GET /saved_filters/{id}) to see the shape. Criteria that name something later deleted
        (a project, a colleague) are ignored when the filter is applied.

        `organisation_id` is required only when you belong to more than one organisation. By default only you
        can use the filter (`shared: false`) and only you can edit it (`who_can_edit: individuals`,
        `editor_ids: [your id]`). Everyone in `editor_ids` must be in the filter's organisation.
      operationId: createSavedFilter
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/SavedFilterInput'
                - type: object
                  required: [name, type]
            example:
              name: Open cases in Leeds
              type: cases
              criteria:
                project_ids: ["42"]
                close_cases: false
              shared: true
              who_can_edit: individuals
              editor_ids: [7, 12]
      responses:
        "201":
          description: The Saved Filter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavedFilterDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /saved_filters/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Saved Filters]
      summary: Get a Saved Filter
      description: |
        One Saved Filter, with what you need to add it to a project's toolbar: `shortcut_views`, the views
        of its app the shortcut can open (e.g. Contacts › Overview, or one of your Custom tables), and
        `shortcut_projects`, the projects you can add it to. `shortcut_projects` is empty when
        `can_add_shortcut` is false.
      operationId: getSavedFilter
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Saved Filter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavedFilterDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Saved Filters]
      summary: Update a Saved Filter
      description: |
        Changes only the fields sent, as the Saved Filter's edit popup does. Sending `criteria` replaces all of
        them. A Saved Filter's `type` and `organisation_id` can't be changed. You need to be able to edit the
        filter (`can_edit`): its owner, someone in its `editor_ids`, or, when `who_can_edit` is
        `organisation_admins`, an Organisation Admin of its organisation.
      operationId: updateSavedFilter
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SavedFilterInput'
            example:
              name: Open cases in Leeds and Bradford
              criteria:
                project_ids: ["42", "43"]
      responses:
        "200":
          description: The Saved Filter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavedFilterDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Saved Filters]
      summary: Delete a Saved Filter
      description: |
        Deletes the Saved Filter and any shortcuts to it on project toolbars, as Delete in its edit popup does.
        You need to be able to edit the filter (`can_edit`).
      operationId: deleteSavedFilter
      security: [{tokenAuth: []}]
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /saved_filters/{id}/shortcuts:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    post:
      tags: [Saved Filters]
      summary: Add a Saved Filter to a project's toolbar
      description: |
        Adds the Saved Filter to a project's toolbar (its Workflow) as a shortcut, as the Saved Filter's
        Add to workflow button does. Clicking the shortcut opens the chosen view with the filter applied.
        The shortcut goes first on the toolbar; move it with Adjust toolbar.

        Choose `project_id` from the filter's `shortcut_projects` and `view_key` from its `shortcut_views`
        (GET /saved_filters/{id}). You need to be an Organisation Admin, or an Editor of the project.
        Colleagues who can't see the Saved Filter don't see its shortcut.
      operationId: createSavedFilterShortcut
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SavedFilterShortcutInput'
            example:
              project_id: 42
              view_key: contacts_overview
              name: Young carers
      responses:
        "201":
          description: The shortcut
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SavedFilterShortcut'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /tours:
    get:
      tags: [Welcome Tours]
      summary: List Welcome Tours
      description: |
        Lists Welcome Tours: the guided tours of Makerble's own pages that a new colleague is offered after the
        photo step of their welcome journey. Each tour belongs to an Organisation and, optionally, one of its
        Teams; a tour with no team (`team_id` null) is the Organisation's default, for people whose teams have
        none. Only a `live` tour is shown to people. Each stop focuses on one part of a page and either waits
        for Next or asks the person to click something (`action: click`).

        System Access users (Makerble staff) see every tour. An Organisation Admin sees their own
        Organisation's tours. Anyone else gets 403.
      operationId: listTours
      security: [{tokenAuth: []}]
      parameters:
        - name: organisation_id
          in: query
          required: false
          description: Only this Organisation's tours. An Organisation the user isn't an Organisation Admin of is refused with 403.
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Welcome Tours
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedTours'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
    post:
      tags: [Welcome Tours]
      summary: Create a Welcome Tour
      description: |
        Creates a Welcome Tour for an Organisation, as Site Overview › Welcome Tours does. It is a `draft`
        (seen by nobody) until `status` is `live`; each Team, and the default, can have one live tour.
        Each stop's `stop_key` is one of the stops Makerble knows: navbar_spaces, navbar_user, focus_table,
        contacts_table, contacts_search, contacts_filters, events_table, event_guests. System Access users only.
      operationId: createTour
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TourInput'
            example:
              name: Centre Administrators Welcome Tour
              organisation_id: 123
              team_id: 45
              mode: required
              status: draft
              later_limit: 3
              stops:
                - stop_key: navbar_spaces
                  position: 1
                  group_name: Essentials
                  title: Your work lives in Spaces
                  body: Everything you do starts in one of your workspaces.
                  action_text: Click Spaces to see yours.
      responses:
        "201":
          description: The created Welcome Tour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tour'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /tours/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Welcome Tours]
      summary: Get a Welcome Tour
      description: One Welcome Tour with its stops in order. System Access users, or an Organisation Admin of its Organisation.
      operationId: getTour
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Welcome Tour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tour'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Welcome Tours]
      summary: Update a Welcome Tour
      description: |
        Changes only the fields sent. System Access users can change everything; a stop with `_destroy: true`
        is removed, and a stop without an `id` is added.

        An Organisation Admin of the tour's Organisation can change what their Welcome journey settings page
        changes: `mode` (`required` is "Mandatory", `optional` lets people skip or end it), `start_skippable`
        ("People can skip the tour when it is first offered"), `later_limit` (how many times someone can choose
        "I'll do this later", 1 to 10), and for each stop, named by its `id` or its `stop_key`: `included`
        (whether the tour shows it; an unticked stop keeps its wording for when it is ticked again), `body` (its
        wording, up to 280 characters of plain text; empty means Makerble's `default_body`) and `skippable` (on
        stops that ask for a click). A `stop_key` the tour doesn't have yet adds that stop. Essentials stops
        (navbar_spaces, navbar_user) are always included. Only the fields sent change. Sending anything else as
        an Organisation Admin is refused with 403.

        Both can set `watch_checklist_ids`: up to 2 Checklists of the tour's Organisation that Watch the journey
        shows a new colleague straight after the tour, one step at a time, in the order sent. A person sees only
        those on their own workspaces. An empty list means they see up to 2 Checklists on their workspaces, most
        recently updated first. More than 2, or a Checklist from another Organisation, is refused with 422.
      operationId: updateTour
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TourInput'
            example:
              later_limit: 2
              stops:
                - id: 678
                  skippable: true
                - id: 679
                  included: false
                - stop_key: contacts_table
                  body: Every child you work with has a record here.
      responses:
        "200":
          description: The updated Welcome Tour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tour'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /feature_launches:
    get:
      tags: [Feature Launches]
      summary: List feature launches
      description: |
        Lists feature launches: one record per Makerble feature holding its launch content. A launch has the feature's
        name as people see it in Makerble (such as "Registers"), its tier, the short description its announcements
        show, the longer email description the feature launch emails use, its links (User Guide page, blog post, deep
        link, feature tour and Intro), its email visual and which of its links the email shows.

        An announcement for a launch (`feature_launch_id` on the announcement) shows the launch's short description,
        User Guide link, deep link and feature tour wherever it has none of its own.

        Send `search` to find launches by name. System Access users (Makerble staff) only. Anyone else gets 403.
      operationId: listFeatureLaunches
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: search
          in: query
          required: false
          description: Only launches whose name contains this text, ignoring case.
          schema:
            type: string
      responses:
        "200":
          description: Paginated feature launches
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFeatureLaunches'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
    post:
      tags: [Feature Launches]
      summary: Create a feature launch
      description: |
        Creates a feature launch, as Site Overview › Feature launches does. Only `name` is required, and it must be
        unique. To link an announcement to it, send its `id` as the announcement's `feature_launch_id`.
        System Access users only.
      operationId: createFeatureLaunch
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureLaunchInput'
            example:
              name: Registers
              tier: major
              short_description: Take a register at every session and see who came at a glance.
              email_description: >-
                Registers show who came to each session. Tick people off as they arrive, and the numbers flow into your
                reports. Open Events to take your first one.
              user_guide_url: https://makerble.atlassian.net/wiki/spaces/MCPD/pages/123/Registers
              deep_link: registers
              email_visual: gif
              email_visual_alt: A register being ticked off as people arrive
              email_primary_link: deep_link
              email_text_links: [user_guide]
              jira_keys: [CP-9271]
              released_on: '2026-12-01'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FeatureLaunchInput'
      responses:
        "201":
          description: The created feature launch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureLaunchWithNotices'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /feature_launches/email_preview:
    post:
      tags: [Feature Launches]
      summary: Preview the feature launch email
      description: |
        Gives the feature launch email for up to 10 feature launches, as one person would get it, without sending
        anything: the subject, the HTML and the plain-text version. It is the email the weekly and one-off feature
        launch emails send, and the same as Site Overview › Feature launches › Preview email shows.

        Send `user_email` to see it as that Makerble user gets it: a deep link ("Open Registers") and Take the tour
        show only when their account can open the page. Leave it out to see it as someone without a Makerble account,
        who gets the User Guide and blog links instead. The launches appear in the order of `feature_launch_ids`.
        System Access users (Makerble staff) only. Anyone else gets 403.
      operationId: previewFeatureLaunchEmail
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureLaunchEmailInput'
            example:
              feature_launch_ids: [12, 9]
              user_email: someone@example.org
              intro: Here is what we released this month.
      responses:
        "200":
          description: The email as that person would get it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureLaunchEmailPreview'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /feature_launches/email_test:
    post:
      tags: [Feature Launches]
      summary: Send yourself a test of the feature launch email
      description: |
        Sends the feature launch email, as `user_email` (or someone without an account) would get it, to you and no
        one else. The subject starts "[Test]". Takes the same input as POST /feature_launches/email_preview.
        System Access users (Makerble staff) only. Anyone else gets 403.
      operationId: sendFeatureLaunchEmailTest
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureLaunchEmailInput'
            example:
              feature_launch_ids: [12]
      responses:
        "200":
          description: The test is on its way
          content:
            application/json:
              schema:
                type: object
                required: [message, to]
                properties:
                  message:
                    type: string
                    example: Test sent to you@makerble.com.
                  to:
                    type: string
                    description: The address it was sent to, always your own.
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /weekly_feature_email:
    get:
      tags: [Weekly Email]
      summary: Get a week's weekly email of feature announcements
      description: |
        The weekly email of feature announcements for one week (Monday to Sunday), as on Site Overview › Weekly email:
        its items (feature launches) in order, subject, opening paragraph, whether it is paused, when it sends, and once
        sent, when and to how many people. Without `week`, the coming week's: this week's until it has been sent, then
        next week's. A week's email is made the first time it is asked for, filled with the feature launches of
        Makerble's announcements that start that week.

        Each person gets only the items whose announcement they are in the audience of. Contacts with a login, Survey
        Portal users and people who turned it off in Notification settings get nothing, and a week with no items sends
        nothing. System Access users (Makerble staff) only. Anyone else gets 403.
      operationId: getWeeklyFeatureEmail
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/WeeklyEmailWeek'
      responses:
        "200":
          description: The week's email and how the weekly email is sent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WeeklyFeatureEmailWithSetting'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    patch:
      tags: [Weekly Email]
      summary: Change a week's weekly email
      description: |
        Changes a week's email, as Site Overview › Weekly email does. Only what you send changes.
        `feature_launch_ids` is the whole list of items, in order: launches left out are removed (and stay removed
        when the week fills again from new announcements) and new ones are added. `paused: true` stops it sending until
        it is resumed. A week that has been sent, or is over, can't change (422). System Access users only.
      operationId: updateWeeklyFeatureEmail
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                week:
                  type: string
                  format: date
                  description: Any date in the week. Without it, the coming week's email.
                feature_launch_ids:
                  type: array
                  maxItems: 10
                  items: { type: integer }
                  description: Every item, in order (see GET /feature_launches)
                subject:
                  type: string
                  maxLength: 150
                  description: Leave empty to name the features
                intro:
                  type: string
                  maxLength: 1000
                  description: An opening paragraph
                paused:
                  type: boolean
            example:
              week: '2026-12-07'
              feature_launch_ids: [12, 9]
              intro: Here's what's new in Makerble this week.
      responses:
        "200":
          description: The week's email, after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WeeklyFeatureEmailWithSetting'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /weekly_feature_email/preview:
    post:
      tags: [Weekly Email]
      summary: Preview a week's weekly email as a chosen user gets it
      description: |
        The week's email as one user would get it, sending nothing: only the items whose announcement they are in the
        audience of, with their name and their unsubscribe link. Without `user_email`, your own. If they would get
        nothing, `gets_email` is false and `left_out` says why. System Access users only.
      operationId: previewWeeklyFeatureEmail
      security: [{tokenAuth: []}]
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                week:
                  type: string
                  format: date
                  description: Any date in the week. Without it, the coming week's email.
                user_email:
                  type: string
                  description: Whose email to show. Without it, your own.
            example:
              week: '2026-12-07'
              user_email: busi@example.com
      responses:
        "200":
          description: The email as that user gets it, or why they get none
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WeeklyFeatureEmailPreview'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /weekly_feature_email/approve:
    post:
      tags: [Weekly Email]
      summary: Approve and send a week's weekly email
      description: |
        Approve and send, as on Site Overview › Weekly email: records that you approved the week's email, resumes it if
        it was paused and sends it straight away. With Send once approved, the email goes only once someone does this.
        A week with no items, or one already sent, returns 422. System Access users only.
      operationId: approveWeeklyFeatureEmail
      security: [{tokenAuth: []}]
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                week:
                  type: string
                  format: date
                  description: Any date in the week. Without it, the coming week's email.
            example:
              week: '2026-12-07'
      responses:
        "200":
          description: The week's email, now sent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WeeklyFeatureEmailWithSetting'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /weekly_feature_email/setting:
    patch:
      tags: [Weekly Email]
      summary: Change how the weekly email is sent
      description: |
        Send automatically (`send_mode: automatic`) sends each week's email on its day and hour, unless it is paused.
        Send once approved (`send_mode: approval`) waits until someone approves it. `send_day` is 1 (Monday) to 7
        (Sunday) and `send_hour` 0 to 23, in UK time. Only what you send changes. System Access users only.
      operationId: updateWeeklyFeatureEmailSetting
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                send_mode: { type: string, enum: [automatic, approval] }
                send_day: { type: integer, minimum: 1, maximum: 7 }
                send_hour: { type: integer, minimum: 0, maximum: 23 }
            example:
              send_mode: approval
      responses:
        "200":
          description: How the weekly email is sent, after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WeeklyFeatureEmailSetting'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /weekly_feature_emails:
    get:
      tags: [Weekly Email]
      summary: List weekly emails
      description: |
        Every week's email that has been made, newest week first, with when each was sent and to how many people.
        System Access users only.
      operationId: listWeeklyFeatureEmails
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated weekly emails
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedWeeklyFeatureEmails'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
  /feature_launches/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Feature Launches]
      summary: Get a feature launch
      description: One feature launch, with the ids of the announcements for it. System Access users only.
      operationId: getFeatureLaunch
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The feature launch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureLaunchWithNotices'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Feature Launches]
      summary: Update a feature launch
      description: |
        Changes only the fields sent; send null or an empty string to clear one. `jira_keys` and `email_text_links`
        replace the whole list when sent. An `email_image` sent replaces the saved one, and changing `email_visual`
        away from `image` removes it. System Access users only.
      operationId: updateFeatureLaunch
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureLaunchInput'
            example:
              blog_url: https://www.makerble.com/blog/registers
              email_text_links: [user_guide, blog]
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FeatureLaunchInput'
      responses:
        "200":
          description: The updated feature launch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureLaunchWithNotices'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /social_posts:
    get:
      tags: [Social Posts]
      summary: List social posts
      description: |
        Lists social posts: a feature launch's posts for Makerble's own LinkedIn company page, Instagram and X, at most
        one per channel for each launch. They are only ever about Makerble's feature launches, never an organisation's
        data. Each has its copy (`body`), media, link, planned date and time, and a status: draft, approved, scheduled,
        published or failed. Posts are listed by planned time, those without one last.

        Narrow the list with `feature_launch_id`, `channel`, `status` or `week` (any date in the week; weeks start on
        Monday), as Site Overview › Social posts shows them. System Access users (Makerble staff) only. Anyone else
        gets 403.
      operationId: listSocialPosts
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: feature_launch_id
          in: query
          required: false
          description: Only the posts for this feature launch.
          schema:
            type: integer
        - name: channel
          in: query
          required: false
          schema:
            type: string
            enum: [linkedin, instagram, x]
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: [draft, approved, scheduled, published, failed]
        - name: week
          in: query
          required: false
          description: Only posts planned in the week (Monday to Sunday) holding this date, such as 2026-12-07.
          schema:
            type: string
            format: date
      responses:
        "200":
          description: Paginated social posts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSocialPosts'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    post:
      tags: [Social Posts]
      summary: Create a social post
      description: |
        Creates a draft post for one channel of a feature launch, as Site Overview › Social posts does. A launch can
        have one post per channel. Each channel's rules are checked:

        - X: at most 280 characters, counting a link as 23 (as X does).
        - Instagram: only for Major feature launches; needs media; at most 2,200 characters. Its link isn't clickable
          in a caption, so a post with a link must say the setting's wording, "link in bio" unless changed (see
          GET /social_post_settings).
        - LinkedIn: at most 3,000 characters, and an image or GIF rather than a video.

        Leave out `planned_at` and it is 10:00 UK time on the start date of the launch's first Makerble announcement;
        leave out `link_url` and it is the blog post for a Major launch, otherwise the launch's deep link. Send either
        as null to leave it empty. The post is a draft until someone approves it (POST /social_posts/{id}/approve).
        System Access users only.
      operationId: createSocialPost
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SocialPostCreateInput'
            example:
              feature_launch_id: 12
              channel: linkedin
              body: >-
                Registers are here. Tick people off as they arrive at each session, and the numbers flow straight into
                your reports.
              media: gif
              media_alt: A register being ticked off as people arrive
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SocialPostCreateInput'
      responses:
        "201":
          description: The created social post
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPost'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /social_posts/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Social Posts]
      summary: Get a social post
      description: One social post. System Access users only.
      operationId: getSocialPost
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The social post
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPost'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Social Posts]
      summary: Update a social post
      description: |
        Changes only the fields sent; send null or an empty string to clear one. The channel can't be changed.
        Changing an approved post sends it back to draft, so it is approved again as it will go out. A published post
        can't be changed. An `image` sent replaces the saved one, and changing `media` away from `image` removes it.
        System Access users only.
      operationId: updateSocialPost
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SocialPostInput'
            example:
              body: Registers are here. Tick people off as they arrive. Link in bio.
              planned_at: '2026-12-07T10:00:00Z'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SocialPostInput'
      responses:
        "200":
          description: The updated social post
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPost'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /social_posts/{id}/approve:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    post:
      tags: [Social Posts]
      summary: Approve a social post
      description: |
        Approves a draft, as the Approve button does, recording who approved it and when. It must pass its channel's
        rules and have a planned time. With the setting "Publish once approved" (the default), only approved posts are
        published. System Access users only.
      operationId: approveSocialPost
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The approved social post
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPost'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /social_posts/{id}/send_back:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    post:
      tags: [Social Posts]
      summary: Send a social post back to draft
      description: |
        Sends an approved or failed post back to draft, as the Send back to draft button does. A draft, scheduled or
        published post can't be sent back. System Access users only.
      operationId: sendBackSocialPost
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The social post, now a draft
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPost'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /social_post_settings:
    get:
      tags: [Social Posts]
      summary: Get the social post settings
      description: |
        How social posts are published: `once_approved` (the default, because they go out from Makerble's public
        company profiles) publishes only approved posts; `automatically` publishes drafts too when their planned time
        comes. Also the wording Instagram captions use instead of a link. System Access users only.
      operationId: getSocialPostSettings
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPostSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
    patch:
      tags: [Social Posts]
      summary: Update the social post settings
      description: Changes only the fields sent. System Access users only.
      operationId: updateSocialPostSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SocialPostSettingsInput'
            example:
              publish_mode: once_approved
      responses:
        "200":
          description: The updated settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SocialPostSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /feature_tours:
    get:
      tags: [Feature Tours]
      summary: List feature tours
      description: |
        Lists feature tours: short tours that introduce one feature to people who already use Makerble. Unlike a
        Welcome Tour, a feature tour belongs to no Organisation. A `live` tour with a `page_key` is offered by
        "Take the tour" on that page's Intro (the Show/Hide Guidance panel at the top of a Manage page); each Intro
        has at most one live tour. Each stop is one of the stops Welcome Tours use, named by `stop_key`, and shows
        Makerble's `default_title` and `default_body` unless it has its own `title` or `body`.

        System Access users (Makerble staff) only. Anyone else gets 403.
      operationId: listFeatureTours
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated feature tours
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFeatureTours'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
    post:
      tags: [Feature Tours]
      summary: Create a feature tour
      description: |
        Creates a feature tour, as Site Overview › Feature Tours does. It is a `draft` (offered to nobody) until
        `status` is `live`, which needs at least one stop. `key` is lowercase words joined by underscores and must
        be unique. `page_key`, if sent, is the key of a page's Intro, such as `contacts` or `events`. Each stop's
        `stop_key` is one of the stops Makerble knows (the `stop_key` values a Welcome Tour's stops use).
        System Access users only.
      operationId: createFeatureTour
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureTourInput'
            example:
              key: contacts_filters
              name: Filters on Contacts
              page_key: contacts
              status: draft
              auto_prompt: false
              stops:
                - stop_key: contacts_table
                  position: 1
                - stop_key: contacts_filters
                  position: 2
                  body: Filters let you see just the people you need.
      responses:
        "201":
          description: The created feature tour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureTour'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /tour_stops:
    get:
      tags: [Feature Tours]
      summary: List the stops a tour can use
      description: |
        Lists every stop Makerble knows: the stops Welcome Tours and feature tours are built from. Each one focuses
        on one part of one page, such as the Filters button on Contacts. Use a stop's `key` as the `stop_key` of a
        feature tour's or a Welcome Tour's stop.

        Stops come in registry order, grouped by feature (`group_name`, such as Contacts, Checklists, Registers or
        Results Canvas; "Other" for a stop with no group). Each says which page it opens (`page`), whether it waits
        for Next or for a click, Makerble's default wording, the wording it shows instead when the person has
        nothing on that page yet (`empty`), and who it is shown to (`shown_to`). A stop the person can't use is
        skipped when the tour runs.

        Each stop also says how many feature tours and Welcome Tours use it. Send `group_name` to list one
        feature's stops. Marketing and Admin users can change a stop's default title and text with
        `PATCH /tour_stops/{key}`.

        System Access users (Makerble staff) only. Anyone else gets 403.
      operationId: listTourStops
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - name: group_name
          in: query
          required: false
          description: Only the stops in this feature group, e.g. `Registers`
          schema:
            type: string
          example: Registers
      responses:
        "200":
          description: Paginated stops
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedTourStopDefinitions'
              example:
                page: 1
                page_size: 1
                page_count: 36
                total_count: 36
                data:
                  - key: contacts_filters
                    label: 'Contacts: Filters'
                    group_name: Contacts
                    page: Contacts (contacts)
                    action: click
                    action_label: Waits for a click
                    default_title: Narrow the list down
                    default_body: Filters let you see just the people you need, such as one year group.
                    empty: null
                    shown_to: Skipped for someone who is not a member of the organisation
                    feature_tour_count: 1
                    welcome_tour_count: 0
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
  /tour_stops/{key}:
    patch:
      tags: [Feature Tours]
      summary: Change a stop's default wording
      description: |
        Changes Makerble's default title and text for one stop, as Site Overview › Tour Stops does. Every
        Welcome Tour and feature tour stop that has no wording of its own shows the new default straight away.

        Only the fields sent change. A field sent empty, or the same as Makerble's original wording, goes back to
        the original. Returns the stop as `GET /tour_stops` lists it.

        Marketing and Admin users (Makerble staff) only. Support users and anyone else get 403.
      operationId: updateTourStop
      security: [{tokenAuth: []}]
      parameters:
        - name: key
          in: path
          required: true
          description: The stop's key, from `GET /tour_stops`
          schema:
            type: string
          example: contacts_table
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TourStopWordingInput'
            example:
              default_title: Your contacts
      responses:
        "200":
          description: The stop with its new default wording
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TourStopDefinition'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /feature_tours/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Feature Tours]
      summary: Get a feature tour
      description: One feature tour with its stops in order. System Access users only.
      operationId: getFeatureTour
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The feature tour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureTour'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Feature Tours]
      summary: Update a feature tour
      description: |
        Changes only the fields sent. A stop with `_destroy: true` is removed, a stop with an `id` is changed and a
        stop without one is added. A stop's empty `title` or `body` shows Makerble's default. A tour can't be
        `live` without a stop, and only one live tour can use each `page_key`. System Access users only.
      operationId: updateFeatureTour
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureTourInput'
            example:
              status: live
              stops:
                - id: 678
                  title: Your caseload
                - id: 679
                  _destroy: true
      responses:
        "200":
          description: The updated feature tour
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureTour'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Feature Tours]
      summary: Delete a feature tour
      description: Deletes a feature tour, its stops and everyone's progress through it. System Access users only.
      operationId: deleteFeatureTour
      security: [{tokenAuth: []}]
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /feature_tours/{id}/funnel:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Feature Tours]
      summary: Get a feature tour's funnel
      description: |
        How people get on with a feature tour, the same numbers as its Funnel page in Site Overview › Feature Tours:
        for each stop, how many people reached it, completed it, skipped it themselves or had it skipped because they
        couldn't use it (each person counted once per stop and event); and the tour's totals from everyone's progress.
        Stop-by-stop counts start on `counts_since`, the day they were first recorded; the totals cover everyone.
        System Access users only.
      operationId: getFeatureTourFunnel
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The feature tour's funnel
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureTourFunnel'
              example:
                id: 12
                name: Filters on Contacts
                status: live
                counts_since: "2026-12-04"
                totals: { started: 40, completed: 31, in_progress: 4, ended_early: 5 }
                stops:
                  - { id: 101, position: 1, stop_key: contacts_table, title: Where all the records live, reached: 40, completed: 38, skipped_by_user: 0, skipped_by_system: 2 }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /tours/{id}/progress:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Welcome Tours]
      summary: See who has finished a Welcome Tour
      description: |
        Who has finished the tour, as the Who has finished page shows it: the colleagues in the tour's Team
        (everyone in the Organisation for its default tour), by name, each with their team, how far they have
        got, how many times they have chosen "I'll do this later" and when they were last reminded. Only
        colleagues (Organisation Admins, reporters and observers) are listed, never Contacts or active
        participants. `summary` counts the same people: `average_minutes` counts only tours finished without
        "I'll do this later". An Organisation Admin of the tour's Organisation, or a System Access user.
      operationId: listTourProgress
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated colleagues and how far each has got
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedTourProgress'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /tours/{id}/reminders:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
    post:
      tags: [Welcome Tours]
      summary: Remind a colleague to finish their Welcome Tour
      description: |
        Emails a colleague who hasn't finished their Welcome Tour a link that opens it at the stop they reached,
        as Send a reminder on the Who has finished page does. Each person can be reminded once every 7 days;
        a second reminder sooner is refused with 422, saying when the next one can be sent, as is someone who
        has finished or isn't a colleague in the Organisation. An Organisation Admin of the tour's Organisation,
        or a System Access user.
      operationId: createTourReminder
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [user_id]
              properties:
                user_id:
                  type: integer
                  description: The colleague to remind
            example:
              user_id: 4567
      responses:
        "201":
          description: The reminder was sent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TourReminder'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /users/{user_id}/capacity:
    parameters:
      - name: user_id
        in: path
        required: true
        description: The colleague (User)
        schema:
          type: integer
      - name: charity_id
        in: query
        required: true
        description: The Organisation (Charity). A colleague has separate caps in each Organisation.
        schema:
          type: integer
    get:
      tags: [Staff Capacity]
      summary: Get a colleague's capacity
      operationId: getColleagueCapacity
      description: |
        A colleague's capacity caps in one Organisation, and how much they have taken on, as in the
        **Edit capacity** popup on the Staff availability page.

        - **Sessions** are every event in the Organisation where the colleague is an Event Worker, group
          or appointment. `max_sessions_per_day` and `max_sessions_per_week` cap them.
        - An **appointment** is a session whose Event Format has the Appointment type
          (`appointment_type: one_to_one`). An appointment can have more than one staff member: it counts
          once for each of its Event Workers. `max_per_day` and `max_per_week` cap appointments, and
          `max_one_to_one_contacts` caps the Contacts who have an upcoming appointment with them.
        - `null` means no limit. A colleague is fully booked on a day when they reach either cap.
        - `usage` counts sessions and appointments for today and this week (Monday to Sunday) in the
          Organisation's timezone, and counts their ongoing appointment Contacts: the distinct guests
          of their upcoming appointments.
        - Anyone who sees the colleague on Staff availability can read this: the colleague themselves,
          their Team Leaders, Project Editors of their Projects and Organisation Admins. Anyone else in
          the Organisation gets `403`; an Organisation you aren't in returns `404`.
        - `can_edit` says whether you may change the caps.
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The colleague's caps and usage
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ColleagueCapacity'
              example:
                user_id: 812
                charity_id: 123
                max_sessions_per_day: 6
                max_sessions_per_week: 20
                max_per_day: 4
                max_per_week: 15
                max_one_to_one_contacts: 12
                can_edit: true
                usage:
                  sessions_today: 3
                  sessions_this_week: 14
                  appointments_today: 2
                  appointments_this_week: 11
                  ongoing_one_to_one_contacts: 9
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You can't see this colleague on Staff availability
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "forbidden"
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Staff Capacity]
      summary: Set a colleague's capacity
      operationId: updateColleagueCapacity
      description: |
        Sets a colleague's capacity caps in one Organisation, as **Edit capacity** on the Staff
        availability page does. Only the caps you send change; send `null` to remove a limit. Whole
        numbers from 0 to 1000.

        Only an **Organisation Admin**, or a **Team Leader** of a Team the colleague is in, may set them.
        A colleague can't set their own (`403`).
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                max_sessions_per_day:
                  type: integer
                  nullable: true
                  description: Maximum sessions (group or appointment) a day
                max_sessions_per_week:
                  type: integer
                  nullable: true
                  description: Maximum sessions (group or appointment) a week
                max_per_day:
                  type: integer
                  nullable: true
                  description: Maximum appointments a day
                max_per_week:
                  type: integer
                  nullable: true
                  description: Maximum appointments a week
                max_one_to_one_contacts:
                  type: integer
                  nullable: true
                  description: Maximum ongoing Contacts with appointments
            example:
              max_sessions_per_day: 6
              max_per_day: 4
              max_per_week: null
              max_one_to_one_contacts: 12
      responses:
        "200":
          description: The colleague's caps and usage, as **Get a colleague's capacity** returns them
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ColleagueCapacity'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are not an Organisation Admin or a Team Leader of a Team the colleague is in, or this is your own capacity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only a Charity Editor, or a Team Leader of a Team the colleague is in, can change their capacity."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /users/{user_id}/free_slots:
    get:
      tags: [Staff Matching]
      summary: Find a colleague's free slots
      operationId: getColleagueFreeSlots
      description: |
        When a colleague is free for an appointment of an Event Format in one Organisation. A start
        time is free when the appointment, padded by the Event Format's preparation and debrief times:

        - fits inside one of the colleague's availability times on the Staff availability page, which
          may be limited to some Event Formats or Projects;
        - overlaps none of their unavailability (leave, sickness, training);
        - overlaps none of the events they are an Event Worker on, each padded by its own Event
          Format's preparation and debrief times;
        - is on a day, and in a week, where they are below their caps. A colleague at their limit of
          ongoing one-to-one Contacts has no free one-to-one slots at all.

        Start times fall on the quarter hour, in the Organisation's timezone. The Event Format needs a
        Default length.

        Without `weekly_sessions`, each free start time is returned. With it, each weekly time (for
        example Mondays at 10:00) is returned once, from the first date on which every one of the
        sessions is free: use it to plan a recurring appointment.

        Any member of the Organisation can see a colleague's slot times. `capacity` is `null` unless you
        see the colleague on Staff availability (the colleague themselves, their Team Leaders, Project
        Editors of their Projects and Organisation Admins).
      security: [{tokenAuth: []}]
      parameters:
        - name: user_id
          in: path
          required: true
          description: The colleague (User)
          schema:
            type: integer
        - name: charity_id
          in: query
          required: true
          description: The Organisation (Charity)
          schema:
            type: integer
        - name: event_category_id
          in: query
          required: true
          description: The Event Format (event category). It needs a Default length.
          schema:
            type: integer
        - name: project_id
          in: query
          required: false
          description: The Project the appointment is for. Availability limited to other Projects is left out.
          schema:
            type: integer
        - name: from
          in: query
          required: false
          description: First date (YYYY-MM-DD). Default today.
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          description: Last date (YYYY-MM-DD), at most 26 weeks after `from`. Default 8 weeks after `from`.
          schema:
            type: string
            format: date
        - name: weekly_sessions
          in: query
          required: false
          description: Return weekly series of this many sessions (1 to 52) instead of single slots.
          schema:
            type: integer
            minimum: 1
            maximum: 52
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The free slots, or weekly series, earliest first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ColleagueFreeSlots'
              example:
                user_id: 812
                charity_id: 123
                event_category_id: 41
                project_id: null
                time_zone: Europe/London
                from: "2026-11-23"
                to: "2027-01-18"
                weekly_sessions: 6
                length_minutes: 60
                preparation_minutes: 30
                debrief_minutes: 30
                capacity:
                  max_per_day: 4
                  max_per_week: 15
                  max_one_to_one_contacts: 12
                  ongoing_one_to_one_contacts: 9
                  at_one_to_one_limit: false
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - starts_at: "2026-11-24T10:00:00+00:00"
                    ends_at: "2026-11-24T11:00:00+00:00"
                    date: "2026-11-24"
                    weekday: tuesday
                    start_time: "10:00"
                    end_time: "11:00"
                    sessions: 6
                    summary: "Tuesdays 10:00–11:00 from 24 Nov"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /users/{user_id}/unavailabilities:
    parameters:
      - name: user_id
        in: path
        required: true
        description: The colleague (User) whose unavailability this is
        schema:
          type: integer
      - name: charity_id
        in: query
        required: true
        description: The Organisation (Charity). A colleague in several Organisations has separate unavailability in each.
        schema:
          type: integer
    get:
      tags: [Staff Unavailability]
      summary: List a colleague's unavailability
      description: |
        The dates and times a colleague can't work for an Organisation (annual leave, sick leave, training or other),
        as on their Unavailability page, oldest first. Anyone can list their own. Team Leaders can list the colleagues
        in their Team, Project Editors the colleagues in their Project, and Charity Editors everyone in the Organisation;
        anyone else gets 403. `private_note` is returned only to the colleague themselves and to Charity Editors.
      operationId: listUserUnavailabilities
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of unavailability ranges, oldest first
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/Unavailability' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Staff Unavailability]
      summary: Record when a colleague is unavailable
      description: |
        Records one range when the colleague can't work: whole days (`all_day`, the default) from `from_date` to
        `to_date`, or part of a day with `from_time` and `to_time`, in the Organisation's timezone. Makerble won't then
        assign them to events automatically at those times. The same people as for listing may do this.

        If the colleague is already an Event Worker on upcoming events during the range, they are listed in
        `conflicting_events`. To take the colleague off some of them in the same call, send their ids in
        `unassign_event_ids`; only events the caller may edit (`editable`) are changed. Each affected event's Event
        Managers are emailed either way, saying whether the colleague was unassigned.
      operationId: createUserUnavailability
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UnavailabilityInput'
            example:
              from_date: '2026-12-03'
              to_date: '2026-12-03'
              all_day: false
              from_time: '13:00'
              to_time: '17:30'
              reason_type: training
              private_note: Safeguarding refresher
              unassign_event_ids: [5012]
      responses:
        "201":
          description: The range recorded, with the events it clashes with
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnavailabilityWithConflicts'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /users/{user_id}/unavailabilities/{id}:
    parameters:
      - name: user_id
        in: path
        required: true
        schema:
          type: integer
      - name: id
        in: path
        required: true
        description: The unavailability range
        schema:
          type: integer
      - name: charity_id
        in: query
        required: true
        description: The Organisation (Charity)
        schema:
          type: integer
    patch:
      tags: [Staff Unavailability]
      summary: Change when a colleague is unavailable
      description: |
        Changes only the fields sent. If the dates or times change, events the colleague is already working during the
        new range are returned in `conflicting_events`, and `unassign_event_ids` works as when recording a range. A Team
        Leader or Project Editor can't see or change the private note.
      operationId: updateUserUnavailability
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UnavailabilityInput'
            example:
              to_date: '2026-12-05'
      responses:
        "200":
          description: The range, with the events it clashes with
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnavailabilityWithConflicts'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Staff Unavailability]
      summary: Remove a range of unavailability
      description: Removes the range. Events the colleague was taken off are not changed back.
      operationId: deleteUserUnavailability
      security: [{tokenAuth: []}]
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /organisations/{organisation_id}/training_materials:
    parameters:
      - name: organisation_id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Training Materials]
      summary: List an Organisation's Training materials
      description: |
        The Organisation's Training materials, as on the Training materials page under Helpdesk: links to its own
        training documents and videos (Google Docs, Word Online, SharePoint, Loom and so on). Returns only those the
        caller may see: an Organisation Admin or System Access user sees them all; anyone else sees those linked to
        the whole Organisation, to a Team they are in, or to a Workspace they hold a role on, and those they own.
        Someone with no part in the Organisation gets 403. `project_id` narrows the list to the materials linked to one Workspace.
      operationId: listTrainingMaterials
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: query
          required: false
          description: Only the materials linked to this Workspace (Project) of the Organisation
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Training materials, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/TrainingMaterial' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Training Materials]
      summary: Add a Training material
      description: |
        Adds a link to one of the Organisation's training documents or videos, and says who it is for: the whole
        Organisation (`all_organisation`), or one or more Teams (`team_ids`) and Workspaces (`project_ids`). At least one
        is required. Makerble keeps only the link, so share the document with the same people. The owner defaults to
        the caller and must be an Organisation Admin, Team Leader or Project Editor of the Organisation. An
        Organisation Admin, Team Leader or Project Editor of the Organisation, or a System Access user.
      operationId: createTrainingMaterial
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrainingMaterialInput'
            example:
              name: How to add a new school
              url: https://docs.google.com/document/d/abc123
              description: For centre administrators
              material_type: document
              team_ids: [12]
      responses:
        "201":
          description: The Training material added
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainingMaterial'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /organisations/{organisation_id}/training_materials/{id}:
    parameters:
      - name: organisation_id
        in: path
        required: true
        schema:
          type: integer
      - name: id
        in: path
        required: true
        schema:
          type: integer
    patch:
      tags: [Training Materials]
      summary: Change a Training material
      description: |
        Changes only the fields sent. `team_ids` and `project_ids` replace the Teams and Workspaces it is linked to.
        Send `mark_as_reviewed: true` to set its last reviewed date to now ("Mark as reviewed"). An Organisation Admin of
        the Organisation or a System Access user can change any of them; a Team Leader or Project Editor only those
        they own.
      operationId: updateTrainingMaterial
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/TrainingMaterialInput'
                - type: object
                  properties:
                    mark_as_reviewed:
                      type: boolean
                      description: Set its last reviewed date to now
            example:
              team_ids: [14]
              mark_as_reviewed: true
      responses:
        "200":
          description: The Training material
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainingMaterial'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Training Materials]
      summary: Remove a Training material
      description: Removes the link from Makerble. The document itself is not touched. An Organisation Admin of the Organisation or a System Access user can remove any of them; a Team Leader or Project Editor only those they own.
      operationId: deleteTrainingMaterial
      security: [{tokenAuth: []}]
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /organisations/{organisation_id}/picked_tours:
    parameters:
      - name: organisation_id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Training Tours]
      summary: List the Welcome Tours picked for you
      description: |
        The Welcome Tours picked for you in the Organisation, as on Training materials › Tours picked for me:
        the Organisation's tour for everyone, and the tour of each Team you are in there, from the day you join it.
        Each says how far you have got. Someone with no part in the Organisation gets 403.
      operationId: listPickedTours
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The Welcome Tours picked for you
          content:
            application/json:
              schema:
                type: object
                required: [page, page_size, page_count, total_count, data]
                properties:
                  page: { type: integer }
                  page_size: { type: integer }
                  page_count: { type: integer }
                  total_count: { type: integer }
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/PickedTour'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - {id: 3, name: Welcome to Hillside, team: null, stop_count: 6, status: not_started}
                  - {id: 7, name: Admin basics, team: {id: 12, name: Centre Administrators}, stop_count: 4, status: finished}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You have no part in this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
  /organisations/{organisation_id}/picked_tours/{id}/restart:
    parameters:
      - name: organisation_id
        in: path
        required: true
        schema:
          type: integer
      - name: id
        in: path
        required: true
        description: The Welcome Tour's id
        schema:
          type: integer
    post:
      tags: [Training Tours]
      summary: Restart a Welcome Tour picked for you
      description: |
        Starts a Welcome Tour picked for you again from its first stop, as Restart the tour on Training materials
        does, even one you have finished. It runs the next time you open a Makerble page. A tour not picked for you is refused.
      operationId: restartPickedTour
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The tour has started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartedTour'
              example: {id: 7, status: started, url: /charities/hillside/beneficiaries}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You have no part in this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /training_tours:
    get:
      tags: [Training Tours]
      summary: List every training tour
      description: |
        Every feature tour, the short tours that each introduce one feature, as on Training materials › All training
        tours, with how far you have got: ready_to_watch (not started), started (begun but not finished) or completed.
      operationId: listTrainingTours
      security: [{tokenAuth: []}]
      parameters:
        - name: status
          in: query
          required: false
          description: Only the tours with this status
          schema:
            type: string
            enum: [ready_to_watch, started, completed]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The training tours
          content:
            application/json:
              schema:
                type: object
                required: [page, page_size, page_count, total_count, data]
                properties:
                  page: { type: integer }
                  page_size: { type: integer }
                  page_count: { type: integer }
                  total_count: { type: integer }
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/TrainingTour'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - {id: 4, name: Checklists, stop_count: 5, status: ready_to_watch}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /training_tours/{id}/start:
    parameters:
      - name: id
        in: path
        required: true
        description: The feature tour's id
        schema:
          type: integer
    post:
      tags: [Training Tours]
      summary: Start a training tour
      description: |
        Starts a feature tour for you from its first stop, as Take the tour does, even one you have finished.
        It runs the next time you open a Makerble page.
      operationId: startTrainingTour
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The tour has started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartedTour'
              example: {id: 4, status: started, url: /charities/hillside/checklists}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /organisations/{organisation_id}/supplementary_details:
    parameters:
      - name: organisation_id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Charities]
      summary: Get an Organisation's Supplementary Details
      description: |
        The details about an Organisation (Charity) and the person who represents it that Twilio, Makerble's
        SMS partner, needs before the Organisation can send SMS messages, as on its Supplementary details page.
        Before anything is saved every field is blank. `missing_fields` lists what Twilio still needs, and
        `verification_status` where Twilio's check has got to. Only an Editor of the Organisation.
      operationId: getSupplementaryDetails
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SupplementaryDetails'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Charities]
      summary: Update an Organisation's Supplementary Details
      description: |
        Saves the fields sent and leaves the rest. They can be saved part-filled. Refused with 422 while
        Twilio is checking them, or once it has approved them (`editable` false). Send `country_id` to set
        the Organisation's country when it has none; it is ignored when the Organisation already has one.
        Once every field Twilio needs is filled in (`missing_fields` is empty), saving sends the details to
        Twilio to check, and `verification_status` moves on from `not_started` as Twilio's check proceeds.
      operationId: updateSupplementaryDetails
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                country_id:
                  type: integer
                website_url:
                  type: string
                  description: "Website, e.g. www.example.org. https:// is added when it doesn't start with http:// or https://"
                business_type:
                  type: string
                  description: "Organisation type: Sole Proprietorship, Partnership, Limited Liability Corporation, Co-operative, Non-profit Corporation or Corporation"
                business_industry:
                  type: string
                  description: "Industry, as Twilio names it, e.g. NOT_FOR_PROFIT, EDUCATION, HEALTHCARE"
                business_registration_identifier:
                  type: string
                  description: "Registration ID type: EIN, CBN, CN, ACN, CIN, VAT, VATRN, RN or Other. Set from the Organisation's country when registration_identifier_automatic is true, whatever is sent"
                other_registration_identifier:
                  type: string
                  description: "Name of the other registration type, when the type is Other"
                business_registration_number:
                  type: string
                  description: "Registration number"
                business_regions_of_operation:
                  type: string
                  description: "Region of operation: AFRICA, ASIA, EUROPE, LATIN_AMERICA, USA_AND_CANADA or AUSTRALIA"
                address_friendly_name:
                  type: string
                  description: "Address name, e.g. Headquarters"
                street:
                  type: string
                  description: "Street address"
                street_secondary:
                  type: string
                  description: "Street address line 2 (optional)"
                city:
                  type: string
                  description: "City"
                region:
                  type: string
                  description: "State, province or region"
                postal_code:
                  type: string
                  description: "Postal code"
                representative_first_name:
                  type: string
                  description: "The representative's first name"
                representative_last_name:
                  type: string
                  description: "The representative's last name"
                representative_business_title:
                  type: string
                  description: "The representative's job title"
                representative_job_position:
                  type: string
                  description: "Job position: Director, GM, VP, CEO, CFO, General Counsel or Other"
                representative_other_job_position:
                  type: string
                  description: "The job position, when Job position is Other"
                representative_email:
                  type: string
                  description: "The representative's email address"
                representative_phone_number:
                  type: string
                  description: "The representative's phone number in international format, e.g. +447700900123"
            example:
              website_url: https://www.example.org
              city: London
              representative_phone_number: "+447700900123"
      responses:
        "200":
          description: The details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SupplementaryDetails'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /organisations/{organisation_id}/welcome_journey_settings:
    parameters:
      - name: organisation_id
        in: path
        required: true
        schema:
          type: integer
    get:
      tags: [Welcome Tours]
      summary: Get an Organisation's welcome journey settings
      description: Whether people joining the Organisation can skip adding a profile picture on their welcome journey, and its Welcome Tours. An Organisation Admin of it, or a System Access user.
      operationId: getWelcomeJourneySettings
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WelcomeJourneySettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Welcome Tours]
      summary: Update an Organisation's welcome journey settings
      description: Sets "People can skip adding a profile picture" and "People can skip Watch the journey". Send either or both. Change each tour's own settings with PATCH /tours/{id}.
      operationId: updateWelcomeJourneySettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                photo_skippable:
                  type: boolean
                watch_skippable:
                  type: boolean
            example:
              photo_skippable: false
      responses:
        "200":
          description: The settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WelcomeJourneySettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /teams:
    get:
      tags: [Teams]
      summary: List an Organisation's Teams
      description: |
        The Teams of an Organisation (Charity) the user belongs to, as the Teams page lists them. A
        Team groups colleagues across Projects; its managers are shown as "Managers" (leaders in
        older screens) and everyone else as "Members". When `auto_add_to_projects` is true, someone
        who joins the Team is added, at that moment, to the Projects in `auto_add_project_ids` and to
        every open Project that one of the saved project filters in `auto_add_filter_ids` matches,
        with the project role in `auto_add_manager_role` or `auto_add_member_role`.
      operationId: listTeams
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          description: The Organisation whose Teams to list. Another Organisation reads as not found.
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Teams
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TeamList'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /teams/{id}:
    get:
      tags: [Teams]
      summary: Get a Team
      description: A Team of one of the user's Organisations, with its managers, members and the Projects it adds people to.
      operationId: getTeam
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The Team
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Team'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Teams]
      summary: Set which Projects a Team adds people to
      description: |
        Changes the "Automatically add managers and members to projects" settings of a Team, as the
        Create/Edit Team popup does. Only an Organisation Admin of the Team's Organisation can do
        this. Send only the fields to change.

        People are added only at the moment they join the Team. Changing these settings doesn't add
        the Team's current managers and members to anything, and someone removed from one of these
        Projects later isn't added back. People who already have a role on a Project keep it.

        `auto_add_project_ids` must be open Projects of the Team's Organisation. `auto_add_filter_ids`
        must be saved Projects page filters the user can use: their own, or ones colleagues have
        shared (the same list as `saved_filters` in `GET /project_automations/options?charity_id=`).
        Projects and filters already on the Team are kept even if this user couldn't choose them.
        Roles are `editor` (Project Manager), `reporter` (Changemaker) or `observer` (Analyst).
      operationId: updateTeam
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TeamUpdateRequest'
            example:
              auto_add_to_projects: true
              auto_add_project_ids: [619, 620]
              auto_add_filter_ids: [88]
              auto_add_manager_role: editor
              auto_add_member_role: reporter
      responses:
        "200":
          description: The updated Team
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Team'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /teams/{id}/members:
    post:
      tags: [Teams]
      summary: Add colleagues to a Team
      description: |
        Adds colleagues to a Team as Members or Managers, as the Create/Edit Team popup and the Teams
        tab of Invite a colleague do. The Team's other people are left as they are, and someone already
        in the Team in that role is skipped. Only an Organisation Admin of the Team's Organisation can
        do this, and everyone added must already be a colleague in the Organisation (use
        `GET /users` to find them).

        When the Team has `auto_add_to_projects` on, the people who join are added, in the background,
        to its Projects and to the open Projects its saved filters match, with the Team's project role
        for a Manager or a Member. People who already have a role on a Project keep it.
      operationId: addTeamMembers
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TeamAddMembersRequest'
            example:
              user_ids: [4012, 4013]
              role: member
      responses:
        "200":
          description: The Team, with the people added
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Team'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /toolkits:
    get:
      tags: [Toolkits]
      summary: List Toolkits
      description: |
        The Toolkits on Explore Toolkits: ready-made sets of Surveys, Contact Forms, Impact Frameworks,
        metrics and tips an organisation can add to its Projects in one go (Collections in the
        database). A user with Marketing or Admin system access also sees listed Toolkits still
        awaiting approval, as Site Overview › Manage Toolkits shows them.
      operationId: listToolkits
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Toolkits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolkitList'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /toolkits/{id}:
    get:
      tags: [Toolkits]
      summary: Get a Toolkit
      description: |
        One Toolkit, if the user can see its page: a Toolkit on Explore Toolkits, or one the user can
        edit. Any other returns 404.
      operationId: getToolkit
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Toolkit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolkitWithItems'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Toolkits]
      summary: Update a Toolkit's number and image settings
      description: |
        Sets the Toolkit number, the cover image's alt text, and whether the thumbnail (on Explore
        Toolkits) and the cover image (on the Toolkit's page) are darkened, as the Create/Edit Collection page does. Only the fields sent
        change. The user must be able to edit the Toolkit: its owner, an editor of its Organisation, or
        a user with Marketing or Admin system access.
      operationId: updateToolkit
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToolkitUpdateRequest'
            example:
              toolkit_number: "T14"
              darken_cover_image: true
              cover_image_alt: "Volunteers sorting food parcels"
      responses:
        "200":
          description: The Toolkit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolkitWithItems'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /toolkits/{id}/items:
    post:
      tags: [Toolkits]
      summary: Add a Checklist Template or story Label to a Toolkit
      description: |
        Adds one of your organisation's Checklist Templates, or a story Label, to a Toolkit, as
        Available Fields does on the Create/Edit Collection page. Inside a Toolkit, a checklist step
        can then count the Toolkit's own Surveys, Contact Forms and story Labels as done, so those steps
        arrive already set up when the Toolkit is installed. The user must be able to edit the
        Toolkit, and the item must belong to one of their organisations (a story Label may also be
        their own). Adding an item the Toolkit already has changes nothing.
      operationId: addToolkitItem
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToolkitItemRequest'
            example:
              item_type: checklist_template
              item_id: 42
      responses:
        "201":
          description: The item, now in the Toolkit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolkitItem'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Toolkits]
      summary: Take a Checklist Template or story Label out of a Toolkit
      description: |
        Takes a Checklist Template or story Label out of a Toolkit. The item itself stays as it is. The
        user must be able to edit the Toolkit.
      operationId: removeToolkitItem
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToolkitItemRequest'
            example:
              item_type: story_label
              item_id: 7
      responses:
        "204":
          description: Taken out of the Toolkit
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /toolkits/{id}/image:
    patch:
      tags: [Toolkits]
      summary: Replace a Toolkit's thumbnail or cover image
      description: |
        Uploads a new thumbnail (`kind: thumbnail`, shown on Explore Toolkits) or cover image
        (`kind: cover`, shown on the Toolkit's page), as Replace does on Site Overview › Manage
        Toolkits. Send it as `multipart/form-data`. The image must be a JPEG or PNG. Needs Marketing or
        Admin system access.
      operationId: replaceToolkitImage
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [kind, image]
              properties:
                kind:
                  type: string
                  enum: [thumbnail, cover]
                image:
                  type: string
                  format: binary
      responses:
        "200":
          description: The Toolkit, with its new image
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolkitWithItems'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /albums:
    get:
      tags: [Albums]
      summary: List Albums (Portfolios)
      description: |
        The Albums the user's Albums list shows: those they made, manage or are an Album Analyst of,
        and the Albums of the Organisations they are an editor of. An Album (Bundle in the database;
        being renamed Portfolio on screen) groups Projects so their results can be seen together.
      operationId: listAlbums
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Albums
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlbumList'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Albums]
      summary: Make an Album (Portfolio)
      description: |
        Makes an Album, as the Make an Album form does. Its owner is either the user (`owner_type:
        User`, a personal Album) or one of their Organisations (`owner_type: Charity` with that
        Organisation's ID); the user must be an editor of that Organisation. The user becomes the
        Album's manager. Projects in `project_ids` join straight away when they're the Organisation's
        or the user's own; another Organisation's Project is invited instead and shows in
        `pending_project_ids` until its managers accept.
      operationId: createAlbum
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlbumCreateRequest'
            example:
              name: "Youth programmes 2027"
              owner_type: Charity
              owner_id: 42
              project_ids: [101, 102]
      responses:
        "201":
          description: The Album
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Album'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /albums/{id}:
    get:
      tags: [Albums]
      summary: Get an Album (Portfolio)
      description: |
        One Album, if the user can see it (its visibility setting decides who can). An Album the user
        can't see returns 404.
      operationId: getAlbum
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Album
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Album'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Albums]
      summary: Change an Album's (Portfolio's) settings
      description: |
        Changes the settings on the Edit Album and Album Edit pages. Only the fields sent change;
        `manager_ids` and `analyst_ids` replace the Album's managers and Album Analysts (the Album's
        maker always stays a manager). Projects are added and removed with `/albums/{id}/projects`.
        Only the Album's managers may change it.
      operationId: updateAlbum
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlbumUpdateRequest'
            example:
              name: "Youth programmes 2027"
              description: "Every after-school club we run"
              analyst_ids: [7]
      responses:
        "200":
          description: The Album
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Album'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't one of the Album's managers
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /albums/{id}/projects:
    post:
      tags: [Albums]
      summary: Add Projects to an Album (Portfolio)
      description: |
        Adds Projects to the Album, keeping the ones already in it. A Project the user can't add
        directly (another Organisation's) is invited instead and shows in `pending_project_ids`.
        Only the Album's managers may add Projects.
      operationId: addAlbumProjects
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlbumProjectsRequest'
            example:
              project_ids: [103]
      responses:
        "200":
          description: The Album
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Album'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't one of the Album's managers
        "404":
          $ref: '#/components/responses/NotFound'

    delete:
      tags: [Albums]
      summary: Remove Projects from an Album (Portfolio)
      description: |
        Takes Projects out of the Album. The Projects themselves aren't changed. Only the Album's
        managers may remove Projects.
      operationId: removeAlbumProjects
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlbumProjectsRequest'
            example:
              project_ids: [102]
      responses:
        "200":
          description: The Album
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Album'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't one of the Album's managers
        "404":
          $ref: '#/components/responses/NotFound'

  /albums/{id}/targets:
    get:
      tags: [Albums]
      summary: Get an Album's (Portfolio's) targets
      description: |
        What the Album's Set Targets page shows. With `target_type: automatic_target` the Album adds
        up its Projects' targets from `year_start_date`; with `manual_target` it has its own one-off
        targets on its Activity and Outcome metrics (Changes and Indicators) and its trackers, and its
        own deadline targets. Requires rights to edit the Album's targets.
      operationId: getAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Albums]
      summary: Set an Album's (Portfolio's) targets
      description: |
        Sets what the Album's Set Targets page saves. Only metrics and trackers already on the Album
        can be given a target; anything else is refused with 422 and nothing is saved. `deadlines`,
        when sent, replaces all of the Album's manual deadline targets (send `[]` to clear them).
        Metric, tracker and deadline targets are only saved while the Album uses manual targets.
        Requires rights to edit the Album's targets.
      operationId: setAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AlbumTargetsRequest'
            example:
              target_type: manual_target
              year_start_date: "2026-04-01"
              metrics:
                - { metric_type: Change, metric_id: 55, target: 300 }
              trackers:
                - { tracker_type: CohortTracker, tracker_id: 9, target: 40 }
              deadlines:
                - { metric_type: Change, metric_id: 55, date: "2026-12-31", number: 150 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /albums/{id}/project_contributions:
    get:
      tags: [Albums]
      summary: See how much each Project contributed to an Album's (Portfolio's) results
      description: |
        What the Album's Project Contributions views show. For each metric on the Album (an Activity
        or Outcome metric: a Change or an Indicator), the progress across the Album, the Album's
        target and the percentage of it reached, then each Project's sub-total and its share of the
        Album's progress (`contribution_percentage`). Projects are the Album's open Projects, in
        natural order of name ("2. Pear" before "10. Rice"), each with the colour set on its Edit
        Project page.

        `timeframe` chooses the timeframe, as the Album page's Period, Year to date and All-time
        options do:
        - `all_time` (default): all progress. The Album target is its deadline targets added up, or its
          one-off target when it has no deadlines for the metric. Each Project's own all-time target is
          given too; `target_unavailable` is true when the Project sets that metric's targets by
          deadline instead.
        - `period`: progress between two of the Album's Target Deadlines, against the target for that
          deadline. Empty when the Album has no deadline targets.
        - `year_to_date`: progress over one year from the Album's Year Start (1 January without one),
          against the deadline targets falling in that year, as the Year to date option does.

        `timeframes` lists the periods or years to choose from; send one's `end_date` to see it. Without
        `end_date`, the current period or year is shown. Stories count by their date, on every open
        Project in the Album. The metrics are paged; the projects list is not. Requires access to view
        the Album.
      operationId: getAlbumProjectContributions
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: timeframe
          in: query
          schema:
            type: string
            enum: [all_time, period, year_to_date]
            default: all_time
        - name: end_date
          in: query
          description: The last day of the period or year to show, as listed in `timeframes`
          schema:
            type: string
            format: date
          example: "2026-06-30"
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Each metric's progress, split by Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlbumProjectContributions'
              example:
                album_id: 12
                timeframe: all_time
                timeframes: []
                selected_timeframe: null
                projects:
                  - { project_id: 31, name: "1. Breakfast club", colour: "#225f85" }
                  - { project_id: 30, name: "2. Homework club", colour: "#e82a92" }
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - metric_type: Change
                    metric_id: 55
                    name: Children rehomed
                    outcome_id: null
                    outcome_name: null
                    stage: Activities
                    total: 40
                    target: 80
                    percentage: 50.0
                    projects:
                      - { project_id: 31, subtotal: 10, contribution_percentage: 25.0, target: 12, target_unavailable: false }
                      - { project_id: 30, subtotal: 30, contribution_percentage: 75.0, target: null, target_unavailable: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects:
    get:
      tags: [Projects]
      summary: List all Projects
      description: |
        Returns all Projects accessible to the authenticated user. Every Story and Case belongs to a Project.

        Users hold one of three roles per Project:

        | Role | API name | Front-end | Permissions |
        |---|---|---|---|
        | Editor | `editor` | Manager | Admin — edit Project, manage users |
        | Reporter | `reporter` | Changemaker | Create Stories |
        | Observer | `observer` | Analyst | Read-only |
      operationId: listProjects
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Projects
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedProjects'
        "401":
          $ref: '#/components/responses/Unauthorized'
    post:
      tags: [Projects]
      summary: Create a Project
      description: |
        Creates a Project in an Organisation, as the **Create Project** page does, with the same permissions:
        you must be allowed to create projects there (an Organisation Admin, or a colleague with project creation
        switched on). Project Reporters and Observers can't. You become the Project's Manager unless you send
        `project.editor_ids`. The Project Category's Surveys are added to the Project, and any Project Automation
        the new Project matches is applied.

        Get the Project Types and the Organisation's Project Categories, with each category's form fields, from
        `GET /projects/form` first. Before creating a Project, check with `GET /projects` that the Organisation
        doesn't already have it.
      operationId: createProject
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required: [charity_id, project]
                  properties:
                    charity_id:
                      type: integer
                      description: The Organisation to create the Project in.
                      example: 31
                - $ref: '#/components/schemas/ProjectSaveRequest'
            example:
              charity_id: 31
              project:
                name: "Youth Mentoring"
                project_type_id: 4
                project_category_id: 88
                help_statement: "Weekly mentoring for 14 to 18 year olds"
                reporter_ids: [237]
              story_category_ids: [1203]
              privacy: only_charity_colleagues
      responses:
        "201":
          description: The new Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /projects/form:
    get:
      tags: [Projects]
      summary: Get the Create Project form
      description: |
        What the **Create Project** form offers in an Organisation: the Project Types (each with its solutions)
        and the Organisation's Project Categories. Each category lists its form fields in order:

        - `standard` fields, with the `parameter` that sets them (e.g. `project[help_statement]` for Short
          Description, `project[reporter_ids]` for Changemakers);
        - `custom_field` questions, answered under `custom_fields` by their `field_id`;
        - `dropdown` fields, whose choices go under `sub_ratios` by their `field_id`.

        `is_mandatory` marks the fields the form requires. Returns 404 for an Organisation you don't work in.
      operationId: getProjectForm
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          description: The Organisation the Project is for.
          schema:
            type: integer
            example: 31
      responses:
        "200":
          description: The Create Project form
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectForm'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /projects/{id}:
    get:
      tags: [Projects]
      summary: Get a single Project
      operationId: getProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Project record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Projects]
      summary: Edit a Project
      description: |
        Edits a Project's details, as the **Edit Project** page does, with the same permissions: a Manager of the
        Project or an Organisation Admin. A Changemaker (Project Reporter) gets 403; a Project in an Organisation
        you don't work in reads as 404.

        Only what you send changes. A colleague list you send (`editor_ids`, `reporter_ids` or `observer_ids`)
        replaces that role's colleagues; one you leave out is kept. `story_category_ids` adds Surveys to the
        Project and never removes or stops any. Saving applies any Project Automation the Project matches, as the
        page does.
      operationId: updateProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProjectSaveRequest'
            example:
              project:
                help_statement: "Fortnightly mentoring for 14 to 18 year olds"
                observer_ids: [412]
      responses:
        "200":
          description: The Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /projects/{id}/preferences:
    get:
      tags: [Projects]
      summary: Get a Project's Project Preferences
      description: |
        What the Project's Project Preferences page shows: which Contact Forms create and edit
        Contacts, which Contact statuses (Waiting List, Enrolled, Alumni, Declined) are switched on
        with each one's form and baseline Surveys, editorial control, Case, Event and timesheet
        settings, the Case Form, Event Formats, the default privacy of new Stories, the Mailchimp
        list, and the Region and Industry its localised Financial Values use. Requires rights to change
        the Project's preferences (a Manager or an Organisation Admin).
      operationId: getProjectPreferences
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Project Preferences
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectPreferences'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't change this Project's preferences (e.g. a Changemaker)
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Projects]
      summary: Change a Project's Project Preferences
      description: |
        Saves what the Project Preferences page saves, with the same permissions. Only the settings
        sent change; a list sent replaces that list (send `[]` to empty it). Contact Forms, Case
        Forms, Event Formats and Surveys must be the Project's Organisation's. `event_category_ids`
        sets the Project's Event Formats; it can't be emptied here.
      operationId: updateProjectPreferences
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProjectPreferences'
            example:
              beneficiary_state_ids: [1, 2]
              enable_waiting_list_state_contact_form: true
              waiting_list_state_contact_form_id: 77
              contact_form_ids: [77]
              is_creation_of_events_required: true
              default_story_privacy: only_project_colleagues
      responses:
        "200":
          description: The Project Preferences
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectPreferences'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't change this Project's preferences
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/{id}/targets:
    get:
      tags: [Projects]
      summary: Get a Project's targets
      description: |
        What the Project's Set Targets page shows: the day its target year starts, the one-off target
        on each Activity and Outcome metric on the Project (Changes and Indicators) and on each of its
        Cohort, Workflow and Formula Trackers and filtered versions, and its deadline targets.
        Requires rights to edit the Project's targets.
      operationId: getProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Projects]
      summary: Set a Project's targets
      description: |
        Saves what the Set Targets page saves. Only metrics and trackers already on the Project can be
        given a target (adding metrics is Edit Project Metrics' job); anything else is refused with 422
        and nothing is saved. `deadlines`, when sent, replaces all the Project's deadline targets
        (send `[]` to clear them). Same request as `PATCH /albums/{id}/targets`, without `target_type`.
      operationId: setProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProjectTargetsRequest'
            example:
              year_start_date: "2026-04-01"
              metrics:
                - { metric_type: Change, metric_id: 55, target: 300 }
              deadlines:
                - { metric_type: Change, metric_id: 55, date: "2026-12-31", number: 150 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/add_colleague.json:
    post:
      tags: [Projects]
      summary: Add users to a Project
      description: |
        Adds users to Projects' teams, as the Project's **Add Users** page does: as Project Managers (`editor_ids`),
        Changemakers (`reporter_ids`) or Analysts (`observer_ids`). A user can hold more than one role.

        You must be a Project Manager of every listed Project, or an Organisation Admin of its Organisation. The users
        must already be colleagues in the Project's Organisation, unless the Organisation's preference "Allow Project
        Managers to add Makerble Users outside the organisation to their project" is on.

        The request is all or nothing: if any Project isn't found (404), isn't yours to manage (403) or any user can't
        be added (422), nobody is added to any Project.
      operationId: addColleague
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [role_data]
              properties:
                role_data:
                  type: array
                  items:
                    type: object
                    required: [project_id]
                    properties:
                      project_id:
                        type: integer
                        example: 619
                      editor_ids:
                        type: array
                        items:
                          type: integer
                        example: [559]
                      reporter_ids:
                        type: array
                        items:
                          type: integer
                        example: [560]
                      observer_ids:
                        type: array
                        items:
                          type: integer
                        example: [561]
      responses:
        "200":
          description: Users added
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/AddColleagueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /project_results:
    get:
      tags: [Projects]
      summary: Get Results Canvas figures for Projects
      description: |
        Returns the figures shown on each Project's **Results Canvas** (the Results panel on a Project page),
        one entry per tracker, calculated by Makerble. Covers the Projects you can view (Editor, Reporter or
        Observer of the Project or its Organisation), optionally for a period and split by Project or month.

        | Tracker (front-end) | Backend type | Figures |
        |---|---|---|
        | Activity tracker | Change of Activity type | `times_recorded`, `contacts`, `anonymous_count` |
        | Engagement tracker | Change of Participation type | `times_recorded`, `contacts`, `anonymous_count` |
        | Achievement tracker | Indicator of Binary type | `times_recorded`, `contacts_achieved`, `anonymous_count` |
        | Choice tracker | Indicator of Scale type | `times_recorded`, `contacts`, `answers` (count and contacts per Sub Ratio), `anonymous_count` |
        | Numerical tracker | Indicator of Value type | `total`, `contacts`, `average_per_contact`, `anonymous_count`, `anonymous_total` |

        `times_recorded` counts records, including headcounts and the same Contact recorded more than once, so it is
        not a number of people. `contacts` and `contacts_achieved` count distinct Contacts tagged. `anonymous_count`
        is what was recorded with no Contact tagged.

        Stories count by their date (`created_at`). `target`, `target_deadline` and `percent_of_target` appear when
        the Project has a target: target deadlines dated in the period are added together, otherwise the Project's
        own target is used. `last_sync_datetime` doesn't apply, as the figures are totals.
      operationId: getProjectResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - name: project_ids
          in: query
          schema:
            type: array
            items:
              type: integer
          style: form
          explode: true
          example: [619, 620]
          description: Projects to include, as project_ids[]=619&project_ids[]=620 or a JSON array string ("[619,620]"). Defaults to every Project you can view; Projects you can't view are left out.
        - name: start_date
          in: query
          schema:
            type: string
            format: date
          example: "2026-04-01"
          description: First Story date to include (YYYY-MM-DD). Omit start_date and end_date for all time.
        - name: end_date
          in: query
          schema:
            type: string
            format: date
          example: "2027-03-31"
          description: Last Story date to include (YYYY-MM-DD)
        - name: tracker_types
          in: query
          schema:
            type: array
            items:
              type: string
              enum: [activity, engagement, achievement, choice, numerical]
          example: [activity, choice]
          description: Tracker types to include, as an array or a comma-separated list. Defaults to all.
        - name: group_by
          in: query
          schema:
            type: string
            enum: [project, month]
          description: Split each tracker's figures into a `groups` array by Project or by month (months with nothing recorded are included). Default is one total.
        - name: template_id
          in: query
          schema:
            type: integer
          example: 2413
          description: |
            Return only the trackers in this **Impact Framework** (Template), as choosing it in **Metrics included**
            does on the Results Canvas: its Activity and Engagement trackers, and the indicators under its Outcomes
            (including your organisation's own indicators linked to those Outcomes). It never adds a tracker the
            Projects don't use. The Impact Framework must be your own, or belong to the Organisation of every Project
            requested; otherwise the response is a 422. A Project's default Impact Framework is
            `default_results_template_id` on `GET /projects/{id}`. Omit for every tracker.
      responses:
        "200":
          description: One page of trackers, plus label_results
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginatedProjectResults'
                  - type: object
                    properties:
                      label_results:
                        type: array
                        description: |
                          Each Label (Story Label) that evidences one of the Projects' Outcomes, with the Stories and survey
                          responses carrying it dated in the timeframe, and its deadline targets dated in it. Not paginated.
                        items:
                          type: object
                          properties:
                            label_id: { type: integer }
                            label_name: { type: string }
                            outcome_id: { type: integer }
                            outcome_name: { type: string }
                            story_count: { type: integer }
                            target: { type: integer, nullable: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /distance_travelled:
    get:
      tags: [Projects]
      summary: Get distance travelled on Choice trackers
      description: |
        For each **Choice tracker** (Indicator of Scale type) that has a **success direction**, how many Contacts
        improved, stayed the same or worsened between their first and latest answer. These are the figures in a
        Progress Board's **Success Direction Summary**, and the same rules the **distance travelled** Contact Filter
        uses. Use them for change-over-time evidence such as "68% of young people reported improved confidence".
        Covers the Projects you can view (Editor, Reporter or Observer of the Project or its Organisation).

        Answers are ordered by their Story's date, one answer per Story per Contact, and answers saved with no
        Contact tagged are left out. Contacts with only one answer in the period are **not judged**: they are
        counted in `not_judged`, and every `percent` is of `judged_contacts` only. `contacts_answered` is everyone
        who answered at least once. `success_direction_meaning` says which answer is the best. `answers` is a
        before/after table: for each answer, how many judged Contacts gave it first and how many gave it last.

        Choice trackers with no success direction are left out; when you choose them with `tracker_ids`,
        `skipped_trackers` says which. `last_synced_datetime` doesn't apply, as the figures are totals.
      operationId: getDistanceTravelled
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - name: project_ids
          in: query
          schema:
            type: array
            items:
              type: integer
          style: form
          explode: true
          example: [619, 620]
          description: Projects to include, as project_ids[]=619&project_ids[]=620 or a JSON array string ("[619,620]"). Defaults to every Project you can view; Projects you can't view are left out.
        - name: tracker_ids
          in: query
          schema:
            type: array
            items:
              type: integer
          example: [362]
          description: Choice trackers (Indicator IDs) to include, as an array or a comma-separated list. Defaults to every Choice tracker with a success direction used on the Projects.
        - name: start_date
          in: query
          schema:
            type: string
            format: date
          example: "2026-04-01"
          description: First Story date to include (YYYY-MM-DD). Omit start_date and end_date for all time.
        - name: end_date
          in: query
          schema:
            type: string
            format: date
          example: "2027-03-31"
          description: Last Story date to include (YYYY-MM-DD)
      responses:
        "200":
          description: One page of Choice trackers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedDistanceTravelled'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /sessions_and_attendance:
    get:
      tags: [Events]
      summary: Get sessions run and attendance
      description: |
        Delivery figures from Scheduling for the Projects you can view (Editor, Reporter or Observer of the
        Project or its Organisation): how many **Events** (sessions) were run, the hours delivered, and how well
        they were attended. An Event counts when its start falls between `start_date` and `end_date`.

        `totals` holds:
        - `events_scheduled`: every Event in the dates; `events_held`: those that have already started.
        - `hours_delivered`: the length (start to end) of the Events held, in hours.
        - `invited_contacts`: distinct Contacts added to the Events as guests.
        - `attending_contacts`: distinct Contacts with attendance recorded on an Event's attendance form, whether
          or not they were invited.
        - `attendance_rates`: one entry per Engagement tracker on the Events' attendance forms.
          `attendance_rate` is `attendances` (attendance records) divided by `invitations` (each time a Contact
          was added to an Event), as the **Event Attendance** page's "Total across all guests" row shows it. It
          counts records, not distinct Events, so it can exceed 100% when an Event has duplicate attendance
          Stories. It is `null` when nobody was invited.

        Deleted Contacts are left out. Makerble doesn't record cancelled Events. With `group_by`, `data` holds one
        row per group (every month in the dates, Projects, or Event formats), each with the same figures as
        `totals`; without it `data` is empty. `last_synced_datetime` doesn't apply, as the figures are totals.
        These are the figures ReportMaker uses to answer delivery questions.
      operationId: getSessionsAndAttendance
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - name: project_ids
          in: query
          schema:
            type: array
            items:
              type: integer
          style: form
          explode: true
          example: [619, 620]
          description: Projects to include, as project_ids[]=619&project_ids[]=620 or a JSON array string ("[619,620]"). Defaults to every Project you can view; Projects you can't view are left out.
        - name: start_date
          in: query
          schema:
            type: string
            format: date
          example: "2026-04-01"
          description: First Event start date to include (YYYY-MM-DD). Omit start_date and end_date for all time.
        - name: end_date
          in: query
          schema:
            type: string
            format: date
          example: "2027-03-31"
          description: Last Event start date to include (YYYY-MM-DD)
        - name: group_by
          in: query
          schema:
            type: string
            enum: [project, event_format, month]
          example: month
          description: Split the figures by Project, by Event format (Event Category) or by month. Omit for totals only.
      responses:
        "200":
          description: The totals, and one page of groups when group_by is given
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSessionsAndAttendance'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/bulk_status_change:
    post:
      tags: [Projects]
      summary: Close or reopen many Projects at once
      description: |
        Closes or reopens several Projects in one request. This is **Close projects** and **Reopen
        projects** for the projects ticked in the Rows view of the My Projects page. Each Project is
        closed or reopened the same way as from its own settings menu, so its team is told.

        A closed Project can't get new updates (Stories) or Contacts, and its existing updates can't
        be edited, until it is reopened. Closed Projects are listed on the organisation's Closed
        Projects page.

        **Who may do it.** An Organisation Admin of the Project's organisation, or a Project Manager
        (Project Editor) of the Project. If any listed Project is one the user may not change, nothing
        is changed and the reply is `403` naming those Projects.

        **Already closed or open.** `close` changes only the listed Projects that are open, and
        `reopen` only those that are closed. The others are left as they are.

        **Progress Boards.** Closing a Project also archives the Progress Boards generated for it
        ("<Survey> on <Project>"), and reopening it reopens those boards. A board someone archived by
        hand stays archived when the Project is reopened.

        **Signup Pages.** Closing a Project that an active Signup Page uses would break that Signup
        Page, so `close` needs `signup_pages`:
        - `deactivate`: deactivate those Signup Pages, then close the Project. A Project whose Signup
          Page the user may not deactivate is left open.
        - `skip`: leave those Projects open and close the rest.

        **In the background.** The reply is `202` straight away. The user is emailed when it has
        finished: how many Projects were closed, with a link to the Closed Projects page, or which
        Projects were reopened. Check the result with `GET /projects/{id}` (`is_closed`).
      operationId: bulkChangeProjectStatus
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [status_action, project_ids]
              properties:
                status_action:
                  type: string
                  enum: [close, reopen]
                  description: Whether to close or reopen the Projects
                project_ids:
                  type: array
                  minItems: 1
                  maxItems: 200
                  items: { type: integer }
                  description: The Projects to change, at most 200
                signup_pages:
                  type: string
                  enum: [deactivate, skip]
                  description: Required with `close`. What to do with Projects that an active Signup Page uses.
            example:
              status_action: close
              project_ids: [619, 620]
              signup_pages: skip
      responses:
        "202":
          description: The Projects are being closed or reopened in the background
          content:
            application/json:
              schema:
                type: object
                properties:
                  status_action:
                    type: string
                    enum: [close, reopen]
                  project_ids:
                    type: array
                    items: { type: integer }
                  message:
                    type: string
              example:
                status_action: close
                project_ids: [619, 620]
                message: The projects are being changed in the background. You will be emailed when this is done.
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not close or reopen one of the listed Projects. Nothing is changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "You don't have permission to close or reopen project 619."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/bulk_deletion:
    post:
      tags: [Projects]
      summary: Delete many closed Projects at once
      description: |
        Permanently deletes several closed Projects in one request. This is **Delete projects** for
        the projects ticked in the Rows view of the My Projects page. Each Project is deleted the
        same way as with the Delete project button on the organisation's Closed Projects page: its
        team is emailed, it is listed under Deleted Projects there, and its automations are turned
        off. **Deletion is permanent and cannot be undone**, so confirm the list with the user first.

        **Only closed Projects are deleted.** Open Projects in the list are kept and returned in
        `kept_project_ids`; close them first (`POST /projects/bulk_status_change`) to delete them. A
        list with no closed Project is refused with `422`.

        **Who may do it.** An Organisation Admin of the Project's organisation, or a Project Manager
        (Project Editor) of the Project. If any listed Project is one the user may not delete,
        nothing is deleted and the reply is `403` naming those Projects.

        **In the background.** The reply is `202` straight away and the Projects are deleted soon
        after. `GET /projects/{id}` returns `404` for a Project once it has been deleted.
      operationId: bulkDeleteProjects
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_ids]
              properties:
                project_ids:
                  type: array
                  minItems: 1
                  maxItems: 200
                  items: { type: integer }
                  description: The Projects to delete, at most 200. Only the closed ones are deleted.
            example:
              project_ids: [619, 620]
      responses:
        "202":
          description: The closed Projects are being deleted in the background
          content:
            application/json:
              schema:
                type: object
                properties:
                  project_ids:
                    type: array
                    items: { type: integer }
                    description: The closed Projects that will be deleted
                  kept_project_ids:
                    type: array
                    items: { type: integer }
                    description: The open Projects in the list, which are kept
                  message:
                    type: string
              example:
                project_ids: [619]
                kept_project_ids: [620]
                message: The closed projects are being deleted in the background.
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not delete one of the listed Projects. Nothing is deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "You don't have permission to delete project 619."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries:
    get:
      tags: [Beneficiaries]
      summary: List all Beneficiaries (Contacts)
      description: |
        Returns all Contacts visible to the authenticated user. Filter by `charity_id` or `project_id`.
        Response includes `custom_fields` defined by the Beneficiary Category.

        Fields the Organisation's **Field Visibility** settings hide from you are not returned: a hidden custom field
        comes back with `restricted: true` and `value: null`, and a hidden built-in field (`dob`, `mobile`, `email`,
        `address`) is `null` and named in `restricted_fields`.
      operationId: listBeneficiaries
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: charity_id
          in: query
          schema:
            type: integer
          description: Filter to Contacts in this Organisation
        - name: project_id
          in: query
          schema:
            type: integer
          description: Filter to Contacts enrolled in this Project
      responses:
        "200":
          description: Paginated list of Beneficiaries
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedBeneficiaries'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Beneficiaries]
      summary: Create a Beneficiary (Contact)
      description: |
        Creates a new Contact. Required: `name`, `owner_id`.

        Call `GET /beneficiary_types` for `beneficiary_type_id` values and `GET /custom_fields` for available custom field IDs.

        Setting a field the Organisation's Field Visibility settings hide from you (a custom field, a dropdown answer
        in `sub_ratio_ids`, `date_of_birth` or `address`) is refused with `422` and an `errors` list naming each field;
        no Contact is created.

        A Weekly availability field takes a list of days and times (see WeeklyAvailabilityTime). An answer whose `to`
        isn't after its `from`, or that isn't a list of days and times, is refused with `422` and an `errors` list
        saying why; no Contact is created.
      operationId: createBeneficiary
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BeneficiaryCreateRequest'
            example:
              beneficiary:
                name: "Jack Smith"
                date_of_birth: "13-05-1990"
                address: "123 Example Street, London"
                latitude: "51.5074"
                longitude: "-0.1278"
                beneficiary_type_id: 1
                owner_id: 237
              project_ids: [572]
              beneficiary_category_ids: [294]
              custom_fields:
                "173": "some value"
                "9051":
                  - day: monday
                    from: "15:30"
                    to: "18:00"
      responses:
        "200":
          description: Beneficiary created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BeneficiaryDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries/{id}:
    get:
      tags: [Beneficiaries]
      summary: Get a single Beneficiary (Contact)
      description: "Returns a Contact's full profile including all custom fields, and `weekly_availability`: the most recent answer to a Weekly availability field on their Contact Forms, with the Contact Form it came from and when it was saved. Opening a Contact this way is recorded in its Access Log, the audit trail of who has viewed it, under the caller's name and marked as via the API (or via MCP when the Makerble MCP server sends `X-Makerble-Client: makerble-mcp`). Views by the same caller less than 30 minutes apart are counted together. Use the list endpoint when you only need to find or scan Contacts."
      operationId: getBeneficiary
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Beneficiary record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BeneficiaryDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/{beneficiary_id}/bio_fields:
    patch:
      tags: [Beneficiaries]
      summary: Change a Contact's Bio answers
      operationId: updateContactBioFields
      description: |
        Changes a Contact's answers to some of their Bio fields: the fields on their Contact Forms, such as
        School, Gender or Date of birth. This is what a cell of the **Bio per Contact** and **Custom Table**
        views saves in Edit mode, and it goes through the same save as the Contact's Edit Bio page.

        Each field is named by `field_class` and `field_id`, as each custom field in GET /beneficiaries/{id} gives them:

        - `CustomField`: a text, number, date, time or telephone field, by its id. `value` is a string.
          Dates may be `YYYY-MM-DD` and times `HH:MM` (24-hour).
        - `RatioSet`: a Dropdown, by its id. `value` is an array of answer (Sub Ratio) ids; `[]` clears it.
          A Dropdown that allows one answer keeps the first.
        - `BeneficiaryColumn`: `date_of_birth` (`YYYY-MM-DD`) or `address`. `value` is a string.

        A blank string clears an answer. Every field is checked before anything is saved, so one refused
        field leaves the Contact unchanged. A field is refused when you can't edit the Contact (403), Field
        Visibility hides it from you (403), it doesn't exist (404), it isn't on any of the Contact's own
        Contact Forms, it is a file, signature, weekly availability or extended table field or an email the
        organisation messages Contacts through, a mandatory field is left empty, or a Dropdown answer isn't
        one of its choices (422).
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          description: The Contact (Beneficiary)
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [fields]
              properties:
                fields:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    type: object
                    required: [field_class, field_id, value]
                    properties:
                      field_class:
                        type: string
                        enum: [CustomField, RatioSet, BeneficiaryColumn]
                      field_id:
                        oneOf:
                          - type: integer
                          - type: string
                            enum: [date_of_birth, address]
                      value:
                        oneOf:
                          - type: string
                          - type: array
                            items:
                              type: integer
            example:
              fields:
                - { field_class: CustomField, field_id: 412, value: Lydiard Park Academy }
                - { field_class: RatioSet, field_id: 37, value: [215] }
                - { field_class: BeneficiaryColumn, field_id: date_of_birth, value: "2008-04-17" }
      responses:
        "200":
          description: The answers were saved. Each value is what the field now shows (Dropdown answers joined with ", ").
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        field_class: { type: string }
                        field_id: { type: string }
                        value: { type: string }
              example:
                data:
                  - { field_class: CustomField, field_id: "412", value: Lydiard Park Academy }
                  - { field_class: RatioSet, field_id: "37", value: Female }
                  - { field_class: BeneficiaryColumn, field_id: date_of_birth, value: "2008-04-17" }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries/{beneficiary_id}/staff_suggestions:
    get:
      tags: [Staff Matching]
      summary: Suggest colleagues for a Contact
      operationId: getStaffSuggestions
      description: |
        Which colleagues could take on a Contact for one-to-one appointments of an Event Format in a
        Project, best fit first, and when each could start. Use it before booking a recurring
        appointment with **Create an event**.

        The candidates are the Project's colleagues. One with a free series of 6 weekly sessions
        starting in the next 8 weeks (see **Find a colleague's free slots**) is a suggestion. One without
        is listed in `fully_booked`, with `free_from`, the date they free up if it is within 16 weeks.

        Suggestions are ranked by:

        1. having every Essential need as a Specialism. Colleagues missing one still appear, lower down,
           with the missing need shown;
        2. the number of Desirable needs matched;
        3. the earliest series inside the Contact's Weekly availability. If that isn't recorded, or is
           hidden from you, any series counts and `contact_availability_note` says why;
        4. the fewest ongoing one-to-one Contacts relative to their cap, to share the work fairly.

        Each suggestion explains itself: `specialisms_summary` (for example "Eating disorders ✓
        (essential) · Music ✗ (desirable)"), `first_slot.summary` ("Mondays 10:00–11:00 from 24 Nov"),
        `inside_contact_availability`, and `load.summary` ("9 of 12 one-to-one Contacts"). A fully
        booked colleague's `summary` reads, for example, "Sarah Jones: fully booked until 8 Dec".

        You need to see the Contact's profile and the Project's events (as an Organisation Admin or an
        Editor of the Project). `load` and `at_one_to_one_limit` are `null` for colleagues you don't see
        on Staff availability. The lists are bounded by the Project's colleagues and aren't paged.
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          description: The Contact (Beneficiary)
          schema:
            type: integer
        - name: project_id
          in: query
          required: true
          description: The Project the appointments are for. The Contact must be in it.
          schema:
            type: integer
        - name: event_category_id
          in: query
          required: true
          description: A one-to-one Event Format (event category) with a Default length
          schema:
            type: integer
      responses:
        "200":
          description: The suggestions, best fit first, and the fully booked colleagues
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StaffSuggestions'
              example:
                beneficiary_id: 5512
                project_id: 77
                event_category_id: 41
                sessions: 6
                weeks: 8
                contact_availability_note: null
                suggestions:
                  - rank: 1
                    user: { id: 812, name: Claire Hughes }
                    has_all_essential: true
                    specialisms:
                      - { skill_id: 3, name: Eating disorders, importance: essential, matched: true }
                      - { skill_id: 9, name: Music, importance: desirable, matched: false }
                    specialisms_summary: "Eating disorders ✓ (essential) · Music ✗ (desirable)"
                    load: { ongoing_one_to_one_contacts: 9, max_one_to_one_contacts: 12, summary: "9 of 12 one-to-one Contacts" }
                    first_slot:
                      starts_at: "2026-11-24T10:00:00+00:00"
                      ends_at: "2026-11-24T11:00:00+00:00"
                      date: "2026-11-24"
                      weekday: tuesday
                      start_time: "10:00"
                      end_time: "11:00"
                      sessions: 6
                      summary: "Tuesdays 10:00–11:00 from 24 Nov"
                    inside_contact_availability: true
                fully_booked:
                  - user: { id: 815, name: Sarah Jones }
                    has_all_essential: true
                    specialisms:
                      - { skill_id: 3, name: Eating disorders, importance: essential, matched: true }
                      - { skill_id: 9, name: Music, importance: desirable, matched: true }
                    specialisms_summary: "Eating disorders ✓ (essential) · Music ✓ (desirable)"
                    load: { ongoing_one_to_one_contacts: 12, max_one_to_one_contacts: 12, summary: "12 of 12 one-to-one Contacts" }
                    free_from: "2027-01-25"
                    summary: "Sarah Jones: fully booked until 25 Jan"
                    at_one_to_one_limit: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You can't see the Project's events
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "You can't see this Project's events. A Charity Editor of its organisation or an Editor of the Project can."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries/{beneficiary_id}/summary:
    parameters:
      - name: beneficiary_id
        in: path
        required: true
        schema:
          type: integer
        description: Contact (Beneficiary) ID
    get:
      tags: [Beneficiaries]
      summary: Get the AI summary of a Contact (SummaryMaker)
      description: |
        Returns the SummaryMaker summary of a Contact, as shown in the Summary tile on the
        Contact profile: three sections (**Who**, **Progress**, **Watch for**) written from the
        Contact's bio and the Stories the signed-in user is allowed to see. Every sentence
        lists its sources: `bio` (true if it came from the bio) and `story_ids`.

        A summary is never made from, and never returns, a Story or bio field the user can't
        see. Users with the same access share one summary, and it is only remade when the bio
        or Stories change, so repeated calls return the same text.

        `status` is one of:
        - `ready`: the summary is current.
        - `stale`: an older summary made only from Stories you can see; `new_story_count`
          Stories have been added since. POST to make a fresh one.
        - `pending`: SummaryMaker is writing it in the background. `summary` is null, or the
          previous version while an update is made. Call again in a few seconds.
        - `failed`: it could not be made. POST to try again.
        - `empty`: the Contact has no bio or Stories you can see.

        Only available to organisations that have turned on SummaryMaker in their
        preferences (off by default).
      operationId: getBeneficiarySummary
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Contact summary and its status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactSummaryResponse'
              example:
                status: ready
                new_story_count: 0
                summary:
                  id: 812
                  generated_at: "2026-09-29T10:14:03Z"
                  model: claude-haiku-4-5-20251001
                  source_story_ids: [5521, 5530, 5544]
                  sections:
                    - heading: Who
                      text: Amira joined the programme in June and is looking for warehouse work.
                      bio: true
                      story_ids: []
                      sentences:
                        - text: Amira joined the programme in June and is looking for warehouse work.
                          bio: true
                          story_ids: []
                    - heading: Progress
                      text: Amira updated her CV and has started interview practice.
                      bio: false
                      story_ids: [5530, 5544]
                      sentences:
                        - text: Amira updated her CV and has started interview practice.
                          bio: false
                          story_ids: [5530, 5544]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: SummaryMaker is not turned on for this organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: SummaryMaker is not enabled for this organisation
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Beneficiaries]
      summary: Update the AI summary of a Contact (SummaryMaker)
      description: |
        Makes a fresh summary from the latest bio and Stories the signed-in user can see, like
        the **Update summary** button on the Contact profile. Returns `202` with status
        `pending`; call the GET endpoint until the status is `ready`. No request body.
      operationId: updateBeneficiarySummary
      security: [{tokenAuth: []}]
      responses:
        "202":
          description: Summary update started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactSummaryResponse'
              example:
                status: pending
                new_story_count: 0
                summary: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: SummaryMaker is not turned on for this organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: SummaryMaker is not enabled for this organisation
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/advanced_custom_fields:
    get:
      tags: [Beneficiaries]
      summary: Get advanced custom fields for all Beneficiaries
      description: |
        Returns the per-record custom field values (Custom Forms answers) for all Beneficiaries.
        An answer the Organisation's Field Visibility settings hide from you comes back with `restricted: true` and `value: null`.
      operationId: listBeneficiaryAdvancedCustomFields
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated custom field records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /beneficiaries/impact_box_data:
    get:
      tags: [Beneficiaries]
      summary: Get Impact Box data (Progress Trackers per Contact)
      description: Aggregated metric progress per Beneficiary — the data shown in the Progress Trackers box on a Contact Profile page.
      operationId: getBeneficiaryImpactBoxData
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated impact box records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /beneficiaries/bulk_project_moves:
    post:
      tags: [Beneficiaries]
      summary: Move many Contacts through Projects at once
      description: |
        Adds many Contacts (Beneficiaries) to Projects, changes their status (Beneficiary State, e.g.
        Enrolled, Waiting List, Alumni, Declined) in them, or removes them from them, in one request.
        This is **Move through projects** for the Contacts selected on the Manage Contacts page. Each
        change is made the same way as moving one Contact from their profile, so it appears in each
        Contact's History and the Project's team is notified.

        **Which Contacts.** Either
        - `beneficiary_ids`: at most 500 Contacts of the organisation; or
        - everyone matching `filter_data` (the Manage Contacts filters, e.g.
          `{"project_ids": ["572"], "beneficiary_state_ids": ["1"]}`), leaving out `excluded_ids`. Give
          `project_id` as a shortcut for the Project filter. With neither, every Contact the user can
          see in the organisation is selected.

        **What changes.** `changes` lists one entry per Project: `project_id` and `state`, which is a
        status id switched on for that Project (`beneficiary_states` in `GET /projects/{id}`) or
        `remove`. Projects must be open (not closed) and in the organisation.

        **Skipped Contacts.** Contacts are skipped, not refused, and counted in `skip_counts`:
        - `headline_only`: the user only has Headline Only Access to them;
        - `not_allowed`: the user may not move them between Projects (Organisation Editors, Reporters
          and Observers may move any Contact; others only Contacts they may edit).
        A Contact already in the chosen status, or not in a Project they'd be removed from, is left as
        they are and isn't counted as changed.

        **Small and large requests.** Up to 50 Contacts change straight away and the reply is `200`
        with the counts. More than 50 run in the background: the reply is `202` with an `id`, and
        `GET /beneficiaries/bulk_project_moves/{id}` reports the progress until `status` is
        `completed` or `failed`. The user also gets a notification when it finishes.

        `charity_id` may be left out when the user belongs to one organisation. Not available to
        connected apps (OAuth tokens) yet.
      operationId: moveBeneficiariesThroughProjects
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [changes]
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to move
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to move, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                project_id:
                  type: integer
                  description: Shortcut for the Project filter (Contacts in this Project)
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
                changes:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required: [project_id, state]
                    properties:
                      project_id:
                        type: integer
                      state:
                        description: A status id switched on for the Project, or `remove`
                        oneOf:
                          - type: integer
                          - type: string
                            enum: [remove]
            example:
              charity_id: 12
              beneficiary_ids: [160498, 160499, 160500]
              changes:
                - project_id: 572
                  state: 3
                - project_id: 573
                  state: remove
      responses:
        "200":
          description: The Contacts were moved straight away
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkProjectMove'
              example:
                id: 41
                status: completed
                total_count: 3
                processed_count: 3
                changed_count: 2
                skip_counts: { headline_only: 1 }
                background: false
                summary: "2 contacts changed. 1 skipped: 1 because you have Headline Only Access to them."
        "202":
          description: More than 50 Contacts, so the move runs in the background. Poll GET /beneficiaries/bulk_project_moves/{id}.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkProjectMove'
              example:
                id: 42
                status: pending
                total_count: 812
                processed_count: 0
                changed_count: 0
                skip_counts: {}
                background: true
                summary: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiaries/bulk_project_moves/{id}:
    get:
      tags: [Beneficiaries]
      summary: Get the progress of a bulk project move
      description: |
        The progress of a move started with `POST /beneficiaries/bulk_project_moves`. Only the user
        who started it can see it. `status` is `pending`, `running`, `completed` or `failed`;
        `processed_count` of `total_count` Contacts have been reached so far, and `summary` is filled in
        once it has finished.
      operationId: getBulkProjectMove
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: integer }
      responses:
        "200":
          description: The move's progress
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkProjectMove'
              example:
                id: 42
                status: running
                total_count: 812
                processed_count: 240
                changed_count: 231
                skip_counts: { not_allowed: 9 }
                background: true
                summary: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /beneficiaries/bulk_actions/{id}:
    get:
      tags: [Beneficiaries]
      summary: Get the progress of a bulk action on Contacts
      description: |
        The progress of any change to many Contacts at once, such as adding everyone matching
        `filter_data` as an event's guests (`POST /events/{id}/guests`). Only the user who started
        it can see it. `action_name` says which change it is (e.g. `add_to_event`,
        `move_through_projects`). `status` is `pending`, `running`, `completed`, `failed` or
        `undone`; `processed_count` of `total_count` Contacts have been reached so far, and `summary`
        is filled in once it has finished.
      operationId: getBeneficiaryBulkAction
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: integer }
      responses:
        "200":
          description: The bulk action's progress
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/BeneficiaryBulkAction'
                  - type: object
                    properties:
                      action_name:
                        type: string
                        description: Which change this is, e.g. add_to_event or move_through_projects
              example:
                id: 52
                status: running
                total_count: 812
                processed_count: 240
                changed_count: 231
                skip_counts: { not_in_project: 9 }
                background: true
                summary: null
                action_name: add_to_event
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /beneficiaries/bulk_checklists:
    post:
      tags: [Beneficiaries]
      summary: Start a Checklist for many Contacts at once
      description: |
        Starts a Checklist for many Contacts (Beneficiaries) in one request. This is **Add to › A
        Checklist** for the Contacts selected on the Manage Contacts page. Each Contact is started
        the same way as Add a Checklist on their profile, and actions their records already prove
        done are marked done straight away.

        **Which Checklist.** `checklist_id` and `project_id`: a Checklist the project lets colleagues
        add by hand, through that project. Organisation Editors and Reporters may use any open
        project; other users only projects they are an Editor or Reporter of. Anything else is
        refused with `422`.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`. With `filter_data`,
        `project_id` also narrows the filters to Contacts in that project, since anyone outside it
        would be skipped anyway.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` (the user only has
        Headline Only Access to them), `not_in_project` (they aren't in the project), `not_allowed`
        (the Checklist can't be started for them). A Contact who already has the Checklist keeps
        their progress and isn't counted as changed.

        Up to 50 Contacts are started straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: startChecklistForBeneficiaries
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [checklist_id, project_id]
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to start it for
                checklist_id:
                  type: integer
                  description: The Checklist to start
                project_id:
                  type: integer
                  description: The project it is started through (one that lets colleagues add it by hand)
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              checklist_id: 31
              project_id: 572
              beneficiary_ids: [160498, 160499, 160500]
      responses:
        "200":
          description: The Checklist was started straight away (50 Contacts or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BeneficiaryBulkAction' }
              example:
                id: 61
                status: completed
                total_count: 10
                processed_count: 10
                changed_count: 7
                skip_counts: { not_in_project: 3 }
                background: false
                summary: "7 contacts changed. 3 skipped: 3 because they aren't in Youth Mentoring."
        "202":
          description: More than 50 Contacts, so it runs in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BeneficiaryBulkAction' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiaries/bulk_relationships:
    post:
      tags: [Beneficiaries]
      summary: Link many Contacts to one Contact with the same relationship
      description: |
        Gives many Contacts (Beneficiaries) the same relationship with one Contact, in one request.
        This is **Add to › A relationship** for the Contacts selected on the Manage Contacts page,
        e.g. making Oakfield School the School of every selected pupil. Each relationship is added
        the same way as Add a Relationship on a Contact's profile, so it appears on both Contacts'
        History.

        **Which relationship.** `relationship_category_id` is one of the organisation's
        Relationship Categories (`GET /relationship_categories`), which has two sides, e.g. School &
        Pupil. `related_contact_id` is the one Contact everyone is linked to, and
        `related_contact_is` says which side that Contact takes: `parent` (the first title, School)
        or `child` (the second, Pupil). Each selected Contact takes the other side.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` (the user only has
        Headline Only Access to them), `already_linked` (they already have that relationship with
        that Contact), `same_contact` (the chosen Contact itself), `not_allowed` (the relationship
        couldn't be saved for them).

        Up to 50 Contacts are linked straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: linkBeneficiariesToContact
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [relationship_category_id, related_contact_id, related_contact_is]
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to link
                relationship_category_id:
                  type: integer
                  description: One of the organisation's Relationship Categories
                related_contact_id:
                  type: integer
                  description: The Contact every selected Contact is linked to
                related_contact_is:
                  type: string
                  enum: [parent, child]
                  description: Which side of the category the related Contact takes; the selected Contacts take the other
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to link, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              relationship_category_id: 8
              related_contact_id: 160400
              related_contact_is: parent
              beneficiary_ids: [160498, 160499, 160500]
      responses:
        "200":
          description: The Contacts were linked straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BeneficiaryBulkAction' }
              example:
                id: 71
                status: completed
                total_count: 5
                processed_count: 5
                changed_count: 5
                skip_counts: {}
                background: false
                summary: "5 contacts changed."
        "202":
          description: More than 50 Contacts, so they are linked in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BeneficiaryBulkAction' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /project_beneficiaries:
    get:
      tags: [Beneficiaries]
      summary: List Project–Beneficiary associations
      description: >
        Join table linking Contacts (Beneficiaries) to Projects (many-to-many). Only projects the
        authenticated user can see are included. Use project_ids to narrow the results to specific
        projects; it can never widen them to projects the user cannot see.
      operationId: listProjectBeneficiaries
      security: [{tokenAuth: []}]
      parameters:
        - name: project_ids
          in: query
          required: false
          description: >
            Only include these projects. Send as repeated project_ids[]=12&project_ids[]=34, or as a
            JSON array string (project_ids=[12,34]).
          schema:
            type: array
            items: { type: integer }
          style: form
          explode: true
          example: [12, 34]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Project–Beneficiary records (id, project_id, beneficiary_id, created_at, updated_at)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Beneficiaries]
      summary: Add existing Contacts to a Project
      description: |
        Adds existing Contacts (Beneficiaries) to a Project, all with one status (Beneficiary State,
        e.g. Enrolled or Waiting List). This is the same as "Assign Contacts to projects" on the
        Contacts page: each Contact added gets an entry on their activity timeline, and the Project's
        team is notified. It doesn't create Contacts: use `POST /beneficiaries` for that.

        Use it before `POST /project_story_categories/{id}/survey_links` with `beneficiary_ids`, when
        the Contacts aren't in the Survey Campaign's Project yet.

        - `beneficiary_state_id` is optional. Without it the Contacts are Enrolled, or get the
          Project's first status if Enrolled is switched off. `GET /projects/{id}` lists the
          statuses switched on in `beneficiary_states`.
        - A Contact already in the Project is left as they are (their status doesn't change) and is
          returned with `already_in_project: true`.
        - Nothing is added if any Contact is refused.
        - The Project must be open (not closed).

        Requires an Organisation Editor, Reporter or Observer, or a user who may edit the Contact
        (a Project Editor, or a Project Reporter if the organisation allows it, of a Project the
        Contact is in).
      operationId: addProjectBeneficiaries
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_id, beneficiary_ids]
              properties:
                project_id:
                  type: integer
                  description: The Project to add the Contacts to
                beneficiary_ids:
                  type: array
                  maxItems: 200
                  items:
                    type: integer
                  description: Contacts of the Project's organisation, at most 200
                beneficiary_state_id:
                  type: integer
                  description: Optional Contact status, from `beneficiary_states` in GET /projects/{id}
            example:
              project_id: 572
              beneficiary_ids: [160498, 160499]
              beneficiary_state_id: 3
      responses:
        "201":
          description: One entry per Contact, in the order given
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: The Project–Contact link
                        project_id:
                          type: integer
                        beneficiary_id:
                          type: integer
                        beneficiary_state_id:
                          type: integer
                          nullable: true
                          description: The Contact's status in the Project
                        already_in_project:
                          type: boolean
                          description: The Contact was already in the Project and was left as they were
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
              example:
                data:
                  - id: 88121
                    project_id: 572
                    beneficiary_id: 160498
                    beneficiary_state_id: 3
                    already_in_project: false
                    created_at: "2026-10-22T10:15:00.000Z"
                    updated_at: "2026-10-22T10:15:00.000Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not move these Contacts between Projects
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: string
              example:
                errors: ["You do not have permission to move these contacts between projects: 160498."]
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: |
            Invalid request: ids that aren't Contacts of the Project's organisation (listed in
            `beneficiary_ids_not_found`; the same whether the Contact is in another organisation or
            doesn't exist), a status not switched on for the Project, a closed Project, no ids, or more
            than 200.
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: string
                  beneficiary_ids_not_found:
                    type: array
                    items:
                      type: integer
              example:
                errors: ["These contacts were not found in the project's organisation: 9876."]
                beneficiary_ids_not_found: [9876]


  /beneficiary_categories:
    get:
      tags: [Beneficiary Categories]
      summary: List all Beneficiary Categories (Contact Bio Forms)
      operationId: listBeneficiaryCategories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedBeneficiaryCategories'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /beneficiary_categories/{id}:
    get:
      tags: [Beneficiary Categories]
      summary: Get a single Beneficiary Category
      operationId: getBeneficiaryCategory
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Beneficiary Category record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BeneficiaryCategory'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiary_categories/current_fields:
    get:
      tags: [Beneficiary Categories]
      summary: Get current active fields for Beneficiary Categories
      operationId: getBeneficiaryCategoryCurrentFields
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Current field definitions
          content:
            application/json:
              schema:
                type: object
        "401":
          $ref: '#/components/responses/Unauthorized'

  /custom_tables:
    get:
      tags: [Custom Tables]
      summary: List Custom Tables
      description: |
        The Custom Tables the user can see on Manage Contacts in their Organisations: their own tables,
        and the Organisation's tables shared with all colleagues or with them. Pass `charity_id` for one
        Organisation's tables.
      operationId: listCustomTables
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          description: Only this Organisation's tables
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Custom Tables
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomTableList'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Custom Tables]
      summary: Create a Custom Table
      description: |
        Creates a Custom Table, as Manage Contacts › Custom tables › Create a table does. Choose its
        columns from `GET /custom_tables/available_columns` and send each one as that endpoint lists it,
        in the order the table should show them; `display_name` is the column heading and may be changed.
        A column the Organisation doesn't offer, or a field hidden from the user by "Hide certain
        fields", is refused. `owner: User` makes a table only its creator sees; `owner: Charity` shares it
        with colleagues: with everyone (`visibility: charity_colleagues`, Organisation editors only), with
        the colleagues in `individual_list`, or with the Teams in `team_ids` (`visibility: specific_teams`).
        Organisation editors may choose any of the Organisation's Teams; anyone else only Teams they lead or
        belong to. A Team table is visible to the Teams' members and leaders, its creator and Organisation editors.
      operationId: createCustomTable
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomTableCreateRequest'
            example:
              custom_table:
                charity_id: 42
                name: "Attendance and confidence"
                owner: Charity
                visibility: charity_colleagues
                columns:
                  - { class_name: Beneficiary, field_name: name, field_id: "", display_name: Name }
                  - { class_name: Story, field_name: last_date, field_id: "", display_name: Date of most recent story }
                  - { class_name: Indicator, field_name: most_recent_value, field_id: "318", display_name: Confidence - most recent value }
      responses:
        "201":
          description: The Custom Table
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomTable'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /custom_tables/available_columns:
    get:
      tags: [Custom Tables]
      summary: List the columns a Custom Table can have
      description: |
        Every column the user may add to one of the Organisation's Custom Tables, grouped as the Create a
        table form groups them: basic fields, Bio Form questions, Survey Questions and Progress Trackers
        (first and most recent answers, totals), other information about a Contact, survey questions with
        a column per named wave, and relationships. Fields hidden from the user are left out. Send a
        column back unchanged in `columns` to add it.
      operationId: listCustomTableAvailableColumns
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          description: The Organisation the table belongs to
          schema:
            type: integer
      responses:
        "200":
          description: The columns, grouped
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomTableAvailableColumns'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /custom_tables/{id}:
    get:
      tags: [Custom Tables]
      summary: Get a Custom Table
      description: |
        A Custom Table's name, owner, who sees it and its columns. A table the user can't see returns 404.
        Use `GET /custom_tables/{id}/rows` for its values.
      operationId: getCustomTable
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Custom Table
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomTable'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Custom Tables]
      summary: Change a Custom Table
      description: |
        Changes the attributes sent and leaves the others as they are. `columns` replaces all the
        columns; a column the table already has is kept even if it could no longer be added. Only the
        table's creator, or an Organisation editor for a table that is the Organisation's, may change it.
      operationId: updateCustomTable
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomTableUpdateRequest'
            example:
              custom_table:
                name: "Attendance, confidence and projects"
      responses:
        "200":
          description: The Custom Table
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomTable'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can see the table but may not change it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

    delete:
      tags: [Custom Tables]
      summary: Delete a Custom Table
      description: Deletes the table, with the same permission rule as changing it. Contacts and their data are untouched.
      operationId: deleteCustomTable
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can see the table but may not delete it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          $ref: '#/components/responses/NotFound'

  /custom_tables/{id}/rows:
    get:
      tags: [Custom Tables]
      summary: Read a page of a Custom Table
      description: |
        One page of the table as Manage Contacts shows it: a row per Contact the user may see in the
        table's Organisation, ordered by Contact ID, with one value per heading in `headers`. Narrow it
        to Contacts in some Projects (`project_ids`) or in the Projects of some Albums (`album_ids`).
        Fields hidden from the user read as restricted. Bio Form "extended table" fields aren't included.
      operationId: getCustomTableRows
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: project_ids
          in: query
          required: false
          description: Comma-separated Project IDs; only Contacts in any of them
          schema:
            type: string
        - name: album_ids
          in: query
          required: false
          description: Comma-separated Album IDs the user can see; only Contacts in their Projects
          schema:
            type: string
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: A page of rows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomTableRows'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /custom_fields:
    get:
      tags: [Beneficiary Categories]
      summary: List Custom Field definitions (Contact Bio Forms)
      description: |
        Filter by `beneficiary_category_ids[]` to get fields for specific forms. Each field's
        `capture_type` is `video`, `audio` or `picture` for a Video, Audio or Picture question (an
        Attachment field, `field_data_type: file`, that asks for that kind of media), otherwise null.
      operationId: listCustomFields
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: "beneficiary_category_ids[]"
          in: query
          schema:
            type: integer
          description: Filter by Beneficiary Category ID (repeat for multiple)
      responses:
        "200":
          description: Paginated Custom Field definitions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /beneficiaries/bulk_groups:
    post:
      tags: [Beneficiaries]
      summary: Add many Contacts to Groups, or take them out of Groups
      description: |
        Adds many Contacts (Beneficiaries) to some of the organisation's Groups and takes them out of
        others, in one request. This is **Add or remove › Groups** for the Contacts selected on the
        Manage Contacts page, e.g. putting every selected Contact in "Girls' football". Each change is
        made the same way as ticking or unticking a Group on the Edit Contact page, so it appears on
        the Contact's History.

        **Which Groups.** `add_ids` and `remove_ids` are ids of the organisation's Groups
        (`GET /groups`). Give at least one, and never the same Group in both. A Contact already in a
        Group being added, or not in a Group being removed, is left as they are.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` (the user only has
        Headline Only Access to them) and `not_allowed` (the user may not edit them).

        Up to 50 Contacts are changed straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: changeBeneficiaryGroups
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to change
                add_ids:
                  type: array
                  items: { type: integer }
                  description: Groups to add every Contact to
                remove_ids:
                  type: array
                  items: { type: integer }
                  description: Groups to take every Contact out of
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to change, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              add_ids: [31]
              remove_ids: [32]
              beneficiary_ids: [160498, 160499, 160500]
      responses:
        "200":
          description: The Contacts were changed straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
              example:
                id: 72
                status: completed
                total_count: 3
                processed_count: 3
                changed_count: 2
                skip_counts: { not_allowed: 1 }
                background: false
                summary: "2 contacts changed. 1 skipped: 1 because you aren't allowed to edit them."
        "202":
          description: More than 50 Contacts, so they are changed in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiaries/bulk_flags:
    post:
      tags: [Beneficiaries]
      summary: Raise Flags on many Contacts, or remove them
      description: |
        Raises some of the organisation's Flags (Contact Flags) on many Contacts (Beneficiaries) and
        removes others, in one request. This is **Add or remove › Flags** for the Contacts selected
        on the Manage Contacts page. Each Flag is raised the same way as on a Contact's profile, by
        you, enabled and with no description.

        **Which Flags.** `add_ids` and `remove_ids` are ids of Flags you may raise
        (`GET /flags`): a Flag restricted to Teams is only yours to use if you are in one of them.
        Give at least one, and never the same Flag in both. A Contact who already has a Flag being
        added, or lacks one being removed, is left as they are. You need to be an Organisation
        Editor, or a colleague on one of the organisation's Projects, to raise Flags.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` (the user only has
        Headline Only Access to them) and `raised_by_someone_else` (only the person who raised a Flag
        may remove it; such a Contact is left unchanged).

        Up to 50 Contacts are changed straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: changeBeneficiaryFlags
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to change
                add_ids:
                  type: array
                  items: { type: integer }
                  description: Flags to raise on every Contact
                remove_ids:
                  type: array
                  items: { type: integer }
                  description: Flags to remove from every Contact
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to change, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              add_ids: [5]
              beneficiary_ids: [160498, 160499, 160500]
      responses:
        "200":
          description: The Contacts were changed straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "202":
          description: More than 50 Contacts, so they are changed in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /flags:
    get:
      tags: [Beneficiaries]
      summary: List the Flags you may raise
      description: |
        The organisation's Flags (Contact Flags), e.g. "Safeguarding concern", that you may raise on a
        Contact: a Flag restricted to Teams is listed only for members of those Teams. Use an `id`
        with `POST /beneficiaries/bulk_flags`. `charity_id` may be left out when the user belongs to
        one organisation.
      operationId: listFlags
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Flags, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/Flag' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /groups:
    get:
      tags: [Beneficiaries]
      summary: List the organisation's Groups
      description: |
        The organisation's Groups (Contact Groups), the labels Contacts are sorted into, e.g. "Girls'
        football". These are the Groups the Edit Contact page offers. Use an `id` with
        `POST /beneficiaries/bulk_groups`. Any member of the organisation can list them.
        `charity_id` may be left out when the user belongs to one organisation.
      operationId: listGroups
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Groups, by title
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/Group' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiaries/bulk_audiences:
    post:
      tags: [Beneficiaries]
      summary: Give many Contacts Audiences, or end them
      description: |
        Gives many Contacts (Beneficiaries) some of the organisation's Audiences (Contact Roles) and
        ends others, in one request. This is **Add or remove › Audiences** for the Contacts selected
        on the Manage Contacts page.

        **Which Audiences.** `add_ids` and `remove_ids` are ids from `GET /audiences`. Audiences being
        added start on `start_date` (default today). Removing an Audience ends it today rather than
        deleting it, so it stays in the Contact's history. A Contact already in an Audience being
        added, or not in one being removed, is left as they are. You need to be a colleague in the
        organisation.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` and `not_allowed_to_end`
        (you may end an Audience only if you added it, are an Organisation Editor, or are an editor or
        reporter on one of the Contact's Projects).

        Up to 50 Contacts are changed straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: changeBeneficiaryAudiences
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to change
                add_ids:
                  type: array
                  items: { type: integer }
                  description: Audiences to give every Contact
                remove_ids:
                  type: array
                  items: { type: integer }
                  description: Audiences to end for every Contact, today
                start_date:
                  type: string
                  format: date
                  description: When the Audiences being added start. Default today.
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to change, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              add_ids: [7]
              start_date: "2026-11-01"
              beneficiary_ids: [160498, 160499]
      responses:
        "200":
          description: The Contacts were changed straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "202":
          description: More than 50 Contacts, so they are changed in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiaries/bulk_type:
    post:
      tags: [Beneficiaries]
      summary: Change the Type of many Contacts
      description: |
        Changes the Type (Contact Type, e.g. Person or Organisation) of many Contacts (Beneficiaries)
        in one request. This is **Add or remove › Type** for the Contacts selected on the Manage
        Contacts page. A Contact has one Type, so `beneficiary_type_id` (from `GET /beneficiary_types`)
        is the Type to change them all to. Bio fields that only show for one Type stay saved, but are
        hidden while a Contact has a Type without them.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` and `not_allowed` (you may
        not edit them). A Contact already of that Type is left as they are.

        Up to 50 Contacts are changed straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: changeBeneficiaryType
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [beneficiary_type_id]
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to change
                beneficiary_type_id:
                  type: integer
                  description: The Type to change every Contact to
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to change, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              beneficiary_type_id: 3
              beneficiary_ids: [160498, 160499, 160500]
      responses:
        "200":
          description: The Contacts were changed straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "202":
          description: More than 50 Contacts, so they are changed in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiaries/bulk_required_skills:
    post:
      tags: [Beneficiaries]
      summary: Add Specialisms to many Contacts' specialist needs, or remove them
      description: |
        Adds some of the organisation's Specialisms (Skills) to what many Contacts (Beneficiaries)
        **need a specialist in** (Skills Required), and removes others, in one request. This is
        **Add or remove › Specialist needs** for the Contacts selected on the Manage Contacts page.
        Each change is made as in the "Needs a specialist in" box on a Contact's profile.

        **Which Specialisms.** `add_ids` and `remove_ids` are ids from `GET /skills`. Give at least
        one, and never the same Specialism in both. A Contact who already needs one being added, or
        doesn't need one being removed, is left as they are. Anyone who can see a Contact may add a
        Specialism; only Organisation Editors may remove one. Needs added here are Essential unless
        `importance` is `desirable`.

        **Needs from form answers.** Only needs added by hand are added and removed here. A need a
        Contact has because of an answer in their Contact form (see `POST /skills/{id}/linked_answers`)
        stays until the answer changes, and a Specialism can be added by hand alongside it.

        **Which Contacts.** Either `beneficiary_ids` (at most 500), or everyone matching
        `filter_data` (the Manage Contacts filters) leaving out `excluded_ids`.

        **Skipped Contacts** are counted in `skip_counts`: `headline_only` and
        `not_allowed_to_remove` (you aren't an Organisation Editor, so the Contact is left unchanged).

        Up to 50 Contacts are changed straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `charity_id` may be left out when
        the user belongs to one organisation.
      operationId: changeBeneficiaryRequiredSkills
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose Contacts to change
                add_ids:
                  type: array
                  items: { type: integer }
                  description: Specialisms to add to what every Contact needs a specialist in
                remove_ids:
                  type: array
                  items: { type: integer }
                  description: Specialisms to remove from what every Contact needs a specialist in
                importance:
                  type: string
                  enum: [essential, desirable]
                  default: essential
                  description: How much the Contacts need the Specialisms being added
                beneficiary_ids:
                  type: array
                  maxItems: 500
                  items: { type: integer }
                  description: The Contacts to change, at most 500. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts, used when beneficiary_ids is left out
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: Contacts matching the filters to leave out
            example:
              charity_id: 12
              add_ids: [31]
              remove_ids: [32]
              beneficiary_ids: [160498, 160499, 160500]
      responses:
        "200":
          description: The Contacts were changed straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
              example:
                id: 72
                status: completed
                total_count: 3
                processed_count: 3
                changed_count: 2
                skip_counts: {}
                background: false
                summary: "2 contacts changed."
        "202":
          description: More than 50 Contacts, so they are changed in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/BulkProjectMove' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /skills:
    get:
      tags: [Beneficiaries]
      summary: List the organisation's Specialisms (Skills)
      description: |
        The organisation's Specialisms (Skills), e.g. "Eating disorders", as offered in the "Needs a
        specialist in" box on a Contact's profile and the Specialisms box on a colleague's profile.
        Use an `id` with `POST /beneficiaries/bulk_required_skills` or `POST /users/{id}/specialisms`.
        Each one lists its `linked_answers`: the Contact form answers that make a Contact need it
        (see `POST /skills/{id}/linked_answers`). Any member of the organisation can list them.
        `charity_id` may be left out when the user belongs to one organisation.
      operationId: listSkills
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Skills, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/Skill' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /skills/{id}/linked_answers:
    post:
      tags: [Beneficiaries]
      summary: Link a Specialism to answers in the Contact forms
      description: |
        Links a Specialism (Skill) to answers (Sub Ratios) of one dropdown question (Ratio Set) on the
        organisation's Contact forms (Beneficiary Categories), as **Contacts who need this specialism**
        on the Specialism's edit page does. Every Contact whose form records one of the answers then
        needs a specialist in it, with the given `importance`, and stops needing it when the answer
        changes. Contacts are updated in the background, which can take a few minutes for a large
        organisation; the user who made the change gets a notification when it's done.

        `ratio_set_id` must be a question on one of the organisation's Contact forms
        (`GET /beneficiary_categories/current_fields` lists them), and `sub_ratio_ids` its answers
        (`GET /sub_ratios?ratio_set_ids[]=`). Linking an answer that is already linked changes its
        importance. Only Organisation Editors can do this.
      operationId: linkSkillToAnswers
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [ratio_set_id, sub_ratio_ids]
              properties:
                ratio_set_id:
                  type: integer
                  description: The dropdown question, e.g. Presenting issue
                sub_ratio_ids:
                  type: array
                  items: { type: integer }
                  description: Its answers to link, e.g. Anorexia
                importance:
                  type: string
                  enum: [essential, desirable]
                  default: essential
                  description: How much Contacts matched this way need the Specialism
            example:
              ratio_set_id: 812
              sub_ratio_ids: [4410, 4411]
              importance: essential
      responses:
        "201":
          description: The answers are linked; Contacts are being updated in the background
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SkillLinkedAnswers' }
              example:
                id: 31
                name: Eating disorders
                linked_answers:
                  - ratio_set_id: 812
                    sub_ratio_ids: [4410, 4411]
                    importance: essential
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You aren't allowed to make this change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                error: forbidden
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Beneficiaries]
      summary: Unlink answers from a Specialism
      description: |
        Removes the link between a Specialism (Skill) and some answers in the Contact forms. Contacts
        who needed it only because of those answers stop needing it; needs added by hand stay.
        Contacts are updated in the background. Only Organisation Editors can do this.
      operationId: unlinkSkillAnswers
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [sub_ratio_ids]
              properties:
                sub_ratio_ids:
                  type: array
                  items: { type: integer }
                  description: The answers to unlink
            example:
              sub_ratio_ids: [4411]
      responses:
        "200":
          description: The answers are unlinked; Contacts are being updated in the background
          content:
            application/json:
              schema: { $ref: '#/components/schemas/SkillLinkedAnswers' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You aren't allowed to make this change
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Error' }
              example:
                error: forbidden
        "404":
          $ref: '#/components/responses/NotFound'
  /relationship_categories:
    get:
      tags: [Beneficiaries]
      summary: List the organisation's Relationship Categories
      description: |
        The kinds of relationship Contacts can have with each other in the organisation, each with
        its two sides, e.g. School & Pupil or Mother & Son. A fixed Signup Page and a permitted
        relationship (`POST /permitted_relationships`) use one. Any member of the organisation can
        list them.
        `charity_id` may be left out when the user belongs to one organisation.
      operationId: listRelationshipCategories
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Relationship Categories, by title
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/RelationshipCategory' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    post:
      tags: [Beneficiaries]
      summary: Create a Relationship Category
      description: |
        Adds a kind of relationship Contacts can have with each other, as the New Relationship Type
        page does: its two sides, e.g. Parent & Child or Client & Emergency Contact. A fixed Signup
        Page needs at least one to connect the people it signs up.

        Only organisation editors (Organisation Admins) may create them (`403` otherwise). The same
        pair of titles can't exist twice in an organisation, whatever their case: `422` then gives
        `existing_id`, the one already there, to reuse. List them first with
        `GET /relationship_categories`. `charity_id` may be left out when the user belongs to one
        organisation.
      operationId: createRelationshipCategory
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [parent_title, child_title]
              properties:
                charity_id:
                  type: integer
                  description: The organisation to add it to
                parent_title:
                  type: string
                  description: The first side, e.g. Parent
                child_title:
                  type: string
                  description: The second side, e.g. Child
                counts_as_household:
                  type: boolean
                  default: false
                  description: Whether Contacts linked by this category count as one household
            example:
              charity_id: 12
              parent_title: Parent
              child_title: Child
              counts_as_household: true
      responses:
        "201":
          description: The Relationship Category made
          content:
            application/json:
              schema: { $ref: '#/components/schemas/RelationshipCategory' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: Validation failed, or the pair of titles already exists
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items: { type: string }
                  existing_id:
                    type: integer
                    description: The Relationship Category with these titles already, when that is why
              example:
                errors: ["Already exists"]
                existing_id: 34
  /relationship_categories/{id}:
    patch:
      tags: [Beneficiaries]
      summary: Update a Relationship Category
      description: |
        Changes a kind of relationship's two titles, or whether it counts as a household, as Edit
        on the organisation's Relationship Types page does. Mark the family relationships an
        organisation uses (e.g. Parent & Child, Partner & Partner) with `counts_as_household`, and
        Contacts linked by them, directly or through other Contacts, are counted as one household.
        Households are recalculated in the background within a few minutes.

        Only organisation editors (Organisation Admins) may change them (`403` otherwise). Send
        only the fields to change.
      operationId: updateRelationshipCategory
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: integer }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                parent_title:
                  type: string
                  description: The new first side
                child_title:
                  type: string
                  description: The new second side
                counts_as_household:
                  type: boolean
                  description: Whether Contacts linked by this category count as one household
            example:
              counts_as_household: true
      responses:
        "200":
          description: The Relationship Category as changed
          content:
            application/json:
              schema: { $ref: '#/components/schemas/RelationshipCategory' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /audiences:
    get:
      tags: [Beneficiaries]
      summary: List the organisation's audiences
      description: |
        The organisation's audiences (Contact Roles; Beneficiary Roles), e.g. Participant or Parent,
        as on its Audiences page, by name. Each lists the Contact Types (Person, Organisation, …) it
        is for. A flexible Signup Page signs people up as audiences, and a permitted relationship
        says which audiences may be on each side of a Relationship Category. Any member of the
        organisation can list them. `charity_id` may be left out when the user belongs to one
        organisation.
      operationId: listAudiences
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of audiences, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/Audience' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    post:
      tags: [Beneficiaries]
      summary: Create an audience
      description: |
        Adds an audience (Contact Role; Beneficiary Role), as the New Audience page does. `color` is
        one of the approved colours (the first, `#f96d67`, if left out). `contact_type_id` links it to
        a Contact Type (`GET /beneficiary_types`); it is linked to Person if left out. Only
        organisation editors (Organisation Admins) may create audiences (`403` otherwise). Names
        aren't unique, so list them first with `GET /audiences` and reuse one that fits.
      operationId: createAudience
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                charity_id:
                  type: integer
                  description: The organisation to add it to
                name:
                  type: string
                  description: e.g. Participant
                color:
                  type: string
                  description: |
                    One of #f96d67, #f31208, #bc1204, #f92915, #f26f21, #ff6800, #e59200, #ffa300,
                    #62a837, #71c240, #2b800e, #36ac9a, #2e9283, #226c61, #225f85, #2e85bc, #3596d6,
                    #063262, #ac3898, #6c235f, #620a4d, #8c1b6d, #d07db7, #a81e6a, #e82a92, #8e0132
                contact_type_id:
                  type: integer
                  description: The Contact Type (Beneficiary Type) it is for; Person if left out
            example:
              charity_id: 12
              name: Parent
              color: '#ac3898'
      responses:
        "201":
          description: The audience made
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Audience' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /permitted_relationships:
    get:
      tags: [Beneficiaries]
      summary: List the organisation's permitted relationships
      description: |
        The organisation's permitted relationships (Role-holder Relationships), as on its
        Role-holder Relationships page: for a Relationship Category, which audience (Contact Role)
        may be on its parent side and which on its child side, and which of the category's titles
        each may hold. A flexible Signup Page can only sign people up as audiences that have one.
        Only organisation editors (Organisation Admins) can list them (`403` otherwise).
        `relationship_category_id` narrows the list to one category. `charity_id` may be left out
        when the user belongs to one organisation.
      operationId: listPermittedRelationships
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
        - name: relationship_category_id
          in: query
          required: false
          description: Only those for this Relationship Category
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of permitted relationships, oldest first
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/PermittedRelationship' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    post:
      tags: [Beneficiaries]
      summary: Create a permitted relationship
      description: |
        Says which audience (Contact Role) may be on each side of a Relationship Category, as the New
        Role-holder Relationship page does, e.g. Parent on the parent side of Parent & Child and
        Participant on the child side. A flexible Signup Page needs one for the audiences it signs up.

        By default the parent audience holds the category's `parent_title` and the child audience its
        `child_title`; `parent_audience_titles` and `child_audience_titles` choose others from the
        category's two titles. The category and both audiences must be the organisation's own
        (`404` otherwise). Only organisation editors may create them (`403` otherwise). List them
        first with `GET /permitted_relationships` and reuse one that fits.
      operationId: createPermittedRelationship
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [relationship_category_id, parent_audience_id, child_audience_id]
              properties:
                charity_id:
                  type: integer
                  description: The organisation to add it to
                relationship_category_id:
                  type: integer
                  description: One of the organisation's Relationship Categories
                parent_audience_id:
                  type: integer
                  description: The audience on the category's parent side (Audience A)
                child_audience_id:
                  type: integer
                  description: The audience on the category's child side (Audience B)
                parent_audience_titles:
                  type: array
                  items: { type: string }
                  description: Which of the category's titles the parent audience may hold; its parent_title if left out
                child_audience_titles:
                  type: array
                  items: { type: string }
                  description: Which of the category's titles the child audience may hold; its child_title if left out
            example:
              charity_id: 12
              relationship_category_id: 34
              parent_audience_id: 56
              child_audience_id: 78
      responses:
        "201":
          description: The permitted relationship made
          content:
            application/json:
              schema: { $ref: '#/components/schemas/PermittedRelationship' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /beneficiary_types:
    get:
      tags: [Beneficiary Types]
      summary: List all Beneficiary Types
      description: Returns the four types — Person (1), Organisation (2), Animal (3), Object (4). The ID is required when creating a Beneficiary.
      operationId: listBeneficiaryTypes
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of Beneficiary Types
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedBeneficiaryTypes'
              example:
                page: 1
                page_size: 4
                page_count: 1
                total_count: 4
                data:
                  - id: 1
                    name: "Person"
                    updated_at: "2020-09-28T15:19:24.310+01:00"
                    created_at: "2020-09-28T15:19:24.310+01:00"
                  - id: 2
                    name: "Object"
                    updated_at: "2020-09-28T15:19:24.319+01:00"
                    created_at: "2020-09-28T15:19:24.319+01:00"
                  - id: 3
                    name: "Organisation"
                    updated_at: "2020-09-28T15:19:24.324+01:00"
                    created_at: "2020-09-28T15:19:24.324+01:00"
                  - id: 4
                    name: "Animal"
                    updated_at: "2021-09-11T10:04:59.074+01:00"
                    created_at: "2021-09-11T10:04:59.074+01:00"
        "401":
          $ref: '#/components/responses/Unauthorized'

  /beneficiary_types_categories:
    get:
      tags: [Beneficiary Types]
      summary: List Beneficiary Type–Category associations
      operationId: listBeneficiaryTypesCategories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /stories:
    get:
      tags: [Stories]
      summary: List all Stories
      description: |
        Returns all Stories visible to the authenticated user. Stories capture text, media, and progress towards Changes and Indicators, and can be tagged to Beneficiaries.

        **Timestamp note:** `actual_created_at` = Date Posted · `created_at` = Date Happened · `updated_at` = Date Edited

        Returns up to 200 Stories per page. A `per_page` above 200 returns a 422 error; page through larger sets with `page`.
      operationId: listStories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Stories
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedStories'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
        "429":
          $ref: '#/components/responses/TooManyRequests'

    post:
      tags: [Stories]
      summary: Create a Story
      description: |
        Creates a Story tagged to zero, one, or multiple Beneficiaries.

        **Recommended workflow:**
        1. `GET /story_categories/:id` — retrieve the survey's fields, Indicators, Outcomes, and scale choices
        2. `GET /sub_ratios?ratio_set_ids[]=N` — retrieve valid answer choice IDs for Scale Indicators
        3. Submit this endpoint with the full payload

        | Field | Notes |
        |---|---|
        | `story.story_group` | Always `"change_created"` |
        | `story.story_format` | Always `"old"` |
        | `story.created_at` | Date Happened in `YYYY-MM-DD` |
        | `story_changes` | Activity/Participation totals — `[{change_id, number}]` |
        | `story_change_beneficiaries` | Per-contact Participation records — `[{change_id, beneficiary_id}]` |
        | `story_indicator_beneficiaries` | Per-contact indicator responses (see schema) |
        | `custom_fields` | `{custom_field_id: value}` for text/date/time fields |

        > For binary indicators: include `binray_indicator_value: "on"` if ticked; omit the record entirely if not.
        > Activity Changes: include in `story_changes` only — cannot be tagged to beneficiaries.
      operationId: createStory
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StoryCreateRequest'
            example:
              story:
                story_group: "change_created"
                story_format: "old"
                project_id: 19
                story_category_id: 327
                text: "Session notes from today."
                created_at: "2024-06-01"
                source_of_story: "api"
                is_public: false
              story_privacy: "only_charity_colleagues"
              beneficiary_ids: [413]
              story_changes:
                - change_id: 199
                  number: 2
              story_change_beneficiaries:
                - change_id: 199
                  beneficiary_id: 413
              story_indicator_beneficiaries:
                - indicator_id: 243
                  indicator_type: "scale"
                  outcome_id: 145
                  sub_ratio_id: 54
                  beneficiary_id: 413
              custom_fields:
                "19": "2024-06-01"
                "26": "Some text answer"
      responses:
        "200":
          description: Story created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Story'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /draft_stories:
    post:
      tags: [Stories]
      summary: Save an Answer In Progress (draft Story)
      description: |
        Saves a partly completed survey response as an **Answer In Progress** (a draft Story).
        It appears on the organisation's Answers In Progress page, where a colleague can
        review it, finish it and publish it as a Story in Makerble. Use this instead of
        `POST /stories` when a response should be checked by a person before it is published.

        **Who can save one** (otherwise the response is `403`):
        - for a Project: its editors, reporters and observers, and the organisation's editors and reporters (open Projects only);
        - for an Event's Project: the Event's workers and managers too, when `story.event_id` belongs to that Project;
        - with no Project: the organisation's editors and reporters for `story.charity_id`.

        A `story.charity_id` that isn't the Project's organisation, a closed or unknown Project,
        or a request with neither `project_id` nor `charity_id` is refused with `403`.
        Contacts (Beneficiaries) go in the top-level `beneficiaries` array.
      operationId: createDraftStory
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DraftStoryCreateRequest'
            example:
              story:
                project_id: 19
                story_category_id: 327
                text: "Notes from today's session, to be reviewed."
                event_id: 88
              beneficiaries: [413]
              story_privacy: "only_charity_colleagues"
              custom_fields:
                "26": "Some text answer"
      responses:
        "201":
          description: Answer In Progress saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftStoryCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /factor_options:
    get:
      tags: [Financial Values]
      summary: List the Regions and Industries
      description: |
        The Regions and Industries an Organisation or Project can choose for localised Financial
        Values, each with the factors it holds, in the order the tables list them. Makerble publishes
        these tables, e.g. the TOM System 2024 "Location" sheet (each Region's median annual wage,
        Regional GVA and National GVA) and "Industry" sheet (each Industry's GVA multiplier).

        A localised Financial Value's formula names a factor as `dimension.key`, e.g.
        `region.median_wage`. Pass an option's id as `region_factor_option_id` or
        `industry_factor_option_id` to `PATCH /charities/{id}` or `PATCH /projects/{id}/preferences`.
      operationId: listFactorOptions
      security: [{tokenAuth: []}]
      parameters:
        - name: dimension
          in: query
          required: false
          schema: { type: string, example: region }
          description: Only this table's options, by its key (region or industry)
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Regions and Industries
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/FactorOption' }
              example:
                page: 1
                page_size: 1
                page_count: 12
                total_count: 12
                data:
                  - id: 7
                    name: North East
                    dimension: region
                    dimension_name: Region
                    edition: TOM System 2024 Location
                    year: 2024
                    position: 0
                    factors:
                      - { key: median_wage, name: Median annual wage, value: '37666.5' }
                      - { key: national_gva, name: National GVA, value: '0.8' }
                      - { key: regional_gva, name: Regional GVA, value: '1.5718765958' }
                    updated_at: '2026-11-29T17:00:00Z'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /financial_values:
    get:
      tags: [Financial Values]
      summary: Search the Financial Values you may use
      description: |
        The Financial Values you may choose on a project's Financial Value calculator, by name: your own, your
        organisations', those shared with you and those shared with everyone. A Financial Value is a published
        money value per person for an outcome, e.g. "Moving into work: £1,234 a year", in the currency of its country.
      operationId: listFinancialValues
      security: [{tokenAuth: []}]
      parameters:
        - name: search
          in: query
          required: false
          schema: { type: string }
          description: Part of the name or code, case-insensitive
        - name: category_id
          in: query
          required: false
          schema: { type: integer }
          description: Only this Methodology (Financial Value Category)
        - name: source_id
          in: query
          required: false
          schema: { type: integer }
          description: Only those from this Source
        - name: country_id
          in: query
          required: false
          schema: { type: integer }
          description: Only those for this country
        - name: verified
          in: query
          required: false
          schema: { type: boolean }
          description: true for only those Makerble has checked, false for only unchecked ones
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Financial Values, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/FinancialValue' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Financial Values]
      summary: Create a Financial Value
      description: |
        Creates a Financial Value, as the Create Financial Value form does. It belongs to the organisation you name,
        which you must be an Organisation Admin of, or to you if you name none. category, sources and country are
        names that already exist in Makerble.
      operationId: createFinancialValue
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/FinancialValueInput' }
            example:
              name: Moving into work
              amount: 1234.5
              year: 2023
              country: United Kingdom
              privacy: Organisation colleagues only
              organisation_id: 913
              category: Wellbeing valuation
              sources: [HACT]
      responses:
        "201":
          description: The new Financial Value
          content:
            application/json:
              schema: { $ref: '#/components/schemas/FinancialValue' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          description: Something was wrong, e.g. a country that doesn't exist. existing_id is given when the owner already has a Financial Value with this name.
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors: { type: array, items: { type: string } }
                  existing_id: { type: integer }
              example:
                errors: ["Country 'Atlantis' not found"]
  /financial_values/{id}:
    get:
      tags: [Financial Values]
      summary: Get a Financial Value
      description: One Financial Value you may use. Any other reads as not found.
      operationId: getFinancialValue
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: integer }
      responses:
        "200":
          description: The Financial Value
          content:
            application/json:
              schema: { $ref: '#/components/schemas/FinancialValue' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /projects/{project_id}/financial_values:
    get:
      tags: [Financial Values]
      summary: List a project's Financial Values
      description: |
        Which Financial Values a project puts against which of its Metrics on its Financial Value calculator, each
        with the Metric's result (quantity) and sub_total, and the totals they come to for each currency, as on the
        project's Financial Calculator tile. For Project Managers and Organisation Admins of the project.
      operationId: listProjectFinancialValues
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The project's totals and a page of its attachments
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      project_id: { type: integer }
                      financial_calculator_enabled: { type: boolean, description: Whether the project's Financial Calculator is turned on in its Preferences }
                      totals:
                        type: array
                        items:
                          type: object
                          properties:
                            currency: { type: string, example: GBP }
                            symbol: { type: string, example: '£' }
                            amount: { type: string, example: '3702.0' }
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/ProjectFinancialValue' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Financial Values]
      summary: Put a Financial Value against a project's Metric
      description: |
        Puts a Financial Value against one of the project's Metrics (a Change or an Indicator the project tracks or
        records in its Stories), as the Financial Value calculator page does, and turns on the project's Financial
        Calculator if it is off. Attaching one that is already there only changes its colour. A Financial Value shared
        with Project colleagues only can only be used in its projects. For Project Managers and Organisation Admins.
      operationId: attachProjectFinancialValue
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          schema: { type: integer }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [metric_type, metric_id, financial_value_id]
              properties:
                metric_type: { type: string, enum: [Change, Indicator] }
                metric_id: { type: integer }
                financial_value_id: { type: integer }
                color: { type: string, pattern: '^#[0-9a-fA-F]{6}$', description: "The Metric's colour on the calculator. Default the Metric's current colour, or #3595d5" }
            example:
              metric_type: Indicator
              metric_id: 5521
              financial_value_id: 88
      responses:
        "201":
          description: The attachment
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ProjectFinancialValue' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /projects/{project_id}/financial_values/{id}:
    delete:
      tags: [Financial Values]
      summary: Take a Financial Value off a project's Metric
      description: Removes one attachment, by its id from the list. For Project Managers and Organisation Admins.
      operationId: detachProjectFinancialValue
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          schema: { type: integer }
        - name: id
          in: path
          required: true
          schema: { type: integer }
          description: The attachment id
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /labels:
    get:
      tags: [Labels]
      summary: List your organisations' Labels
      description: |
        The Labels (Story Labels) of the organisations you belong to, by name: the ones the Label popup
        on a Story offers. Organisations use them to code Stories and survey responses by theme.
      operationId: listLabels
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema: { type: integer }
          description: Only this organisation's Labels
        - name: search
          in: query
          required: false
          schema: { type: string }
          description: Part of the name, case-insensitive
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of Labels, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/Label' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Labels]
      summary: Create a Label
      description: Creates a Label for one of your organisations.
      operationId: createLabel
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/LabelInput'
                - required: [charity_id, name]
            example:
              charity_id: 913
              name: Housing
              color: '#36ac9a'
              privacy: only_charity_colleagues
      responses:
        "201":
          description: The new Label
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Label' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /labels/{id}:
    patch:
      tags: [Labels]
      summary: Change a Label
      description: Renames a Label, changes its colour or privacy, or moves it to another of your organisations. Only the fields sent change.
      operationId: updateLabel
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: integer }
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/LabelInput' }
            example:
              name: Safe housing
      responses:
        "200":
          description: The Label
          content:
            application/json:
              schema: { $ref: '#/components/schemas/Label' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /labels/{id}/stories:
    get:
      tags: [Labels]
      summary: List a Label's Stories
      description: |
        The Stories and survey responses with this Label that you can see, newest first: ids and dates
        only. Fetch one with GET /stories/{id}.
      operationId: listLabelStories
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: integer }
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: A page of labelled Stories
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          type: object
                          properties:
                            id: { type: integer }
                            actual_created_at: { type: string, format: date-time, description: Date Posted }
                            created_at: { type: string, format: date-time, description: Date Happened }
                            labelled_at: { type: string, format: date-time }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /labels/{label_id}/outcomes:
    parameters:
      - name: label_id
        in: path
        required: true
        schema: { type: integer }
    get:
      tags: [Labels]
      summary: List the Outcomes a Label evidences
      description: |
        Stories and survey responses with a Label show under the Outcomes it evidences on a Project's Results Canvas.
        `editable` is false for an Outcome you can't edit, whose link you can't remove.
      operationId: listLabelOutcomes
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The linked Outcomes
          content:
            application/json:
              schema: { $ref: '#/components/schemas/LabelOutcomesPage' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Labels]
      summary: Set the Outcomes a Label evidences
      description: |
        `outcome_ids` replaces the links you may change. Links to Outcomes you can't edit are kept. You can only link
        Outcomes you can edit. Linking from the Outcome side edits the same links.
      operationId: setLabelOutcomes
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [outcome_ids]
              properties:
                outcome_ids: { type: array, items: { type: integer } }
            example:
              outcome_ids: [5120, 5121]
      responses:
        "200":
          description: The linked Outcomes
          content:
            application/json:
              schema: { $ref: '#/components/schemas/LabelOutcomesPage' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /outcomes/{outcome_id}/labels:
    parameters:
      - name: outcome_id
        in: path
        required: true
        schema: { type: integer }
    get:
      tags: [Labels]
      summary: List the Labels that evidence an Outcome
      description: |
        Your organisations' Labels linked to the Outcome. Other organisations' Labels are counted in `other_label_count`.
        `editable` says whether you may change the Outcome's Labels.
      operationId: listOutcomeLabels
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The linked Labels
          content:
            application/json:
              schema: { $ref: '#/components/schemas/OutcomeLabelsPage' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Labels]
      summary: Set the Labels that evidence an Outcome
      description: |
        `label_ids` replaces your organisations' Labels on the Outcome; other organisations' are kept. You must be able
        to edit the Outcome.
      operationId: setOutcomeLabels
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [label_ids]
              properties:
                label_ids: { type: array, items: { type: integer } }
            example:
              label_ids: [412]
      responses:
        "200":
          description: The linked Labels
          content:
            application/json:
              schema: { $ref: '#/components/schemas/OutcomeLabelsPage' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /stories/{story_id}/labels:
    parameters:
      - name: story_id
        in: path
        required: true
        schema: { type: integer }
    post:
      tags: [Labels]
      summary: Add a Label to a Story
      description: Adds one of your organisations' Labels to a Story or survey response you can see. Adding one it already has changes nothing.
      operationId: addStoryLabel
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [label_id]
              properties:
                label_id: { type: integer }
            example:
              label_id: 412
      responses:
        "201":
          description: The Label and the Story's Labels
          content:
            application/json:
              schema: { $ref: '#/components/schemas/StoryLabelsResult' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Labels]
      summary: Take a Label off a Story
      description: Takes a Label off a Story or survey response. Removing one it hasn't got changes nothing.
      operationId: removeStoryLabel
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [label_id]
              properties:
                label_id: { type: integer }
            example:
              label_id: 412
      responses:
        "200":
          description: The Label and the Story's remaining Labels
          content:
            application/json:
              schema: { $ref: '#/components/schemas/StoryLabelsResult' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /stories/{id}:
    get:
      tags: [Stories]
      summary: Get a single Story
      description: "Returns a Story with full detail — custom fields, beneficiary IDs, case IDs, indicator responses, change values, and verdict scores. Opening a Story this way is recorded in its Access Log, the audit trail of who has viewed it, under the caller's name and marked as via the API (or via MCP when the Makerble MCP server sends `X-Makerble-Client: makerble-mcp`). Views by the same caller less than 30 minutes apart are counted together. Use the list endpoint when you only need to find or scan Stories."
      operationId: getStory
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Story with full detail
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StoryDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "429":
          $ref: '#/components/responses/TooManyRequests'

  /stories/{id}/attachments:
    get:
      tags: [Stories]
      summary: Get attachments for a single Story
      operationId: getStoryAttachments
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated attachments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /stories/attachments:
    get:
      tags: [Stories]
      summary: List all Story attachments
      operationId: listStoryAttachments
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated attachments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /stories/story_category_response:
    get:
      tags: [Stories]
      summary: Get Stories with full survey response detail
      description: |
        Returns Stories enriched with named Indicators, Changes, and Custom Fields — ideal for reporting and data exports.
      operationId: listStoryCategoryResponses
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - name: story_category_ids
          in: query
          schema:
            type: string
          description: >-
            Filter by one or more Surveys (Story Categories). Accepts a JSON array (`[1,2]`), a repeated
            array parameter (`story_category_ids[]=1&story_category_ids[]=2`), a comma-separated list (`1,2`)
            or a single ID. Only Surveys the authenticated user can access are returned; any others are
            ignored. `story_category_id` is also accepted as an alias.
        - name: project_ids
          in: query
          schema:
            type: string
          description: Filter by one or more Project IDs. Accepts the same formats as `story_category_ids`.
        - name: start_date
          in: query
          schema:
            type: string
            format: date
          description: "Filter: stories on or after this date (YYYY-MM-DD)"
        - name: end_date
          in: query
          schema:
            type: string
            format: date
          description: "Filter: stories on or before this date (YYYY-MM-DD)"
      responses:
        "200":
          description: Stories with full survey response data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedStoryCategoryResponses'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /stories/search:
    get:
      tags: [Stories]
      summary: Search Stories by keyword, Label or Outcome
      description: |
        Searches the text of the Stories and survey responses you can see, and their written answers to Survey
        questions, and returns a short snippet of each match. Search by `query` (keywords or a phrase; word forms
        match, so "confident" finds "confidence"), by `label_ids` (Stories carrying any of these Labels), or by
        `outcome_id` (Stories carrying a Label linked to that Outcome). Give at least one of the three. With a
        query, results are ordered by relevance; without one, newest first. Contacts' names in snippets are
        replaced with "[name]". `total_count` stops at 1000, and `total_count_capped` is then true. Label ids that
        aren't your organisations' are ignored and listed in `ignored_label_ids`.
      operationId: searchStories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - name: per_page
          in: query
          description: Default 10, at most 25
          schema: { type: integer, default: 10, maximum: 25 }
        - name: query
          in: query
          description: Keywords or a phrase
          schema: { type: string }
          example: found a job
        - name: label_ids[]
          in: query
          description: Only Stories carrying any of these Labels
          schema: { type: array, items: { type: integer } }
        - name: outcome_id
          in: query
          description: Only Stories carrying a Label linked to this Outcome
          schema: { type: integer }
        - name: project_ids[]
          in: query
          description: Only these projects; by default every project you can see
          schema: { type: array, items: { type: integer } }
        - name: story_category_id
          in: query
          description: Only Stories of this Survey (Story Category)
          schema: { type: integer }
        - name: start_date
          in: query
          description: Earliest Story date, YYYY-MM-DD
          schema: { type: string, format: date }
        - name: end_date
          in: query
          description: Latest Story date, YYYY-MM-DD
          schema: { type: string, format: date }
      responses:
        "200":
          description: A page of matching Stories with snippets
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      total_count_capped: { type: boolean, description: True when more than 1000 Stories match }
                      ignored_label_ids: { type: array, items: { type: integer } }
                      data:
                        type: array
                        items:
                          type: object
                          properties:
                            story_id: { type: integer }
                            story_category: { type: string, description: The Survey's name }
                            project: { type: string }
                            created_at: { type: string, format: date }
                            labels: { type: array, items: { type: string } }
                            snippet: { type: string, description: "Up to 300 characters, with Contacts' names replaced by [name]" }
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                total_count_capped: false
                ignored_label_ids: []
                data:
                  - story_id: 1234
                    story_category: Exit survey
                    project: Into work
                    created_at: "2026-03-10"
                    labels: [Found work]
                    snippet: "[name] found a job at the bakery after six weeks of mentoring."
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /stories/search_labels:
    get:
      tags: [Stories]
      summary: List the Labels used on Stories, with counts
      description: |
        The Labels carried by the Stories you can see in the given projects and dates, with how many Stories carry
        each and the Outcomes each is linked to. Labels no Story there carries are left out. Use the ids with
        GET /stories/search.
      operationId: listStorySearchLabels
      security: [{tokenAuth: []}]
      parameters:
        - name: project_ids[]
          in: query
          description: Only these projects; by default every project you can see
          schema: { type: array, items: { type: integer } }
        - name: start_date
          in: query
          description: Earliest Story date, YYYY-MM-DD
          schema: { type: string, format: date }
        - name: end_date
          in: query
          description: Latest Story date, YYYY-MM-DD
          schema: { type: string, format: date }
      responses:
        "200":
          description: The Labels in use, by name
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: integer }
                        name: { type: string }
                        stories_in_scope: { type: integer }
                        outcomes:
                          type: array
                          items:
                            type: object
                            properties:
                              id: { type: integer }
                              title: { type: string }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /story_categories:
    get:
      tags: [Story Categories]
      summary: List all Story Categories (Surveys)
      operationId: listStoryCategories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedStoryCategories'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /story_categories/{id}:
    get:
      tags: [Story Categories]
      summary: Get a single Story Category (Survey) — with full field detail
      description: |
        Returns the survey's complete structure:
        - `current_fields` — all questions in order with `field_class_name`, `priority`, `is_mandatory`, `outcome_id`
        - `scale_indicator_choices` — choice type per Scale Indicator
        - `verdict_data` — scoring bands and point values per level

        **Always call this before posting a Story** to determine which Indicators are in the survey, their Outcome IDs, and valid Sub Ratio IDs.
      operationId: getStoryCategory
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Story Category with full detail
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StoryCategoryDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /story_categories/{id}/verdicts:
    get:
      tags: [Story Categories]
      summary: Get verdict scores for a Survey Campaign
      description: Verdict scores grouped by Beneficiary for a specific Survey within a Project.
      operationId: getStoryCategoryVerdicts
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Story Category ID
        - name: project_id
          in: query
          required: true
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Verdict scores grouped by Beneficiary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerdictScoresResponse'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /story_categories/{id}/itemised_totals:
    get:
      tags: [Story Categories]
      summary: Get a Survey's itemised totals
      description: |
        A Survey's results side by side across Projects or Albums, as on its Itemised totals page: one table per tracker
        in the Survey (in question order), plus Verdict tables when the Survey has Verdicts on, with a row per Project, or per
        Album adding up its Projects. Only Projects that use the Survey and that you may view are included. An answer is one
        Contact's response in one Story. Pages run over tables.

        Table kinds: `activity` (Activity change amount), `engagement` (Participation change amount), `achievement` (Yes and
        Not ticked answers with percentages), `choice` (answers per choice, with percentages), `numerical` (sum and mean
        average, with `unit`), `verdicts`, `verdicts_across_intervals` and `change_in_verdicts_across_intervals` (grouped by
        Shared Interval in `column_groups`). Each row's `values` line up with the table's `columns`.
      operationId: getStoryCategoryItemisedTotals
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Survey (Story Category) ID
        - name: project_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: integer
          description: Projects to show, a row each, as project_ids[]=1&project_ids[]=2 or a JSON array. Leave out for every Project you may view that uses the Survey.
        - name: album_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: integer
          description: Albums to show, a row each adding up its Projects. Overrides project_ids.
        - name: date_happened_from
          in: query
          required: false
          schema:
            type: string
            format: date
          description: Only Stories that happened on or after this date (YYYY-MM-DD).
        - name: date_happened_to
          in: query
          required: false
          schema:
            type: string
            format: date
          description: Only Stories that happened on or before this date (YYYY-MM-DD).
        - name: date_posted_from
          in: query
          required: false
          schema:
            type: string
            format: date
          description: Only Stories posted on or after this date (YYYY-MM-DD).
        - name: date_posted_to
          in: query
          required: false
          schema:
            type: string
            format: date
          description: Only Stories posted on or before this date (YYYY-MM-DD).
        - name: label_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: integer
          description: Only Stories with one of these Labels.
        - name: group_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: integer
          description: Only answers from Contacts in one of these Contact Groups.
        - name: scope
          in: query
          required: false
          schema:
            type: string
            enum: [all, earliest, latest]
          description: Which responses from each Contact count, by Date Posted (default all).
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The tables, one per entry in data
          content:
            application/json:
              example:
                story_category_id: 12
                story_category_name: Wellbeing check
                row_type: project
                rows: [{id: 7, name: Meadow}, {id: 3, name: Orchard}]
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - key: indicator-41
                    kind: choice
                    description: Choice tracker (Indicator of Scale type)
                    title: Confidence
                    metric_id: 41
                    unit: null
                    column_groups: null
                    columns: [{key: sub_ratio_5, title: Low}, {key: sub_ratio_6, title: High}]
                    rows:
                      - {id: 7, name: Meadow, values: [1.0, 3.0], percentages: [25, 75]}
                      - {id: 3, name: Orchard, values: [2.0, 2.0], percentages: [50, 50]}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /progress_boards:
    get:
      tags: [Progress Boards]
      summary: List Progress Boards
      description: |
        The Progress Boards the Manage Progress Boards page lists for the user: boards they made, are a
        Board Admin or Colleague of, or were granted. `archived` boards are hidden from their members
        until reopened. `automated_by: Project` marks the boards generated for each Survey on a Project
        ("<Survey> on <Project>"). `can_archive` says whether the user may archive or reopen the board
        (its Board Admins and the person who made it); `can_delete` whether they may delete it (Board
        Admins who are Organisation Editors).
      operationId: listProgressBoards
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: status
          in: query
          required: false
          schema: {type: string, enum: [open, archived, all], default: all}
          description: Which boards to list
      responses:
        "200":
          description: Paginated list of Progress Boards
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: {type: integer}
                  page_size: {type: integer}
                  page_count: {type: integer}
                  total_count: {type: integer}
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: {type: integer}
                        name: {type: string}
                        slug: {type: string}
                        charity_id: {type: integer}
                        board_type: {type: string}
                        automated_by: {type: string, nullable: true}
                        automated_by_id: {type: integer, nullable: true}
                        archived: {type: boolean}
                        can_archive: {type: boolean}
                        can_delete: {type: boolean}
                        created_at: {type: string, format: date-time}
                        updated_at: {type: string, format: date-time}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /progress_boards/bulk_action:
    post:
      tags: [Progress Boards]
      summary: Archive, reopen or delete several Progress Boards
      description: |
        Archives, reopens or deletes several Progress Boards at once, as the Archive, Reopen and Delete
        buttons do for the boards ticked in the Rows view of the Manage Progress Boards page. Archiving
        hides a board until it is reopened, and keeps it archived if its Project is later reopened.
        Delete is permanent.

        Each board is changed only if the user may: archive and reopen need a Board Admin or the board's
        creator; delete needs a Board Admin who is an Organisation Editor. Boards the user may not
        change, or can't see, are listed in `skipped` with the reason; the rest still change. At most
        100 boards at a time.
      operationId: bulkActionProgressBoards
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [bulk_action, progress_board_ids]
              properties:
                bulk_action: {type: string, enum: [archive, reopen, delete]}
                progress_board_ids:
                  type: array
                  items: {type: integer}
                  minItems: 1
                  maxItems: 100
            example: {bulk_action: archive, progress_board_ids: [301, 302]}
      responses:
        "200":
          description: What changed and what was skipped
          content:
            application/json:
              schema:
                type: object
                properties:
                  action: {type: string}
                  updated_ids: {type: array, items: {type: integer}}
                  skipped:
                    type: array
                    items:
                      type: object
                      properties:
                        id: {type: integer}
                        name: {type: string, nullable: true}
                        reason: {type: string}
                  message: {type: string}
              example:
                action: archive
                updated_ids: [301]
                skipped: [{id: 302, name: "Youth outcomes", reason: "Only its admins can archive or reopen it"}]
                message: "1 Progress Board archived. 1 skipped, as you can't archive it."
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /project_story_categories:
    get:
      tags: [Project Story Categories]
      summary: List all Survey Campaigns (Project Story Categories)
      operationId: listProjectStoryCategories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedProjectStoryCategories'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /project_story_categories/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema: {type: integer}
        description: The Survey Campaign (Project Story Category) ID
    patch:
      tags: [Project Story Categories]
      summary: Change a Survey Campaign's settings
      description: |
        Turns "Force colleagues to select an interval" on or off, as the Survey Campaign
        Settings page does. When on and the Survey Campaign has intervals (Waves), every story,
        survey invitation, shared link and automation for it must name an interval. Requires
        Project Editor (Project Manager) or Organisation Editor (Organisation Admin) access.
      operationId: updateProjectStoryCategory
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [force_interval]
              properties:
                force_interval: {type: boolean}
            example: {force_interval: true}
      responses:
        "200":
          description: The updated Survey Campaign
          content:
            application/json:
              schema: {$ref: '#/components/schemas/ProjectStoryCategory'}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not change this Survey Campaign
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Project Story Categories]
      summary: Remove a Survey from a Project
      description: |
        Removes a Survey from a Project by deleting its Survey Campaign, as Remove from project does in
        the Actions menu of a Survey Campaign page. The Survey stays in the Organisation's library and
        can be added to the Project again. The Progress Board created automatically for that Survey on
        that Project is deleted too.

        Refused with 422 and the reason while anything in the Project depends on the campaign: survey
        responses recorded with it in that Project, saved draft responses, Events in the Project that
        use it, Survey Invitations sent for it, or it being the Project's default survey. It can then
        only be deactivated. Requires Project Editor (Project Manager) or Organisation Editor
        (Organisation Admin) access.
      operationId: deleteProjectStoryCategory
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Survey Campaign was removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  id: {type: integer}
                  project_id: {type: integer}
                  story_category_id: {type: integer}
                  removed: {type: boolean}
              example: {id: 812, project_id: 101, story_category_id: 55, removed: true}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not remove this Survey from the Project
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: Something in the Project still depends on the Survey Campaign
          content:
            application/json:
              schema: {$ref: '#/components/schemas/Error'}
              example:
                error: "This survey can't be removed from Youth Club because survey responses have been recorded with it in this project. You can deactivate it instead."

  /project_story_categories/{id}/survey_links:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: The Survey Campaign (Project Story Category) ID
    post:
      tags: [Project Story Categories]
      summary: Generate personal survey links for Contacts (without sending them)
      description: |
        Generates a personal survey link (Survey Invitation link) for each Contact, as the
        **Send Survey** page does, and returns the links. **Nothing is emailed or texted.**
        Each response submitted through a link is recorded against that Contact.

        - `beneficiary_ids` must be Contacts already in the Survey Campaign's Project.
        - `emails` are matched to an existing Contact of the organisation with that email
          address; if there is none, a new Contact is created for the organisation.
        - At most 200 `beneficiary_ids` and `emails` per request.
        - `link_expiry`: `use_once` (default) — the link stops working after one response;
          `evergreen` — the link stays active.

        Requires Project Editor or Organisation Editor access to the Survey Campaign's Project.
        The links then appear on the Unique Survey Links page.
      operationId: createSurveyLinks
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                beneficiary_ids:
                  type: array
                  items:
                    type: integer
                  description: Contacts (Beneficiaries) in the Survey Campaign's Project
                emails:
                  type: array
                  items:
                    type: string
                    format: email
                  description: Email addresses, matched to or creating Contacts. No email is sent.
                send_survey_wave_id:
                  type: integer
                  description: >-
                    Wave, from GET /project_story_categories/{id}/survey_waves. Required when the
                    Survey Campaign's force_interval is true and it has Waves; otherwise optional.
                link_expiry:
                  type: string
                  enum: [use_once, evergreen]
                  default: use_once
                is_anonymised:
                  type: boolean
                  default: false
            example:
              beneficiary_ids: [1201, 1202]
              emails: ["sam@example.org"]
              link_expiry: use_once
              is_anonymised: false
      responses:
        "201":
          description: Links generated
          content:
            application/json:
              schema:
                type: object
                properties:
                  send_survey_id:
                    type: integer
                    description: The Survey Invitation batch the links belong to
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/SurveyLink'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not send surveys for this Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: |
            Invalid request: Contacts outside the Project (listed in `invalid_beneficiary_ids`),
            more than 200 recipients, no recipients, an unknown `link_expiry`, or a Wave that
            is not available for this Survey Campaign.

            Refused Contacts are also split in two. `beneficiary_ids_not_in_project` are Contacts of
            the organisation who aren't in the Survey Campaign's Project: add them with
            `POST /project_beneficiaries`, then try again, or pass their email addresses in `emails`.
            `beneficiary_ids_not_found` aren't Contacts of the organisation (the same answer whether
            the id belongs to another organisation or doesn't exist). A Contact created from an
            email address joins the organisation but not the Project. The three lists are only
            present when Contacts were refused.
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: string
                  invalid_beneficiary_ids:
                    type: array
                    items:
                      type: integer
                  beneficiary_ids_not_in_project:
                    type: array
                    items:
                      type: integer
                  beneficiary_ids_not_found:
                    type: array
                    items:
                      type: integer
              example:
                errors:
                  - >-
                    These contacts are in your organisation but not in the project "Understanding Italian": 9876.
                    Add them to the project first (API: POST /api/v2/project_beneficiaries; MCP:
                    makerble_add_contacts_to_project; in Makerble: Contacts page, More options, Assign Contacts
                    to projects), then try again. Or pass their email addresses in emails instead, which doesn't
                    need them to be in the project.
                  - "These contacts were not found in your organisation: 9877."
                invalid_beneficiary_ids: [9876, 9877]
                beneficiary_ids_not_in_project: [9876]
                beneficiary_ids_not_found: [9877]
    get:
      tags: [Project Story Categories]
      summary: List personal survey links for a Survey Campaign
      description: |
        Lists the personal survey links already generated for a Survey Campaign, e.g. to
        reuse a Contact's existing link. A `use_once` link that has been answered has
        `expired: true`. Requires Project Editor or Organisation Editor access.

        Each link's `responses_in_progress` lists the survey responses the Contact has
        started on it but not finished (saved with Finish Later), newest first. This is the
        **Surveys in progress** column on the Survey Campaign's Response Rates tab. Pass
        `in_progress=true` to list only links with one. Unfinished responses are kept for 30
        days after they were last updated. Saving one doesn't change the link's `updated_at`,
        so `last_synced_datetime` doesn't pick it up.
      operationId: listSurveyLinks
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: beneficiary_id
          in: query
          schema:
            type: integer
          description: Only this Contact's links
        - name: send_survey_wave_id
          in: query
          schema:
            type: integer
          description: Only links for this Wave
        - name: in_progress
          in: query
          schema:
            type: boolean
          description: "`true`: only links where the Contact has started a response but not finished it"
      responses:
        "200":
          description: Paginated list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSurveyLinks'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 812
                    send_survey_id: 340
                    beneficiary_id: 5521
                    email: sam@example.org
                    survey_token: 0f8c1d2e3b4a59687a6b5c4d3e2f1a0b
                    survey_url: https://app.makerble.com/stories/new/0f8c1d2e3b4a59687a6b5c4d3e2f1a0b
                    link_expiry: use_once
                    is_anonymised: false
                    send_survey_wave_id: 12
                    expired: false
                    created_at: "2026-10-01T09:00:00Z"
                    updated_at: "2026-10-01T09:00:00Z"
                    responses_in_progress:
                      - send_survey_wave_id: 12
                        last_updated_at: "2026-10-03T14:30:00Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user may not send surveys for this Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          $ref: '#/components/responses/NotFound'

  /project_story_categories/{id}/survey_waves:
    get:
      tags: [Project Story Categories]
      summary: List the Waves of a Survey Campaign
      description: |
        Lists the Waves (named rounds of a longitudinal survey, e.g. Baseline and Exit) that
        survey links can be generated for, in priority order. Empty when the Survey Campaign
        doesn't use Waves.
      operationId: listSurveyWaves
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: The Survey Campaign (Project Story Category) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSurveyWaves'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /story_beneficiaries:
    get:
      tags: [Story Metrics]
      summary: List Story Beneficiaries
      description: |
        Records that directly tag a Beneficiary to a Story. The three tagging mechanisms are:
        1. **Story Beneficiary** — direct tag (this endpoint)
        2. **Story Change Beneficiary** — tagged via a Participation Change
        3. **Story Indicator Beneficiary** — tagged via an Indicator response
      operationId: listStoryBeneficiaries
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /story_changes:
    get:
      tags: [Story Metrics]
      summary: List Story Changes
      description: |
        Per-story metric totals for Activity and Participation Changes. Filter by `story_id`.

        - Activity Changes: value = number entered directly
        - Participation Changes: value = tagged Beneficiaries + anonymous participants
      operationId: listStoryChanges
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: story_id
          in: query
          schema:
            type: integer
          description: Filter to a specific Story
      responses:
        "200":
          description: Paginated Story Change records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /story_change_beneficiaries:
    get:
      tags: [Story Metrics]
      summary: List Story Change Beneficiaries
      description: Per-Beneficiary Participation Change records. Only applies to Participation type Changes.
      operationId: listStoryChangeBeneficiaries
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /story_indicators:
    get:
      tags: [Story Metrics]
      summary: List Story Indicators
      description: Total indicator progress logged per Story. Filter by `story_id`.
      operationId: listStoryIndicators
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: story_id
          in: query
          schema:
            type: integer
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /story_indicator_beneficiaries:
    get:
      tags: [Story Metrics]
      summary: List Story Indicator Beneficiaries
      description: Per-Beneficiary indicator responses. Each record = one Contact's answer to one Indicator in one Story.
      operationId: listStoryIndicatorBeneficiaries
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: story_id
          in: query
          schema:
            type: integer
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGeneric'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /case_notes:
    get:
      tags: [Audio Notes]
      summary: List Audio Notes
      description: |
        The Audio Notes (CaseNotes) the user may see on the **Audio Notes** page, newest first:
        every one in the Organisations (Charities) they are an admin (Charity Editor) of and the
        Projects they are a Project Editor of, plus the ones they recorded themselves. Each is a
        CaseNote (`note_type: case_note`, about one Contact) or a SessionNote
        (`note_type: session_note`, about an Event). Get one to read its transcript and summary.
      operationId: listCaseNotes
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          schema:
            type: integer
          description: Only Audio Notes in this Organisation (Charity)
        - name: project_id
          in: query
          schema:
            type: integer
          description: Only Audio Notes in this Project
        - name: beneficiary_id
          in: query
          schema:
            type: integer
          description: Only CaseNotes about this Contact (Beneficiary)
        - name: event_id
          in: query
          schema:
            type: integer
          description: Only SessionNotes about this Event
        - name: note_type
          in: query
          schema:
            type: string
            enum: [case_note, session_note]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Audio Notes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedCaseNotes'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Audio Notes]
      summary: Attach an audio file as a new Audio Note
      description: |
        Creates an Audio Note (CaseNote) from an audio file, as the **New AudioNote** popup on the Audio
        Notes page does. Send it as `multipart/form-data`. Makerble then transcribes and summarises it
        and writes a draft survey response, the same as for a recording made in Makerble; poll
        **Get an Audio Note** until `status` is `completed`. The note's `source` is `manual` and its
        `platform` is `api`.

        Choose an Organisation (Charity) with AI AudioNotes turned on and one of its running Projects
        the user is a member of. For a `case_note` give a Contact (Beneficiary) in that Project whom
        the user may see. For a `session_note` the `event_id` is optional; it must be an Event in that
        Project that the user is an Event Manager or Event Worker of (a Project or Organisation admin
        may choose any of the Project's Events). The file must be MP3, M4A, MP4, WAV, WEBM, OGG, OGA,
        AAC or FLAC audio, up to 200 MB.
      operationId: createCaseNote
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [charity_id, project_id, note_type, audio_file]
              properties:
                charity_id:
                  type: integer
                project_id:
                  type: integer
                note_type:
                  type: string
                  enum: [case_note, session_note]
                beneficiary_id:
                  type: integer
                  description: Required for a `case_note`
                event_id:
                  type: integer
                  description: Optional, for a `session_note`
                audio_file:
                  type: string
                  format: binary
            example:
              charity_id: 913
              project_id: 2201
              note_type: case_note
              beneficiary_id: 50412
              audio_file: "(binary) session.mp3"
      responses:
        "201":
          description: The Audio Note, queued for transcription
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseNoteDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          description: A choice was missing or not allowed, or the file is not a supported audio file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Choose a contact."
        "503":
          description: The audio file could not be stored; nothing was created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /case_notes/{id}:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    get:
      tags: [Audio Notes]
      summary: Get an Audio Note
      description: |
        One Audio Note (CaseNote) with its transcript and AI summary, if the user may see it on the
        **Audio Notes** page (otherwise `404`).
      operationId: getCaseNote
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Audio Note
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseNoteDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /case_notes/{id}/recording:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    delete:
      tags: [Audio Notes]
      summary: Delete an Audio Note's recording
      description: |
        Deletes the audio recording of an Audio Note (CaseNote), for example to meet a privacy request,
        as **Delete Recording** does on the Audio Note page. The note itself is kept, with its transcript,
        summary and draft or saved survey response; `has_recording` becomes false and `audio_deleted_at`
        is set. This cannot be undone. Only the Organisation's admins (Charity Editors) and Makerble
        System Access admins may do this (`403`), and only once the note has finished processing
        (`status` is `completed` or `failed`; otherwise `422`). Deleting an already deleted recording
        returns the note unchanged. `503` means the recording could not be removed from storage and
        nothing was changed: try again.
      operationId: deleteCaseNoteRecording
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Audio Note, without its recording
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseNoteDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user is not an admin of the Audio Note's Organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only an organisation admin can delete a recording."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: The Audio Note is still being processed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "The recording can be deleted once it has been transcribed."
        "503":
          description: The recording could not be removed from storage; nothing was changed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /cases:
    get:
      tags: [Cases]
      summary: List all Cases
      description: |
        Each Case is linked to one Beneficiary and one Project.

        Filter the Cases by their answers to Case Form questions with `custom_field_definition_hash`, as the Manage Cases page does.
        Call `GET /cases/filter_fields` first for the question IDs and the shape of value each one takes (its `filter_format`):

        - `text`: text the answer contains, ignoring case, e.g. `custom_field_definition_hash[71]=theft`
        - `number_range`: `[min]` and/or `[max]`
        - `date_range`, `time_range`, `datetime_range`: `[from]` and/or `[to]`, both included (e.g. `2025-01-31`, `09:00`, `2025-01-31T14:00`)
        - `choice_ids`: answer choice IDs, e.g. `custom_field_definition_hash[72][]=5`
        - `yes_no`: `[]=yes` for ticked, `[]=no` for not ticked
        - `has_files_no_files`: `[]=has_files` or `[]=no_files`
        - `album_ids`: Album IDs the Case is linked to through the question

        A Case must match every question given. A question the user can't filter by is ignored.
      operationId: listCases
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: custom_field_definition_hash
          in: query
          style: deepObject
          explode: true
          required: false
          description: Answers to Case Form questions to filter by, keyed by question (custom field definition) ID. See the description above.
          schema:
            type: object
            additionalProperties: true
          example:
            "71": theft
      responses:
        "200":
          description: Paginated list of Cases
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedCases'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Cases]
      summary: Create a Case
      description: |
        Creates a Case for a Beneficiary within a Project.

        Call `GET /custom_field_categories` first to discover the field definition IDs for `custom_field_categories_definition`.
      operationId: createCase
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CaseCreateRequest'
            example:
              case:
                title: "Housing support case"
              custom_field_categories_definition:
                "71": "My case note"
                "121": true
              case_owner_id: 654
              case_worker_ids: [231, 422]
              project_id: 123
              beneficiary_id: 321
      responses:
        "200":
          description: Case created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Case'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /cases/filter_fields:
    get:
      tags: [Cases]
      summary: List the Case Form questions Cases can be filtered by
      description: |
        Lists the questions (custom field definitions) on the Case Forms of the organisations whose Cases the user can see, each once, alphabetically.
        These are the custom filters on the Manage Cases page. Pass a question's `id` and a value in its `filter_format` to
        `GET /cases` as `custom_field_definition_hash`. Select questions list their answer `choices`.
      operationId: listCaseFilterFields
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of Case Form questions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedCaseFilterFields'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - id: 71
                    name: Type of crime
                    field_type: ratio_set
                    filter_format: choice_ids
                    choices:
                      - { id: 5, name: Harassment }
                      - { id: 4, name: Theft }
                  - id: 72
                    name: Date of incident
                    field_type: date
                    filter_format: date_range
                    choices: []
        "401":
          $ref: '#/components/responses/Unauthorized'

  /projects_beneficiaries_cases:
    get:
      tags: [Cases]
      summary: List Project–Beneficiary–Case associations
      operationId: listProjectsBeneficiariesCases
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedProjectsBeneficiariesCases'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /custom_field_categories:
    get:
      tags: [Custom Field Categories]
      summary: List all Custom Field Categories (Case Forms)
      description: |
        Case Form field schemas. Use field definition IDs in `custom_field_categories_definition` when creating a Case.

        Supported field types: Text (short/long) · Number · Date & time · Time · Attachment · Select · Tickbox
      operationId: listCustomFieldCategories
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedCustomFieldCategories'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /versions:
    get:
      tags: [Versions]
      summary: List a record's Versions (audit trail)
      description: |
        Returns every Version of one record, newest first: each time it was created or edited, who did it and when.
        `record_type` is `Contact` (a Contact, i.e. Beneficiary) or `Story` (a Story or Survey Response). A Story is
        named `[story ID] <survey> in <project> by <user> on <date happened>`. A deleted record's Versions are still
        listed, with `record.deleted: true`.

        Visible to Charity Editors (any Contact or Story in their Organisation) and Project Editors (Contacts in at
        least one of their Projects, and Stories in their Projects that they may read: a Story shared only with
        specific individuals is hidden unless they are one of them). Anything the caller may not see returns `404`,
        so the endpoint never confirms that another Organisation's record exists.

        `user_name` is `System` when no signed-in user made the change (e.g. a CSV import run in the background).
        One Save can write several Versions a fraction of a second apart. Use `GET /versions/{id}` to see the full
        record as it was saved in a Version.

        Pass `include_fields=true` to compare the Versions side by side, as the **Version History** page does: each
        Version then also has `fields`, one entry per field of the record with its label, display value, state, and
        whether it changed since the Version saved just before it.
      operationId: listVersions
      security: [{tokenAuth: []}]
      parameters:
        - name: record_type
          in: query
          required: true
          schema:
            type: string
            enum: [Contact, Story]
          description: '`Contact` (Beneficiary) or `Story` (a Story or Survey Response)'
        - name: record_id
          in: query
          required: true
          schema:
            type: integer
          description: The Contact (Beneficiary) ID or the Story ID
        - $ref: '#/components/parameters/Page'
        - name: per_page
          in: query
          schema:
            type: integer
            default: 10
            maximum: 200
          description: Records per page (default 10, max 200)
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: include_fields
          in: query
          schema:
            type: boolean
            default: false
          description: Add each Version's `fields`, labelled and compared with the Version before it
      responses:
        "200":
          description: Paginated list of the record's Versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedVersions'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                record: { record_type: Contact, record_id: 185170, charity_id: 304, name: Bella Thornton, deleted: false }
                data:
                  - { id: 76, record_type: Contact, record_id: 185170, charity_id: 304, event: update, action: Edited, user_id: 190, user_name: Sam Ahmed, created_at: "2026-09-29T07:50:02.709Z" }
                  - { id: 74, record_type: Contact, record_id: 185170, charity_id: 304, event: create, action: Created, user_id: 190, user_name: Sam Ahmed, created_at: "2026-09-29T07:50:02.319Z" }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /versions/{id}:
    get:
      tags: [Versions]
      summary: Get a single Version, with the full record snapshot
      description: |
        Returns one Version including `full_object`: every field of the record exactly as it was saved at that
        moment, not just the fields that changed. Compare two Versions' `full_object` to see what changed.
        For a Story, `full_object` is `{schema_version, story, privacy_settings, contact_ids, outcome_ids, label_ids,
        media, answers}`, where each answer carries the survey question's label as it was then.
        For a Contact, fields the Organisation's Field Visibility settings hide from you are `null` in `full_object`
        and named in `restricted_fields`.

        `fields` lists the record's fields as the **Version History** page shows them: the label, the display value,
        the `state` (`value`; `blank` when the field existed but was empty; `absent` when it wasn't a field of the
        record at that time, such as a survey question added later or since removed from the survey; `restricted`
        when Field Visibility hides it from you, with a null value), and `changed`, true when the value differs from
        the Version saved just before this one.
        Same permissions as `GET /versions`.
      operationId: getVersion
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Version with full_object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VersionDetail'
              example:
                id: 76
                record_type: Contact
                record_id: 185170
                charity_id: 304
                event: update
                action: Edited
                user_id: 190
                user_name: Sam Ahmed
                created_at: "2026-09-29T07:50:02.709Z"
                full_object: { id: 185170, name: Bella T, mobile: null }
                restricted_fields: [mobile]
                fields:
                  - { key: name, label: Name, value: Bella T, state: value, changed: true }
                  - { key: mobile, label: Mobile, value: null, state: restricted, changed: false }
                  - { key: country_code, label: Country code, value: null, state: blank, changed: false }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /access_logs:
    get:
      tags: [Access Logs]
      summary: List who viewed a record (Access Logs)
      description: |
        Returns the Access Log of one record, newest first: each time a colleague opened it in Makerble or fetched it
        through the API, who it was, when, and how many times. This is the **Access Logs** tab beside Versions on the
        Manage Versions page. Changes are in `GET /versions` instead.
        `record_type` is `Contact` (a Contact, i.e. Beneficiary) or `Story` (a Story or Survey Response).

        Views by the same colleague, through the same route, less than 30 minutes apart are one entry with a
        `view_count`. Entries older than the Organisation's retention period (3 to 12 months, set on Organisation
        Preferences) are rolled up into one entry per colleague per month, with `monthly_summary: true` and
        `first_viewed_at` / `last_viewed_at` spanning that month. `source` is `web` (opened in Makerble), `api` (fetched with `GET /beneficiaries/{id}`) or `mcp`
        (fetched through the Makerble MCP server).

        Visible to Charity Editors (any Contact or Story in their Organisation) and Project Editors (Contacts in at
        least one of their Projects, and Stories in their Projects that they may read: a Story shared only with
        specific individuals is hidden unless they are one of them). Anything the caller may not see returns `404`,
        so the endpoint never confirms that another Organisation's record exists.
      operationId: listAccessLogs
      security: [{tokenAuth: []}]
      parameters:
        - name: record_type
          in: query
          required: true
          schema:
            type: string
            enum: [Contact, Story]
          description: '`Contact` (Beneficiary) or `Story` (a Story or Survey Response)'
        - name: record_id
          in: query
          required: true
          schema:
            type: integer
          description: The Contact (Beneficiary) ID or the Story ID
        - name: from
          in: query
          schema:
            type: string
            format: date
          description: Only entries on or after this date (YYYY-MM-DD)
        - name: to
          in: query
          schema:
            type: string
            format: date
          description: Only entries on or before this date (YYYY-MM-DD)
        - name: user_id
          in: query
          schema:
            type: integer
          description: Only this colleague's views
        - $ref: '#/components/parameters/Page'
        - name: per_page
          in: query
          schema:
            type: integer
            default: 10
            maximum: 200
          description: Records per page (default 10, max 200)
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Access Log entries for the record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAccessLogs'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                record: { record_type: Contact, record_id: 185170, charity_id: 304, name: Bella Thornton, deleted: false }
                data:
                  - { id: 912, record_type: Contact, record_id: 185170, charity_id: 304, action: "Viewed ×1", view_count: 1, source: mcp, user_id: 190, user_name: Sam Ahmed, first_viewed_at: "2026-10-02T14:05:00.000+01:00", last_viewed_at: "2026-10-02T14:05:00.000+01:00", monthly_summary: false }
                  - { id: 877, record_type: Contact, record_id: 185170, charity_id: 304, action: "Viewed ×3", view_count: 3, source: web, user_id: 212, user_name: Jane Smith, first_viewed_at: "2026-10-01T09:20:00.000+01:00", last_viewed_at: "2026-10-01T09:30:00.000+01:00", monthly_summary: false }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /audit_trail:
    get:
      tags: [Audit Trail]
      summary: List an Organisation's latest changes and views (Audit Trail)
      description: |
        Returns the Organisation's **Audit Trail**, newest first: the changes (Versions: Created, Edited, Destroyed) and
        views (Access Logs: Viewed) across all its Contacts (Beneficiaries) and Stories (including Survey Responses).
        This is the **Audit Trail** page, reached from Contacts → More Options → Audit trail. For one record's
        complete history use `GET /versions` and `GET /access_logs` instead.

        Views by the same colleague, through the same route, less than 30 minutes apart are one entry with a
        `view_count`. Only views within the Organisation's retention period are listed; older views are monthly
        summaries on `GET /access_logs`. Stories have views but no Versions yet.

        Visible to Charity Editors (everything in their Organisation) and Project Editors (Contacts and Stories in
        their Projects). An Organisation the caller may not audit returns `404`.
      operationId: listAuditTrail
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - name: actions
          in: query
          schema:
            type: string
          example: created,edited
          description: Comma-separated types of action to include, from `created`, `edited`, `destroyed`, `viewed` (default all)
        - name: user_id
          in: query
          schema:
            type: integer
          description: Only this colleague's actions
        - name: record_type
          in: query
          schema:
            type: string
            enum: [Contact, Story]
          description: Only Contacts, or only Stories
        - name: record_id
          in: query
          schema:
            type: integer
          description: Only this record (needs `record_type`)
        - $ref: '#/components/parameters/Page'
        - name: per_page
          in: query
          schema:
            type: integer
            default: 10
            maximum: 200
          description: Records per page (default 10, max 200)
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Audit Trail entries for the Organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAuditTrail'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - { entry_type: access_log, id: 912, action: Viewed, record_type: Contact, record_id: 185170, record_name: Bella Thornton, occurred_at: "2026-10-02T14:05:00.000+01:00", user_id: 190, who: Sam Ahmed (via MCP), view_count: 2, source: mcp }
                  - { entry_type: version, id: 50211, action: Edited, record_type: Contact, record_id: 185170, record_name: Bella Thornton, occurred_at: "2026-10-01T09:30:00.000+01:00", user_id: 212, who: Jane Smith, view_count: null, source: null }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /changes:
    get:
      tags: [Changes]
      summary: List all Changes (Activity & Participation metrics)
      description: |
        Custom KPIs / progress trackers. Two types:
        - **Activity** — numerical, not linked to an Outcome, beneficiaries cannot be tagged (Progress Panel col 1)
        - **Participation** — attendance-type, per-beneficiary tagging supported (Progress Panel col 2)
      operationId: listChanges
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Changes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedChanges'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /engagement_trackers:
    post:
      tags: [Changes, Library]
      summary: Create an Engagement Tracker
      operationId: createEngagementTracker
      description: |
        Creates an Engagement Tracker (a participation Change, also called an Attendance tracker):
        a yes/no record of whether a Contact took part, e.g. "Attended the weekly session". It is
        made as on the Create Metric page and the Engagement Tracker tab of the Create/Edit Survey
        page: hidden from other organisations, and editable only by the owning organisation's
        Organisation Editors. Leave out `owner_id` to own it yourself. Near-identical names get
        `409`, as for **Create a List**. To put it in a Survey, use its `id` as a question's
        `activity_tracker_id`.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                name:
                  type: string
                owner_id:
                  type: integer
                  description: The organisation (Charity) that will own it; one you belong to
                force:
                  $ref: '#/components/schemas/ForceCreate'
            example:
              name: "Attended the weekly session"
              owner_id: 913
      responses:
        "201":
          description: The new Engagement Tracker
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  name:
                    type: string
                  icon:
                    type: string
                    nullable: true
                  stage_id:
                    type: integer
                  activity:
                    type: boolean
                  participation:
                    type: boolean
                  owner_type:
                    type: string
                    enum: [Charity, User]
                  owner_id:
                    type: integer
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
              example:
                id: 2841
                name: "Attended the weekly session"
                icon: "/system/changes/icons/2841/original/icon.png"
                stage_id: 2
                activity: false
                participation: true
                owner_type: Charity
                owner_id: 913
                created_at: "2026-10-29T10:00:00Z"
                updated_at: "2026-10-29T10:00:00Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /indicators:
    get:
      tags: [Indicators]
      summary: List all Indicators
      description: |
        Indicative Progress Trackers linked to Outcomes. Three types:
        - **Scale** — multiple-choice using a Ratio Set
        - **Binary** — tickbox (yes/no)
        - **Value** — numerical

        Returns only the Indicators the signed-in user can see: their own, and those of
        every organisation where they are an editor, reporter or observer. Indicators from
        the public library shared by all organisations are added only when
        `include_public_library=true`, matching the Indicator search in the Makerble app.
      operationId: listIndicators
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - $ref: '#/components/parameters/IncludePublicLibrary'
      responses:
        "200":
          description: Paginated list of Indicators
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedIndicators'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /indicators/create_v2:
    post:
      tags: [Indicators]
      summary: Create a Metric
      operationId: createIndicator
      description: |
        Creates a Metric (an Indicator) for one of your organisations, or for yourself, and links it
        to the Outcomes it measures. This is the request the Metric form in the Makerble app sends,
        so its body uses the form's field names.

        To create a Metric by type name (`scale`, `binary` or `value`) as part of a Survey or an
        Impact Framework, use **Create a Survey** (`new_metric`) or **Create an Impact Framework**
        (`new_metrics`) instead. They also create a new List for a scale Metric in the same call.

        Search the library first (**Search the library**) and reuse a Metric that fits. If your
        organisation or the public library already has a Metric with the same or a near-identical
        name (ignoring case, spacing and punctuation), nothing is created and you get `409` with the
        matches. Send `force: true` to create it anyway.

        The Metric is visible only to your organisation's editors and leaders. It is recorded as made
        through the API, or through the MCP server when the request comes from it.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [indicator]
              properties:
                indicator:
                  type: object
                  required: [name, indicator_type_id]
                  properties:
                    name:
                      type: string
                    indicator_type_id:
                      type: integer
                      description: |
                        The ID of the Metric type: scale (multiple choice from a List), binary (tickbox)
                        or value (a number). These IDs differ between environments.
                    unit_id:
                      type: integer
                      description: The Unit shown beside a value Metric's number, e.g. hours
                    owner_type:
                      type: string
                      enum: [Charity, User]
                      description: "Charity: owned by the organisation in owner_id. User: owned by you."
                    owner_id:
                      type: integer
                      description: The organisation (Charity) that will own it; it must be one of yours
                outcome_ids:
                  type: array
                  items:
                    type: integer
                  description: Outcomes it measures, owned by one of your organisations or by you
                department_ids:
                  type: array
                  items:
                    type: integer
                  description: Cause areas (Departments); defaults to the first one
                selected_ratio_set_id:
                  type: integer
                  description: For a scale Metric, the List (Ratio Set) of answer choices; one you can see
                current_field_id:
                  type: integer
                  description: A question on one of your organisations' Surveys that this Metric should answer
                force:
                  $ref: '#/components/schemas/ForceCreate'
            example:
              indicator:
                name: "Felt more confident"
                indicator_type_id: 2
                owner_type: Charity
                owner_id: 913
              outcome_ids: [5844]
      responses:
        "200":
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: success
                  indicator:
                    type: string
                    description: The new Metric as a JSON-encoded string
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: |
            An owner, Outcome, List or Survey question you may not use. `errors` says which, e.g.
            "These outcomes (outcome_ids) can't be used: 5844".
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: string
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "500":
          description: The Metric is invalid, e.g. a missing name; `errors` lists the problems and nothing is created
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: string

  /indicators/{id}:
    get:
      tags: [Indicators]
      summary: Get a single Indicator
      description: |
        Returns 404 for an Indicator the signed-in user cannot see, with the same body as
        for an ID that does not exist. A public-library Indicator owned by another
        organisation is returned only when `include_public_library=true`.
      operationId: getIndicator
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/IncludePublicLibrary'
      responses:
        "200":
          description: Indicator record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IndicatorDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Indicators, Library]
      summary: Change a Metric's name or question
      operationId: updateIndicator
      description: |
        Renames a Metric (an Indicator) or rewords its default question, the question people see
        when it is asked in a Survey. Nothing else about the Metric changes, and results already
        recorded stay against it, so only reword a Metric when its meaning stays the same.

        You must be able to edit the Metric: it belongs to one of your organisations. A Metric you
        can see but not edit, such as another organisation's public Metric, is `403`; one you can't
        see is `404`. Sending neither `name` nor `default_question` is `422`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                default_question:
                  type: string
            example:
              default_question: "How confident do you feel about getting a job?"
      responses:
        "200":
          $ref: '#/components/responses/LibraryItemUpdated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /scale_indicator_choices:
    get:
      tags: [Indicators]
      summary: Get Scale Indicator choices
      description: Choice configuration (single/multiple) for Scale Indicators in a Story Category.
      operationId: listScaleIndicatorChoices
      security: [{tokenAuth: []}]
      parameters:
        - name: story_category_id
          in: query
          schema:
            type: integer
        - name: indicator_id
          in: query
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Scale indicator choice records
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ScaleIndicatorChoice'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /outcomes:
    get:
      tags: [Outcomes]
      summary: List all Outcomes
      description: |
        Each Outcome has a stage (short/medium/long-term) placing it in Progress Panel cols 3–5.

        Returns only the Outcomes the signed-in user can see: their own, those of every
        organisation where they are an editor, reporter or observer, and those used by one of
        their Projects. Outcomes from the public library shared by all organisations are
        added only when `include_public_library=true`.
      operationId: listOutcomes
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - $ref: '#/components/parameters/IncludePublicLibrary'
      responses:
        "200":
          description: Paginated list of Outcomes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedOutcomes'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Outcomes, Library]
      summary: Create an Outcome
      operationId: createOutcome
      description: |
        Creates an Outcome: a change your organisation wants to see in the people it works with,
        e.g. "Improved confidence". It stays unapproved and private to your organisation unless you
        are Makerble staff: `approved`, `private` and `is_default` are honoured for staff only and
        ignored for everyone else. Near-identical titles get `409`, as for **Create a List**.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [organisation_id, title, stage]
              properties:
                organisation_id:
                  type: integer
                  description: The organisation (Charity) that will own it; you must be one of its editors
                title:
                  type: string
                stage:
                  type: string
                  enum: [Short-term outcomes, Medium-term outcomes, Long-term outcomes]
                description:
                  type: string
                instruction:
                  type: string
                  description: Guidance for staff recording it
                department:
                  type: string
                  description: A cause area (Department) name, e.g. Health
                approved:
                  type: boolean
                  description: Makerble staff only
                private:
                  type: boolean
                  description: Makerble staff only
                is_default:
                  type: boolean
                  description: Makerble staff only
                force:
                  $ref: '#/components/schemas/ForceCreate'
            example:
              organisation_id: 913
              title: "Improved confidence"
              stage: "Short-term outcomes"
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /outcomes/{id}:
    get:
      tags: [Outcomes]
      summary: Get a single Outcome
      description: |
        Returns 404 for an Outcome the signed-in user cannot see, with the same body as for
        an ID that does not exist. A public-library Outcome owned by another organisation is
        returned only when `include_public_library=true`.
      operationId: getOutcome
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/IncludePublicLibrary'
      responses:
        "200":
          description: Outcome record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Outcome'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /metrics/{id}/copy:
    post:
      tags: [Outcomes]
      summary: Copy a metric (an Output, Outcome or Indicator)
      description: >-
        Copies an Output (API: Change), an Outcome or an Indicator (Progress Tracker), as on a metric's page in Makerble.
        The copy is called "Copy of <original name>" (numbered, e.g. "Copy of X (2)", when that name is taken), keeps the
        original's owner, settings, survey question wording and levels, and is not added to any Project, Survey or
        Impact Framework. A copied Indicator keeps the original's Outcomes; a copied Outcome keeps the original's
        Indicators. Only someone who can edit the original may copy it.
      operationId: copyMetric
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [metric_class]
              properties:
                metric_class:
                  type: string
                  enum: [Change, Indicator, Outcome]
                  description: What kind of metric `id` is.
            example:
              metric_class: Indicator
      responses:
        "201":
          description: The copy
          content:
            application/json:
              schema:
                type: object
                properties:
                  id: {type: integer}
                  metric_class: {type: string, enum: [Change, Indicator, Outcome]}
                  name: {type: string}
                  owner_type: {type: string, enum: [Charity, User]}
                  owner_id: {type: integer}
                  copied_from_id: {type: integer}
              example:
                id: 912
                metric_class: Indicator
                name: Copy of Hours of sleep
                owner_type: Charity
                owner_id: 42
                copied_from_id: 311
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /outcome_indicators:
    get:
      tags: [Outcome Indicators]
      summary: List all Outcome Indicators
      description: Join table pairing Outcomes with Indicators (many-to-many). Use to find the `outcome_id` when creating story indicator responses.
      operationId: listOutcomeIndicators
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedOutcomeIndicators'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /framework_sets:
    get:
      tags: [Framework Sets]
      summary: List the Framework Sets an organisation can use
      description: |
        A Framework Set groups Impact Frameworks (backend: templates) into one thing an organisation
        reports its contribution towards, e.g. the 17 SDG Impact Frameworks form "UN Sustainable
        Development Goals". Returns the live sets available to the organisation (platform sets, sets of
        Networks it belongs to, and its own sets), plus the draft sets the user can edit.
      operationId: listFrameworkSets
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The organisation (Charity) whose available sets to list. The user must belong to it.
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Framework Sets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFrameworkSets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Framework Sets]
      summary: Create a Framework Set
      description: |
        Creates a Framework Set from existing Impact Frameworks (and, optionally, new ones named in
        `new_frameworks`). Who can use it is set by `availability`: `platform` (every organisation,
        System Access users only), `network` (organisations in `network_id`, that Network's admins) or
        `charity` (the organisation in `charity_id` only, its organisation admins).
      operationId: createFrameworkSet
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FrameworkSetInput'
            example:
              charity_id: 913
              name: Our strategy 2027
              level1_singular: Objective
              level1_plural: objectives
              level2_singular: Key result
              level2_plural: key results
              availability: charity
              status: live
              frameworks:
                - template_id: 1475
                  short_code: O1
                  colour: "#C5192D"
                  text_colour: "#FFFFFF"
      responses:
        "201":
          description: The created Framework Set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameworkSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /framework_sets/{id}:
    get:
      tags: [Framework Sets]
      summary: Get a Framework Set
      description: A Framework Set with its Impact Frameworks in order, and the Financial Values it defines per Outcome.
      operationId: getFrameworkSet
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Framework Set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameworkSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Framework Sets]
      summary: Update a Framework Set
      description: |
        Updates a Framework Set the user can edit. Send `frameworks` to replace the list of Impact
        Frameworks (in order), and `financial_values` to replace the Financial Value defined for each
        Outcome, and optionally for each of an Outcome's own Indicators (`indicator_id`, e.g. a TOMs Measure). `charity_id` is the organisation the user is acting for.
      operationId: updateFrameworkSet
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FrameworkSetInput'
            example:
              charity_id: 913
              name: Our strategy 2027 (revised)
              availability: charity
              value_source: set_values
              frameworks:
                - template_id: 1475
              financial_values:
                - outcome_id: 5521
                  financial_value_id: 88
                - outcome_id: 5521
                  indicator_id: 2240
                  financial_value_id: 91
      responses:
        "200":
          description: The updated Framework Set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameworkSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /framework_sets/{id}/contribution:
    get:
      tags: [Framework Sets]
      summary: Get an organisation's contribution to a Framework Set
      description: |
        The figures on the Contribution page: which Impact Frameworks (e.g. SDG Goals) and Outcomes (e.g.
        SDG Targets) in the set the organisation's Stories contribute to. A Story counts when it records
        a value against an Indicator inside an Outcome as a Core indicator, or as one of the
        organisation's Linked indicators whose project scope includes the Story's project. Draft
        Stories never count.

        `summary` counts each Story, Contact (person or organisation reached) and indicator entry once
        for the whole set. `financial_value` is the value the counted entries generate, worked out the
        way each project's Financial Calculator works it out, or from the set's own Financial Values
        when the set defines them. The per-framework and per-Outcome figures overlap (an entry linked
        to two Outcomes appears under both), so never add them up into a total. Core indicators that
        no Story records are listed with zero Stories.
      operationId: getFrameworkSetContribution
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The organisation (Charity) whose contribution to report. The user must belong to it.
        - name: project_id
          in: query
          schema:
            type: integer
          description: Only count Stories in this project of the organisation.
        - name: bundle_id
          in: query
          schema:
            type: integer
          description: Only count Stories in the projects of this Album (Bundle) of the organisation.
        - name: period
          in: query
          schema:
            type: string
            enum: [all_time, last_12_months, financial_year, custom]
            default: all_time
          description: "`financial_year` starts on 5 April. `custom` uses `from` and `to`."
        - name: from
          in: query
          schema:
            type: string
            format: date
          description: First day of a custom period
        - name: to
          in: query
          schema:
            type: string
            format: date
          description: Last day of a custom period
      responses:
        "200":
          description: The contribution figures
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameworkContribution'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'

  /framework_sets/{id}/migrate_links:
    post:
      tags: [Framework Sets]
      summary: Copy Linked indicators onto a new version of a Framework Set
      description: |
        For a Framework Set that replaces an older version (`supersedes_id`), copies the organisation's
        Linked indicators from the older version onto this one, wherever the same Outcome is in this
        version, either as the same Outcome or as one with the same title. Project scopes are kept.
        The links on the older version stay, so its reports don't change. Returns the links carried
        across and those that couldn't be, because this version has no matching Outcome. Needs an
        organisation admin.
      operationId: migrateFrameworkLinks
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id]
              properties:
                charity_id:
                  type: integer
                  description: The organisation whose links to copy. The user must be one of its admins.
            example:
              charity_id: 913
      responses:
        "200":
          description: The links carried across, and those that could not be
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameworkLinkMigration'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'

  /framework_links:
    get:
      tags: [Framework Sets]
      summary: List an organisation's Linked indicators
      description: |
        A Linked indicator is one of the organisation's own Indicators linked to an Outcome (e.g. an SDG
        Target) in a Framework Set it can use. Every Story recorded against the Indicator then counts
        towards that Outcome, in every project or only in the projects listed.
      operationId: listFrameworkLinks
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The organisation (Charity) whose links to list. The user must belong to it.
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated Linked indicators
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFrameworkLinks'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Framework Sets]
      summary: Link an Indicator to an Outcome in a Framework Set
      description: |
        Links one of the organisation's Indicators (one it owns or one used in its projects) to an
        Outcome in a Framework Set available to it. Leave `project_ids` empty to count it in every
        project. If the link already exists for some projects, the new projects are added to it.
        Requires an organisation admin.
      operationId: createFrameworkLink
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, indicator_id, outcome_id]
              properties:
                charity_id:
                  type: integer
                indicator_id:
                  type: integer
                outcome_id:
                  type: integer
                framework_indicator_id:
                  type: integer
                  description: |
                    Optional. Which of the Outcome's own Indicators this indicator counts as (e.g. a TOMs
                    Measure). In a Framework Set with its own Financial Values, Stories are then valued at
                    that Indicator's value. It can't be changed on an existing link; remove the link first.
                project_ids:
                  type: array
                  items:
                    type: integer
            example:
              charity_id: 913
              indicator_id: 2201
              outcome_id: 5521
              project_ids: [3104]
      responses:
        "201":
          description: The Linked indicator
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FrameworkLink'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /framework_links/{id}:
    delete:
      tags: [Framework Sets]
      summary: Remove a Linked indicator
      description: Requires an organisation admin of the organisation in `charity_id`.
      operationId: deleteFrameworkLink
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'

  /ratio_sets:
    get:
      tags: [Ratio Sets]
      summary: List all Ratio Sets (Dropdown/List fields)
      description: |
        Reusable dropdown field definitions. Each has a type:
        - **Identity** — for Beneficiary Categories (Contact Bio Forms)
        - **Progress** — for Scale Indicators

        Pass `search` to find Dropdowns the way the search box on Manage Dropdowns does: it matches a Dropdown's
        name, its answer choices, or a place it is used (Contact Bio Forms, Project Templates and Event Forms in your
        organisations, choice trackers built on it, and the Surveys those trackers are in), ignoring case.
      operationId: listRatioSets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: search
          in: query
          required: false
          description: Text to look for in the Dropdown's name, answer choices or places used
          schema:
            type: string
          example: housing
      responses:
        "200":
          description: Paginated list of Ratio Sets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedRatioSets'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /ratio_sets/{id}/records_populated:
    get:
      tags: [Ratio Sets]
      summary: Count the records holding answers from a Dropdown
      description: |
        Records populated on Manage Dropdowns. For a Dropdown (Ratio Set), how many Contacts, Stories, Projects and
        Events hold an option chosen from it, and how many Surveys and Ideas are set up with its options, in each
        organisation the user is an Organisation Admin of. `external_usage` says whether records outside those
        organisations hold any, without counting them. A Dropdown can be deleted (`deletable`) once it is in no form
        and no record holds answers from it.
      operationId: getRatioSetRecordsPopulated
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Records holding answers, per organisation
          content:
            application/json:
              schema:
                type: object
                required: [ratio_set_id, title, deletable, records]
                properties:
                  ratio_set_id:
                    type: integer
                    example: 412
                  title:
                    type: string
                    example: Do you have a Freedom Pass?
                  deletable:
                    type: boolean
                    example: false
                  records:
                    type: array
                    items:
                      type: object
                      required: [record, organisations, external_usage]
                      properties:
                        record:
                          type: string
                          enum: [Contacts, Stories, Projects, Events, Surveys, Ideas]
                        organisations:
                          type: array
                          items:
                            type: object
                            required: [id, name, count]
                            properties:
                              id:
                                type: integer
                                example: 16
                              name:
                                type: string
                                example: Riverside Trust
                              count:
                                type: integer
                                example: 1
                        external_usage:
                          type: boolean
                          example: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /sub_ratios:
    get:
      tags: [Sub Ratios]
      summary: List all Sub Ratios (Answer Choices)
      description: |
        Individual answer choices within Ratio Sets. Filter by `ratio_set_ids[]`.

        Use returned IDs as `sub_ratio_id` when submitting Scale Indicator responses in a Story.
      operationId: listSubRatios
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: "ratio_set_ids[]"
          in: query
          schema:
            type: integer
          description: Filter by Ratio Set ID (repeat for multiple)
      responses:
        "200":
          description: Paginated list of Sub Ratios
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSubRatios'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /sub_ratios/{id}:
    get:
      tags: [Sub Ratios]
      summary: Get a single Sub Ratio
      operationId: getSubRatio
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Sub Ratio record
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubRatio'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /ratio_set_choiceables:
    get:
      tags: [Ratio Set Choiceables]
      summary: List all Ratio Set Choiceables
      description: |
        Selection rules for Ratio Sets within forms. Choice types:
        - `single` — one answer only (default)
        - `limited_multiple` — up to `limit` answers
        - `unlimited_multiple` — any number of answers
      operationId: listRatioSetChoiceables
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
        - name: "beneficiary_category_ids[]"
          in: query
          schema:
            type: integer
          description: Filter by Contact Bio Form ID
      responses:
        "200":
          description: Paginated records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedRatioSetChoiceables'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /referral_link_details:
    get:
      tags: [Signup Pages]
      summary: List Signup Pages
      description: |
        The Signup Pages the user can see, with what the **Manage Sign-up Pages** table shows for
        each. A Signup Page (Referral Link Detail in the API) is a public form people fill in to sign
        themselves, and often their family, up; each person becomes a Contact in a Project.

        Organisation Editors see all their Organisation's Signup Pages. Project Editors, Project
        Reporters and Project Observers see the Signup Pages that collect into one of their Projects,
        through the Signup Page itself or one of its individuals or audiences. Organisations with
        Signup Pages switched off show none. Deactivated Signup Pages are included, with
        `active: false`.

        `type` is `fixed` (each person is an individual, A, B, C, filled in a fixed order) or
        `flexible` (people are added per audience, a Beneficiary Role, in any number and order).
        `individuals` lists each individual or audience with its Contact Form, Project, project
        status (Beneficiary State), Surveys and any Wave, and whether a Send Emails email goes to
        that person. `public_link` is the customised link when there is one.
      operationId: listReferralLinkDetails
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          description: Only this Organisation's Signup Pages
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Signup Pages, ordered by name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SignupPageList'
        "401":
          $ref: '#/components/responses/Unauthorized'
    post:
      tags: [Signup Pages]
      summary: Make a Signup Page
      description: |
        Makes a Signup Page as the **New Signup Page** screen does, active unless `active: false`.
        Only Organisation Editors can (403 otherwise). Returns the Signup Page in the list's shape,
        with its `public_link`.

        - **Fixed** (`type: fixed`): Individual A is the person signing up, with `project_id`,
          `beneficiary_state_id` (project status), `contact_form_id` and `surveys`. Each entry in
          `individuals` adds Individual B, C, ... in that order, related to Individual A through
          one of the Organisation's Relationship Categories (`relationship` is its parent or child
          title, e.g. "Child"). The Organisation needs at least one Relationship Category.
        - **Flexible** (`type: flexible`): each entry in `audiences` is a Beneficiary Role
          respondents can add any number of people as, in any order. Each audience must be a role
          with a permitted relationship (role-holder relationship) in the Organisation. The first
          audience's project, status and Contact Form are the Signup Page's own unless given.

        Every Project, Contact Form, Relationship Category and audience must be the
        Organisation's, and each survey one its Project collects (with `wave_id` one of that
        survey's waves). Otherwise the response is 422, naming each problem in `errors`.
      operationId: createReferralLinkDetail
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SignupPageCreateRequest'
            example:
              charity_id: 42
              name: "Family signup"
              type: fixed
              project_id: 7
              beneficiary_state_id: 1
              contact_form_id: 155
              surveys: [{ id: 391, wave_id: 12 }]
              thank_you_message: "Thanks for signing up!"
              individuals:
                - relationship_category_id: 3
                  relationship: "Child"
                  project_id: 8
                  beneficiary_state_id: 1
                  contact_form_id: 156
      responses:
        "201":
          description: The new Signup Page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SignupPage'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You're in the Organisation but aren't an Organisation Editor
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /referral_link_details/{id}/definition:
    get:
      tags: [Signup Pages]
      summary: Get a Signup Page's Form Definition (staff API access)
      description: |
        Returns the Form Definition JSON for a Signup Page — its contact form/survey
        fields, skip logic, branding, and settings — the same document format the
        Offline Collector renderer ingests.

        This is the **staff, token-authenticated** variant: standard `X-User-Email` /
        `X-User-Token` headers, scoped to Signup Pages belonging to a charity the
        authenticated user has access to. Useful for testing or integration work
        without a browser session.

        When any **Send Emails** email is switched on for the Signup Page, the response also has
        `send_emails`: for each individual (or audience) whether its confirmation email is on and,
        if so, its subject line, body, merge tags (the `{{Field name}}` personalisation tags, each
        matched to the Contact Form field's ID and type, or `null` when no field matches), the
        email fields it is sent to and whose submitted details are included; and the same for
        Additional Recipients, whose emails aren't personalised. Without `send_emails`, no email
        is on. The anonymous device-fetch variant never includes it.
      operationId: getReferralLinkDetailDefinition
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Form Definition JSON
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StaffFormDefinition'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          description: Signup Page not found, or not accessible to the current user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /referral_link_details/{id}/email_settings:
    put:
      tags: [Signup Pages]
      summary: Set a Signup Page's Send Emails settings
      description: |
        Saves what the **Send Emails** screen saves for a Signup Page: the confirmation email each
        individual (or audience) receives after the Signup Page is completed, and the email sent
        to Additional Recipients. Name each individual by the `label` that
        `GET /referral_link_details/{id}/definition` returns (e.g. `Individual A`); individuals left
        out keep their settings. Use `{{Field name}}` merge tags in the subject line and body to
        personalise an individual's email with their answers. Additional Recipients' emails aren't
        personalised.

        Only Organisation Editors can set these (403 otherwise), and the Organisation must have email
        messaging switched on in its Preferences (422 otherwise). Everything is saved or nothing is.
        Returns the new `send_emails` in the definition's shape, including when every email is off.
      operationId: updateReferralLinkDetailEmailSettings
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SignupPageEmailSettingsRequest'
            example:
              individuals:
                - label: "Individual A"
                  enabled: true
                  subject_line: "Welcome to the club, {{name}}"
                  message_body: "<p>Hi {{name}}, thanks for signing up.</p>"
                  recipient_field_ids: [4521]
                  include_submission_details: true
                  included_individuals: ["Individual A", "Individual B"]
                - label: "Individual B"
                  enabled: false
              additional_recipients:
                enabled: true
                recipients: ["office@example.org"]
                subject_line: "New family signup"
                message_body: "<p>A family has signed up.</p>"
                include_submission_details: true
                included_individuals: ["Individual A"]
      responses:
        "200":
          description: The Signup Page's Send Emails settings, as saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  send_emails:
                    $ref: '#/components/schemas/SignupPageSendEmails'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You can see the Signup Page but aren't an Organisation Editor
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /offline_collector_definition:
    get:
      tags: [Signup Pages]
      summary: Get a Signup Page's Form Definition (offline device fetch)
      description: |
        The **anonymous** variant of the Form Definition endpoint, called automatically
        by the installed Offline Collector PWA (`/offline/:token`) when it first loads.
        There is no Devise session and no `X-User-Email`/`X-User-Token` pair involved —
        the query-param token stands in for both identifying the Signup Page and
        authorising the request.

        The response is identical to the staff API variant, **plus one extra key**:
        `submission_credential` — the bearer token the device later uses to post the
        completed submission back via `POST /referral_submissions`.
      operationId: getOfflineCollectorDefinition
      security: []
      parameters:
        - name: token
          in: query
          required: true
          schema:
            type: string
          description: The offline collector token embedded in the Signup Page's "Offline QR Code" / "Offline version" links
      responses:
        "200":
          description: Form Definition JSON, including submission_credential
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/FormDefinition'
                  - type: object
                    properties:
                      submission_credential:
                        $ref: '#/components/schemas/SubmissionCredential'
        "401":
          description: Token unknown, or the Signup Page has been deactivated since the token was issued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "unauthorized"

  /event_categories:
    get:
      tags: [Event Formats]
      summary: List Event Formats
      operationId: listEventFormats
      description: |
        Lists the Event Formats (Event Categories in the API) of the organisations you are an
        **Organisation Admin** of, as on the Manage Event Formats page. Use it to find the `id`
        for **Delete an Event Format**, and to see beforehand whether deletion will be allowed.

        - Pass `charity_id` to list one organisation's Event Formats.
        - Only Organisation Admins can list Event Formats. Anyone else gets `403`, as does a
          `charity_id` of an organisation you don't administer.
        - `events_count` and `projects_count` say what is blocking deletion, and
          `delete_blocked_reason` gives the same reason **Delete an Event Format** would return.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema:
            type: integer
          description: Only this Organisation's (Charity's) Event Formats
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Event Formats
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedEventFormats'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - id: 4521
                    name: "Workshops"
                    is_default: true
                    charity_id: 123
                    created_at: "2026-03-02T10:15:00.000Z"
                    updated_at: "2026-09-14T08:30:00.000Z"
                    events_count: 3
                    projects_count: 2
                    can_delete: false
                    delete_blocked_reason: "This Event Format can't be deleted because it has 3 events. Delete or move those events first. This Event Format can't be deleted because it is added to 2 projects. Remove it from those projects first."
                  - id: 4530
                    name: "Drop-in Sessions"
                    is_default: false
                    charity_id: 123
                    created_at: "2026-10-01T12:00:00.000Z"
                    updated_at: "2026-10-01T12:00:00.000Z"
                    events_count: 0
                    projects_count: 0
                    can_delete: true
                    delete_blocked_reason: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are not an Organisation Admin (of the organisation in `charity_id`, if given)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only an Organisation Admin can list Event Formats."

    post:
      tags: [Event Formats]
      summary: Create an Event Format
      operationId: createEventFormat
      description: |
        Creates an Event Format (Event Category in the API), as **Create Event Format** on the
        Manage Event Formats page does. Only an **Organisation Admin** of `charity_id` may create one.
        Send `guest_status_ids` (the Guest Statuses its events use, in order). If you leave it out, the
        new Event Format gets the organisation's Invited then Cancelled Guest Statuses, where it has them.

        **Add to Calendar email** (all optional):
        - `send_add_to_calendar_email`: email each guest (Contact) added to an event of this format, so
          they can add it to their calendar. The organisation must have email messaging turned on.
        - `allow_guests_to_cancel`: let guests cancel from that email.
        - `cancellation_guest_status_id`: the Guest Status a guest who cancels is moved to. Required
          when `allow_guests_to_cancel` is true, and must be one of `guest_status_ids`.

        **Appointment settings** (all optional):
        - `appointment_type`: `one_to_one` (shown as "Appointment": one Contact, with one or more staff members), `group`, or `null` for "Not an appointment" (the default).
          An appointment is with one Contact, and can have more than one staff member.
        - `default_length_minutes`: how long an event of this format usually lasts, in 5-minute
          steps up to 1440, or `null`.
        - `preparation_minutes` and `debrief_minutes`: time a colleague needs before and after
          each appointment, 0 to 1440 (default 0). A colleague won't be offered another
          appointment in this time.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/EventFormatInput'
                - type: object
                  required: [charity_id, name]
                  properties:
                    charity_id:
                      type: integer
                      description: The Organisation (Charity) the Event Format belongs to
            example:
              charity_id: 123
              name: "Therapy session"
              guest_status_ids: [55, 56]
              appointment_type: one_to_one
              default_length_minutes: 60
              preparation_minutes: 30
              debrief_minutes: 30
              send_add_to_calendar_email: true
              allow_guests_to_cancel: true
              cancellation_guest_status_id: 56
      responses:
        "201":
          description: The Event Format was created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventFormatDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are not an Organisation Admin of `charity_id`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only an Organisation Admin can manage Event Formats."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /event_categories/{id}:
    get:
      tags: [Event Formats]
      summary: Get an Event Format
      operationId: getEventFormat
      description: |
        Returns one Event Format (Event Category in the API) with its settings, Guest Statuses,
        projects and appointment settings. Only an **Organisation Admin** of its organisation may
        read it; an Event Format of an organisation you are not in returns `404`.

        **Appointment settings** (all optional):
        - `appointment_type`: `one_to_one` (shown as "Appointment": one Contact, with one or more staff members), `group`, or `null` for "Not an appointment" (the default).
          An appointment is with one Contact, and can have more than one staff member.
        - `default_length_minutes`: how long an event of this format usually lasts, in 5-minute
          steps up to 1440, or `null`.
        - `preparation_minutes` and `debrief_minutes`: time a colleague needs before and after
          each appointment, 0 to 1440 (default 0). A colleague won't be offered another
          appointment in this time.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Event Format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventFormatDetail'
              example:
                id: 4521
                name: "Therapy session"
                is_default: false
                charity_id: 123
                attendance_form_id: null
                survey_kiosk_enabled: false
                survey_kiosk_registration_enabled: false
                enable_guest_fields: false
                enable_guest_booking_form: false
                assign_guests_to_workers_setting: "default"
                suggest_shortened_address: false
                apply_shortened_address: false
                enable_event_roles: false
                event_role_ids_for_event_managers_and_workers: []
                event_role_ids_for_guests: []
                appointment_type: one_to_one
                default_length_minutes: 60
                preparation_minutes: 30
                debrief_minutes: 30
                guest_statuses:
                  - { id: 55, name: "Invited" }
                project_ids: [987]
                created_at: "2026-11-14T08:00:00.000Z"
                updated_at: "2026-11-14T08:00:00.000Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are not an Organisation Admin of the organisation that owns this Event Format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only an Organisation Admin can manage Event Formats."
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Event Formats]
      summary: Edit an Event Format
      operationId: updateEventFormat
      description: |
        Changes an Event Format's settings, as **Edit** on the Manage Event Formats page does. Only
        the settings you send change. Only an **Organisation Admin** of its organisation may edit it.

        **Organisation default:** send `is_organisation_default: true` to make this the organisation's
        default Event Format, as **Make default** on the Manage Event Formats page does. The default
        is added to a Project whenever events are turned on there (on Project Preferences, by adding
        the Events app to the Project, or by a Project Automation), unless the Project's Event Formats
        are chosen at the same time. It moves from any other Event Format, so an organisation has at
        most one. `false` stops this Event Format being the default.

        **Add to Calendar email** (all optional): `send_add_to_calendar_email`, `allow_guests_to_cancel`
        and `cancellation_guest_status_id`, as on Create. The Guest Status used for cancellations must
        stay one of the Event Format's Guest Statuses, so remove it from `guest_status_ids` only after
        turning `allow_guests_to_cancel` off.

        **Appointment settings** (all optional):
        - `appointment_type`: `one_to_one` (shown as "Appointment": one Contact, with one or more staff members), `group`, or `null` for "Not an appointment" (the default).
          An appointment is with one Contact, and can have more than one staff member.
        - `default_length_minutes`: how long an event of this format usually lasts, in 5-minute
          steps up to 1440, or `null`.
        - `preparation_minutes` and `debrief_minutes`: time a colleague needs before and after
          each appointment, 0 to 1440 (default 0). A colleague won't be offered another
          appointment in this time.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/EventFormatInput'
                - type: object
                  properties:
                    is_organisation_default:
                      type: boolean
                      description: true makes this the organisation's default Event Format; false stops it being the default
            example:
              appointment_type: group
              default_length_minutes: 90
              preparation_minutes: 15
              debrief_minutes: 15
              is_organisation_default: true
      responses:
        "200":
          description: The edited Event Format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventFormatDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are not an Organisation Admin of the organisation that owns this Event Format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only an Organisation Admin can manage Event Formats."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Event Formats]
      summary: Delete an Event Format
      operationId: deleteEventFormat
      description: |
        Permanently deletes an Event Format (Event Category in the API). This is the
        same action as **Delete** in the Actions menu on the Manage Event Formats page,
        and runs through the same permission and blocking rules.

        - Only an **Organisation Admin** of the organisation that owns the Event Format
          may delete it. Other members of that organisation get `403`.
        - An Event Format belonging to an organisation you are not a member of returns
          `404`, as does an unknown id.
        - Deletion is refused with `422` while the Event Format still has any events, or
          is still added to any project. The `error` gives the reason and the counts.
        - Default Event Formats (Appointments, Classes, Conferences, Gatherings, Meetings,
          Other Events, Sessions, Workshops) can be deleted under the same rules.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Event Format was deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  message:
                    type: string
              example:
                id: 4521
                message: "Event Format was successfully deleted."
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are not an Organisation Admin of the organisation that owns this Event Format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Only an Organisation Admin can delete Event Formats."
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: The Event Format has events or is added to projects, so it can't be deleted yet
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "This Event Format can't be deleted because it has 3 events. Delete or move those events first. This Event Format can't be deleted because it is added to 2 projects. Remove it from those projects first."
  /event_categories/{id}/projects:
    post:
      tags: [Event Formats]
      summary: Add an Event Format to a project
      operationId: addEventFormatToProject
      description: |
        Adds an Event Format (Event Category in the API) to a project, so the project's events can
        use it, as **Add to projects** on the Manage Event Formats page does. It also turns events
        on for the project. Adding one that is already added does nothing and returns `200`.

        - Only an **Organisation Admin** of the organisation that owns the Event Format may (`403`).
        - The project must be in the same organisation (`422`). An Event Format or project in an
          organisation you are not a member of returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_id]
              properties:
                project_id:
                  type: integer
            example:
              project_id: 301
      responses:
        "201":
          description: Added
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventFormatProject'
              example:
                event_category_id: 4530
                project_id: 301
                status: added
        "200":
          description: It was already added
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventFormatProject'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventFormatAdminOnly'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: The project isn't in the Event Format's organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "That project isn't in the Event Format's organisation."
  /event_categories/{id}/projects/{project_id}:
    delete:
      tags: [Event Formats]
      summary: Remove an Event Format from a project
      operationId: removeEventFormatFromProject
      description: |
        Takes an Event Format off a project, so new events in the project can't use it. Events
        that already use it keep it. Same permissions as **Add an Event Format to a project**;
        an Event Format that isn't added to the project returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Removed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventFormatProject'
              example:
                event_category_id: 4530
                project_id: 301
                status: removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventFormatAdminOnly'
        "404":
          $ref: '#/components/responses/NotFound'
  /event_catalogues:
    get:
      tags: [Event Catalogues]
      summary: List an organisation's Event Catalogues
      operationId: listEventCatalogues
      description: |
        Lists an organisation's Event Catalogues, as on the Manage Event Catalogues page. An Event
        Catalogue is a public, bookable list of the organisation's upcoming events, chosen by its
        filters, at its `public_url` (which can also be embedded on a website). Contacts can also
        see a catalogue on their Contacts' Portal, if the project allows it (see **Get who can see
        an Event Catalogue in a project**).

        Organisation Admins, Organisation Reporters and Project Managers of the organisation's
        projects can list them; anyone else in the organisation gets `403`.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity)
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Event Catalogues, by name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedEventCatalogues'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventCatalogueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Event Catalogues]
      summary: Create an Event Catalogue
      operationId: createEventCatalogue
      description: |
        Creates an Event Catalogue, as **New Event Catalogue** on the Manage Event Catalogues page
        does. Organisation Admins and Project Managers of the organisation's projects may.

        A catalogue only ever shows events that haven't started yet, that have a Signup Page and
        whose listing is turned on, and that match `filters`. With no filters it shows every such
        event in the organisation.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, name]
              properties:
                charity_id:
                  type: integer
                name:
                  type: string
                filters:
                  $ref: '#/components/schemas/EventCatalogueFilters'
            example:
              charity_id: 123
              name: "Drop-ins"
              filters:
                project_ids: [301]
                event_category_ids: [4530]
      responses:
        "201":
          description: The Event Catalogue was created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventCatalogueDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventCatalogueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /event_catalogues/{id}:
    get:
      tags: [Event Catalogues]
      summary: Get an Event Catalogue
      operationId: getEventCatalogue
      description: |
        Reads one Event Catalogue, with `upcoming_events_count`, the number of events its public
        page shows now. Same permissions as **List an organisation's Event Catalogues**; a
        catalogue of an organisation you are not in returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Event Catalogue
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventCatalogueDetail'
              example:
                id: 77
                name: "Drop-ins"
                charity_id: 123
                filters:
                  project_ids: [301]
                public_url: "https://makerble.com/events-catalogue/Zx9s1Qk2vB7nT4pR"
                created_at: "2026-10-22T12:00:00.000Z"
                updated_at: "2026-10-22T12:00:00.000Z"
                upcoming_events_count: 9
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventCatalogueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Event Catalogues]
      summary: Edit an Event Catalogue
      operationId: updateEventCatalogue
      description: |
        Renames an Event Catalogue or replaces its filters. Give only what changes; `filters`,
        when given, replaces them all. Its `public_url` stays the same. Same permissions as
        **Create an Event Catalogue**.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                filters:
                  $ref: '#/components/schemas/EventCatalogueFilters'
            example:
              name: "Evening drop-ins"
      responses:
        "200":
          description: The Event Catalogue was changed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventCatalogueDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventCatalogueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /event_catalogues/{id}/projects/{project_id}/access:
    get:
      tags: [Event Catalogues]
      summary: Get who can see an Event Catalogue in a project
      operationId: getEventCatalogueAccess
      description: |
        Says which of a project's Contacts can see an Event Catalogue on their Contacts' Portal, as
        the project's Event Catalogues page shows it: `every_enrolled` (every Contact currently
        Enrolled in the project) or `specific` (only the Contacts in `contact_ids`). Project
        Managers and Reporters of the project, and the organisation's Admins and Reporters, may
        read it. A catalogue that doesn't show the project's events, or isn't the project's
        organisation's, returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Who can see the catalogue
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventCatalogueAccess'
              example:
                event_catalogue_id: 77
                project_id: 301
                mode: specific
                contact_ids: [9001, 9002]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventCatalogueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Event Catalogues]
      summary: Change who can see an Event Catalogue in a project
      operationId: updateEventCatalogueAccess
      description: |
        Changes who in a project can see an Event Catalogue on the Contacts' Portal. Only the
        project's Project Managers and the organisation's Admins may. Switching to
        `every_enrolled` drops the ticked Contacts. Contacts can only be ticked under `specific`,
        and must be in the project.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                mode:
                  type: string
                  enum: [every_enrolled, specific]
                add_contact_ids:
                  type: array
                  items:
                    type: integer
                remove_contact_ids:
                  type: array
                  items:
                    type: integer
            example:
              mode: specific
              add_contact_ids: [9001]
      responses:
        "200":
          description: Who can now see the catalogue
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventCatalogueAccess'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/EventCatalogueForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /projects/{project_id}/portal_links:
    get:
      tags: [Contacts' Portal]
      summary: List Contacts' Portal links in a project
      operationId: listPortalLinks
      description: |
        Lists the project's Contacts who can see at least one Event Catalogue on the Contacts'
        Portal, where Contacts book onto events, as the project's Portal Links page shows them:
        whether each has a Portal link, when it was last sent and how, and whether they can be
        sent it by email or SMS. The link itself is never returned, because it signs the Contact
        in to their Portal. Project Managers and Reporters of the project, and the organisation's
        Admins and Reporters, may read it. To give a Contact access, change who can see an Event
        Catalogue in the project (`PATCH /event_catalogues/{id}/projects/{project_id}/access`).
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: One page of Contacts, by name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedPortalLinks'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - contact_id: 9001
                    name: Amara Diallo
                    link_status: active
                    last_sent_at: "2026-10-20T09:15:00Z"
                    last_sent_channel: email
                    can_email: true
                    can_sms: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/PortalLinksForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
  /projects/{project_id}/portal_links/send:
    post:
      tags: [Contacts' Portal]
      summary: Send Contacts their Portal link
      operationId: sendPortalLinks
      description: |
        Sends each Contact their own link to the Contacts' Portal by email or SMS, as the Send
        button on the project's Portal Links page does, creating the link if they don't have one
        yet. Every Contact must be in the project and able to see at least one of its Event
        Catalogues; otherwise nothing is sent and the response says why. Contacts with no email
        address (or, for SMS, no mobile number) are skipped and named in `skipped`. Only the
        project's Project Managers and the organisation's Admins may send links.
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [contact_ids, channel]
              properties:
                contact_ids:
                  type: array
                  items:
                    type: integer
                channel:
                  type: string
                  enum: [email, sms]
            example:
              contact_ids: [9001, 9002]
              channel: email
      responses:
        "200":
          description: The links were queued to send
          content:
            application/json:
              schema:
                type: object
                properties:
                  sent:
                    type: integer
                    description: How many Contacts were sent their link
                  skipped:
                    type: array
                    description: Names of the Contacts with no way to receive it
                    items:
                      type: string
              example:
                sent: 1
                skipped: [Ben Okafor]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/PortalLinksForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /events:
    get:
      tags: [Events]
      summary: List events
      operationId: listEvents
      description: |
        Lists the events you can see, as on the **Manage Events** page, soonest first.
        Organisation Admins see every event in their organisation; other users see the events
        of the projects they are an editor of and the events they are an Event Manager or Event
        Worker at.

        Filter by `project_id`, `event_category_id` (Event Format), `event_type`, a
        `start_date`/`end_date` range (the event's start falls between them), or
        `master_event_id` to list every event in one recurring series (the master event and
        its subsequent events). Pass `charity_id` to list one organisation; one you are not a
        member of returns `404`.

        Filter by the answers on the events' **Event Creation Form** (the custom fields and
        Dropdowns of their Event Format) with `form_field_filters`, as the "Event Creation Form
        fields" section of the Filter Events panel does. Get the keys from
        `GET /event_filter_fields`. Values: text the answer contains for a Text or Email Address
        field; digits for a Telephone field; `yes` or `no` for a Tickbox, Attachment or
        Signature field; `<key>_from` and/or `<key>_to` for a Number, Date (`YYYY-MM-DD`) or
        Time (`HH:MM`) range, inclusive; a list of answer choice (Sub Ratio) ids for a Dropdown,
        matching an event that has any of them. Every key given must match.

        `sort` orders the whole list, not just one page, by those fields: a `sort_key` from
        `GET /event_filter_fields` and optionally `asc` (the default) or `desc`, several
        separated by commas. Blank answers come last. An unknown filter or sort key returns `422`.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema:
            type: integer
          description: Only this Organisation's (Charity's) events
        - name: project_id
          in: query
          required: false
          schema:
            type: integer
        - name: event_category_id
          in: query
          required: false
          schema:
            type: integer
          description: Only events of this Event Format (Event Category)
        - name: event_type
          in: query
          required: false
          schema:
            type: string
            enum: [one-off, master, subsequent]
          description: "`master` is the first event of a recurring series; `subsequent` are the rest of the series"
        - name: start_date
          in: query
          required: false
          schema:
            type: string
            format: date
          description: Only events starting on or after this date
        - name: end_date
          in: query
          required: false
          schema:
            type: string
            format: date
          description: Only events starting on or before this date
        - name: master_event_id
          in: query
          required: false
          schema:
            type: integer
          description: Only the events of this recurring series
        - name: form_field_filters
          in: query
          required: false
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties: true
          example:
            custom_field_12: archery
            custom_field_15_from: 5
            custom_field_15_to: 10
            ratio_set_7: [31, 32]
          description: Event Creation Form answers to match, keyed by the `filter_keys` of `GET /event_filter_fields`, e.g. `form_field_filters[custom_field_12]=archery&form_field_filters[ratio_set_7][]=31`
        - name: sort
          in: query
          required: false
          schema:
            type: string
          example: "custom_field_12 desc, ratio_set_7 asc"
          description: "Sort by Event Creation Form fields: `sort_key` values from `GET /event_filter_fields`, each optionally followed by `asc` or `desc`. Default: soonest first"
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of events
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedEvents'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 9120
                    name: "Yoga 2"
                    charity_id: 123
                    start_datetime: "2030-01-15T14:00:00.000Z"
                    end_datetime: "2030-01-15T15:00:00.000Z"
                    timezone: "Europe/London"
                    location: "Main Hall"
                    event_type: "subsequent"
                    listing_enabled: false
                    created_at: "2026-10-01T09:00:00.000Z"
                    updated_at: "2026-10-01T09:00:00.000Z"
                    project: { id: 456, name: "Youth Club" }
                    event_category: { id: 4521, name: "Workshops" }
                    master_event_id: 9119
                    guests_count: 12
                    managers_count: 1
                    workers_count: 2
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

    post:
      tags: [Events]
      summary: Create an event
      operationId: createEvent
      description: |
        Creates a one-off event, or a recurring series when `recurring_schedule` and
        `recurring_end_date` are given: the master event plus every subsequent event up to the
        Recurring End Date, as the Create Event form does.

        Work out the ids first: list the Event Formats you can use in the project
        (`GET /projects/{id}/event_categories`), then get the form for the one you choose
        (`GET /projects/{id}/event_form`). Every id in the request is checked against that form.
        Problems are returned together as `422`.

        Times are ISO 8601. A time without an offset is a local time in `timezone`, an IANA
        time zone name that defaults to yours; daylight saving is worked out for you.
        You become the Event Manager unless you give `manager_ids`.

        Not handled by the API: an event image, and Event Steps (project automations).
        To add a Contact as a guest, use the guests endpoints.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventCreateRequest'
            examples:
              recurringSeries:
                summary: A weekly series with a Dropdown, a custom field and a Signup Page
                value:
                  project_id: 456
                  event_category_id: 42
                  name: "Youth Club"
                  start_datetime: "2030-01-08T18:00"
                  end_datetime: "2030-01-08T20:00"
                  timezone: "Europe/London"
                  location: "Main Hall"
                  custom_fields: { "77": "B-114" }
                  dropdowns: { "3012": [88101] }
                  signup_page_id: 310
                  guest_status_for_signup_id: 7
                  capacity:
                    guests: fixed
                    max_guests: 20
                    allow_signup_after_full: true
                    guest_status_after_full_id: 8
                    confirmation_message_after_full: "We're full, but we'll let you know if a place comes up."
                  recurring_schedule: { frequency: weekly, interval: 1, days_of_week: [tuesday] }
                  recurring_end_date: "2030-03-26"
      responses:
        "201":
          description: The event, as Get an event returns it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /event_filter_fields:
    get:
      tags: [Events]
      summary: List the fields events can be filtered and sorted by
      operationId: listEventFilterFields
      description: |
        Lists the custom fields and Dropdowns used on the **Event Creation Forms** of your
        organisations' Event Formats, alphabetically, as the "Event Creation Form fields"
        section of the Filter Events panel on the Manage Events page lists them. Use their
        `filter_keys` in the `form_field_filters` of `GET /events`, and their `sort_key` in its
        `sort`.

        `data_type` is one of `text`, `email_address`, `telephone`, `number`, `date`, `time`,
        `tickbox`, `file` (Attachment), `signature` or `dropdown`. A Number, Date or Time field
        has two filter keys, `<key>_from` and `<key>_to`. A Dropdown's filter takes answer
        choice ids: list them with `GET /event_filter_fields/{id}/choices`.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema:
            type: integer
          description: Only this Organisation's (Charity's) Event Creation Forms
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of fields
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: { type: integer }
                  page_size: { type: integer }
                  page_count: { type: integer }
                  total_count: { type: integer }
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        key: { type: string }
                        id: { type: integer, description: The custom field or Dropdown (Ratio Set) id }
                        name: { type: string }
                        data_type: { type: string }
                        filter_keys: { type: array, items: { type: string } }
                        filter_hint: { type: string }
                        sort_key: { type: string }
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - key: ratio_set_7
                    id: 7
                    name: Activity
                    data_type: dropdown
                    filter_keys: [ratio_set_7]
                    filter_hint: A list of answer choice ids; an event matches if it has any of them
                    sort_key: ratio_set_7
                  - key: custom_field_15
                    id: 15
                    name: Age
                    data_type: number
                    filter_keys: [custom_field_15_from, custom_field_15_to]
                    filter_hint: A number for either or both ends of the range, inclusive
                    sort_key: custom_field_15
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /event_filter_fields/{id}/choices:
    get:
      tags: [Events]
      summary: List a Dropdown's answer choices for filtering events
      operationId: listEventFilterFieldChoices
      description: |
        Lists the answer choices (Sub Ratios) of a Dropdown (Ratio Set) from
        `GET /event_filter_fields`, alphabetically, as the Filter Events panel's typeahead
        offers them. Pass their ids in `form_field_filters[ratio_set_<id>]` of `GET /events`.
        A Dropdown that isn't on an Event Creation Form of your organisations returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: The Dropdown (Ratio Set) id
        - name: query
          in: query
          required: false
          schema:
            type: string
          description: Only answer choices whose name contains this, ignoring case
        - name: charity_id
          in: query
          required: false
          schema:
            type: integer
          description: Only this Organisation's Event Creation Forms
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of answer choices
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: { type: integer }
                  page_size: { type: integer }
                  page_count: { type: integer }
                  total_count: { type: integer }
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: integer }
                        name: { type: string }
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - { id: 31, name: Archery }
                  - { id: 32, name: Boxing }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /events/{id}:
    get:
      tags: [Events]
      summary: Get an event
      operationId: getEvent
      description: |
        One event, with everything shown on its event page and Edit Event page: its Event
        Format's custom fields and Dropdown answers, the Signup Page, the Self Check-in Survey
        and Wave, capacity and timesheet settings, listing details, and the links guests use to
        sign up and check themselves in. For a master event (the first in a recurring series)
        it also returns the Recurring Schedule, the Recurring End Date and how many events are
        in the series.

        Anyone who can open the event page can read it. A member of the organisation who can't
        gets `403`; an event of another organisation, or an unknown id, returns `404`.
        `can_edit` and `can_delete` say whether you may change or delete it.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The event
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
              example:
                id: 9119
                name: "Yoga 1"
                charity_id: 123
                start_datetime: "2030-01-08T14:00:00.000Z"
                end_datetime: "2030-01-08T15:00:00.000Z"
                timezone: "Europe/London"
                location: "Main Hall"
                event_type: "master"
                listing_enabled: true
                created_at: "2026-10-01T09:00:00.000Z"
                updated_at: "2026-10-01T09:00:00.000Z"
                project: { id: 456, name: "Youth Club" }
                event_category: { id: 4521, name: "Workshops" }
                master_event_id: null
                guests_count: 12
                managers_count: 1
                workers_count: 2
                can_edit: true
                can_delete: true
                recurring_schedule:
                  rule: { rule_type: "IceCube::WeeklyRule", interval: 1, validations: { day: [2] } }
                  description: "Weekly on Tuesdays"
                recurring_end_date: "2030-03-26"
                series_events_count: 12
                custom_fields:
                  - { id: 77, name: "Room booking reference", value: "B-114" }
                dropdowns:
                  - id: 3012
                    name: "Session type"
                    answer_choices: [{ id: 88101, name: "Drop-in" }]
                signup_page: { id: 310, name: "Youth Club signup" }
                self_check_in:
                  survey: { id: 5501, name: "Session feedback", project_survey_id: 9921 }
                  wave: null
                capacity:
                  guests: "fixed"
                  max_guests: 20
                  allow_signup_after_full: true
                  guest_status_for_signup_id: 41
                  guest_status_after_full_id: 43
                  confirmation_message_after_full: "Unfortunately we have no more space, however we will keep your details on file and let you know if a space becomes available."
                  thank_you_message: "Your registration has been received. Thank you."
                  workers: "unlimited"
                  max_workers: 0
                  timesheets_for_workers: true
                  timesheets_for_guests: false
                listing:
                  listing_enabled: true
                  location: "Main Hall"
                  description: "<p>Gentle yoga for all abilities.</p>"
                  image_url: null
                links:
                  self_check_in: "https://app.makerble.com/events/9119/kiosk"
                  signup: "https://app.makerble.com/charities/123/projects/456/beneficiaries/new?event_id=9119&redirect_to_check_in=false&referral_link_detail_id=310"
                  signup_and_self_check_in: "https://app.makerble.com/charities/123/projects/456/beneficiaries/new?event_id=9119&referral_link_detail_id=310"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: You are in the organisation but may not see this event
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "You don't have permission to see this event."
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Events]
      summary: Update an event
      operationId: updateEvent
      description: |
        Changes the fields you give and leaves the rest as they are; Dropdowns you don't mention
        keep their answers. Anyone who can open the Edit Event page can update the event.

        For a master event (the first in a recurring series), `apply_to: all_events_in_series`
        also applies the change to every subsequent event, like the form's "Update this event
        and all future events" button. The default is `this_event`.

        Locked after creation, as on the Edit Event page: the project, a series' time zone, and
        a master event's start and end (they set the times of the whole series).

        To change a series' Recurring Schedule or Recurring End Date, as the Edit Event Series
        page does, send `recurring_schedule` and/or `recurring_end_date` on the master event.
        Call Preview a series schedule change first: it lists the events that would no longer
        fit the new schedule. Each of those must be listed in `keep_event_ids` or
        `delete_event_ids`, or nothing changes and you get `422`. Missing dates are created,
        and the series is renumbered in date order.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventUpdateRequest'
            example:
              name: "Evening Youth Club"
              location: "Hall 3"
              apply_to: all_events_in_series
      responses:
        "200":
          description: The event, as Get an event returns it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

    delete:
      tags: [Events]
      summary: Delete an event
      operationId: deleteEvent
      description: |
        Deletes an event, as the event page's Delete Event does. Deleting a master event (the
        first of a recurring series) deletes the whole series. For a later event in a series,
        `delete_option` chooses what goes: `this_event` (the default),
        `current_and_upcoming_series_events`, or `all_series_events`. Anyone who can edit the
        event can delete it. Deleting an event also deletes what is recorded against it.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: delete_option
          in: query
          required: false
          schema: { type: string, enum: [this_event, current_and_upcoming_series_events, all_series_events], default: this_event }
      responses:
        "200":
          description: The ids of the deleted events
          content:
            application/json:
              schema:
                type: object
                required: [deleted_event_ids]
                properties:
                  deleted_event_ids: { type: array, items: { type: integer } }
              example:
                deleted_event_ids: [9120, 9121]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /events/{id}/series_schedule_preview:
    post:
      tags: [Events]
      summary: Preview a series schedule change
      operationId: previewEventSeriesScheduleChange
      description: |
        Shows what a new Recurring Schedule or Recurring End Date would do to a recurring series,
        without changing anything, as the Edit Event Series page does before you save. Send it to
        the master event (the first event of the series). Leave out either field to keep its
        current value.

        `required_dates` lists every date the new schedule needs, with the event already on that
        date or `exists: false` for one that would be created. `no_longer_fitting_events` lists
        the events that don't fit the new schedule, and whether each has Stories or timesheets
        recorded against it. Pass each of their ids in `keep_event_ids` or `delete_event_ids`
        when you make the change with Update an event.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeriesScheduleChangeRequest'
            example:
              recurring_schedule: { frequency: weekly, interval: 2, days_of_week: [tuesday] }
              recurring_end_date: "2030-02-05"
      responses:
        "200":
          description: What the change would do
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeriesSchedulePreview'
              example:
                master_event_id: 9119
                recurring_schedule: { frequency: weekly, interval: 2, days_of_week: [tuesday], days_of_month: [], description: "Every 2 weeks on Tuesdays" }
                recurring_end_date: "2030-02-05"
                required_dates:
                  - { start_datetime: "2030-01-08T18:00:00.000Z", event_id: 9119, exists: true }
                  - { start_datetime: "2030-01-22T18:00:00.000Z", event_id: 9121, exists: true }
                  - { start_datetime: "2030-02-05T18:00:00.000Z", event_id: null, exists: false }
                no_longer_fitting_events:
                  - { id: 9120, name: "Youth Club 2", start_datetime: "2030-01-15T18:00:00.000Z", has_stories: false, has_timesheets: false }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /registers:
    get:
      tags: [Events]
      summary: List my Registers
      operationId: listRegisters
      description: |
        The Registers of the recurring event series the user staffs: each series in which they
        are an Event Worker or Event Manager of an event starting today or later, with that next
        event, soonest first. This is the list the Registers tab of the Events tile on My Homepage
        shows.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: A page of series
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          type: object
                          properties:
                            master_event_id: { type: integer }
                            name: { type: string, description: The series name, without the event's number }
                            project:
                              type: object
                              properties: { id: { type: integer }, name: { type: string } }
                            next_event:
                              type: object
                              properties:
                                id: { type: integer }
                                name: { type: string }
                                start_datetime: { type: string, format: date-time }
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data: [{ master_event_id: 812, name: Ruby Training, project: { id: 41, name: Coding Club }, next_event: { id: 815, name: Ruby Training 4, start_datetime: "2026-11-23T10:00:00Z" } }]
        "401":
          $ref: '#/components/responses/Unauthorized'
  /events/{id}/register:
    get:
      tags: [Events]
      summary: Get an event series' Register
      operationId: getEventRegister
      description: |
        The Register page of a recurring event series: a row per guest (Contact) invited to any
        event in the series, in alphabetical order, and for every event in the series, in date
        order, that guest's answers in their latest attendance Story for it. The attendance Survey
        is the one set on the master event's Event Format. Activity metrics are counted once per
        event, so they are returned as each event's `totals` rather than per guest. `id` is any
        event in the series; a one-off event has no register. Anyone who can open the event page
        can read it.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The series and a page of its guests
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      master_event_id: { type: integer }
                      name: { type: string, description: "The series name, without the event's number" }
                      schedule: { type: string, example: Weekly on Mondays from 2nd November 2026 to 14th December 2026 }
                      project:
                        type: object
                        properties: { id: { type: integer }, name: { type: string } }
                      survey:
                        type: object
                        nullable: true
                        description: The attendance Survey, or null when the Event Format has none
                        properties: { id: { type: integer }, name: { type: string } }
                      columns:
                        type: array
                        items:
                          type: object
                          properties:
                            current_field_id: { type: integer }
                            name: { type: string }
                            type: { type: string, enum: [scale, binary, value, participation, custom_field] }
                            compulsory: { type: boolean }
                      events:
                        type: array
                        items:
                          type: object
                          properties:
                            id: { type: integer }
                            name: { type: string }
                            start_datetime: { type: string, format: date-time }
                            full: { type: boolean, description: The event has reached its guest capacity }
                            totals:
                              type: array
                              items:
                                type: object
                                properties:
                                  current_field_id: { type: integer }
                                  name: { type: string }
                                  total: { type: number }
                      data:
                        type: array
                        items:
                          type: object
                          properties:
                            contact_id: { type: integer }
                            name: { type: string }
                            events:
                              type: array
                              items:
                                type: object
                                properties:
                                  event_id: { type: integer }
                                  in_event: { type: boolean }
                                  story_id: { type: integer, nullable: true }
                                  answers:
                                    type: object
                                    description: Answers by current_field_id; empty when the guest is not in the event
                                    additionalProperties: { type: string, nullable: true }
              example:
                master_event_id: 812
                name: Ruby Training
                schedule: Weekly on Mondays from 2nd November 2026 to 14th December 2026
                project: { id: 41, name: Coding Club }
                survey: { id: 77, name: Attendance }
                columns: [{ current_field_id: 9001, name: Minutes late, type: value, compulsory: false }]
                events: [{ id: 812, name: Ruby Training 1, start_datetime: "2026-11-02T10:00:00Z", full: false, totals: [] }]
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data: [{ contact_id: 5521, name: Ann Smith, events: [{ event_id: 812, in_event: true, story_id: 33410, answers: { "9001": "4" } }] }]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /events/{id}/register/cells:
    patch:
      tags: [Events]
      summary: Save one answer on an event series' Register
      operationId: updateEventRegisterCell
      description: |
        Saves one guest's answer to one question of the attendance Survey for one event, as the
        pencil in a Register cell does. `id` is the event the answer is for. The answer goes in the
        guest's latest attendance Story for that event; if they have none, they are added to the
        event's latest Story, or a Story is created. Only that answer changes, and compulsory
        questions may be left unanswered. For an Activity metric, which is counted once per event,
        leave out `contact_id` and send the event's total as a whole number. The guest must already
        be in the event. The event's Event Workers and Event Managers, its Project Managers and
        Organisation Admins may save answers.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [current_field_id, value]
              properties:
                contact_id: { type: integer, description: The guest; leave out for an Activity metric total }
                current_field_id: { type: integer, description: "The question, from the Register's columns or an event's totals" }
                value:
                  description: |
                    scale: an array of answer choice (sub-ratio) ids; binary and participation: true or
                    false; value: a number of 0 or more; custom_field: text, a date as YYYY-MM-DD or a
                    time as HH:MM. An empty value clears the answer.
                  oneOf:
                    - { type: array, items: { type: integer } }
                    - { type: boolean }
                    - { type: number }
                    - { type: string }
            example: { contact_id: 5521, current_field_id: 9001, value: "4" }
      responses:
        "200":
          description: The saved answer
          content:
            application/json:
              schema:
                type: object
                properties:
                  event_id: { type: integer }
                  contact_id: { type: integer, nullable: true }
                  current_field_id: { type: integer }
                  story_id: { type: integer, nullable: true }
                  answer: { description: The answer as the Register shows it, or the event's total }
              example: { event_id: 812, contact_id: 5521, current_field_id: 9001, story_id: 33410, answer: "4" }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /events/{id}/guests:
    get:
      tags: [Events]
      summary: List an event's guests
      operationId: listEventGuests
      description: |
        The event's guests (Contacts), with each one's Guest Status (event state) and, when
        the Event Format has Event Roles turned on, Event Role. Anyone who can open the event
        page can see them. Use search to find guests by part of their name or Contact ID, as
        the search box above the event page's guests table does.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: search
          in: query
          required: false
          description: Part of a guest's name or Contact ID (the prefix and leading zeros of a Contact ID are ignored). Searches every page.
          schema: { type: string }
          example: Mokoena
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of guests, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/EventGuest' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Events]
      summary: Add guests to an event
      operationId: addEventGuests
      description: |
        Adds Contacts in the event's project as guests, as the event page's Add Guests does.
        Contacts already on the event are left as they are. `guest_status_id` is one of the
        Event Format's Guest Statuses (default: its first), and each Contact must meet that
        Guest Status's requirements. `event_role_id` must be one of the Event Format's Event
        Roles for guests. A fixed guest limit is respected. For an event in a recurring
        series, `apply_to: this_and_upcoming_events` adds them to the later events too.
        Anyone who can open the event page can add guests.

        **Adding everyone who matches the Manage Contacts filters.** Instead of `contact_ids`, give
        `filter_data` (the Manage Contacts filters, e.g. `{"beneficiary_state_ids": ["1"]}`; `{}`
        for every Contact the user can see), leaving out `excluded_ids`. `project_id` is a shortcut
        for the Project filter. This is **Add to › An event** for the Contacts selected on Manage
        Contacts. Each Contact is added in turn, and those that can't be added are skipped and
        counted in `skip_counts` rather than refusing the whole request:
        - `headline_only`: the user only has Headline Only Access to them;
        - `not_in_project`: they aren't in the event's project;
        - `event_full`: the event's guest limit has been reached;
        - `requirements_not_met`: they don't meet the Guest Status's requirements.
        Contacts already on the event keep their Guest Status. Up to 50 Contacts are added
        straight away (`200`); more run in the background (`202`), and
        `GET /beneficiaries/bulk_actions/{id}` reports the progress. `filter_data` adds guests to
        this event only, and can't be combined with `contact_ids` or `event_role_id`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contact_ids:
                  type: array
                  items: { type: integer }
                  description: The Contacts to add. Leave out to use filter_data instead.
                filter_data:
                  type: object
                  additionalProperties: true
                  description: Manage Contacts filters selecting the Contacts to add, used instead of contact_ids
                excluded_ids:
                  type: array
                  items: { type: integer }
                  description: With filter_data, Contacts matching the filters to leave out
                project_id:
                  type: integer
                  description: With filter_data, a shortcut for the Project filter (Contacts in this Project)
                guest_status_id: { type: integer }
                event_role_id: { type: integer }
                apply_to: { type: string, enum: [this_event, this_and_upcoming_events], default: this_event }
            examples:
              contacts:
                summary: Named Contacts
                value:
                  contact_ids: [5501, 5502]
                  guest_status_id: 12
                  event_role_id: 4
              matching:
                summary: Everyone matching the Manage Contacts filters
                value:
                  filter_data: { beneficiary_state_ids: ["1"] }
                  excluded_ids: [5503]
                  guest_status_id: 12
      responses:
        "200":
          description: filter_data was given and the matching Contacts were added straight away (50 or fewer)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/EventGuestsBulkAdd' }
              example:
                id: 51
                status: completed
                total_count: 8
                processed_count: 8
                changed_count: 6
                skip_counts: { not_in_project: 1 }
                background: false
                summary: "6 contacts changed. 1 skipped: 1 because they aren't in Youth Mentoring, the event's project."
                event_id: 2201
                guests_count: 14
        "201":
          description: The guests were added
          content:
            application/json:
              schema: { $ref: '#/components/schemas/EventGuestCount' }
        "202":
          description: filter_data was given and more than 50 Contacts match, so they are added in the background. Poll GET /beneficiaries/bulk_actions/{id}.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/EventGuestsBulkAdd' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /events/{id}/guests/{contact_id}:
    patch:
      tags: [Events]
      summary: Change a guest's Guest Status or Event Role
      operationId: updateEventGuest
      description: |
        Changes one guest's Guest Status (checking its requirements) and/or Event Role on this
        event. Send `event_role_id: null` to clear the role.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - { name: contact_id, in: path, required: true, schema: { type: integer }, description: "The guest's Contact (beneficiary) id" }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                guest_status_id: { type: integer }
                event_role_id: { type: integer, nullable: true }
            example:
              guest_status_id: 13
      responses:
        "200":
          description: The guest was changed
          content:
            application/json:
              schema: { $ref: '#/components/schemas/EventGuestCount' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Events]
      summary: Remove a guest from an event
      operationId: removeEventGuest
      description: |
        Removes the Contact from the event's guests. For an event in a recurring series,
        `apply_to: this_and_upcoming_events` removes them from the later events too.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - { name: contact_id, in: path, required: true, schema: { type: integer }, description: "The guest's Contact (beneficiary) id" }
        - { name: apply_to, in: query, required: false, schema: { type: string, enum: [this_event, this_and_upcoming_events], default: this_event } }
      responses:
        "200":
          description: The guest was removed
          content:
            application/json:
              schema: { $ref: '#/components/schemas/EventGuestCount' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /events/{id}/guests/{contact_id}/calendar_links:
    get:
      tags: [Events]
      summary: Get a guest's Add to Calendar links
      operationId: getEventGuestCalendarLinks
      description: |
        The links a guest (Contact) uses to put the event in their own calendar, the same ones
        their Personal Portal and the Add to Calendar email give them: Google Calendar, Outlook.com
        and Microsoft 365 links that open a new, filled-in event, and an .ics file for Apple Calendar
        and any other calendar app. `cancel_url` is the page where the guest can cancel their booking,
        or null when the event's Event Format doesn't let guests cancel.

        The `.ics` and cancel links work without signing in and belong to this one guest, so send them
        only to that guest. Anyone who can open the event page can get them. A Contact who isn't a
        guest of the event returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - { name: contact_id, in: path, required: true, schema: { type: integer }, description: "The guest's Contact (beneficiary) id" }
      responses:
        "200":
          description: The guest's calendar links
          content:
            application/json:
              schema: { $ref: '#/components/schemas/EventGuestCalendarLinks' }
              example:
                event_id: 881
                contact_id: 5521
                google_calendar_url: "https://calendar.google.com/calendar/render?action=TEMPLATE&dates=20300108T180000Z%2F20300108T200000Z&text=Pottery+taster"
                outlook_url: "https://outlook.live.com/calendar/0/action/compose?path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&subject=Pottery+taster"
                office365_url: "https://outlook.office.com/calendar/0/action/compose?path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&subject=Pottery+taster"
                ics_url: "https://www.makerble.com/event-bookings/eyJfcmFpbHMi...--abc123/calendar.ics"
                cancel_url: "https://www.makerble.com/event-bookings/eyJfcmFpbHMi...--abc123"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'

  /events/{id}/staff:
    get:
      tags: [Events]
      summary: List an event's Event Managers and Workers
      operationId: listEventStaff
      description: |
        The event's Event Managers and Event Workers, with their roles on the event and, when
        the Event Format has Event Roles turned on, their Event Role. Anyone who can open the
        event page can see them.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: A page of staff, by name
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PaginationEnvelope'
                  - type: object
                    properties:
                      data:
                        type: array
                        items: { $ref: '#/components/schemas/EventStaffMember' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Events]
      summary: Add Event Managers or Workers
      operationId: addEventStaff
      description: |
        Adds colleagues in the event's project or organisation as Event Managers or Event
        Workers, as the Edit Event form does, respecting a fixed worker limit. `event_role_id`
        must be one of the Event Format's Event Roles for Event Managers and Workers, and is
        set on this event. For a master event, `apply_to: all_events_in_series` adds them to
        the whole series. Needs permission to edit the event.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [user_ids, role]
              properties:
                user_ids: { type: array, items: { type: integer } }
                role: { type: string, enum: [manager, worker] }
                event_role_id: { type: integer }
                apply_to: { type: string, enum: [this_event, all_events_in_series], default: this_event }
            example:
              user_ids: [301]
              role: worker
              event_role_id: 7
      responses:
        "200":
          description: The event, as Get an event returns it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /events/{id}/staff/{user_id}:
    patch:
      tags: [Events]
      summary: Change an Event Manager's or Worker's Event Role
      operationId: updateEventStaffMember
      description: "Sets or clears (`event_role_id: null`) the Event Role of one of the event's Event Managers or Workers."
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - { name: user_id, in: path, required: true, schema: { type: integer } }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                event_role_id: { type: integer, nullable: true }
            example:
              event_role_id: 7
      responses:
        "200":
          description: The event, as Get an event returns it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
    delete:
      tags: [Events]
      summary: Remove an Event Manager or Worker
      operationId: removeEventStaffMember
      description: |
        Removes the user as an Event Manager and/or Worker (`role` to remove only one). At
        least one Event Manager must remain. For a master event, `apply_to:
        all_events_in_series` removes them from the whole series.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - { name: user_id, in: path, required: true, schema: { type: integer } }
        - { name: role, in: query, required: false, schema: { type: string, enum: [manager, worker] } }
        - { name: apply_to, in: query, required: false, schema: { type: string, enum: [this_event, all_events_in_series], default: this_event } }
      responses:
        "200":
          description: The event, as Get an event returns it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /projects/{id}/event_categories:
    get:
      tags: [Events]
      summary: List the Event Formats you can create events with in a Project
      description: >-
        The Event Formats (Event Categories) assigned to the Project, which are the formats the
        Create Event form offers there. Returns 403 unless you can create events in the Project:
        it must have events turned on, and you must be an Organisation Admin, a Project Manager,
        or a Project Reporter or Observer chosen as one of its Event Creators.
      operationId: listProjectEventFormats
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The Project's Event Formats
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedProjectEventFormats'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'

  /projects/{id}/event_form:
    get:
      tags: [Events]
      summary: Get the Create or Edit Event form for an Event Format in a Project
      description: >-
        Everything the Create Event form offers once an Event Format is chosen: its fields (event
        details, custom fields and Dropdowns with their answer choices), the Surveys and Waves
        available for Self Check-in, the Project's Signup Pages, the Guest Statuses a Signup Page
        can put guests into, and the Event Roles. Pass event_id to get the Edit Event form for an
        existing event, which also allows the Event Format the event already uses. Returns 403
        unless you can create events in the Project, or edit the event.
      operationId: getEventForm
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - name: event_category_id
          in: query
          required: true
          description: The Event Format (Event Category) chosen for the event.
          schema:
            type: integer
          example: 42
        - name: event_id
          in: query
          required: false
          description: The event being edited, for the Edit Event form.
          schema:
            type: integer
          example: 889
      responses:
        "200":
          description: The form's fields and choices
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventForm'
              example:
                project: {id: 572, name: "Youth Mentoring Programme 2024"}
                event_category: {id: 42, name: "Drop-in Session"}
                event_id: null
                fields:
                  - {name: name, kind: event_attribute, field_id: null, data_type: text, mandatory: true, priority: 0, validation_hint: null, dropdown: null}
                  - {name: start_datetime, kind: event_attribute, field_id: null, data_type: datetime, mandatory: true, priority: 1, validation_hint: null, dropdown: null}
                  - {name: end_datetime, kind: event_attribute, field_id: null, data_type: datetime, mandatory: true, priority: 2, validation_hint: null, dropdown: null}
                  - {name: "Room code", kind: custom_field, field_id: 311, data_type: text, mandatory: false, priority: 3, validation_hint: "Must contain exactly 3 letters and numbers", dropdown: null}
                  - name: "Session type"
                    kind: dropdown
                    field_id: 15
                    data_type: dropdown
                    mandatory: true
                    priority: 4
                    validation_hint: null
                    dropdown:
                      choice: limited_choice
                      choice_limit: 2
                      options: [{id: 101, name: "Group"}, {id: 102, name: "One to one"}]
                self_check_in:
                  enabled: true
                  surveys: [{project_story_category_id: 2053, story_category_id: 2136, name: "Attendance"}]
                  waves: [{id: 31, name: "Week 1", story_category_id: 2136, project_story_category_id: 2053}]
                signup_pages: [{id: 88, name: "Book a place"}]
                guest_statuses: [{id: 7, name: "Booked"}, {id: 8, name: "Waiting list"}]
                event_roles:
                  enabled: false
                  guests: []
                  event_managers_and_workers: []
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'

  /impact_store/search:
    get:
      tags: [ImpactStore]
      summary: Search the ImpactStore
      operationId: searchImpactStore
      description: |
        Searches the Makerble ImpactStore: the ready-made Surveys, Contact Forms, Case Forms, Impact
        Frameworks, Report Templates, Toolkits and Project Types published for any organisation to
        reuse. Use it before making one of these from scratch.

        - Only published items are searched: those the Explore pages list (approved, shared with
          everyone, and with a name and, except for Contact and Case Forms, a description), and every
          Project Type, since only Makerble makes them. Withdrawn Report Templates never appear.
        - Items matching more of the words in `query` come first; an item matching none of them is
          left out. Common words such as "a", "for" and "the" are ignored. `matched_words` says how
          many words each item matched.
        - `item_type` limits the search to one kind: `survey` (Survey), `contact_form` (Contact
          Form), `case_form` (Case Form), `impact_framework` (Impact Framework), `report_template`
          (Report Template), `toolkit` (Toolkit) or `project_type` (Project Type). Front-end names
          such as `Contact form` work too. Default: every kind.
        - `cause` keeps items tagged with that cause or subcause from the Explore page (a cause takes
          in its subcauses). Contact Forms, Case Forms, Report Templates and Project Types have no
          causes, so a cause leaves them out. With a `cause`, `query` may be left out to list everything for the cause.
        - `used_by_count` is how many organisations use the item: those with a Project using the
          Survey, Impact Framework, Toolkit or Project Type, those that added the Contact Form, those
          with a Case made from the Case Form, and those with the Report Template in their library.
        - `explore_url` is null for a Project Type, which has no Explore page.
        - Read any item but a Report Template in full with **Get a library item**, using the same
          `type` and `id`.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: wellbeing young people
          description: Words to look for in the name and description
        - name: item_type
          in: query
          required: false
          schema:
            type: string
            enum: [survey, contact_form, case_form, impact_framework, report_template, toolkit, project_type]
          description: Only this kind of item (default every kind)
        - name: cause
          in: query
          required: false
          schema:
            type: string
          example: Mental health
          description: Only items tagged with this cause or subcause, by name, in any case
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Matching published items, best match first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedImpactStoreSearch'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 431
                    type: survey
                    type_label: Survey
                    name: Youth wellbeing check-in
                    description: A short wellbeing survey for young people aged 11 to 18
                    causes: [Health, Mental health]
                    used_by_count: 12
                    explore_url: https://www.makerble.com/story_categories/431
                    matched_words: 3
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          description: An unknown `item_type` or `cause`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /explore/surveys:
    get:
      tags: [Explore]
      summary: Explore Surveys
      operationId: listExploreSurveys
      description: |
        Lists the Surveys (Story Categories) published to the Makerble® ImpactStore™ and approved,
        with the same search, filters, counts and sort as the Explore Surveys page. Every caller
        sees the same Surveys; `yours` and `added_to_a_project` depend on the caller's organisations.

        - `query` matches the Survey's name or description.
        - The filters take option keys, as arrays (`theme[]=health`) or comma-separated
          (`theme=health,organisational`). Options in one filter combine with OR and filters
          combine with AND:
          - `theme`: `mental_health_and_wellbeing`, `children_and_young_people`,
            `employment_and_skills`, `community_and_culture`, `health`, `organisational`
          - `audience` (Who answers it): `children_under_16`, `young_people_16_to_25`, `adults`,
            `staff_and_volunteers`
          - `time` (Time to complete): `under_5`, `5_to_15`, `over_15`
          - `feature`: `validated` (Validated scale), `verdicts` (Verdicts set up), `repeats`
            (Repeat at intervals)
        - `chip` is one of the page's Popular chips: `Wellbeing`, `Young people`, `Employment`,
          `Feedback`, `Staff and volunteers`.
        - `facets` gives each filter's options with how many Surveys each would return, given the
          other filters already chosen.
        - `sort` is `added` (most organisations using it first, the default), `new` or `az`.
        - Add a Survey to a project in the app with **Add to a project** on Explore Surveys.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: wellbeing
          description: Words to look for in the Survey's name or description
        - name: theme
          in: query
          required: false
          schema:
            type: string
          example: mental_health_and_wellbeing
          description: Theme option keys, comma-separated or repeated as theme[]
        - name: audience
          in: query
          required: false
          schema:
            type: string
          example: children_under_16
          description: Who answers it option keys, comma-separated or repeated as audience[]
        - name: time
          in: query
          required: false
          schema:
            type: string
          example: under_5,5_to_15
          description: Time to complete option keys, comma-separated or repeated as time[]
        - name: feature
          in: query
          required: false
          schema:
            type: string
          example: validated
          description: Feature option keys, comma-separated or repeated as feature[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [Wellbeing, Young people, Employment, Feedback, Staff and volunteers]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed Surveys that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreSurveys'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 412
                    name: Stirling Children's Wellbeing Scale
                    description: Positive emotional state and outlook for children aged 8 to 15.
                    shared_by: Makerble Templates
                    tag: Verdicts
                    question_count: 15
                    estimated_minutes: 5
                    themes: [mental_health_and_wellbeing, children_and_young_people]
                    audiences: [children_under_16]
                    repeats_at_intervals: true
                    validated: true
                    verdicts: true
                    libraries_count: 31
                    yours: false
                    added_to_a_project: false
                facets:
                  - key: audience
                    label: Who answers it
                    options:
                      - value: children_under_16
                        label: Children under 16
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'

  /explore/surveys/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Survey
      operationId: getExploreSurvey
      description: |
        One Survey listed on Explore Surveys, as its Preview shows it: the fields of
        **Explore Surveys** plus `sections`, each with its `title` (null for questions before the
        first section header) and its `questions` in the order the Survey asks them. A Survey
        that isn't listed on Explore (unpublished, unapproved or without a description) is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 412
      responses:
        "200":
          description: The Survey's preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreSurveyPreview'
              example:
                id: 412
                name: Stirling Children's Wellbeing Scale
                description: Positive emotional state and outlook for children aged 8 to 15.
                shared_by: Makerble Templates
                tag: Verdicts
                question_count: 2
                estimated_minutes: 1
                themes: [mental_health_and_wellbeing]
                audiences: [children_under_16]
                repeats_at_intervals: true
                validated: true
                verdicts: true
                libraries_count: 31
                yours: false
                added_to_a_project: false
                sections:
                  - title: Positive emotional state
                    questions: ["I've been feeling calm", "I've been in a good mood"]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /explore/report_templates:
    get:
      tags: [Explore]
      summary: Explore Report Templates
      operationId: listExploreReportTemplates
      description: |
        Lists the Report Templates in the Makerble® ImpactStore™, with the same search, filters,
        counts and sort as the Explore Report Templates page. Every caller sees the same Report
        Templates; `yours` and `in_your_library` depend on the caller's organisations.

        - `query` matches the Report Template's name or description, or the label of who it's for
          or its theme.
        - The filters take option keys, as arrays (`theme[]=community`) or comma-separated
          (`theme=community,governance`). Options in one filter combine with OR and filters
          combine with AND:
          - `recipient` (Who it's for): `funder`, `trustees`, `local_authority` (Commissioner or
            contract), `corporate_partner`, `internal`
          - `theme`: `children_and_young_people`, `community`, `employment`, `governance`,
            `health_and_wellbeing`, `volunteering`
          - `output` (Answer formats): `narrative`, `number`, `chart`, `table`. A Report Template matches
            when any of its questions asks for that format.
        - `facets` gives each filter's options with how many Report Templates each would return,
          given the other filters already chosen.
        - `sort` is `added` (in the most organisations' libraries first, the default), `new` or `az`.
        - Add a Report Template to your organisation's library in the app with **Add to your
          library** on Explore Report Templates.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: end of grant
          description: Words to look for in the Report Template's name, description, recipient or theme
        - name: recipient
          in: query
          required: false
          schema:
            type: string
          example: funder,trustees
          description: Who it's for option keys, comma-separated or repeated as recipient[]
        - name: theme
          in: query
          required: false
          schema:
            type: string
          example: community
          description: Theme option keys, comma-separated or repeated as theme[]
        - name: output
          in: query
          required: false
          schema:
            type: string
          example: chart
          description: Answer format option keys, comma-separated or repeated as output[]
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed Report Templates that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreReportTemplates'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 18
                    slug: annual-grant-report-to-a-funder
                    name: Annual Grant Report to a Funder
                    description: The yearly report most grant funders ask for.
                    recipient: funder
                    theme: community
                    question_count: 5
                    answer_formats: [narrative, number, chart]
                    shared_by: Makerble® ImpactStore™
                    libraries_count: 31
                    yours: false
                    in_your_library: false
                facets:
                  - key: recipient
                    label: Who it's for
                    options:
                      - value: funder
                        label: Funder
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/report_templates/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Report Template
      operationId: getExploreReportTemplate
      description: |
        One Report Template listed on Explore Report Templates, as its Preview shows it: the fields
        of **Explore Report Templates** plus `questions`, each with its `title` and the
        `answer_formats` it asks for, in order. A Report Template that isn't in the ImpactStore is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 18
      responses:
        "200":
          description: The Report Template's preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreReportTemplatePreview'
              example:
                id: 18
                slug: annual-grant-report-to-a-funder
                name: Annual Grant Report to a Funder
                description: The yearly report most grant funders ask for.
                recipient: funder
                theme: community
                question_count: 2
                answer_formats: [narrative, number]
                shared_by: Makerble® ImpactStore™
                libraries_count: 31
                yours: false
                in_your_library: false
                questions:
                  - title: What did you set out to achieve?
                    answer_formats: [narrative]
                  - title: Who did you reach?
                    answer_formats: [number]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /report_templates:
    get:
      tags: [Reports]
      summary: List an organisation's Report Templates
      operationId: listReportTemplates
      description: |
        The Report Templates an organisation can use in ReportMaker: its own and those in its
        library, with each question's Expected Outputs and their `output_settings`. Requires
        someone who can see Report Templates in the organisation; another organisation is a 404.

        A template ReportMaker saved for one Report (so the next report to the same recipient can
        reuse its questions) has that Report's id in `created_for_report_id`. Manage Report Templates
        lists those only under its **Made for a single report** filter; pass
        `made_for_single_report=false` to leave them out the same way, or `true` to list only them.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          example: 42
          description: The organisation
        - name: made_for_single_report
          in: query
          required: false
          schema:
            type: boolean
          example: false
          description: true for only the templates made for a single report, false to leave them out. Leave it out for every template
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The organisation's Report Templates
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedReportTemplates'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Reports]
      summary: Create a Report Template
      operationId: createReportTemplate
      description: |
        Creates a Report Template, as **Create a Report Template** does. Each question's
        `expected_output_types` are any of `narrative`, `number`, `chart` and `table`, and its
        `output_settings` hold:

        - `word_limit`: a whole number of words for a Narrative the recipient limits, e.g. "max 250 words".
        - `table`: for a Table, `columns` (each a `heading` and a `type` of `text` or `number`; at
          least one, at most 20, with different headings), `row_mode` (`reporter_adds`, the default,
          or `fixed`) and, for fixed rows, `fixed_row_labels`. With fixed rows, every Report has one row
          per label and the first column holds the labels (its type is always `text`).

        Settings for an output the question doesn't expect are dropped. Questions are saved in the
        order given. Errors name the question, e.g. `Question 1: Table needs at least one column`.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportTemplateInput'
            example:
              charity_id: 42
              name: Pilot evaluation
              description: Our end-of-year evaluation for the funder
              recipient_type: funder
              questions:
                - question_title: How did each pilot do?
                  guidance_notes: Give the figures for each pilot
                  expected_output_types: [narrative, table]
                  output_settings:
                    word_limit: 250
                    table:
                      columns:
                        - heading: Pilot
                        - heading: People reached
                          type: number
                      row_mode: fixed
                      fixed_row_labels: [Pilot A, Pilot B]
      responses:
        "201":
          description: The new Report Template
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportTemplate'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /report_templates/{id}:
    get:
      tags: [Reports]
      summary: Get a Report Template
      operationId: getReportTemplate
      description: One Report Template with its questions in order. A template you can't see is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 7
      responses:
        "200":
          description: The Report Template
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportTemplate'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Reports]
      summary: Change a Report Template
      operationId: updateReportTemplate
      description: |
        Changes a Report Template, as **Edit Report Template** does. Fields left out stay as they
        are. In `questions`, give an existing question's `id` to change it (questions without one are
        added), and `{id, _destroy: true}` to remove one. Requires the template's creator or an
        Organisation Admin, and the template must not be approved for the ImpactStore; otherwise 403.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 7
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportTemplateInput'
            example:
              questions:
                - id: 31
                  expected_output_types: [table]
                  output_settings:
                    table:
                      columns:
                        - heading: Indicator
                        - heading: Target
                          type: number
                        - heading: Actual
                          type: number
      responses:
        "200":
          description: The changed Report Template
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportTemplate'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /reporting_cycles:
    get:
      tags: [Reports]
      summary: List Reporting Cycles
      operationId: listReportingCycles
      description: |
        Reporting Cycles in ReportMaker. A Reporting Cycle is a series of reports owed to one
        recipient (e.g. quarterly to Comic Relief), each Deadline saying which Report Template, which
        projects and albums, which timeframe and when it is due. An Organisation Admin sees every cycle
        of the organisation; anyone else sees only the cycles they are an Editor or Reporter of.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema:
            type: integer
          example: 42
          description: Only this organisation's cycles; leave out for every organisation you belong to
        - name: q
          in: query
          required: false
          schema:
            type: string
          example: Comic Relief
          description: Words in the name or the recipient
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The Reporting Cycles you can see
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedReportingCycles'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Reports]
      summary: Create a Reporting Cycle
      operationId: createReportingCycle
      description: |
        Creates a Reporting Cycle with its Deadlines, as **Create a Reporting Cycle** does. Give
        every Deadline explicit dates (`YYYY-MM-DD`). Every id must belong to the organisation:
        `editor_ids` and `reporter_ids` are its users, `project_ids` its projects you can view,
        `album_ids` its albums and `report_template_id` a Report Template it can use. Errors name the
        Deadline, e.g. `Deadline "Q1": Timeframe from must be on or before timeframe to`. Requires an
        Organisation Admin; another organisation is a 404.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportingCycleInput'
            example:
              charity_id: 42
              name: Comic Relief 2027
              recipient: Comic Relief
              reporter_ids: [118]
              deadlines:
                - name: Q1 2027 report
                  report_template_id: 7
                  timeframe_from: "2027-01-01"
                  timeframe_to: "2027-03-31"
                  submission_deadline: "2027-04-30"
                  project_ids: [301, 302]
                  album_ids: [12]
                - name: Q2 2027 report
                  report_template_id: 7
                  timeframe_from: "2027-04-01"
                  timeframe_to: "2027-06-30"
                  submission_deadline: "2027-07-31"
                  project_ids: [301, 302]
                  album_ids: [12]
      responses:
        "201":
          description: The new Reporting Cycle
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportingCycle'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /reporting_cycles/{id}:
    get:
      tags: [Reports]
      summary: Get a Reporting Cycle
      operationId: getReportingCycle
      description: One Reporting Cycle with its Deadlines in due order. A cycle you can't see is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 15
      responses:
        "200":
          description: The Reporting Cycle
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportingCycle'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Reports]
      summary: Change a Reporting Cycle
      operationId: updateReportingCycle
      description: |
        Changes a Reporting Cycle, as **Edit Reporting Cycle** does. Fields left out stay as they are;
        `editor_ids` and `reporter_ids`, when given, replace the list. In `deadlines`, give an existing
        Deadline's `id` to change it (Deadlines without one are added), and `{id, _destroy: true}` to
        remove one; Deadlines not listed are kept. Requires an Organisation Admin or an Editor of the
        cycle; a Reporter of it gets 403. Deleting a cycle is only on its page.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 15
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportingCycleInput'
            example:
              deadlines:
                - id: 51
                  timeframe_from: "2027-01-01"
                  timeframe_to: "2027-03-31"
                - id: 52
                  _destroy: true
      responses:
        "200":
          description: The changed Reporting Cycle
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportingCycle'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /requirement_sets:
    get:
      tags: [Reports]
      summary: List an organisation's Requirement Sets
      operationId: listRequirementSets
      description: |
        A Requirement Set holds a funder's reporting requirements for a programme (one or more
        albums and/or projects), and the metrics that answer each. Each Requirement is one thing
        the funder asks for, e.g. "KPI 3: number of young people completing the programme"; one
        with no metrics linked is "Not covered". Requires someone who can see Report Templates in
        the organisation; another organisation is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          example: 42
          description: The organisation
        - name: recipient
          in: query
          required: false
          schema:
            type: string
          example: Comic Relief
          description: Only sets for this recipient, whatever its case and surrounding spaces
        - name: project_id
          in: query
          required: false
          schema:
            type: integer
          description: Only sets covering this project, directly or through an album holding it
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: Only sets covering this album
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The organisation's Requirement Sets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedRequirementSets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags: [Reports]
      summary: Create a Requirement Set
      operationId: createRequirementSet
      description: |
        Creates a Requirement Set, as **Add reporting requirements** does. The scope is
        `project_ids` and/or `album_ids` (at least one), all the organisation's and ones you can
        view. `requirements` are saved in the order given. Each requirement's `metrics` are
        `{type, id}` with type `Change`, `Indicator`, `CohortTracker`, `WorkflowTracker`,
        `FormulaTracker` or `FilteredMetric`, all the organisation's. `answer_shape` is one of
        `count`, `sum`, `average`, `ratio`, `share_meeting_threshold`, `change_over_time`,
        `breakdown` or `quote`. Errors name the requirement, e.g.
        `KPI 2: Answer shape is not included in the list`.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequirementSetInput'
            example:
              charity_id: 42
              name: Comic Relief 2027 grant
              recipient: Comic Relief
              source_name: Grant agreement
              source_url: https://example.org/grant-agreement.pdf
              album_ids: [15]
              requirements:
                - reference: KPI 1
                  wording: Number of young people completing the programme
                  answer_shape: count
                  answer_format: makerble_data
                  answer_preset: target_vs_actual
                  metrics:
                    - type: CohortTracker
                      id: 4
                - reference: KPI 2
                  wording: A story of change from a young person
                  answer_shape: quote
                  answer_format: narrative
                  word_limit: 250
      responses:
        "201":
          description: The new Requirement Set
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/RequirementSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /requirement_sets/{id}:
    get:
      tags: [Reports]
      summary: Get a Requirement Set
      operationId: getRequirementSet
      description: One Requirement Set with its requirements in order and the metrics answering each. A set you can't see is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 9
      responses:
        "200":
          description: The Requirement Set
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/RequirementSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Reports]
      summary: Change a Requirement Set
      operationId: updateRequirementSet
      description: |
        Changes a Requirement Set. Fields left out stay as they are. Giving `project_ids` or
        `album_ids` replaces the whole scope. `requirements`, when given, is the full list in order:
        give an existing requirement's `id` to keep and change it; any left out are removed. A
        requirement's `metrics`, when given, replaces its links. Requires the set's creator or an
        Organisation Admin; otherwise 403.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 9
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequirementSetInput'
            example:
              requirements:
                - id: 31
                  reference: KPI 1
                  wording: Number of young people completing the programme
                  metrics:
                    - type: CohortTracker
                      id: 4
                    - type: FilteredMetric
                      id: 12
      responses:
        "200":
          description: The changed Requirement Set
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/RequirementSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    delete:
      tags: [Reports]
      summary: Delete a Requirement Set
      operationId: deleteRequirementSet
      description: Deletes a Requirement Set with its requirements and metric links. Requires the set's creator or an Organisation Admin; otherwise 403.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 9
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
  /reports/{report_id}/requirements:
    get:
      tags: [Reports]
      summary: Get the reporting requirements for a Report
      operationId: getReportRequirements
      description: |
        The Requirement Sets that apply to a Report: sets for the Report's recipient (whatever its
        case and spacing) whose albums and projects overlap the Report's. `match` says how they were
        chosen: `exact` (a set scoped to exactly the Report's albums and projects), `narrowest` (the
        narrowest set containing all of them), `candidates` (sets that only partly overlap, offered
        rather than chosen) or `none`. `conflicting` is true when two or more sets qualify equally;
        all are returned, and none is picked. A Report you can't see is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: report_id
          in: path
          required: true
          schema:
            type: integer
          example: 120
      responses:
        "200":
          description: The Requirement Sets for the Report
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      recipient:
                        type: string
                        nullable: true
                      match:
                        type: string
                        enum: [exact, narrowest, candidates, none]
                      conflicting:
                        type: boolean
                      requirement_sets:
                        type: array
                        items:
                          $ref: '#/components/schemas/RequirementSet'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /reports/{report_id}/contents:
    get:
      tags: [Reports]
      summary: List a Report's answers
      operationId: listReportContents
      description: |
        A Report's answers (Report Contents), one per question of its Report Template, answered or
        not, in the template's order. A Report you can't see is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: report_id
          in: path
          required: true
          schema:
            type: integer
          example: 15
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The Report's answers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedReportContents'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /reports/{report_id}/contents/{question_id}:
    get:
      tags: [Reports]
      summary: Get a Report's answer to one question
      operationId: getReportContent
      security: [{tokenAuth: []}]
      parameters:
        - name: report_id
          in: path
          required: true
          schema:
            type: integer
          example: 15
        - name: question_id
          in: path
          required: true
          schema:
            type: integer
          example: 31
          description: A question of the Report's Report Template
      responses:
        "200":
          description: The answer
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportContent'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Reports]
      summary: Write a Report's answer to one question
      operationId: updateReportContent
      description: |
        Writes the answer as **Write the Content** does. `table_rows` replaces the whole table: one
        array of cells per row, in the order of the template's columns. Cells beyond the columns and
        empty rows are dropped, a cell in a Number column must be a number, and with fixed rows the
        first cell of each row is the template's label whatever is sent. A Narrative over its word
        limit is saved; `words_over_limit` says by how much. Requires a Report Editor, a Report
        Reporter or an Organisation Admin; someone who can only read the Report gets a 403.
      security: [{tokenAuth: []}]
      parameters:
        - name: report_id
          in: path
          required: true
          schema:
            type: integer
          example: 15
        - name: question_id
          in: path
          required: true
          schema:
            type: integer
          example: 31
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                narrative_content:
                  type: string
                  description: HTML, as the rich text editor saves it
                number_content:
                  type: number
                table_rows:
                  type: array
                  items:
                    type: array
                    items: {}
            example:
              table_rows:
                - [Referrals, 120, 134]
                - [Sessions, 40, 38]
      responses:
        "200":
          description: The saved answer
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportContent'
              example:
                data:
                  report_id: 15
                  question_id: 31
                  question_title: How are we doing against our KPIs?
                  expected_output_types: [table]
                  output_settings:
                    table:
                      columns:
                        - {heading: Indicator, type: text}
                        - {heading: Target, type: number}
                        - {heading: Actual, type: number}
                      row_mode: reporter_adds
                  narrative_content: null
                  number_content: null
                  word_count: 0
                  words_over_limit: null
                  table_columns:
                    - {heading: Indicator, type: text}
                    - {heading: Target, type: number}
                    - {heading: Actual, type: number}
                  table_rows:
                    - [Referrals, 120, 134]
                    - [Sessions, 40, 38]
                  table_changed_in_template: false
                  ai_status: not_requested
                  data_gaps: []
                  updated_at: "2026-11-29T21:40:00Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /reports/{report_id}/contents/{question_id}/refresh_data:
    post:
      tags: [Reports]
      summary: Fill or refresh a Makerble data block
      operationId: refreshReportContentData
      description: |
        **Fill from data** / **Refresh from data** on Write the Content. The figures are taken in the
        background from the Report's timeframe, projects and albums, and Exclusive Focus, and stay
        frozen until refreshed again. Answers 202 with `data_status` queued; read the answer again
        until it is `filled` (or `failed`, with `data_block.error`). `metrics` chooses this Report's
        own metrics, for a template whose metrics the organisation doesn't have; the template is
        unchanged. Requires a Report Editor, a Report Reporter or an Organisation Admin.
      security: [{tokenAuth: []}]
      parameters:
        - name: report_id
          in: path
          required: true
          schema:
            type: integer
          example: 15
        - name: question_id
          in: path
          required: true
          schema:
            type: integer
          example: 31
          description: A question of the Report's template with a Makerble data block
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                metrics:
                  type: array
                  items:
                    type: string
            example:
              metrics: ["Change:12", "CohortTracker:4"]
      responses:
        "202":
          description: The fill is queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ReportContent'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /report_data_presets:
    get:
      tags: [Reports]
      summary: List the Makerble data block presets
      operationId: listReportDataPresets
      description: |
        What a Makerble data block in a Report Template can show: Target vs actual, Key figures,
        Contact breakdown, Distance travelled, and Sessions and attendance. Each preset has its
        settings, the displays it allows, an "answers questions like" description and its answer
        shapes, so a requirement can be matched to the preset that answers it. `answer_shapes` lists
        every shape.
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The presets
          content:
            application/json:
              schema:
                type: object
                properties:
                  page:
                    type: integer
                  page_size:
                    type: integer
                  page_count:
                    type: integer
                  total_count:
                    type: integer
                  answer_shapes:
                    type: array
                    items:
                      $ref: '#/components/schemas/AnswerShape'
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/DataBlockPreset'
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/forms:
    get:
      tags: [Explore]
      summary: Explore Forms
      operationId: listExploreForms
      description: |
        Lists the forms published to the Makerble® ImpactStore™ and approved by Makerble, with the
        same search, filters, counts and sort as the Explore Forms page: Contact Forms (bio forms),
        Case Forms, Custom Forms for Contacts, Event Forms and Project Forms. Every caller sees the
        same forms; `yours` depends on the caller's organisations.

        - Each form's `id` is a key naming its type and number, such as `contact-4`, `case-5`,
          `event-6` or `project-7`. Case Forms and Custom Forms for Contacts both use `case-`.
        - `query` matches the form's name, and a Contact Form's description.
        - The filters take option keys, as arrays (`type[]=case_form`) or comma-separated
          (`type=case_form,event_form`). Options in one filter combine with OR and filters
          combine with AND:
          - `type` (Type of form): `contact_form`, `case_form`, `custom_contact_form`, `event_form`,
            `project_form`
          - `theme`: `referral_and_intake`, `equality_monitoring`, `safeguarding`, `events`,
            `project_information`. Event Forms always have `events` and Project Forms
            `project_information`.
          - `fields` (Number of fields): `up_to_10`, `11_to_25`, `over_25`
          - `includes`: `consent` (a consent question), `standard_dropdowns` (Dropdowns from the
            ImpactStore), `address` (an address or postcode field)
        - A form's fields are the questions it asks: built-in fields and section headings are not
          counted.
        - `chip` is one of the page's Popular chips: `Referral`, `Equality monitoring`,
          `Safeguarding`, `Registration`.
        - `facets` gives each filter's options with how many forms each would return, given the
          other filters already chosen.
        - `sort` is `added` (used by the most organisations first, the default), `new` or `az`.
        - Add a form to your organisation in the app with **Add to organisation** on Explore Forms.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: referral
          description: Words to look for in the form's name, or a Contact Form's description
        - name: type
          in: query
          required: false
          schema:
            type: string
          example: case_form
          description: Type of form option keys, comma-separated or repeated as type[]
        - name: theme
          in: query
          required: false
          schema:
            type: string
          example: safeguarding
          description: Theme option keys, comma-separated or repeated as theme[]
        - name: fields
          in: query
          required: false
          schema:
            type: string
          example: up_to_10
          description: Number of fields option keys, comma-separated or repeated as fields[]
        - name: includes
          in: query
          required: false
          schema:
            type: string
          example: standard_dropdowns
          description: Includes option keys, comma-separated or repeated as includes[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [Referral, Equality monitoring, Safeguarding, Registration]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed forms that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreForms'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: case-5
                    name: Safeguarding concern
                    type: case_form
                    field_count: 14
                    uses_standard_dropdowns: true
                    themes: [safeguarding]
                    shared_by: Makerble Templates
                    used_by_count: 12
                    yours: false
                    public_url: https://www.makerble.com/case-forms/safeguarding-concern
                facets:
                  - key: type
                    label: Type of form
                    options:
                      - value: case_form
                        label: Case form
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/forms/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Form
      operationId: getExploreForm
      description: |
        One form listed on Explore Forms: the fields of **Explore Forms** plus the name of every
        field it asks, in order. A form that isn't listed on Explore (not published or not
        approved), or a key that names no form, is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          example: case-5
          description: The form's key from Explore Forms
      responses:
        "200":
          description: The form and its fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreFormPreview'
              example:
                id: case-5
                name: Safeguarding concern
                type: case_form
                field_count: 3
                uses_standard_dropdowns: false
                themes: [safeguarding]
                shared_by: Makerble Templates
                used_by_count: 12
                yours: false
                public_url: https://www.makerble.com/case-forms/safeguarding-concern
                fields: [Date of concern, What happened, Action taken]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /explore/dropdowns:
    get:
      tags: [Explore]
      summary: Explore Dropdowns
      operationId: listExploreDropdowns
      description: |
        Lists the Dropdowns (answer-choice lists, Ratio Sets) shared to the Makerble® ImpactStore™
        and approved, with the same search, filters, counts and sort as the Explore Dropdowns page.
        Every caller sees the same Dropdowns; `yours` depends on the caller's organisations.

        - `query` matches the Dropdown's title or any of its answer choices.
        - The filters take option keys, as arrays (`theme[]=scales`) or comma-separated
          (`theme=scales,demographics`). Options in one filter combine with OR and filters
          combine with AND:
          - `designed_for`: `surveys_and_trackers`, `forms` (bio, event and project forms)
          - `choices` (Number of choices): `up_to_10`, `11_to_100`, `over_100`
          - `theme`: `scales`, `demographics`
        - `chip` is one of the page's Popular chips: `Scales`, `Demographics`, `Equality monitoring`.
        - `facets` gives each filter's options with how many Dropdowns each would return, given the
          other filters already chosen.
        - `sort` is `added` (used in the most surveys, trackers and forms first, the default), `new`
          or `az`.
        - Copy a Dropdown into your organisation in the app with **Add to organisation** on Explore
          Dropdowns.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: ethnicity
          description: Words to look for in the Dropdown's title or answer choices
        - name: designed_for
          in: query
          required: false
          schema:
            type: string
          example: surveys_and_trackers
          description: Designed for option keys, comma-separated or repeated as designed_for[]
        - name: choices
          in: query
          required: false
          schema:
            type: string
          example: up_to_10
          description: Number of choices option keys, comma-separated or repeated as choices[]
        - name: theme
          in: query
          required: false
          schema:
            type: string
          example: scales
          description: Theme option keys, comma-separated or repeated as theme[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [Scales, Demographics, Equality monitoring]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed Dropdowns that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreDropdowns'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 87
                    title: Agreement scale
                    choice_count: 5
                    designed_for: [surveys_and_trackers]
                    themes: [scales]
                    shared_by: Makerble Templates
                    used_in_count: 42
                    yours: false
                facets:
                  - key: theme
                    label: Theme
                    options:
                      - value: scales
                        label: Scales
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/dropdowns/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Dropdown
      operationId: getExploreDropdown
      description: |
        One Dropdown listed on Explore Dropdowns: the fields of **Explore Dropdowns** plus every
        one of its answer `choices`, in order. A Dropdown that isn't listed on Explore (not shared
        or not approved) is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 87
      responses:
        "200":
          description: The Dropdown and its answer choices
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreDropdownPreview'
              example:
                id: 87
                title: Agreement scale
                choice_count: 5
                designed_for: [surveys_and_trackers]
                themes: [scales]
                shared_by: Makerble Templates
                used_in_count: 42
                yours: false
                choices: [Strongly disagree, Disagree, Not sure, Agree, Strongly agree]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /explore/checklist_templates:
    get:
      tags: [Explore]
      summary: Explore Checklist Templates
      operationId: listExploreChecklistTemplates
      description: |
        Lists the Checklist Templates shared to the Makerble® ImpactStore™ and approved, with the
        same search, filters, counts and sort as the Explore Checklist Templates page. A Checklist
        Template is a ready-made Checklist (participant journey) without an organisation's own
        content: each step carries a hint for what counts as done, such as "a baseline wellbeing
        survey", which is matched to your own Surveys, forms and statuses when you use it.

        - `query` matches the template's name and description, and its steps' titles and hints.
        - The filters take option keys, as arrays (`shape[]=with_stages`) or comma-separated.
          Options in one filter combine with OR and filters combine with AND:
          - `designed_for`: `young_people`, `adults`, `families`, `volunteers`, `everyone`
          - `journey_part` (Part of the journey): `referral`, `enrolment`, `safeguarding`, `exit_and_alumni`
          - `shape`: `with_stages`, `without_stages`
          - `shared_by`: `makerble`, `others`
        - `chip` is one of the page's Popular chips: `Referral`, `Safeguarding`, `Enrolment`,
          `Volunteers`, `Bursary`.
        - `sort` is `used` (used by the most organisations first, the default), `new`, `az` or
          `steps` (fewest steps first).
        - `yours` is true for a template that belongs to one of your organisations.
        - Use a template with **Use a Checklist Template** (`/checklist_templates/{id}/mapping`
          and `/checklist_templates/{id}/use`).
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: safeguarding
          description: Words in the template's name, description, or steps' titles and hints
        - name: designed_for
          in: query
          required: false
          schema:
            type: string
          example: young_people
          description: Designed for option keys, comma-separated or repeated as designed_for[]
        - name: journey_part
          in: query
          required: false
          schema:
            type: string
          example: safeguarding
          description: Part of the journey option keys, comma-separated or repeated as journey_part[]
        - name: shape
          in: query
          required: false
          schema:
            type: string
          example: with_stages
          description: Shape option keys, comma-separated or repeated as shape[]
        - name: shared_by
          in: query
          required: false
          schema:
            type: string
          example: makerble
          description: Shared by option keys, comma-separated or repeated as shared_by[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [Referral, Safeguarding, Enrolment, Volunteers, Bursary]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [used, new, az, steps]
            default: used
          description: Most used, Newest, A to Z, or Fewest steps
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed Checklist Templates that match, and each filter's option counts
          content:
            application/json:
              schema:
                type: object
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 12
                    name: Safeguarding onboarding
                    description: The checks to complete before anyone takes part in activities.
                    steps_count: 4
                    stages_count: 0
                    designed_for: everyone
                    journey_part: safeguarding
                    shared_by: Makerble
                    used_by: 3
                    published_at: "2026-11-24T09:00:00Z"
                    yours: false
                facets:
                  - key: journey_part
                    label: Part of the journey
                    options:
                      - value: safeguarding
                        label: Safeguarding
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/checklist_templates/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Checklist Template
      operationId: getExploreChecklistTemplate
      description: |
        One Checklist Template listed on Explore Checklist Templates, as its preview shows it: the
        fields of **Explore Checklist Templates** plus its `stages` (name, icon) and `steps` (title,
        action type, and the `hint` for what counts as done where the step needs one). A template
        that isn't listed (not shared or not approved) is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 12
      responses:
        "200":
          description: The template with its stages and steps
          content:
            application/json:
              schema:
                type: object
              example:
                id: 12
                name: Safeguarding onboarding
                steps_count: 2
                stages_count: 0
                designed_for: everyone
                journey_part: safeguarding
                shared_by: Makerble
                used_by: 3
                yours: false
                stages: []
                steps:
                  - id: 101
                    stage_id: null
                    title: Record consent
                    action_type: complete_form
                    action_name: Complete a form
                    hint: a consent form
                    needs_hint: true
                  - id: 102
                    stage_id: null
                    title: Agree next steps with a key worker
                    action_type: create_task
                    action_name: Create a task
                    hint: null
                    needs_hint: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /explore/impact_frameworks:
    get:
      tags: [Explore]
      summary: Explore Impact Frameworks
      operationId: listExploreImpactFrameworks
      description: |
        Lists the public, approved Impact Frameworks (Templates) in the Makerble® ImpactStore™, with
        the same search, filters, counts and sort as the Explore Impact Frameworks page. Every caller
        sees the same Impact Frameworks; `yours` depends on the caller's organisations.

        - `query` matches the Impact Framework's name or description.
        - The filters take option keys, as arrays (`theme[]=inclusion`) or comma-separated
          (`theme=inclusion,leadership`). Options in one filter combine with OR and filters
          combine with AND:
          - `theme`: `mental_health_and_wellbeing`, `children_and_young_people`, `employment_and_skills`, `community_and_culture`, `health`, `organisational`, `global_goals`, `inclusion`, `education_and_training`, `leadership`
          - `set` (Part of a Framework Set): a platform-wide Framework Set's id, or `none` for
            frameworks in no set. `facets` lists the sets.
          - `size`: `up_to_5`, `6_to_10`, `over_10` outcomes
        - `chip` is one of the page's Popular chips: `SDGs`, `Inclusion`, `Employment`, `Wellbeing`.
        - `facets` gives each filter's options with how many Impact Frameworks each would return,
          given the other filters already chosen.
        - `sort` is `added` (on the most organisations' projects first, the default), `new` or `az`.
        - Add an Impact Framework to projects in the app with **Add to projects** on Explore Impact
          Frameworks.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: inclusion
          description: Words to look for in the Impact Framework's name or description
        - name: theme
          in: query
          required: false
          schema:
            type: string
          example: global_goals
          description: Theme option keys, comma-separated or repeated as theme[]
        - name: set
          in: query
          required: false
          schema:
            type: string
          example: none
          description: Framework Set ids or none, comma-separated or repeated as set[]
        - name: size
          in: query
          required: false
          schema:
            type: string
          example: up_to_5
          description: Size option keys, comma-separated or repeated as size[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [SDGs, Inclusion, Employment, Wellbeing]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed Impact Frameworks that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreImpactFrameworks'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 301
                    name: Quality Education
                    description: Outcomes for SDG 4.
                    themes: [global_goals, children_and_young_people]
                    framework_sets:
                      - id: 2
                        name: UN Sustainable Development Goals
                        short_code: SDG 4
                    outcome_count: 10
                    progress_tracker_count: 3
                    shared_by: Makerble Templates
                    libraries_count: 15
                    yours: false
                facets:
                  - key: size
                    label: Size
                    options:
                      - value: 6_to_10
                        label: 6 to 10 outcomes
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/impact_frameworks/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Impact Framework
      operationId: getExploreImpactFramework
      description: |
        One Impact Framework listed on Explore Impact Frameworks, as its Preview shows it: the fields
        of **Explore Impact Frameworks** plus `stages`, each stage of change with its `title`
        (Activities, Engagement, Ability, Behaviour or Effect) and the outcomes and progress trackers
        in it as `items`. An Impact Framework that isn't public and approved is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 301
      responses:
        "200":
          description: The Impact Framework's preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreImpactFrameworkPreview'
              example:
                id: 301
                name: Quality Education
                description: Outcomes for SDG 4.
                themes: [global_goals]
                framework_sets: []
                outcome_count: 1
                progress_tracker_count: 1
                shared_by: Makerble Templates
                libraries_count: 15
                yours: false
                stages:
                  - title: Activities
                    items: [Sessions delivered]
                  - title: Behaviour (mid-term outcomes)
                    items: [Stays in school]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /explore/ideas:
    get:
      tags: [Explore]
      summary: Explore Ideas
      operationId: listExploreIdeas
      description: |
        Lists the approved Ideas (Tips) shared with everyone in the Makerble® ImpactStore™, with the
        same search, filters, counts and sort as the Explore Ideas page. `shared_by`, `person` and
        `yours` depend on the caller.

        - `query` matches the Idea's title or text.
        - The filters take option keys, as arrays (`theme[]=leadership`) or comma-separated
          (`theme=leadership,inclusion`). Options in one filter combine with OR and filters
          combine with AND:
          - `shared_by`: `anyone`, `colleagues` (colleagues in the caller's organisations and
            projects, or the organisations themselves), `following` (people the caller follows),
            `me`
          - `theme`: `mental_health_and_wellbeing`, `children_and_young_people`, `employment_and_skills`, `community_and_culture`, `health`, `organisational`, `global_goals`, `inclusion`, `education_and_training`, `leadership`
          - `audience`: `public_impact`, `personal`, `professional`, from the Idea's causes
          - `person`: user ids of people who shared Ideas. Only the caller's colleagues, people
            they follow and the caller count; any other id is ignored.
        - `chip` is one of the page's Popular chips: `Community`, `Young people`, `Training`,
          `Leadership`.
        - `facets` gives each filter's options with how many Ideas each would return, given the
          other filters already chosen.
        - `sort` is `added` (saved to the most collections first, the default), `new` or `az`.
        - Save an Idea to a collection in the app with **Save idea** on Explore Ideas.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: cohesion
          description: Words to look for in the Idea's title or text
        - name: shared_by
          in: query
          required: false
          schema:
            type: string
          example: colleagues,following
          description: Shared by option keys, comma-separated or repeated as shared_by[]
        - name: theme
          in: query
          required: false
          schema:
            type: string
          example: leadership
          description: Theme option keys, comma-separated or repeated as theme[]
        - name: audience
          in: query
          required: false
          schema:
            type: string
          example: public_impact
          description: Audience option keys, comma-separated or repeated as audience[]
        - name: person
          in: query
          required: false
          schema:
            type: string
          example: "1204"
          description: User ids of people who shared Ideas, comma-separated or repeated as person[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [Community, Young people, Training, Leadership]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed Ideas that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreIdeas'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 77
                    title: The Resident Leadership Pipeline
                    themes: [leadership, community_and_culture]
                    reading_minutes: 4
                    shared_by: Northside Housing
                    saved_count: 14
                    yours: false
                facets:
                  - key: theme
                    label: Theme
                    options:
                      - value: leadership
                        label: Leadership
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/ideas/{id}:
    get:
      tags: [Explore]
      summary: Read an Explore Idea
      operationId: getExploreIdea
      description: |
        One Idea listed on Explore Ideas: the fields of **Explore Ideas** plus its `text`, without
        formatting. An Idea that isn't approved and shared with everyone is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 77
      responses:
        "200":
          description: The Idea and its text
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreIdeaPreview'
              example:
                id: 77
                title: The Resident Leadership Pipeline
                themes: [leadership]
                reading_minutes: 1
                shared_by: Northside Housing
                saved_count: 14
                yours: false
                text: We grew resident leaders who now run three local groups.
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /experts/{id}:
    get:
      tags: [Explore]
      summary: Read a Makerble Expert's profile
      operationId: getExpert
      description: |
        The public profile of a Makerble Expert listed in the Makerble® ImpactStore™, the same as the Expert profile page
        shows: the organisation, its level (Certified Implementer while one of its people holds a current certification,
        otherwise Makerble Expert), its services in its own words, its newest Ideas and the Toolkits it knows. A Paused
        Expert has `taking_introductions: false`. A Removed or Declined Expert, or one not yet listed, is a 404. The id may
        carry the organisation's name, as on the profile page (`12-ellison-associates`).
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          example: "12"
      responses:
        "200":
          description: The Expert's profile
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExpertProfile'
              example:
                id: 12
                name: Ellison Associates
                level: Certified Implementer
                headline: Theory of Change for youth charities
                bio: We help small teams measure what matters.
                logo_url: null
                how_they_work: Remotely, and in person in Bath and Bristol
                taking_introductions: true
                reviewed_on: "2026-11-03"
                website: https://ellison.example
                typical_project_size: £5k to £15k
                profile_url: https://makerble.com/explore/experts/12-ellison-associates
                services:
                  - key: staff_training
                    name: Staff training
                    description: Half-day sessions for frontline staff.
                certified_people:
                  - name: Rachel Ellison
                    certified_until: "2027-10-31"
                ideas:
                  - id: 77
                    title: Start with the change you want to see
                    yours: false
                toolkits:
                  - id: 5
                    name: Youth Employability
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /explore/metrics:
    get:
      tags: [Explore]
      summary: Explore Metrics
      operationId: listExploreMetrics
      description: |
        Lists the published, approved metrics of the Makerble® ImpactStore™ across the stages of
        change, with the same search, filters, counts and sort as the Explore Metrics page:
        progress trackers (`kind` `change`: Activities and Engagement), outcome indicators (`kind`
        `indicator`: Ability, Behaviour and Effect, taking the stage of the Outcome they sit under
        when they have none of their own) and Financial Values (`kind` `financial_value`). Every
        caller sees the same metrics; `yours` depends on the caller's organisations.

        - `query` matches the metric's name or description.
        - The filters take option keys, as arrays (`stage[]=ability`) or comma-separated
          (`stage=ability,behaviour`). Options in one filter combine with OR and filters
          combine with AND:
          - `stage` (Stage of change): `activities`, `engagement`, `ability`, `behaviour`,
            `effect`, `financial_values`
          - `answer_format`: `count` (progress tracker), `scale` (Choice tracker), `yes_no`
            (Achievement tracker), `value` (Numerical tracker, and Financial Values)
          - `audience`: `public_impact`, `personal`, `professional`
          - `shared_by`: `makerble`, `others`
        - `chip` is one of the page's Popular chips: `Wellbeing`, `Employment`, `Housing`,
          `Attendance`, `SDGs`.
        - `facets` gives each filter's options with how many metrics each would return, given the
          other filters already chosen.
        - `sort` is `added` (on the most organisations' projects first, the default), `new` or `az`.
        - Add a tracker or indicator to a project in the app with **Add to a project** on Explore
          Metrics; a Financial Value from Explore Financial Values.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: confidence
          description: Words to look for in the metric's name or description
        - name: stage
          in: query
          required: false
          schema:
            type: string
          example: ability,behaviour
          description: Stage of change option keys, comma-separated or repeated as stage[]
        - name: answer_format
          in: query
          required: false
          schema:
            type: string
          example: scale
          description: Answer format option keys, comma-separated or repeated as answer_format[]
        - name: audience
          in: query
          required: false
          schema:
            type: string
          example: personal
          description: Audience option keys, comma-separated or repeated as audience[]
        - name: shared_by
          in: query
          required: false
          schema:
            type: string
          example: makerble
          description: Shared by option keys, comma-separated or repeated as shared_by[]
        - name: chip
          in: query
          required: false
          schema:
            type: string
            enum: [Wellbeing, Employment, Housing, Attendance, SDGs]
          description: One of the Popular chips
        - name: sort
          in: query
          required: false
          schema:
            type: string
            enum: [added, new, az]
            default: added
          description: Most added, Newest, or A to Z
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: The listed metrics that match, and each filter's option counts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedExploreMetrics'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - kind: indicator
                    id: 5310
                    name: Job satisfaction
                    stage: ability
                    whats_inside: 5-level scale
                    shared_by: Makerble
                    libraries_count: 21
                    yours: false
                facets:
                  - key: answer_format
                    label: Answer format
                    options:
                      - value: scale
                        label: Scale (Choice tracker)
                        count: 1
                        selected: true
        "401":
          $ref: '#/components/responses/Unauthorized'
  /explore/metrics/{kind}/{id}:
    get:
      tags: [Explore]
      summary: Preview an Explore Metric
      operationId: getExploreMetric
      description: |
        One metric listed on Explore Metrics, as its Preview shows it: the fields of **Explore
        Metrics** plus its `description`, `details` (its key facts by label, such as the Outcomes an
        indicator sits under or a Financial Value's amount and source) and the `choices` of a scale
        or yes-or-no indicator, in order. A metric that isn't published and approved is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: kind
          in: path
          required: true
          schema:
            type: string
            enum: [change, indicator, financial_value]
          example: indicator
        - name: id
          in: path
          required: true
          schema:
            type: integer
          example: 5310
      responses:
        "200":
          description: The metric's preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExploreMetricPreview'
              example:
                kind: indicator
                id: 5310
                name: Job satisfaction
                stage: ability
                whats_inside: 5-level scale
                shared_by: Makerble
                libraries_count: 21
                yours: false
                description: How satisfied someone is with their job.
                details:
                  Answer format: 5-level scale
                  Stage of change: Ability (short-term outcomes)
                  Sits under: Job satisfaction at follow-up
                  Shared by: Makerble
                choices: [Very dissatisfied, Dissatisfied, Neither, Satisfied, Very satisfied]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /library/search:
    get:
      tags: [Library]
      summary: Search the library
      operationId: searchLibrary
      description: |
        Searches the reusable building blocks you may see: your organisation's own library, the
        public library shared by every organisation, or both. Use it before making a new Survey,
        Metric or List, so results keep adding up with those recorded against the original.

        - Every word of `query` must match the item's name or description. Surveys also match on
          their question wording, Lists on their choices, and Metrics on their default question.
        - `item_types` limits the search to some types (comma-separated): `survey` (Survey),
          `metric` (Metric), `activity_tracker` (Activity or Attendance tracker), `outcome`,
          `list` (List of answer choices), `unit`, `field`, `contact_form` (Contact Form),
          `case_form` (Case Form), `impact_framework` (Impact Framework), `toolkit`,
          `project_type` and `idea`. Default: every type.
        - `source` is `organisation` (default), `public` or `both`. The public library holds items
          approved for everyone; Makerble staff also see public items awaiting approval. Units and
          Project Types belong to no organisation and are always included.
        - `page` and `per_page` apply to each type, so a page holds up to `per_page` results of
          each type. `total_count` adds up every type's matches and `page_count` is the page count
          of the type with the most matches.
        - Each result has `owner`: `your organisation`, `public library` or `Makerble`. Metrics also
          have `metric_type` (`scale`, `value` or `binary`) and `choices`; Lists have `choices`.
      security: [{tokenAuth: []}]
      parameters:
        - name: query
          in: query
          required: false
          schema:
            type: string
          example: agree disagree
          description: Words to look for. Leave it out to list everything of the chosen types.
        - name: item_types
          in: query
          required: false
          schema:
            type: string
          example: metric,list
          description: Comma-separated item types to search (default every type)
        - name: source
          in: query
          required: false
          schema:
            type: string
            enum: [organisation, public, both]
            default: organisation
          description: Which library to search
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Matching items, up to `per_page` of each type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedLibrarySearch'
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - id: 812
                    type: metric
                    name: Confidence
                    description: How confident the person feels about the future
                    owner: your organisation
                    metric_type: scale
                    choices: ["Strongly agree", "Agree", "Disagree", "Strongly disagree"]
                  - id: 97
                    type: list
                    name: Agree – Disagree
                    description: null
                    owner: public library
                    choices: ["Strongly agree", "Agree", "Disagree", "Strongly disagree"]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          description: An unknown `item_types` value or `source`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "Unknown item type 'spreadsheet'. Use one of: survey, metric, activity_tracker, outcome, list, unit, field, contact_form, case_form, impact_framework, toolkit, project_type, idea"

  /library/{item_type}/{id}:
    get:
      tags: [Library]
      summary: Get a library item
      operationId: getLibraryItem
      description: |
        Reads one library item in full, so it can be reused or copied. Use the `type` and `id` from
        **Search the library**. Besides `id`, `type`, `name` and `owner`:

        - **survey**: `description`, `intervals` (its Shared Intervals in order), `question_grids`
          (`{outcome_id, heading, questions}`), `scoring` (`{questions, verdicts}` when it is scored), `outcomes` and
          `questions` in the order the Survey shows them. `outcomes` lists each Outcome the Survey's
          Metrics are in as `{id, name, catch_all, other_metric_count, warning}`: every Project using
          the Survey gets all the Metrics in these Outcomes, and `other_metric_count` is how many of
          them the Survey doesn't ask about. `warning` is `true` when that is more than 5, or when the
          Outcome is a catch-all (an organisation's Becoming Able, Influencing Behaviour or Achieving
          Growth, or a person's Not Yet Categorised Outcome) holding any other Metric, so you can show
          the same hint as the Survey editor. A question has `question` (its wording), `mandatory` and
          `item` (the Metric, List, Field or Activity tracker behind it, with `metric_type`, `unit`
          and `choices` where they apply), `by_interval` when it is reworded or hidden in an
          Interval, and `display_if` (a list) and `skip_to` when it has those rules (see **Create a
          Survey with its questions**). A section title is `{section, text}`.
        - **metric**: `description`, `metric_type`, `default_question`, `unit`, `list` (with
          `choices`), `success_direction` and `outcomes`.
        - **list**: `choices` in order, each with `id`, `name` and `points`.
        - **contact_form**: `fields`, shaped like a Survey's questions. **case_form**: `fields`,
          each with `name`, `field_type`, `mandatory` and `choices`.
        - **impact_framework**: `description` and `stages`, each with its `outcomes`,
          `activity_trackers` and `metrics`.
        - **toolkit**: `description` and `contents`, each with `type`, `id` and `name`.
        - **activity_tracker**: `description`, `instruction`. **outcome**: `description`, `metrics`.
          **unit**: `alignment`. **field**: `field_type`, and `capture_type` (`video`, `audio` or
          `picture`) for a Video, Audio or Picture question. **project_type**: `strapline`,
          `description`. **idea**: `description`.

        Linked Outcomes and Metrics are named only when you may see them. An item you may not see
        returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: item_type
          in: path
          required: true
          schema:
            type: string
          example: survey
          description: The item's type, as in **Search the library**
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The item
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LibraryItem'
              example:
                id: 3051
                type: survey
                name: Wellbeing check
                owner: your organisation
                description: Monthly check-in
                questions:
                  - section: About you
                    text: A few questions about you
                  - question: How confident do you feel?
                    mandatory: true
                    item:
                      type: metric
                      id: 812
                      name: Confidence
                      metric_type: scale
                      unit: null
                      choices: ["Strongly agree", "Agree", "Disagree", "Strongly disagree"]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: An unknown `item_type`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /library/{item_type}/{id}/usage:
    get:
      tags: [Library]
      summary: See where a library item is used
      operationId: getLibraryItemUsage
      description: |
        Says whether anything depends on a library item before you change it.

        - `projects`: up to 50 projects you can see that use it, and `other_projects_count` for the rest.
        - `records_count` and `last_used_at`: survey responses for a Survey; recorded values for a
          Metric, Activity tracker, Outcome or List; Contacts for a Contact Form; Cases for a Case Form.
        - `contained_in`: up to 50 Surveys, Contact Forms, Outcomes, Impact Frameworks, Metrics or
          Toolkits that include it and that you may see. `contained_in_count` counts them all.
        - `in_use` is true when any of these is above zero.

        Counts only: no records are returned. An item you may not see returns `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: item_type
          in: path
          required: true
          schema:
            type: string
          example: metric
          description: The item's type, as in **Search the library**
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: Where the item is used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LibraryUsage'
              example:
                id: 812
                type: metric
                name: Confidence
                projects:
                  - id: 4410
                    name: Breakfast club
                other_projects_count: 3
                records_count: 40
                last_used_at: "2026-10-14T09:12:00.000Z"
                contained_in:
                  - type: survey
                    id: 3051
                    name: Wellbeing check
                contained_in_count: 1
                in_use: true
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: An unknown `item_type`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

  /lists:
    post:
      tags: [Library]
      summary: Create a List
      operationId: createList
      description: |
        Creates a List (a Ratio Set): the answer choices for a multiple-choice question or a scale
        Metric, e.g. "Agree - Disagree". The choices keep the order you send, at most 50, each
        different. The List stays private to your organisation.

        Search the library first (**Search the library**) and reuse a List that fits. If your
        organisation or the public library already has a List with the same or a near-identical
        name (ignoring case, spacing and punctuation), nothing is created and you get `409` with the
        matches. Send `force: true` to create it anyway. Your organisation can never have two Lists
        with exactly the same name, so that is a `409` even with `force`.

        Nothing is created unless everything is: a bad choice creates no List.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [organisation_id, name, choices]
              properties:
                organisation_id:
                  type: integer
                  description: The organisation (Charity) that will own it; you must be one of its editors
                name:
                  type: string
                choices:
                  type: array
                  maxItems: 50
                  items:
                    type: string
                force:
                  $ref: '#/components/schemas/ForceCreate'
            example:
              organisation_id: 913
              name: "Agree - Disagree"
              choices: ["Strongly agree", "Agree", "Neutral", "Disagree", "Strongly disagree"]
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /lists/{id}:
    patch:
      tags: [Library]
      summary: Change a List
      operationId: updateList
      description: |
        Renames a List (a Ratio Set) or changes its answer choices. Choices keep their place: the
        first choice you send renames the first choice, and so on. Extra choices are added at the
        end, and saved choices past the last one you send are removed.

        Every Metric and Survey that uses the List sees the change. Check where it is used first
        (**See where a library item is used**), and create a new List instead when other Surveys use it.
        You must be able to edit the List: its creator, or an editor of the organisation that owns
        it. A List you can see but not edit is `403`; one you can't see is `404`. No choices, or
        nothing to change, is `422`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                choices:
                  type: array
                  items:
                    type: string
                  description: Every choice, in order
            example:
              name: "Interview confidence scale"
              choices: ["Very confident", "Quite confident", "Not very confident", "Not at all confident"]
      responses:
        "200":
          $ref: '#/components/responses/LibraryItemUpdated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /units:
    post:
      tags: [Library]
      summary: Create a Unit
      operationId: createUnit
      description: |
        Creates a Unit: the unit of measure shown beside a number answer, e.g. "hours" or "£".
        Units are shared by every organisation, so only Makerble staff may create one; anyone else
        gets `403` and should reuse an existing Unit. A Unit that already exists is never changed.
        Near-identical names get `409`, as for **Create a List**.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name, alignment]
              properties:
                name:
                  type: string
                alignment:
                  type: string
                  enum: [left, right]
                  description: Which side of the number it goes, e.g. left for £10, right for 10 hours
                force:
                  $ref: '#/components/schemas/ForceCreate'
            example:
              name: "sessions"
              alignment: right
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /fields:
    post:
      tags: [Library]
      summary: Create a Field
      operationId: createField
      description: |
        Creates a Field (a Custom Field): a question with a free answer rather than a Metric, e.g.
        "Date of birth" (date) or "Postcode" (text), for a Survey or Contact Form. A `section_title`
        Field is a heading with `section_text` under it; it isn't listed in the library, so the
        response has only its `id`, `type`, `name` and `approved`. Fields are never shared in the
        public library. Near-identical names get `409`, as for **Create a List**.

        **Video, Audio and Picture questions.** `video`, `audio` and `picture` create a Video, Audio
        or Picture question for a Survey (Story Category): an Attachment Field that asks for that kind
        of media, which the person answering can record or take there and then with their camera or
        microphone, or attach from their device. It is stored and returned as `field_type: file` with
        `capture_type` set to `video`, `audio` or `picture`, and its answers are uploaded files like any
        other Attachment answer.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [organisation_id, field_name, field_data_type]
              properties:
                organisation_id:
                  type: integer
                  description: The organisation (Charity) that will own it; you must be one of its editors
                field_name:
                  type: string
                field_data_type:
                  type: string
                  enum: [text, number, date, time, file, video, audio, picture, section_title, email_address, telephone, signature]
                  description: |
                    A Weekly availability field can only be made as part of a Contact Form (`POST /contact_forms`), not here.
                    The kind of answer. `file` is an Attachment for any file; `video`, `audio` and
                    `picture` ask for that kind of media (see above).
                section_text:
                  type: string
                  description: For a section_title Field only
                private:
                  type: boolean
                  description: True if only the organisation's staff may see the answers
                force:
                  $ref: '#/components/schemas/ForceCreate'
            examples:
              text:
                summary: A text Field
                value:
                  organisation_id: 913
                  field_name: "Postcode"
                  field_data_type: text
              video:
                summary: A Video question
                value:
                  organisation_id: 913
                  field_name: "Record a short video telling us what you learnt today"
                  field_data_type: video
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /surveys:
    post:
      tags: [Library, Story Categories]
      summary: Create a Survey with its questions
      operationId: createSurvey
      description: |
        Creates a Survey (Story Category) with all its questions, in the order given (at most 50).
        Each question either reuses an item your organisation or the public library already has, by
        id, or defines a new one:

        - `metric_id`, `field_id` or `activity_tracker_id`: reuse a Metric (Indicator), Field
          (Custom Field) or Activity tracker (Change). Any id you can't see is `404`.
        - `new_metric`: a new Metric, with `outcome_id` for the Outcome it measures. A scale
          Metric needs `list_id` (an existing List) or `list` (a new List with its choices).
        - `new_field`: a new Field; `section_title` makes a heading.

        Search the library first and reuse what fits: results recorded against a copy of a Metric
        don't add up with the original. If a new Metric, List or Field has the same or a
        near-identical name to one you could reuse, nothing is created and you get `409` with the
        matches, each with the `question` it belongs to. Send `force: true` to create them anyway.

        Nothing is created unless everything is: an invalid question creates nothing, and the error
        names it ("Question 3: ..."). The Survey and its new items stay private to your organisation
        unless you are Makerble staff and send `approved: true`.

        **Surveys answered more than once.** Keep one Survey with the same Metrics and name its Shared
        Intervals in `intervals`, e.g. `["Baseline", "Endpoint"]`, so Distance Travelled works. Each
        question can then be reworded or hidden in them (Adjust When):

        - `by_interval`: entries `{interval, respondent, question}` to reword it, or
          `{interval, respondent, hide: true}` to hide it. Leave out `interval` for every Interval and
          `respondent` (`participant`, `colleague`, `observer` or `public`) for everyone. Where two
          entries cover the same Interval and respondent, the one naming more wins; two naming the
          same amount are `422`.
        - `only_in_intervals`: show the question only in these Intervals.

        Projects the Survey is added to later use its Intervals. An Interval the Survey doesn't
        have, or wording without `intervals`, is `422` and creates nothing.

        **Questions that only apply after a certain answer.** Questions are numbered by their place
        in `questions`, counting section headings.

        - `display_if`: `{question, answers}` shows the question only when that earlier question is
          answered with one of `answers` (Display If). A list of them shows it when any is met.
        - `skip_to`: `[{answers, question}]` jumps forward, past the questions in between, to a later
          question that isn't mandatory (Skip To). Each answer may appear in one entry only.

        The question whose answer decides must be a scale Metric, whose answers are its List: for
        yes/no, use a scale Metric on a Yes - No List, not a binary Metric. A Survey can't skip to its
        end. Anything else is `422`, naming the question.

        **Choosing an Outcome.** Every Project using the Survey gets all the Metrics in its questions'
        Outcomes. The response's `outcomes` says how many other Metrics each Outcome adds
        (`other_metric_count`) and sets `warning` when that is a lot; create a right-sized Outcome
        with `POST /outcomes` rather than using a catch-all.

        **Question Grids.** `question_grids: [{outcome_id, questions}]` shows scale questions that
        measure one Outcome first and share one List as one table, headed by the Outcome's title.
        Every scale question of that Outcome in the Survey must be in the grid, on the same List, and
        grid questions can't have `display_if` or `skip_to`. Anything else is `422`, naming the grid.

        **Scoring and Verdicts.** A new scale Metric can have `points` for every answer on its List,
        e.g. `{"Never": 0, "Often": 2}`. `scoring: {questions, verdicts}` adds up those questions'
        points and names each band of totals (Verdicts), e.g. Low 0-4, Medium 5-9, High 10-15.
        Only new Metrics can be given points: a reused Metric's points are shared by every Survey
        using it, so a reused Metric can be scored only if it already has them. The bands must be
        whole numbers covering every possible total with no gaps or overlaps; anything else is
        `422`, naming the question or band.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [organisation_id, name, questions]
              properties:
                organisation_id:
                  type: integer
                  description: The organisation (Charity) that will own it; you must be one of its editors
                name:
                  type: string
                description:
                  type: string
                intro_message:
                  type: string
                departments:
                  type: array
                  items: {type: string}
                causes:
                  type: array
                  items: {type: string}
                sub_causes:
                  type: array
                  items: {type: string}
                scoring:
                  type: object
                  description: A scored Survey (Verdicts)
                  required: [questions, verdicts]
                  properties:
                    questions:
                      type: array
                      description: The numbers of the scale questions whose points add up
                      items: {type: integer}
                    verdicts:
                      type: array
                      description: The bands of totals, covering every possible total with no gaps or overlaps
                      items:
                        type: object
                        required: [name, from, to]
                        properties:
                          name: {type: string, example: Low}
                          from: {type: integer, example: 0}
                          to: {type: integer, example: 4}
                          description: {type: string}
                question_grids:
                  type: array
                  description: Question Grids, each an Outcome and the numbers of the scale questions shown as one table under its title
                  items:
                    type: object
                    required: [outcome_id, questions]
                    properties:
                      outcome_id:
                        type: integer
                      questions:
                        type: array
                        minItems: 2
                        items: {type: integer}
                intervals:
                  type: array
                  maxItems: 10
                  description: The Survey's Shared Intervals in order, when it is answered more than once
                  items: {type: string, maxLength: 255}
                approved:
                  type: boolean
                  description: Makerble staff only
                force:
                  $ref: '#/components/schemas/ForceCreate'
                questions:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    $ref: '#/components/schemas/SurveyDraftQuestion'
            example:
              organisation_id: 913
              name: "Job readiness check-in"
              intervals: [Baseline, Endpoint]
              questions:
                - metric_id: 4412
                  is_mandatory: true
                  by_interval:
                    - interval: Endpoint
                      question: "How confident do you feel about getting a job now, after the course?"
                - new_metric:
                    name: "Job search hours"
                    metric_type: value
                    default_question: "How many hours did you spend looking for work this week?"
                    outcome_id: 3301
                - new_metric:
                    name: "Interview confidence"
                    metric_type: scale
                    default_question: "How confident do you feel about interviews?"
                    outcome_id: 3301
                    list_id: 2210
                - new_field:
                    field_name: "Postcode"
                    field_data_type: text
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /surveys/{id}/projects:
    post:
      tags: [Library, Story Categories]
      summary: Add a Survey to Projects
      operationId: addSurveyToProjects
      description: |
        Adds a Survey (Story Category) to Projects, as **Add survey to project(s)** on a Survey's
        page does, so people in those Projects can answer it and its results show there.

        - The Survey must be one you can see in your library: your organisation's own, or the
          public library. Otherwise `404`.
        - You must manage each Project, or be an Admin of its organisation. Otherwise `404`,
          naming the Project.
        - A closed Project, or one whose Project Category doesn't allow other Surveys, is `422`.

        Every Project is checked first, so if one is refused none is added. A Project that
        already uses the Survey is left as it is and listed in `existing_project_ids`.

        When the Survey has Shared Intervals (shared waves) in a Project's own organisation,
        shared waves are turned on automatically for that Project's survey campaign, including
        one that already used the Survey. They are never turned off.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: The Survey's (Story Category's) id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_ids]
              properties:
                project_ids:
                  type: array
                  minItems: 1
                  items:
                    type: integer
                  description: The Projects to add it to
            example:
              project_ids: [4021, 4022]
      responses:
        "200":
          description: The Survey is in every Project given
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      survey_id:
                        type: integer
                      added_project_ids:
                        type: array
                        items:
                          type: integer
                        description: Projects the Survey was added to now
                      existing_project_ids:
                        type: array
                        items:
                          type: integer
                        description: Projects that already used it
              example:
                data:
                  survey_id: 812
                  added_project_ids: [4021]
                  existing_project_ids: [4022]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /surveys/{id}:
    patch:
      tags: [Library, Story Categories]
      summary: Change a Survey
      operationId: updateSurvey
      description: |
        Changes a Survey's (Story Category's) name, description and intro message, as the Survey's
        Edit page does. Send only what changes. You must be able to edit the Survey: an editor of the
        organisation that owns it.

        A name your organisation already uses for another Survey (ignoring case) is `422`, naming
        that Survey. A Survey you can see but not edit, such as another organisation's public
        Survey, is `403`; one you can't see is `404`.
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                intro_message:
                  type: string
                  description: Shown to people before they start
            example:
              name: "Job readiness check-in"
              intro_message: "This takes about two minutes."
      responses:
        "200":
          $ref: '#/components/responses/LibraryItemUpdated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /surveys/{id}/questions:
    patch:
      tags: [Library, Story Categories]
      summary: Change a Survey's questions
      operationId: updateSurveyQuestions
      description: |
        Adds, removes, replaces and moves a Survey's questions, as the Survey's Edit page does. Send
        the changes in order: each applies to the questions as the changes before it left them.
        Question numbers are as **Get a library item** lists the Survey's questions, starting at 1.

        - `add`: `question`, and optionally `number` to put it at (default: the end).
        - `remove`: `number`. The question is taken off the Survey; the Metric or Field behind it is kept.
        - `replace`: `number` and `question`.
        - `move`: `number` and `to`.

        A new question takes the same format as in **Create a Survey with its questions**: reuse a
        Metric, Field or Activity tracker by id, or define `new_metric` or `new_field`. A new item
        with the same or a near-identical name as one you could reuse is `422`; send `force: true`
        only if none fits.

        Nothing is changed unless every change can be made. A bad change is `422` naming it, e.g.
        "Change 2: there is no question 5".
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [changes]
              properties:
                changes:
                  type: array
                  items:
                    type: object
                    required: [action]
                    properties:
                      action:
                        type: string
                        enum: [add, remove, replace, move]
                      number:
                        type: integer
                      to:
                        type: integer
                        description: move only
                      question:
                        $ref: '#/components/schemas/SurveyDraftQuestion'
                force:
                  $ref: '#/components/schemas/ForceCreate'
            example:
              changes:
                - {action: add, number: 1, question: {metric_id: 14702, is_mandatory: true}}
                - {action: remove, number: 3}
                - {action: move, number: 2, to: 4}
      responses:
        "200":
          $ref: '#/components/responses/LibraryItemUpdated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /contact_forms:
    post:
      tags: [Library, Beneficiary Categories]
      summary: Create a Contact Form with its fields
      operationId: createContactForm
      description: |
        Creates a Contact Form (Beneficiary Category): the form your organisation fills in about each
        Contact of one kind, with its fields in the order given (at most 50). Each field either
        reuses an item you can see by id (`field_id` for a Field, `list_id` for a List of answer
        choices) or defines a new one (`new_field`, `new_list`).

        Only organisations that use Contact Forms can have one (otherwise `403`). Near-identical
        names of new Fields and Lists get `409` with the matches, each with its `question`, unless
        you send `force: true`. Nothing is created unless everything is. Only your organisation uses
        the form unless you are Makerble staff and send `approved: true`.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [organisation_id, name, department, contact_role, questions]
              properties:
                organisation_id:
                  type: integer
                  description: The organisation (Charity) that will own it; you must be one of its editors
                name:
                  type: string
                department:
                  type: string
                  enum: [Personal, Professional, Public Impact]
                contact_role:
                  type: string
                  description: What the Contacts are to the organisation, e.g. Participant
                contact_type:
                  type: string
                  description: Person (default), Organisation, Animal or Object
                approved:
                  type: boolean
                  description: Makerble staff only
                force:
                  $ref: '#/components/schemas/ForceCreate'
                questions:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    $ref: '#/components/schemas/ContactFormDraftQuestion'
            example:
              organisation_id: 913
              name: "Young person registration"
              department: Personal
              contact_role: Participant
              questions:
                - field_id: 5120
                  is_mandatory: true
                - new_list:
                    name: "School year"
                    choices: ["Year 7", "Year 8", "Year 9"]
                - new_field:
                    field_name: "Date of birth"
                    field_data_type: date
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /contact_forms/{id}/projects:
    post:
      tags: [Library, Beneficiary Categories]
      summary: Add a Contact Form to projects
      operationId: addContactFormToProjects
      description: |
        Adds a Contact Form (Beneficiary Category) to projects, as **Add form to project** on a
        Contact Form's page does, so staff in those projects use it when they add or edit Contacts.

        `use` says how each project uses it: `full` (the default) to create new Contacts and edit
        existing ones, `create` to create new Contacts only, or `edit` to edit existing Contacts
        only. Organisation Admins and Project Managers may then edit what it holds. Only the
        project's Contact Form settings change.

        - Each project must belong to the form's organisation, and you must be able to change its
          Project Preferences: an Organisation Admin, or the project's manager. Otherwise `404`,
          naming the project.
        - A form that doesn't exist is `404`; an organisation that doesn't use Contact Forms is `422`.

        Every project is checked first, so if one is refused none is changed. A project that
        already uses the form that way is left as it is and listed in `existing_project_ids`.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: The Contact Form's (Beneficiary Category's) id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_ids]
              properties:
                project_ids:
                  type: array
                  minItems: 1
                  items:
                    type: integer
                  description: The projects to add it to
                use:
                  type: string
                  enum: [full, create, edit]
                  default: full
                  description: How the projects use it
            example:
              project_ids: [4021, 4022]
              use: create
      responses:
        "200":
          description: The form is in every project given
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      contact_form_id:
                        type: integer
                      use:
                        type: string
                        enum: [full, create, edit]
                      added_project_ids:
                        type: array
                        items:
                          type: integer
                        description: Projects the form was added to now
                      existing_project_ids:
                        type: array
                        items:
                          type: integer
                        description: Projects that already used it that way
              example:
                data:
                  contact_form_id: 2391
                  use: create
                  added_project_ids: [4021]
                  existing_project_ids: [4022]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /impact_frameworks:
    post:
      tags: [Library]
      summary: Create an Impact Framework with its entries
      operationId: createImpactFramework
      description: |
        Creates an Impact Framework (Template), your organisation's theory of change, with its
        entries in order. Each entry has a `stage` and exactly one item:

        - `activity_tracker_id` or `new_activity_tracker` (an Activity or Attendance tracker, a
          Change) in `Activity outputs` or `Participation outputs`;
        - `outcome_id` or `new_outcome` in `Short-term outcomes`, `Medium-term outcomes` or
          `Long-term outcomes`. An Outcome entry can also have `new_metrics`: new Metrics
          (Indicators) that measure it, and `indicator_ids`: existing Metrics. For a reused Outcome,
          the framework takes only those of its Metrics (plus its new Metrics) instead of all of
          them, so projects using it don't get Metrics they don't need. For a new Outcome, they are
          linked to it as they are, not copied. An id you can't see, or that isn't one of the reused
          Outcome's Metrics, answers `404` and creates nothing.

        At most 50 entries and new Metrics together. Near-identical names of new items get `409`
        with the matches, each with its `entry`, unless you send `force: true`. Nothing is created
        unless everything is, and an error names the entry. It stays private to your organisation
        unless you are Makerble staff and send `approved: true`.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [organisation_id, name, entries]
              properties:
                organisation_id:
                  type: integer
                  description: The organisation (Charity) that will own it; you must be one of its editors
                name:
                  type: string
                description:
                  type: string
                color:
                  type: string
                causes:
                  type: array
                  items: {type: string}
                department:
                  type: string
                approved:
                  type: boolean
                  description: Makerble staff only
                force:
                  $ref: '#/components/schemas/ForceCreate'
                entries:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    $ref: '#/components/schemas/ImpactFrameworkDraftEntry'
            example:
              organisation_id: 913
              name: "Youth employment"
              entries:
                - stage: Activity outputs
                  new_activity_tracker:
                    name: "Workshops delivered"
                    category: Education
                - stage: Short-term outcomes
                  outcome_id: 3301
                  indicator_ids: [5521, 5524]
                  new_metrics:
                    - name: "Job search hours"
                      metric_type: value
                      default_question: "How many hours did you spend looking for work this week?"
                - stage: Long-term outcomes
                  new_outcome:
                    title: "In sustained work"
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/LibraryCreateForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "409":
          $ref: '#/components/responses/LibraryDuplicates'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /impact_frameworks/{id}/copy:
    post:
      tags: [Library]
      summary: Copy an Impact Framework
      operationId: copyImpactFramework
      description: |
        Copies an Impact Framework (Template), as **Copy** on the Manage Impact Frameworks page does.
        The copy is named `Copy of <name>` and keeps the original's stages, metrics (Activity and
        Attendance trackers, Outcomes and the trackers placed on it), causes, description and colour,
        but none of its projects: it is not added to any project. It is yours, private and unapproved,
        in the original's organisation if you belong to it, otherwise among your own Impact Frameworks.

        You may copy your own Impact Frameworks, any of an organisation you belong to, the Theory of
        Change of a project you edit, and approved ImpactStore frameworks. Any other id answers `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Impact Framework (Template) to copy
          schema:
            type: integer
          example: 7174
      responses:
        "201":
          $ref: '#/components/responses/LibraryItemCreated'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /impact_frameworks/{id}/missing_metrics:
    get:
      tags: [Library]
      summary: List an Impact Framework's metrics a Results Canvas can't show
      operationId: listMissingFrameworkMetrics
      description: |
        When a project's or an album's Results Canvas is viewed through an Impact Framework (its **Metrics**
        dropdown), it shows only the framework's metrics that are already used on the project. This lists
        the rest: the framework's Activity and Attendance trackers (`Change`) and Outcomes (`Outcome`) that
        aren't used on the project, or aren't used on one or more of the album's open projects. It is the
        list the canvas's "metrics aren't shown" popup shows.

        Each metric names the projects without it, and `can_add` says whether you may add it there. Add a
        metric with [Add metric to](#add-metric-to): `POST
        /metrics/{change|outcome}/{metric_id}/destinations/projects/{project_id}`.

        Give `project_id` or `album_id`. The project must be one you can open, the album one you can view,
        and the Impact Framework one the canvas's Metrics dropdown offers you (your organisation's or your
        own). Anything else answers `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Impact Framework (Template)
          schema:
            type: integer
          example: 7174
        - name: project_id
          in: query
          description: The project whose Results Canvas to check
          schema:
            type: integer
          example: 2210
        - name: album_id
          in: query
          description: The album (Bundle) whose Results Canvas to check, instead of a project
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The missing metrics, in the framework's column order
          content:
            application/json:
              schema:
                type: object
                properties:
                  impact_framework:
                    type: object
                    properties:
                      id: { type: integer }
                      name: { type: string }
                  project_id: { type: integer, nullable: true }
                  album_id: { type: integer, nullable: true }
                  page: { type: integer }
                  page_size: { type: integer }
                  page_count: { type: integer }
                  total_count: { type: integer }
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        metric_type: { type: string, enum: [Change, Outcome] }
                        metric_id: { type: integer }
                        name: { type: string }
                        stage: { type: string, description: The Impact Scorecard column the framework puts it in }
                        stage_id: { type: integer }
                        projects:
                          type: array
                          description: The projects that don't use the metric yet
                          items:
                            type: object
                            properties:
                              id: { type: integer }
                              name: { type: string }
                              can_add: { type: boolean, description: Whether you may add the metric to this project }
              example:
                impact_framework: { id: 7174, name: Bambanani ECD Logic Model }
                project_id: null
                album_id: 381
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - metric_type: Outcome
                    metric_id: 5521
                    name: Improved school readiness
                    stage: Short-term outcomes
                    stage_id: 3
                    projects:
                      - { id: 2210, name: Bambanani 2026, can_add: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /impact_frameworks/{id}/measurement_plan:
    get:
      tags: [Library]
      summary: Get an Impact Framework's Measurement Plan
      operationId: getImpactFrameworkMeasurementPlan
      description: |
        The Measurement Plan of an Impact Framework (Template): for each metric on it, why it is measured,
        how it is collected and how often. It is what the framework page's **Measurement plan** view shows.
        A metric can sit on many frameworks, so the plan belongs to the framework, not the metric.

        Rows come in the framework's order: stage by stage (`stage`), with an Outcome's Indicators together
        under that Outcome (`outcome`). `kind` says what the metric counts: `count` (an Activity or Engagement
        tracker), `achievement`, `scale` or `quantity` (an Indicator), or `tracker` (a Cohort, Workflow or
        Formula Tracker). `description` is the framework's own reason for measuring the metric, or the
        metric's description until the framework gives one. `frequency` and `methods` are empty until someone
        plans them.

        A `survey` method names the Survey (Story Category) used. The other methods are `timeline` (posts on
        a contact's timeline or the Newsfeed), `event_register`, `spreadsheet` (an import) and `integration`.

        You must be able to view the framework. For a project's Theory of Change, use
        `GET /projects/{project_id}/measurement_plan`. Anything else answers `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Impact Framework (Template)
          schema:
            type: integer
          example: 7174
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          $ref: '#/components/responses/MeasurementPlan'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Library]
      summary: Change a metric on an Impact Framework's Measurement Plan
      operationId: updateImpactFrameworkMeasurementPlan
      description: |
        Changes the plan for one metric on an Impact Framework: why it is measured (`description`), how often (`frequency`,
        with `custom_frequency` when it is `custom`), how it is collected (`methods`). Give only
        the parts to change; the others stay as they are. All of them are saved, or none.

        `methods` replaces the metric's methods. `methods.survey_ids` must be Surveys (Story Categories) that
        already ask about the metric and are yours, your organisation's, or already chosen. To add
        the metric to a Survey first, use [Add metric to](#add-metric-to). Trackers can't be asked in a Survey.
        Colleagues are assigned on each project's plan, so `assignee_user_ids` answers `422` here.

        You need to be able to edit the plan: the framework's creator, or an Organisation Editor of its organisation. Someone who can read the plan but not edit it gets `403`.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Impact Framework (Template)
          schema:
            type: integer
          example: 7174
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MeasurementPlanChange'
            example:
              metric_type: Indicator
              metric_id: 9921
              description: Shows whether the sessions build confidence
              frequency: start_and_end
              methods: { survey_ids: [812], types: [event_register] }
      responses:
        "200":
          description: The metric's plan as it now stands
          content:
            application/json:
              schema:
                type: object
                properties:
                  impact_framework: { $ref: '#/components/schemas/MeasurementPlanFramework' }
                  data: { $ref: '#/components/schemas/MeasurementPlanRow' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/{project_id}/measurement_plan:
    get:
      tags: [Library, Projects]
      summary: Get a project's Measurement Plan
      operationId: getProjectMeasurementPlan
      description: |
        The Measurement Plan of a project's Theory of Change: the Impact Framework that holds the project's
        own metrics. It is what the project's Results Canvas shows in its **Measurement plan** view. The
        response is the same as `GET /impact_frameworks/{id}/measurement_plan`, with
        `impact_framework.project_id` set.

        You must be on the project, or in its organisation. Anything else answers `404`.
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          description: The id of the project
          schema:
            type: integer
          example: 2210
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          $ref: '#/components/responses/MeasurementPlan'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Library]
      summary: Change a metric on a project's Measurement Plan
      operationId: updateProjectMeasurementPlan
      description: |
        Changes the plan for one metric on a project's Theory of Change: why it is measured (`description`), how often (`frequency`,
        with `custom_frequency` when it is `custom`), how it is collected (`methods`) and who measures it (`assignee_user_ids`). Give only
        the parts to change; the others stay as they are. All of them are saved, or none.

        `methods` replaces the metric's methods. `methods.survey_ids` must be Surveys (Story Categories) that
        already ask about the metric and are yours, your organisation's, the project's, or already chosen. To add
        the metric to a Survey first, use [Add metric to](#add-metric-to). Trackers can't be asked in a Survey.

        `assignee_user_ids` replaces who measures the metric, from the project's editors and reporters. A
        reporter assigned or unassigned here is assigned or unassigned on the project's Assign Metrics page too,
        so an unassigned reporter can no longer record that metric.

        You need to be able to edit the plan: a Project Editor of the project, or an Organisation Editor of its organisation. Someone who can read the plan but not edit it gets `403`.
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: path
          required: true
          description: The id of the project
          schema:
            type: integer
          example: 2210
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MeasurementPlanChange'
            example:
              metric_type: Indicator
              metric_id: 9921
              description: Shows whether the sessions build confidence
              frequency: start_and_end
              methods: { survey_ids: [812], types: [event_register] }
              assignee_user_ids: [4410]
      responses:
        "200":
          description: The metric's plan as it now stands
          content:
            application/json:
              schema:
                type: object
                properties:
                  impact_framework: { $ref: '#/components/schemas/MeasurementPlanFramework' }
                  data: { $ref: '#/components/schemas/MeasurementPlanRow' }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /impact_frameworks/{id}/additions:
    get:
      tags: [Library]
      summary: List where an Impact Framework has been added
      operationId: listImpactFrameworkAdditions
      description: |
        The Projects and other Impact Frameworks this Impact Framework (Template) has been added to, by
        whom and when, as recorded by **Add to projects** and by **Add metrics from another project or
        framework** on Edit metrics. Only Projects and frameworks of your organisations, and frameworks
        you made, are listed.

        `project` is null when the receiving framework isn't a Project's Theory of Change. `added_by` is
        null for additions made before Makerble recorded who added them.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Impact Framework (Template)
          schema:
            type: integer
          example: 7174
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Where the framework has been added
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: {type: integer}
                  page_size: {type: integer}
                  page_count: {type: integer}
                  total_count: {type: integer}
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: {type: integer}
                        impact_framework_id: {type: integer}
                        receiving_framework:
                          type: object
                          properties:
                            id: {type: integer}
                            name: {type: string}
                        project:
                          type: object
                          nullable: true
                          properties:
                            id: {type: integer}
                            name: {type: string}
                        added_by:
                          type: object
                          nullable: true
                          properties:
                            id: {type: integer}
                            name: {type: string}
                        added_at: {type: string, format: date-time}
                        updated_at: {type: string, format: date-time}
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 31
                    impact_framework_id: 7174
                    receiving_framework: {id: 5549, name: Youth Club Theory of Change}
                    project: {id: 5427, name: Youth Club}
                    added_by: {id: 812, name: Sam Patel}
                    added_at: "2026-11-18T09:12:44.000Z"
                    updated_at: "2026-11-18T09:12:44.000Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Library]
      summary: Add an Impact Framework to projects or frameworks
      operationId: addImpactFramework
      description: |
        Adds an Impact Framework's (Template's) metrics to Projects and to other Impact Frameworks, as the
        **Add to projects** page and the **Add metrics from another project or framework** box on Edit
        metrics do. Adding to a Project adds the metrics to that Project's own Theory of Change.

        The framework isn't copied: each metric goes into the same stage, a metric already there in that
        stage is skipped, and the addition is recorded (see List where an Impact Framework has been added).
        Adding the same framework again only adds metrics it has gained since.

        You must be able to edit each Project's or framework's metrics. One you can't edit, or that doesn't
        exist, is listed in `refused` and the rest are still added. Give `project_ids`, `framework_ids` or both.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Impact Framework (Template) whose metrics to add
          schema:
            type: integer
          example: 7174
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                project_ids:
                  type: array
                  items: {type: integer}
                  description: Projects to add the metrics to
                framework_ids:
                  type: array
                  items: {type: integer}
                  description: Other Impact Frameworks (Templates) to add the metrics to
            example:
              project_ids: [5427, 5428]
              framework_ids: [1460]
      responses:
        "201":
          description: What was added and what was refused
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      impact_framework_id: {type: integer}
                      added:
                        type: array
                        items:
                          type: object
                          properties:
                            receiving_framework_id: {type: integer}
                            project_id: {type: integer, nullable: true}
                      refused:
                        type: array
                        items:
                          type: object
                          properties:
                            project_id: {type: integer}
                            framework_id: {type: integer}
                            error:
                              type: string
                              enum: [forbidden, not-found, same_framework, not_saved]
              example:
                data:
                  impact_framework_id: 7174
                  added:
                    - {receiving_framework_id: 5549, project_id: 5427}
                    - {receiving_framework_id: 1460, project_id: null}
                  refused:
                    - {project_id: 5428, error: forbidden}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /referral_submissions:
    post:
      tags: [Signup Pages]
      summary: Sync a completed offline submission
      description: |
        The endpoint an offline device posts a completed Signup Page submission to,
        once it regains connectivity. Reuses the exact same model methods the live,
        online submission flow calls — there's no separate "offline" data path to
        keep in sync with the online one.

        **Authentication is a `ReferralLinkSubmissionCredential` bearer token** (the
        `submission_credential.token` from the Form Definition), **not** the standard
        `X-User-Email`/`X-User-Token` pair. Deactivating a Signup Page automatically
        revokes its credential — there's no separate revoke action.

        `primary` is used for a **structured** link (one primary person plus zero or
        more `related_people`); `roles` is used instead for a **personalised** link
        (one entry per person, no "primary" concept). Every `contact_form_answers` /
        survey `answers` object is keyed by the field's `id` from the Form Definition,
        never by name. See the Form Definition's Field object for the value shape
        each `field_type` expects (Sub Ratio ids for dropdown/scale fields, digits-only
        for `telephone`, base64-encoded payload for `media`/`file`, etc.).
      operationId: createReferralSubmission
      security: [{submissionBearerAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReferralSubmissionRequest'
      responses:
        "201":
          description: New submission processed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferralSubmissionResponse'
        "200":
          description: This `idempotency_key` had already been processed — returns the original result, not a new one
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferralSubmissionResponse'
        "401":
          description: Token unknown, or the Signup Page has been deactivated since the token was issued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: "unauthorized"
        "422":
          description: |
            Either the contact form is a `CustomFieldCategory` ("advanced custom field")
            form — unsupported by this endpoint — or a model validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unsupportedContactForm:
                  value: { error: "unsupported-contact-form", detail: "..." }
                invalidSubmission:
                  value: { error: "invalid-submission", detail: ["..."] }

  /suggested_merges:
    get:
      tags: [Suggested Merges]
      summary: List Suggested Merges
      description: |
        The Suggested Merges page (Contacts > Merge Contacts > Suggested Merges): sets of Contacts
        that look like the same person. Only suggestions where the user can see every Contact are
        returned: all the Organisation's Contacts for an Organisation Admin, the Contacts in their
        Projects for a Project Admin. Requires permission to merge Contacts in the Organisation.
        Sorted High match strength first, then newest.
      operationId: listSuggestedMerges
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - name: status
          in: query
          schema:
            type: string
            enum: [pending, merged, rejected, stale]
            default: pending
          description: "pending: waiting for review; rejected: marked Not duplicates; stale: a Contact was deleted"
        - name: source
          in: query
          schema:
            type: string
            enum: [merge_rule, name_scan]
          description: "merge_rule: from a Merge Rule in Suggest mode; name_scan: from similar names"
        - name: beneficiary_id
          in: query
          schema:
            type: integer
          description: Only suggestions that include this Contact
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Suggested Merges
          content:
            application/json:
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 42
                    status: pending
                    source: merge_rule
                    merge_rule: { id: 7, name: Same email }
                    match_strength: high
                    matched_fields: [{ field_id: 31, field_name: email_address, value: grace@example.com, match_type: exact }]
                    contacts:
                      - { id: 101, name: Grace Mensah, created_at: "2026-09-02T10:15:00Z", created_by: { id: 5, name: Asha Patel } }
                      - { id: 188, name: Grace Mensah, created_at: "2026-10-21T08:02:00Z", created_by: null }
                    created_at: "2026-10-21T09:00:00Z"
                    updated_at: "2026-10-21T09:00:00Z"
                    reviewed_by: null
                    reviewed_at: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't merge Contacts in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /suggested_merges/{id}/merge:
    post:
      tags: [Suggested Merges]
      summary: Merge a Suggested Merge
      description: |
        Merges the suggestion's Contacts into one, as pressing Merge in Compare does. The Contact
        created first is kept unless `winner_id` names another of its Contacts. One merge request is
        made per other Contact; they are merged within a few minutes and can be undone with Unmerge
        on the Merge Contacts page.
      operationId: mergeSuggestedMerge
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                winner_id:
                  type: integer
                  description: The Contact to keep
            example: { winner_id: 101 }
      responses:
        "202":
          description: Merging has begun. Returns `suggested_merge` (now `merged`) and `merge_request_ids`.
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: "`{error}`: the Contact to keep isn't one of the suggestion's, or it has already been reviewed"

  /suggested_merges/{id}/reject:
    post:
      tags: [Suggested Merges]
      summary: Mark a Suggested Merge as Not duplicates
      description: |
        Records that the Contacts are different people, as pressing Not duplicates does. The pair
        is not suggested together again, from any source.
      operationId: rejectSuggestedMerge
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Returns `suggested_merge`, now `rejected`, with `reviewed_by` and `reviewed_at`
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: "`{error}`: it has already been reviewed"

  /duplicate_contacts:
    get:
      tags: [Duplicate Contacts]
      summary: Scan for duplicate Contacts
      description: |
        The Duplicate Contacts page: sets of Contacts that look like the same person. Only Contacts
        the user could merge are scanned (all the Organisation's Contacts for an Organisation Admin,
        the Contacts in their Projects for a Project Admin), and sets someone marked as Not
        duplicates are left out. Requires permission to merge Contacts in the Organisation.

        `match: similar` (the default) ignores titles (Mr, Mrs, Dr), capital letters, punctuation,
        word order and small spelling differences. It runs in the background because a large
        Organisation takes several seconds: while it runs the call answers 202 with
        `status: running`; call again after `retry_after` seconds to get the sets. A finished scan
        is reused for 10 minutes. `match: exact` finds only names spelt exactly the same and
        answers straight away.

        `match_strength` is `high` when the names are the same once normalised or the Contacts
        share a date of birth, email or mobile, and `medium` otherwise. `reasons` are
        `similar_name`, `same_name`, `same_date_of_birth`, `same_email` and `same_mobile`.
      operationId: listDuplicateContacts
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - name: match
          in: query
          schema:
            type: string
            enum: [similar, exact]
            default: similar
          description: "similar: names that look alike; exact: names spelt exactly the same"
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of sets of duplicate Contacts, High first
          content:
            application/json:
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                match: similar
                status: completed
                scanned_at: "2026-10-28T09:00:00Z"
                data:
                  - contacts:
                      - { id: 101, name: Jane Doe, created_at: "2026-09-02T10:15:00Z", created_by: { id: 5, name: Asha Patel } }
                      - { id: 188, name: Mrs Jane Doe, created_at: "2026-10-21T08:02:00Z", created_by: null }
                    match_strength: high
                    reasons: [similar_name, same_date_of_birth]
        "202":
          description: A similar-name scan is running; call again after `retry_after` seconds
          content:
            application/json:
              example: { match: similar, status: running, retry_after: 5 }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't merge Contacts in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /duplicate_contacts/not_duplicates:
    post:
      tags: [Duplicate Contacts]
      summary: Mark Contacts as Not duplicates
      description: |
        Records that a set of Contacts are different people, as pressing Not duplicates on the
        Duplicate Contacts page does. They are never suggested together again: not by the scan,
        the background check of new Contacts or a Merge Rule.
      operationId: markNotDuplicates
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [contact_ids]
              properties:
                contact_ids:
                  type: array
                  items: { type: integer }
                  description: At least two Contacts
                match_strength:
                  type: string
                  enum: [high, medium]
            example: { contact_ids: [101, 188], match_strength: high }
      responses:
        "200":
          description: "`{contact_ids, message}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't merge Contacts in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: "`{error}`: fewer than two Contacts, or a Contact the user can't merge"

  /duplicate_contacts/merge:
    post:
      tags: [Duplicate Contacts]
      summary: Merge a set of duplicate Contacts
      description: |
        Merges the Contacts into one, as Merge Selected Contacts on the Duplicate Contacts page
        does. The Contact created first is kept unless `winner_id` names another of them. One merge
        request is made per other Contact; they are merged within a few minutes and can be undone
        with Unmerge on the Merge Contacts page.
      operationId: mergeDuplicateContacts
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [contact_ids]
              properties:
                contact_ids:
                  type: array
                  items: { type: integer }
                  description: At least two Contacts
                winner_id:
                  type: integer
                  description: The Contact to keep
            example: { contact_ids: [101, 188], winner_id: 101 }
      responses:
        "202":
          description: "Merging has begun: `{winner_id, merge_request_ids, message}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't merge Contacts in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          description: "`{error}`: fewer than two Contacts, a Contact the user can't merge, or a Contact to keep that isn't one of them"

  /duplicate_contacts/settings:
    get:
      tags: [Duplicate Contacts]
      summary: Read "Suggest possible duplicates when contacts are created"
      description: |
        The setting on the Merge Contacts page. When it is on (the default), every Contact created
        is compared with the Organisation's other Contacts each hour, and similar names appear in
        Suggested Merges for someone to review. Requires permission to merge Contacts in the
        Organisation.
      operationId: getDuplicateContactSettings
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: The setting
          content:
            application/json:
              example: { charity_id: 12, suggest_on_create: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't merge Contacts in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Duplicate Contacts]
      summary: Change "Suggest possible duplicates when contacts are created"
      description: Turns the setting on or off. Requires an Organisation Admin (editor).
      operationId: updateDuplicateContactSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, suggest_on_create]
              properties:
                charity_id: { type: integer }
                suggest_on_create: { type: boolean }
            example: { charity_id: 12, suggest_on_create: false }
      responses:
        "200":
          description: The setting, changed
          content:
            application/json:
              example: { charity_id: 12, suggest_on_create: false }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't an Organisation Admin
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /merge_rules:
    get:
      tags: [Merge Rules]
      summary: List an Organisation's Merge Rules
      description: |
        The Manage Merge Rules page. Requires an Admin or Creator (editor or reporter) of the
        Organisation.
      operationId: listMergeRules
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Merge Rules
          content:
            application/json:
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 7
                    name: Same email
                    conditions: [{ id: 31, field_name: email_address }]
                    match_type: and
                    merge_mode: suggest
                    status: Active
                    created_by: { id: 5, name: Asha Patel }
                    last_edited_by: { id: 5, name: Asha Patel }
                    last_edited_at: "2026-10-20T14:00:00Z"
                    created_at: "2026-10-20T14:00:00Z"
                    updated_at: "2026-10-20T14:00:00Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't an Admin or Creator of the Organisation
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Merge Rules]
      summary: Create a Merge Rule
      description: |
        Create a Merge Rule. `conditions` are Contact field (Current Field) ids from the
        Organisation's Contact forms that must be identical. `match_type` `and` needs every
        condition to match, `or` any one. `merge_mode` is required ("When contacts match this
        rule"): `automatic` merges matching Contacts within 2 hours, keeping the one created first;
        `suggest` puts matches in Suggested Merges for someone to review. New rules are Active.
      operationId: createMergeRule
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, name, conditions, merge_mode]
              properties:
                charity_id: { type: integer }
                name: { type: string }
                conditions: { type: array, items: { type: integer } }
                match_type: { type: string, enum: [and, or], default: and }
                merge_mode: { type: string, enum: [automatic, suggest] }
                status: { type: string, enum: [Active, Inactive] }
            example: { charity_id: 12, name: Same email or mobile, conditions: [31, 32], match_type: or, merge_mode: suggest }
      responses:
        "201":
          description: The new Merge Rule
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't an Admin or Creator of the Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /field_visibility_rules:
    get:
      tags: [Field Visibility]
      summary: List who can see each Contact field
      description: |
        The Field Visibility settings page. Every Contact field comes back once, whichever Contact
        forms it is on. `field_class_name` and `field_key` identify it: `CustomField` or `RatioSet`
        with its id for a form field or dropdown, `BeneficiaryColumn` with the column name for a
        built-in field such as `date_of_birth`, `CustomFieldDefinition` with its id for a Custom
        Forms field. `visibility` is `default` (everyone who can view the Contact) or `restricted`:
        only users in one of its `teams`, or colleagues in any role on one of its `projects`, see the
        value; Organisation Admins get no exception. A restriction never gives anyone access to a
        Contact they can't already view. `visible_to_guests` says whether external guest users added
        through a Contact's Override see the field. Requires an Organisation Admin (editor).
        `last_synced_datetime` isn't supported: a field returned to default has no record to sync.
      operationId: listFieldVisibilityRules
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - name: search
          in: query
          schema:
            type: string
          description: Part of the field name
        - name: form
          in: query
          schema:
            type: string
          description: Only fields on this Contact form (its name)
        - name: visibility
          in: query
          schema:
            type: string
            enum: [default, restricted]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of Contact fields
          content:
            application/json:
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - field_class_name: CustomField
                    field_key: "481"
                    name: NHS number
                    forms: [Person being referred]
                    visibility: restricted
                    teams: [{ id: 9, name: Beacons }]
                    projects: [{ id: 33, name: WAY Beacons CYP }]
                    visible_to_guests: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't an Organisation Admin
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Field Visibility]
      summary: Change who can see Contact fields
      description: |
        Change the settings of one or more Contact fields, all together or not at all. For each
        field, `visibility: restricted` needs at least one of `team_ids` or `project_ids` (Teams and
        Projects of the same Organisation); `visibility: default` removes the restriction.
        `visible_to_guests` shows or hides the field from external guest users. Leave a key out to
        keep that setting. Errors name the field, e.g. "NHS number: Choose at least one Team or
        project for a restricted field". Requires an Organisation Admin (editor).
      operationId: updateFieldVisibilityRules
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, rules]
              properties:
                charity_id: { type: integer }
                rules:
                  type: array
                  items:
                    type: object
                    required: [field_class_name, field_key]
                    properties:
                      field_class_name: { type: string, enum: [CustomField, RatioSet, BeneficiaryColumn, CustomFieldDefinition] }
                      field_key: { type: string, description: The field id, or the column name for a BeneficiaryColumn }
                      visibility: { type: string, enum: [default, restricted] }
                      team_ids: { type: array, items: { type: integer } }
                      project_ids: { type: array, items: { type: integer } }
                      visible_to_guests: { type: boolean }
            example:
              charity_id: 12
              rules:
                - { field_class_name: CustomField, field_key: "481", visibility: restricted, team_ids: [9], project_ids: [33], visible_to_guests: false }
      responses:
        "200":
          description: The changed fields
          content:
            application/json:
              example:
                data:
                  - field_class_name: CustomField
                    field_key: "481"
                    name: NHS number
                    forms: [Person being referred]
                    visibility: restricted
                    teams: [{ id: 9, name: Beacons }]
                    projects: [{ id: 33, name: WAY Beacons CYP }]
                    visible_to_guests: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't an Organisation Admin
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    put:
      tags: [Field Visibility]
      summary: Change who can see Contact fields (same as PATCH)
      description: The same as PATCH /field_visibility_rules.
      operationId: replaceFieldVisibilityRules
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, rules]
              properties:
                charity_id: { type: integer }
                rules:
                  type: array
                  items:
                    type: object
                    required: [field_class_name, field_key]
                    properties:
                      field_class_name: { type: string, enum: [CustomField, RatioSet, BeneficiaryColumn, CustomFieldDefinition] }
                      field_key: { type: string, description: The field id, or the column name for a BeneficiaryColumn }
                      visibility: { type: string, enum: [default, restricted] }
                      team_ids: { type: array, items: { type: integer } }
                      project_ids: { type: array, items: { type: integer } }
                      visible_to_guests: { type: boolean }
            example:
              charity_id: 12
              rules:
                - { field_class_name: CustomField, field_key: "481", visibility: restricted, team_ids: [9], project_ids: [33], visible_to_guests: false }
      responses:
        "200":
          description: The changed fields
          content:
            application/json:
              example:
                data:
                  - field_class_name: CustomField
                    field_key: "481"
                    name: NHS number
                    forms: [Person being referred]
                    visibility: restricted
                    teams: [{ id: 9, name: Beacons }]
                    projects: [{ id: 33, name: WAY Beacons CYP }]
                    visible_to_guests: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user isn't an Organisation Admin
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /merge_rules/{id}:
    get:
      tags: [Merge Rules]
      summary: Get a Merge Rule
      operationId: getMergeRule
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The Merge Rule
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Merge Rules]
      summary: Update a Merge Rule
      description: |
        Change any of `name`, `conditions`, `match_type`, `merge_mode` and `status`; anything not
        sent is kept, including the match type when only the conditions change. Set `merge_mode` to
        `suggest` to stop a rule merging automatically, or `status` to `Inactive` to turn it off.
      operationId: updateMergeRule
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name: { type: string }
                conditions: { type: array, items: { type: integer } }
                match_type: { type: string, enum: [and, or] }
                merge_mode: { type: string, enum: [automatic, suggest] }
                status: { type: string, enum: [Active, Inactive] }
            example: { merge_mode: suggest }
      responses:
        "200":
          description: The updated Merge Rule
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /checklist_templates:
    get:
      tags: [Checklists]
      summary: List My Checklist Templates
      operationId: listChecklistTemplates
      description: |
        The Checklist Templates of the organisations you are an Organisation Admin or reporter of
        (My Checklist Templates, the Templates tab of Manage Checklists), shared or not. `sharing` is
        `organisation` (only your organisation can use it), `waiting_for_approval` (published to the
        ImpactStore, waiting for Makerble to approve it) or `published` (listed in the ImpactStore).
        `hints_needed` counts the steps that need a hint for what counts as done and `hints_set` those
        that have one. `used_by_checklists` and `used_by_organisations` count the Checklists made from it.
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: false
          schema:
            type: integer
          description: Only this one of your organisations (404 if you aren't in it)
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of templates
          content:
            application/json:
              schema:
                type: object
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: 31
                    name: Induction
                    sharing: organisation
                    steps_count: 2
                    hints_needed: 1
                    hints_set: 1
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Checklists]
      summary: Save a Checklist as a template
      operationId: createChecklistTemplate
      description: |
        Saves one of your organisation's Checklists as a Checklist Template, as **Save as template** in
        a Checklist's More Options does. Only Organisation Admins can (403 otherwise). Its stages, steps
        and settings are copied; a step's owner is kept when it is "the colleague who added it" or
        "nobody in particular", and saved as nobody in particular otherwise. `hints` maps the Checklist's
        step (action) ids to a hint for what counts as done; steps left out start with a hint made from
        the names of what they count. `share: impact_store` also publishes it for Makerble's approval;
        if a step that needs a hint has none, the template is still saved and the response is 422 with
        `missing_hint_step_ids` and `template_id`.
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [checklist_id]
              properties:
                checklist_id: {type: integer}
                name: {type: string}
                description: {type: string}
                designed_for: {type: string, enum: [young_people, adults, families, volunteers, everyone]}
                journey_part: {type: string, enum: [referral, enrolment, safeguarding, exit_and_alumni]}
                hints: {type: object, additionalProperties: {type: string}}
                share: {type: string, enum: [organisation, impact_store]}
            example:
              checklist_id: 44
              name: Induction
              designed_for: young_people
              hints:
                "301": a caregiver relationship
              share: organisation
      responses:
        "201":
          description: The saved template with its stages and steps
          content:
            application/json:
              schema:
                type: object
              example:
                id: 31
                charity_id: 5
                name: Induction
                description: For new members
                designed_for: young_people
                journey_part: referral
                sharing: organisation
                published_at: null
                saved_from_checklist:
                  id: 44
                  name: Induction
                steps_count: 2
                stages_count: 1
                hints_needed: 1
                hints_set: 1
                used_by_checklists: 0
                used_by_organisations: 0
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /checklist_templates/{id}:
    get:
      tags: [Checklists]
      summary: Get one of My Checklist Templates
      operationId: getChecklistTemplate
      description: |
        One of your organisations' templates with its `stages` and `steps` (each with its `hint` and
        `needs_hint`). Another organisation's template is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: integer}
      responses:
        "200":
          description: The template with its stages and steps
          content:
            application/json:
              schema:
                type: object
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Checklists]
      summary: Change, publish or stop sharing a Checklist Template
      operationId: updateChecklistTemplate
      description: |
        Changes the name, description, Designed for, Part of the journey and hints (keyed by the
        template's own step ids). `share: impact_store` publishes it to the ImpactStore for Makerble's
        approval, and is a 422 naming the steps (`missing_hint_step_ids`) while any that needs a hint
        has none. `share: organisation` stops sharing it; Checklists already made from it don't change.
        Only Organisation Admins can (403 otherwise).

        In a Toolkit, `toolkit_id` with `toolkit_items` points survey, form and story label steps at
        the Toolkit's own Surveys, Contact Forms and story Labels, as Edit Toolkit items does on the
        Toolkit's page. You must be able to edit the Toolkit (403), and it must hold this template (404).
        An item that isn't one of the Toolkit's is a 422.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: integer}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name: {type: string}
                description: {type: string}
                designed_for: {type: string, enum: [young_people, adults, families, volunteers, everyone]}
                journey_part: {type: string, enum: [referral, enrolment, safeguarding, exit_and_alumni]}
                hints: {type: object, additionalProperties: {type: string}}
                share: {type: string, enum: [organisation, impact_store]}
                toolkit_id:
                  type: integer
                  description: A Toolkit holding this template, that you can edit, for toolkit_items
                toolkit_items:
                  type: object
                  additionalProperties: {type: string}
                  description: |
                    The template's step ids mapped to one of the Toolkit's own items: `StoryCategory:<id>`
                    (a Survey), `BeneficiaryCategory:<id>` (a Contact Form) or `Label:<id>` (a story Label),
                    or "" for the hint alone. Installing the Toolkit sets those steps up with no mapping.
                    Each step's `toolkit_item_kind` says which kind it can take (null for none).
            example:
              hints:
                "88": a baseline wellbeing survey
              share: impact_store
      responses:
        "200":
          description: The changed template
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    delete:
      tags: [Checklists]
      summary: Delete a Checklist Template
      operationId: deleteChecklistTemplate
      description: Deletes the template. Checklists made from it are copies, so they don't change. Only Organisation Admins can.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: integer}
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
  /checklist_templates/{id}/mapping:
    get:
      tags: [Checklists]
      summary: Suggested mapping for using a Checklist Template
      operationId: getChecklistTemplateMapping
      description: |
        The mapping step of **Use this template**, for an ImpactStore template or one of your own.
        For each step: its `hint`, your organisation's `options` of the step's kind (each with an `id`
        to send back and a `name`), the `suggested` match by name, the `original` (what the original
        Checklist used, for your own organisation's template), whether a new one can be created
        (`can_create`, with a `create_name` from the hint) and the `default` choice: `original`,
        `suggested`, `leave` (nothing matched, so it is left to set up later) or `none` (nothing to set
        up). `charity_id` picks which of your organisations is using it (default: the template's own if
        it is yours, else your first).

        Installing a Toolkit: pass `toolkit_id`. Any template in a Toolkit you can see can be used,
        published or not. Steps that point at the Toolkit's own Surveys, Contact Forms and story Labels
        then default to `toolkit` (`default_item_id: toolkit`, with the installed item's name under
        `toolkit`): the copies installing the Toolkit added, shown as "Installed with this Toolkit". A
        step whose item wasn't installed falls back to its hint as usual. A template that isn't in the
        Toolkit, or a Toolkit you can't see, is a 404.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: integer}
        - name: charity_id
          in: query
          required: false
          schema: {type: integer}
        - name: toolkit_id
          in: query
          required: false
          description: Installing this Toolkit, which holds the template
          schema: {type: integer}
      responses:
        "200":
          description: The steps and their choices
          content:
            application/json:
              schema:
                type: object
              example:
                template_id: 12
                charity_id: 5
                own_template: false
                needs_setting_up_count: 0
                steps:
                  - step_id: 101
                    number: 1
                    title: Record consent
                    action_type: complete_form
                    action_name: Complete a form
                    hint: a consent form
                    needs_mapping: true
                    default: suggested
                    default_item_id: "beneficiary_category_ids:7"
                    suggested: {id: "beneficiary_category_ids:7", name: Consent}
                    original: null
                    options:
                      - {id: "beneficiary_category_ids:7", name: Consent}
                    can_create: false
                    create_name: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
  /checklist_templates/{id}/use:
    post:
      tags: [Checklists]
      summary: Use a Checklist Template
      operationId: useChecklistTemplate
      description: |
        Creates a Checklist in your organisation from the template. `mapping` has one entry per step:
        `{step_id, item_id}` with an option id from **Suggested mapping** (or `original`),
        `{step_id, create: "<name>"}` to create a new role, specialist need, group or story label, or
        `{step_id, leave: true}` to set it up later. Steps left out take their default. A step left for
        later is never set to "Any": it shows as Needs setting up and doesn't tick off until someone
        chooses what counts. Returns the new Checklist and the steps that still need setting up.
        With `toolkit_id` (installing a Toolkit), `item_id: toolkit` sets a step up with the Toolkit's
        installed item; see **Suggested mapping**.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: integer}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                charity_id: {type: integer}
                toolkit_id: {type: integer, description: Installing this Toolkit, which holds the template}
                name: {type: string}
                mapping:
                  type: array
                  items:
                    type: object
                    required: [step_id]
                    properties:
                      step_id: {type: integer}
                      item_id: {type: string}
                      create: {type: string}
                      leave: {type: boolean}
            example:
              name: Our safeguarding checks
              mapping:
                - {step_id: 101, item_id: "beneficiary_category_ids:7"}
                - {step_id: 103, create: Safeguarding concern}
                - {step_id: 104, leave: true}
      responses:
        "201":
          description: The new Checklist and the steps still to set up
          content:
            application/json:
              schema:
                type: object
              example:
                checklist: {id: 77, name: Our safeguarding checks, charity_id: 5}
                needs_setting_up:
                  - {step_id: 104, title: Flag any safeguarding concerns, hint: a safeguarding flag}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /checklists:
    get:
      tags: [Checklists]
      summary: List an Organisation's Checklists
      description: |
        The Checklists of an Organisation (Charity). Visible to the Organisation's editors and
        reporters, and to managers (editors) of its Projects. With `project_id`, only the Checklists
        added to that Project, as the Checklist panel on its profile page shows them.
      operationId: listChecklists
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - name: project_id
          in: query
          required: false
          schema:
            type: integer
          description: Only the Checklists added to this Project of the Organisation. Not found if the Project isn't the Organisation's.
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: Only the Checklists added to this Album's (Bundle's) Projects that you can see. Not found for an Album you can't see.
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Checklists, each with id, charity_id, name, description, created_by_id and actions_count
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user has no role in the Organisation that lets them see Checklists
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Checklists]
      summary: Create a Checklist
      description: |
        Creates a Checklist (Create > Checklist). Each action has an `action_type` and, unless the
        type has no criteria keys, `criteria` saying what counts as done; see
        `GET /checklists/action_types`. Actions keep the order sent. Requires an editor or reporter
        of the Organisation.

        "What counts as done": send specific values under the type's criteria keys, or
        `criteria: {any: true}` ("Any relationship", "Any survey" and so on) for any record of the
        kind; `any` replaces specific values sent with it. An action with neither is saved as "Not set
        yet" and can't be done for any Contact until its criteria are set.

        Each action may say who is responsible for it ("Who is responsible?"): `owner_kind` is `none`
        (nobody in particular, the default), `adder` (the colleague who added the Checklist to the
        Contact, or the Project's Project Managers when a Project added it automatically), `user`
        (`owner_user_id`, a colleague), `team` (`owner_team_id`, anyone in one of the Organisation's
        Teams who can see the Contact) or `relationship` (`owner_relationship_side`
        "<relationship_category_id>:parent|child", any colleague with that kind of Relationship with
        the Contact, e.g. their Therapist). See `GET /checklists/owner_options`.

        "Only count records in this project": set `only_this_project: true` on an action whose type has
        `project_scopable: true` in `GET /checklists/action_types` (surveys, events, labelled stories,
        cases, project states). Then only records made in the Project through which the Checklist was
        added to the Contact count towards it. It is ignored for other types.

        "Due within N days of the checklist being added": set `due_within_days` (a whole number from 0
        to 3650) to give an action a deadline. Each Contact's due date is the day the Checklist was
        added to them plus that many days, so changing it moves the due date for everyone. Leave it
        out, or send `null`, for no deadline. `GET /beneficiaries/{beneficiary_id}/checklists` then
        says which actions are done late or overdue.

        "Allow colleagues to tick this off by hand with a note": set `allow_manual_completion: true`
        on an action that can happen offline (a phone call, a home visit, a paper form). Colleagues
        who can edit a Contact can then mark it done by hand with
        `POST /beneficiaries/{beneficiary_id}/checklists/{checklist_id}/actions/{action_id}/completion`.
        It is false unless sent; on an update, an action that doesn't mention it keeps its setting.

        "If earlier steps aren't done": set `if_earlier_steps_not_done` to say what a colleague sees
        when they start an action for a Contact before the actions above it are done. `remind` (the
        default, "Show a reminder, let them continue") shows a reminder they can dismiss; `ask_reason`
        ("Warn and ask for a reason to skip") makes them give a reason, which is logged. On an update,
        an action that doesn't mention it keeps its setting.

        "Video (optional)": set `video_url` to a web link (`https://` or `http://`, up to 2048
        characters) to a video about the step, for self-paced training. On the Checklist's page,
        **Watch the journey** shows each step as a card with its video: a YouTube, Vimeo, Loom or
        Google Drive link plays in the card, and any other link (SharePoint, Slack, an intranet)
        opens in a new tab. Send an empty `video_url` to remove it; on an update, an action that
        doesn't mention it keeps its video.

        Participant Journey stages: send `stages`, in order, each with a `key` of your choosing, a
        `name` and an `icon` (see `GET /checklists/stage_icons`; `clipboard` if left out), and give
        each action the `stage_key` of its stage. The Journey view on the Checklist's profile page
        shows each stage as a column with its actions, left to right. Each stage's actions are kept
        together, in stage order. Stages are optional; an action without a stage shows as its own
        column.

        An action may leave out `action_type`: it is saved as "Not set yet", e.g. while mapping a
        participant journey before deciding how each step is recorded, and can't be done until a type
        is chosen. An action with neither a type nor a title is skipped.
      operationId: createChecklist
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            example:
              charity_id: 913
              checklist:
                name: "Induction"
                description: "Steps for every new contact"
                stages:
                  - key: "signup"
                    name: "Sign up"
                    icon: "clipboard"
                  - key: "support"
                    name: "Arrange support"
                    icon: "calendar"
                actions:
                  - title: "How participants sign up"
                    stage_key: "signup"
                  - action_type: "add_role"
                    title: "Give them a Role"
                    stage_key: "support"
                    criteria:
                      beneficiary_role_ids: ["12", "14"]
                  - action_type: "add_relationship"
                    title: "Record a caregiver"
                    criteria:
                      any: true
                  - action_type: "invite_to_event"
                    title: "Invite them to an induction event"
                    only_this_project: true
                    due_within_days: 14
                    criteria:
                      project_event_categories: ["301:7"]
                  - action_type: "create_task"
                    title: "Set a follow-up task"
                    owner_kind: "team"
                    owner_team_id: 18
                    allow_manual_completion: true
                    if_earlier_steps_not_done: "ask_reason"
                    video_url: "https://www.loom.com/share/22af2a7d40a54d0ba6d720140230b565"
      responses:
        "201":
          description: The Checklist, with its actions, projects and contacts_count
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Checklists for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /checklists/action_types:
    get:
      tags: [Checklists]
      summary: List the actions a Checklist can contain
      description: |
        Every action type with its name, the `criteria_keys` it stores, and `any_name`, the "Any"
        choice for it, e.g. "Any relationship" (`criteria: {any: true}`). Criteria values are strings:
        IDs, or pairs such as `project_states` "<project_id>:<beneficiary_state_id>",
        `project_event_categories` "<project_id>:<event_category_id>", `relationship_sides`
        "<relationship_category_id>:parent|child", and `survey_waves`, one of: "<Survey Campaign id>:<Wave id,
        or 0 for a campaign without Waves>" (that Survey Campaign in its Project); "survey:<Survey (Story
        Category) id>" (a survey made with that Survey in any Project); or "shared:<Survey id>:<Shared Wave
        id>" (a survey tagged to that Shared Wave (Shared Interval) of the Survey, in any Project). The "for a
        relative" types take `relatives: [{relationship_side, beneficiary_category_ids | survey_waves}]`.

        `action_type` values never change, so match on them. `name` and `any_name` (and `action_name`
        elsewhere in the Checklists endpoints) are the on-screen wording and can change: since CP-9308,
        `add_role` is "Add to an audience" (was "Add a role") with `any_name` "Any audience" (was "Any role"),
        `send_email` is "Send an email to a contact" (was "Send an Email") and `receive_email` is
        "Receive an email" (was "Receive an Email").
      operationId: listChecklistActionTypes
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: "`{data: [{action_type, name, criteria_keys, any_name, project_scopable}]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'

  /checklists/stage_icons:
    get:
      tags: [Checklists]
      summary: List the icons a Checklist stage can have
      description: |
        The icons a Participant Journey stage can have, in the order the icon picker shows them:
        clipboard (sign-up clipboard), calendar, people, chart, flag, message, home, heart, school and book.
      operationId: listChecklistStageIcons
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: "`{data: [{icon, name}]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'

  /checklists/owner_options:
    get:
      tags: [Checklists]
      summary: List the choices for who is responsible for a Checklist action
      description: |
        The "Who is responsible?" dropdown on the Create / Edit Checklist page: the kinds of owner, the
        Organisation's Teams and its relationship sides ("Therapist from Therapist & Client"). Colleagues
        for `owner_kind: user` come from `GET /users`. Visible to anyone who can see the Organisation's
        Checklists.
      operationId: listChecklistOwnerOptions
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: "`{kinds: [{owner_kind, name}], teams: [{id, name}], relationship_sides: [{owner_relationship_side, name}]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user has no role in the Organisation that lets them see Checklists
        "404":
          $ref: '#/components/responses/NotFound'

  /checklists/sketch:
    get:
      tags: [Checklists]
      summary: Draft a Checklist from a Project's setup
      description: |
        "Sketched from your setup" on the Checklists page: a participant journey drafted from what one of
        the Organisation's Projects already has. Nothing is saved. Without `project_id`, the draft comes
        from the running Project with the most Contacts that has at least two of: an active Signup Page, a
        Contact Form (other than the Organisation's default), a Waiting List or Alumni status, and a
        Survey. With `project_id`, it comes from that Project.

        The draft uses the five Participant Journey stages, leaving out any with nothing found: Sign up
        (one "Complete a form" step per Signup Page), Arrange support (the Contact Forms, then Waiting
        List → Enrolled), Provide support (each Survey's first Wave, and "Invite to an event" for the
        Project's Event Formats), Monitor progress (later Waves) and Achieve the goal (Move to Alumni).
        Every step already says what counts as done.

        `checklist` is in the shape `POST /checklists` takes, so it can be created as it is or after
        changes. Every field is null when no Project has enough to draft from. Needs someone who can
        create Checklists for the Organisation.
      operationId: sketchChecklist
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - name: project_id
          in: query
          required: false
          schema:
            type: integer
          description: Draft from this Project instead of the one Makerble would choose
      responses:
        "200":
          description: The draft
          content:
            application/json:
              example:
                project_id: 7
                project_name: "Youth Programme 2026"
                name: "Youth Programme 2026 journey"
                summary: "Youth Programme 2026 has the Referral Signup Page, the Intake form, a Waiting List → Enrolled → Alumni flow and the Wellbeing survey."
                checklist:
                  name: "Youth Programme 2026 journey"
                  stages:
                    - {key: "stage0", name: "Sign up", icon: "clipboard", position: 0}
                    - {key: "stage1", name: "Arrange support", icon: "calendar", position: 1}
                  actions:
                    - title: "Referral"
                      action_type: "complete_form"
                      criteria: {beneficiary_category_ids: ["31"]}
                      stage_key: "stage0"
                      position: 0
                    - title: "Waiting List → Enrolled"
                      action_type: "add_to_project"
                      criteria: {project_states: ["7:2"]}
                      stage_key: "stage1"
                      position: 1
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Checklists for the Organisation
        "404":
          $ref: '#/components/responses/NotFound'

  /checklists/{id}:
    get:
      tags: [Checklists]
      summary: Get a Checklist
      description: |
        A Checklist with its ordered actions, the Projects that offer it and how many Contacts have it.
        Each action includes who is responsible for it: `owner_kind`, `owner_user_id`, `owner_team_id`,
        `owner_relationship_side` and a readable `owner_description`, and its settings
        `due_within_days`, `only_this_project`, `allow_manual_completion` and
        `if_earlier_steps_not_done` (`remind` or `ask_reason`), its `video_url` (null for none) and its
        `stage_id`. `stages` lists the
        Participant Journey stages in order, each with `id`, `name`, `icon`, `position` and `colour`.
        An action whose type isn't chosen yet has a null `action_type` and `action_name` "Not set yet".
      operationId: getChecklist
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The Checklist, with actions, projects ({project_id, project_name, assignment_mode}) and contacts_count
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          description: Not found, or another Organisation's

    patch:
      tags: [Checklists]
      summary: Update a Checklist
      description: |
        Updates the name, description or actions. An action sent with its `id` is changed;
        `{id, _destroy: true}` removes it; an action without an `id` is added. Requires an editor or
        reporter of the Organisation. Send `due_within_days: null` to remove an action's deadline.

        Stages work the same way: a stage sent with its `id` is renamed, given a new `icon` or moved
        (`position`); `{id, _destroy: true}` removes it; a stage without an `id` is added, with a `key`.
        An action joins a stage with `stage_key`: a new stage's `key`, or an existing stage's `id` as a
        string. An empty `stage_key` takes the action out of its stage, and an action that doesn't send
        `stage_key` stays where it is. A stage left without actions is removed.
      operationId: updateChecklist
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            example:
              checklist:
                name: "Induction (2027)"
                actions:
                  - id: 55
                    action_type: "add_role"
                    title: "Give them any Role"
                    criteria:
                      beneficiary_role_ids: ["12"]
                  - id: 56
                    _destroy: true
                  - id: 57
                    owner_kind: "adder"
                    due_within_days: 7
                    stage_key: "88"
                stages:
                  - id: 88
                    name: "Arrange support"
                    icon: "people"
      responses:
        "200":
          description: The updated Checklist
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Checklist
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /checklists/{id}/skips:
    get:
      tags: [Checklists]
      summary: List a Checklist's skipped steps
      description: |
        The times colleagues did one of the Checklist's actions for a Contact before the earlier steps
        were done, newest first: the exceptions shown on the Checklist's Board. Each skip has
        `beneficiary_id`, `checklist_action_id`, `action_title`, `skipped_actions` ({id, title,
        required_first}), `reason`, `user_id`, `user_name`, `story_id` (its story on the Contact's
        timeline) and `created_at`. Only Contacts the user can see are included.
      operationId: listChecklistSkips
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: "`{page, page_size, page_count, total_count, data: [skip]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /checklists/{id}/projects/{project_id}:
    patch:
      tags: [Checklists]
      summary: Set how a Project offers a Checklist
      description: |
        The Add to Projects popup. `manual`: colleagues may add the Checklist to the Project's Contacts
        by hand. `automatic`: every Contact now in the Project gets it (in the background), and so does
        every Contact who later joins or is created in it. `none`: stop offering it; Contacts who
        already have it keep it. Requires an Organisation editor, or a Project Manager of the Project.

        For an `automatic` Checklist, `on_leave` says what happens when a Contact leaves the Project,
        moves to a closed status in it (Alumni or Declined) or is archived: `keep` (the default) or
        `remove_if_incomplete`, which takes it off them unless every action is done. A Checklist
        removed that way keeps the Contact's progress, and comes back when they rejoin. Send `mode`,
        `on_leave` or both; `on_leave` on its own changes only that, and needs the Checklist to be
        `automatic` in the Project.
      operationId: setChecklistProject
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                mode:
                  type: string
                  enum: [none, manual, automatic]
                on_leave:
                  type: string
                  enum: [keep, remove_if_incomplete]
            example:
              mode: "automatic"
              on_leave: "remove_if_incomplete"
      responses:
        "200":
          description: "`{project_id, assignment_mode, on_leave}`"
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't add Checklists to Projects in this Organisation
        "404":
          description: The Checklist or Project wasn't found, or the user can't edit the Project

  /checklists/{id}/summary:
    get:
      tags: [Checklists]
      operationId: getChecklistSummary
      summary: Checklist Summary across the projects you oversee
      description: >
        The Checklist Summary (the Summary tab of the Focus page) for one Checklist: one row for each
        project (Workspace) you oversee that uses the Checklist, with its Project Managers ("Managed by"),
        its other Workspace colleagues (reporters and observers), and for each step of the Checklist how
        many of the project's contacts with the Checklist have done that step, as a count and a percentage.
        Only Organisation Admins (every open project of their organisation), Team Leaders (open projects
        where someone in a Team they lead is a colleague) and Album Editors (open projects in organisation
        Albums they edit) may call it; anyone else gets 403. With `album_id`, it covers that Album's
        projects instead, for anyone who can see the Album. A Checklist that none of your projects uses
        returns 404. Only contacts you may see, that aren't deleted and are still active in the project,
        are counted. Rows are sorted before pagination; the sort is not remembered.
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          description: Checklist id
          schema: {type: integer}
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: Summarise this Album's (Bundle's) Projects that use the Checklist instead, for anyone who can see the Album, as the Summary tab of its Checklist panel does. Not found for an Album you can't see, or a Checklist none of its Projects uses.
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - name: sort
          in: query
          description: "project (default), managed_by, colleagues, or step_<number> (1 = first step)"
          schema: {type: string, example: step_1}
        - name: direction
          in: query
          schema: {type: string, enum: [asc, desc], default: asc}
      responses:
        "200":
          description: One page of projects
          content:
            application/json:
              example:
                checklist_id: 12
                checklist_name: Intake
                sort: project
                direction: asc
                steps:
                  - {id: 31, number: 1, action_type: create_task, title: Consent form}
                  - {id: 32, number: 2, action_type: add_role, title: Enrol}
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - project_id: 7
                    project_name: Youth Club
                    managed_by: [Ama Ng]
                    workspace_colleagues: [Obi Eze]
                    contacts_count: 2
                    steps:
                      - {action_id: 31, number: 1, done_count: 1, percent: 50}
                      - {action_id: 32, number: 2, done_count: 0, percent: 0}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: Not an Organisation Admin, Team Leader or Album Editor
          content:
            application/json:
              example: {error: forbidden}
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /checklists/{id}/progress:
    get:
      tags: [Checklists]
      summary: Get a Checklist's progress
      description: |
        Where the Contacts on a Checklist have got to: the Progress section of the Checklist's profile
        page. For each action, in order: `completed` (Contacts who have done it), `furthest` (Contacts
        for whom it is the furthest action done) and `waiting` (Contacts for whom it is the first action
        not done, so a Contact who did steps 1 and 3 is waiting on step 2). Each list gives its full
        count (`completed_count`, `furthest_count`, `waiting_count`) and the first `list_limit` (30)
        Contacts alphabetically as `{beneficiary_id, name, actions_done}`, where `actions_done` is how many
        of the Checklist's actions the Contact has done (shown as "3 of 8 actions done"). Each Contact in `waiting` also has the Board's
        details: `days_waiting` (since the Checklist was added or the previous action was done),
        `overdue` (the action is past its due date), `skipped_a_step` (a colleague logged starting a later
        action first) and `responsible` (who is responsible for the action). `contacts_count` is every
        Contact counted, `complete_count` those with every action done (the first of them in `complete`)
        and `overdue_count` those whose waiting action is overdue. Only Contacts the user can see are counted.
      operationId: getChecklistProgress
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: Count only the Contacts in this Album's (Bundle's) Projects, as the Checklist panel on its profile page does. Not found for an Album you can't see, or a `project_id` outside it.
        - name: project_id
          in: query
          required: false
          description: Count only the Contacts in this Project, which must be one the Checklist is added to
          schema:
            type: integer
        - name: responsible
          in: query
          required: false
          description: "Count only the Contacts whose waiting action this person or Team is responsible for: `me` (directly or through one of the user's Teams), `user:<id>` or `team:<id>`"
          schema:
            type: string
      responses:
        "200":
          description: The counts and lists for each action
          content:
            application/json:
              example:
                checklist_id: 42
                project_id: null
                responsible: null
                contacts_count: 3
                complete_count: 1
                overdue_count: 1
                list_limit: 30
                complete: [{beneficiary_id: 904, name: "Refilwe Mahlangu", actions_done: 4}]
                actions:
                  - id: 55
                    number: 1
                    action_type: "complete_form"
                    title: "Complete the Intake form"
                    completed_count: 2
                    completed: [{beneficiary_id: 901, name: "Ayanda Dlamini", actions_done: 2}, {beneficiary_id: 902, name: "Kagiso Mokoena", actions_done: 3}]
                    furthest_count: 0
                    furthest: []
                    waiting_count: 1
                    waiting: [{beneficiary_id: 903, name: "Mpho Sithole", actions_done: 0, days_waiting: 9, overdue: true, skipped_a_step: false, responsible: "Anyone in Youth Workers"}]
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /checklists/{id}/progress/contacts:
    get:
      tags: [Checklists]
      summary: List every Contact behind one of a Checklist's progress counts
      description: |
        Every Contact behind one count of the Checklist's Progress section, a page at a time, as the
        **Show N more** buttons on the Checklist's page do. `GET /checklists/{id}/progress` lists only the
        first `list_limit` (30) of each list; use this to get the rest. Choose the list with `list`:

        - `completed`, `furthest` or `waiting`: the Table's lists for the action `action_id`: who has
          done it, for whom it is the furthest action done, and who is waiting on it
        - `board`: the Board's column for the action `action_id` (those waiting on it, longest waiting first)
        - `complete`: the Board's Fully complete column (no `action_id`)

        Each Contact is `{beneficiary_id, name, actions_done}`. In the `waiting` and `board` lists each
        also has `days_waiting`, `overdue`, `skipped_a_step` and `responsible`. The same `project_id` and
        `responsible` filters as `GET /checklists/{id}/progress` apply. Only Contacts the user can see are
        counted. `per_page` is at most 200.
      operationId: listChecklistProgressContacts
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: Only the Contacts in this Album's (Bundle's) Projects. Not found for an Album you can't see.
        - name: list
          in: query
          required: true
          schema:
            type: string
            enum: [completed, furthest, waiting, board, complete]
        - name: action_id
          in: query
          required: false
          description: The action whose list it is. Required for every list but `complete`
          schema:
            type: integer
        - name: project_id
          in: query
          required: false
          description: Count only the Contacts in this Project, which must be one the Checklist is added to
          schema:
            type: integer
        - name: responsible
          in: query
          required: false
          description: "Count only the Contacts whose waiting action this person or Team is responsible for: `me`, `user:<id>` or `team:<id>`"
          schema:
            type: string
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: One page of the list, in the usual envelope
          content:
            application/json:
              example:
                page: 2
                page_size: 1
                page_count: 2
                total_count: 31
                data:
                  - {beneficiary_id: 903, name: "Mpho Sithole", actions_done: 0, days_waiting: 9, overdue: true, skipped_a_step: false, responsible: "Anyone in Youth Workers"}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /checklists/{id}/journey:
    get:
      tags: [Checklists]
      summary: Get a Checklist's Participant Journey
      description: |
        The Journey view on the Checklist's profile page: its steps left to right, grouped into stages.
        `columns` are in order: each stage with its `stage_id`, `name`, `icon` and `colour`, then its
        `steps`. A Checklist without stages has one column per step, named "Step 1", "Step 2" and so on,
        with a null `stage_id` and `icon`; so does a step left outside the stages. Each step has
        `action_id`, `number` (its place in the Checklist), `title`, `action_type`, `action_name` ("Not
        set yet" while no type is chosen), `done_count` (Contacts who have done it) and `waiting_count`
        (Contacts for whom it is the first step not done), out of `contacts_count`. Only Contacts the user
        can see are counted. With `project_id`, only the Contacts in that Project, as the Checklist panel
        on the Project's profile page counts them.
      operationId: getChecklistJourney
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: Count only the Contacts in this Album's (Bundle's) Projects. Not found for an Album you can't see.
        - name: project_id
          in: query
          required: false
          schema:
            type: integer
          description: Count only the Contacts in this Project. Not found unless the Checklist is added to it.
      responses:
        "200":
          description: The columns of the Journey view
          content:
            application/json:
              example:
                checklist_id: 42
                contacts_count: 10
                columns:
                  - stage_id: 88
                    name: "Sign up"
                    icon: "clipboard"
                    colour: "#AC3898"
                    steps:
                      - action_id: 55
                        number: 1
                        title: "How participants sign up"
                        action_type: "complete_form"
                        action_name: "Complete a form"
                        done_count: 10
                        waiting_count: 0
                  - stage_id: 89
                    name: "Arrange support"
                    icon: "calendar"
                    colour: "#2F7DC0"
                    steps:
                      - action_id: 56
                        number: 2
                        title: "Initial assessment"
                        action_type: null
                        action_name: "Not set yet"
                        done_count: 8
                        waiting_count: 2
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/{beneficiary_id}/checklists:
    get:
      tags: [Checklists]
      summary: Get a Contact's Checklists
      description: |
        The Checklists box on a Contact's profile: each Checklist with `done_count` of `actions_count`,
        and every action with `done: true|false`. Only Contacts the user can see are returned.

        A done action has a `completion` (null while it isn't done) saying when, by whom and with what
        record it was done: `completed_at` (when that record was made, e.g. the survey's date),
        `completed_by_user_id` and `completed_by_name` (null when the record doesn't say who made it),
        `completion_method` (`detected`, or `manual` when a colleague ticked it), `proof_type` and
        `proof_id` (the record, e.g. `Story` 123, `BeneficiariesBeneficiaryRole`, `EventBeneficiary`)
        and `proof_deleted` (true once that record has been deleted). An action stays done even if
        its record is later edited or deleted. Actions are marked done in the background a few seconds
        after the record that completes them is saved.

        Each action also says who is responsible for it for this Contact: the owner fields
        (`owner_kind`, `owner_user_id`, `owner_team_id`, `owner_relationship_side`), `owner_overridden`
        (true when a colleague changed it for this Contact only), `owner_description` (e.g.
        "Safeguarding Team"), `responsible_user_ids` (only colleagues who can see the Contact) and
        `owner_warning` when nobody responsible can see them (e.g. "No one in Safeguarding Team can see
        this contact").

        An action whose Checklist gives it a deadline (`due_within_days`) has `due_on`: the day the
        Checklist was added to the Contact plus that many days (null when there is no deadline).
        `done_late` is true when it was done after `due_on`; `overdue` is true when it isn't done and
        `due_on` has passed. Both are false for an action with no deadline.

        `allow_manual_completion` says whether colleagues may tick the action off by hand
        (`POST .../actions/{action_id}/completion`).
      operationId: listContactChecklists
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of the Contact's Checklists with their progress
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Checklists]
      summary: Add a Checklist to a Contact
      description: |
        Add a Checklist on the Contact's profile. Only a Checklist that one of the Contact's Projects
        lets the user add by hand is allowed; see `GET /beneficiaries/{beneficiary_id}/checklists/available`.
        It is added through a Project, the one whose records count for actions set to "Only count
        records in this project": the only Project that allows it, or `project_id` when more than one
        does (required then). Adding one that was removed from the Contact earlier restores the
        actions they had done. An Organisation Admin may also add back a Checklist that was removed
        from the Contact while one of their Projects adds it automatically; it is added through that
        Project.
      operationId: addContactChecklist
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            example:
              checklist_id: 42
              project_id: 301
      responses:
        "201":
          description: "`{checklist_id, beneficiary_id, added_by_user_id, project_id, created_at}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries/{beneficiary_id}/checklists/{checklist_id}:
    delete:
      tags: [Checklists]
      summary: Remove a Checklist from a Contact
      description: |
        "Remove from this contact" in the ⋯ menu of a Checklist on the Contact's profile, for one added
        by mistake or no longer relevant. It no longer shows on the Contact, in the Checklist's progress
        or on Focus, and the removal is recorded on the Contact's History. The Contact's progress is
        kept: adding the Checklist again (`POST /beneficiaries/{beneficiary_id}/checklists`) restores the
        actions they had done, and a Project that adds the Checklist automatically won't add it back.
        Allowed for Organisation Admins, and for colleagues who could add the Checklist to the Contact by
        hand.
      operationId: removeContactChecklist
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
        - name: checklist_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: "`{checklist_id, beneficiary_id, removed_at, removed_by_user_id}`"
          content:
            application/json:
              example:
                checklist_id: 42
                beneficiary_id: 1001
                removed_at: "2026-11-05T10:00:00Z"
                removed_by_user_id: 7
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: "`{errors}`: the user is neither an Organisation Admin nor able to add this Checklist to the Contact"
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/{beneficiary_id}/checklists/{checklist_id}/actions/{action_id}/owner:
    patch:
      tags: [Checklists]
      summary: Change who is responsible for an action for one Contact
      description: |
        The Change link under an action in a Contact's Checklists box. Sets who is responsible for this
        action for this Contact only; other Contacts keep the Checklist's default. Choosing the
        Checklist's own default removes the change. Takes the same owner fields as an action of
        `POST /checklists`. Requires edit access to the Contact.
      operationId: setContactChecklistActionOwner
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
        - name: checklist_id
          in: path
          required: true
          schema:
            type: integer
        - name: action_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            example:
              owner_kind: "user"
              owner_user_id: 5021
      responses:
        "200":
          description: "`{checklist_id, action_id, owner_kind, owner_user_id, owner_team_id, owner_relationship_side, owner_overridden, owner_description, responsible_user_ids, owner_warning}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can see the Contact but can't edit it
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Checklists]
      summary: Go back to the Checklist's own owner for one Contact
      description: Removes a change made with the PATCH above, so this Contact follows the Checklist's default again. Requires edit access to the Contact.
      operationId: resetContactChecklistActionOwner
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
        - name: checklist_id
          in: path
          required: true
          schema:
            type: integer
        - name: action_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The action's owner fields, as for the PATCH
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can see the Contact but can't edit it
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/{beneficiary_id}/checklists/{checklist_id}/actions/{action_id}/completion:
    post:
      tags: [Checklists]
      summary: Mark a Contact's Checklist action as done by hand
      description: |
        The "Mark as done…" link under an action in a Contact's Checklists box, for steps that leave
        no record Makerble can detect, such as a phone call, a home visit or a paper consent form.
        Only an action whose Checklist allows it (`allow_manual_completion: true`) can be ticked off
        this way, and only while it isn't done. Requires edit access to the Contact.

        `completed_on` is the date it happened (`YYYY-MM-DD`, today or earlier) and `note` says what
        happened. The note, and the `evidence` file when one is sent as multipart form data, are
        saved as a Story on the Contact's timeline, which becomes the action's proof. The Story goes
        in the Project the Checklist was added through, otherwise the Contact's only Project the user
        can record stories in; when there is more than one, send `project_id`.

        The action's `completion` then has `completion_method: manual`, `completed_by_user_id` the
        user, `completed_at` the date given, and `proof_type: Story` with the new Story's `proof_id`.
      operationId: markContactChecklistActionDone
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
        - name: checklist_id
          in: path
          required: true
          schema:
            type: integer
        - name: action_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            example:
              completed_on: "2026-10-20"
              note: "Paper consent signed at the home visit, scanned to file"
              project_id: 301
          multipart/form-data:
            schema:
              type: object
              required: [completed_on, note]
              properties:
                completed_on:
                  type: string
                  format: date
                note:
                  type: string
                project_id:
                  type: integer
                evidence:
                  type: string
                  format: binary
      responses:
        "201":
          description: "`{checklist_id, action_id, done: true, completion: {completed_at, completed_by_user_id, completed_by_name, completion_method, proof_type, proof_id, proof_deleted}}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can see the Contact but can't edit it
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Checklists]
      summary: Undo marking a Contact's Checklist action as done by hand
      description: |
        Takes back a tick made by hand. Only the colleague who made it, or an Organisation Admin, can
        undo it, and only a manual completion can be undone. The Story stays on the Contact's
        timeline. Makerble then looks again for a record that proves the action done, so the
        response can still say `done: true` with a `detected` completion. Requires edit access to the
        Contact.
      operationId: undoContactChecklistActionDone
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
        - name: checklist_id
          in: path
          required: true
          schema:
            type: integer
        - name: action_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: "`{checklist_id, action_id, done, completion}` (completion null when not done)"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can see the Contact but can't edit it
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries/{beneficiary_id}/checklists/next_step:
    get:
      tags: [Checklists]
      summary: Get a Contact's next step
      description: |
        What to do next for a Contact, as on the Next step card of their profile: the first action
        not yet done on each of their Checklists, the most pressing first (overdue, then the earliest
        `due_on`, then by Checklist name), so `data[0]` is the next step. Each step has the Checklist
        (`checklist_id`, `checklist_name`), its place in it (`number` of `total`), the action
        (`action_id`, `action_type`, `action_name`, `title`, `description`), its deadline (`due_on`,
        `overdue`), `if_earlier_steps_not_done` and who is responsible for it (the same owner fields as
        `GET /beneficiaries/{beneficiary_id}/checklists`). `others_count` is how many other Checklists
        are waiting; `all_done` is true when every action on the Contact's Checklists is done. Not
        paginated: a Contact has few Checklists.
      operationId: getContactNextStep
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: "`{all_done, others_count, data: [{checklist_id, checklist_name, number, total, action_id, action_type, action_name, title, description, due_on, overdue, if_earlier_steps_not_done, owner_kind, owner_description, responsible_user_ids, ...}]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/{beneficiary_id}/checklists/{checklist_id}/actions/{action_id}/gate:
    get:
      tags: [Checklists]
      summary: Check the earlier steps before a Checklist action
      description: |
        The "soft gate" a colleague sees on the Contact's profile when they start an action before the
        earlier steps on the same Checklist are done. `gated` is true when some aren't; `missing` lists
        them ({action_id, number, action_type, title, required_first}); `reason_required` is true when
        one is set to "Warn and ask for a reason to skip" (Required first). Nothing is blocked: to go
        ahead, record the skip with `POST .../skips`.
      operationId: getContactChecklistGate
      security: [{tokenAuth: []}]
      parameters:
        - {name: beneficiary_id, in: path, required: true, schema: {type: integer}}
        - {name: checklist_id, in: path, required: true, schema: {type: integer}}
        - {name: action_id, in: path, required: true, schema: {type: integer}}
      responses:
        "200":
          description: "`{gated, reason_required, missing: [{action_id, number, action_type, title, required_first}]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /beneficiaries/{beneficiary_id}/checklists/{checklist_id}/actions/{action_id}/skips:
    post:
      tags: [Checklists]
      summary: Skip the earlier steps of a Checklist action
      description: |
        Records that the action is being done for the Contact before its earlier steps ("Continue
        anyway" on the profile): who, when, which steps and why. The skip is also put on the Contact's
        timeline as a story. `reason` is required when a missing step is Required first. Needs edit
        access to the Contact.
      operationId: skipContactChecklistSteps
      security: [{tokenAuth: []}]
      parameters:
        - {name: beneficiary_id, in: path, required: true, schema: {type: integer}}
        - {name: checklist_id, in: path, required: true, schema: {type: integer}}
        - {name: action_id, in: path, required: true, schema: {type: integer}}
      requestBody:
        required: false
        content:
          application/json:
            example:
              reason: "The induction is this week; consent is in the post"
      responses:
        "201":
          description: The skip ({id, beneficiary_id, checklist_id, checklist_action_id, action_title, skipped_actions, reason, user_id, user_name, story_id, created_at})
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Contact
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /beneficiaries/{beneficiary_id}/checklists/available:
    get:
      tags: [Checklists]
      summary: List the Checklists that can be added to a Contact
      description: |
        The Checklists the user may add to this Contact by hand, other than those it already has, each
        with the Projects it can be added through (`projects: [{id, name}]`). When there is more than
        one, pass the chosen one as `project_id` to `POST /beneficiaries/{beneficiary_id}/checklists`.
      operationId: listAvailableContactChecklists
      security: [{tokenAuth: []}]
      parameters:
        - name: beneficiary_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: "`{data: [{id, name, projects: [{id, name}]}]}`"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /cohort_trackers:
    get:
      tags: [Cohort Trackers]
      summary: List an Organisation's Cohort Trackers
      description: |
        The Cohort Trackers of an Organisation (Charity). Visible to the Organisation's
        editors and reporters, and to managers (editors) of its Projects.
      operationId: listCohortTrackers
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Cohort Trackers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedCohortTrackers'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user has no editor or reporter role in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Cohort Trackers]
      summary: Create a Cohort Tracker
      description: |
        Creates a Cohort Tracker (Create a metric > Cohort Tracker). Every tracker counts only
        members of the Project or Album it is placed on: `membership` is `ever_enrolled`
        (default: anyone whose status History shows them Enrolled at any time) or
        `currently_enrolled` (their current Project State). `criteria` adds further conditions, in
        the Contact Filters format; see `POST /cohort_trackers/preview` for the keys.
        Requires an editor or reporter of the Organisation. `criteria` may also be sent as a JSON string.
      operationId: createCohortTracker
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerRequest'
            example:
              cohort_tracker:
                charity_id: 913
                name: "Bambanani children who start Ignite"
                membership: "ever_enrolled"
                criteria:
                  bundle_ids: ["57", "58"]
      responses:
        "201":
          description: Cohort Tracker created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Cohort Trackers for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /cohort_trackers/preview:
    post:
      tags: [Cohort Trackers]
      summary: Preview Cohort Tracker criteria
      description: |
        How many of the Organisation's Contacts currently meet some criteria, before the tracker is
        placed on a Project or Album ("Currently matches N contacts across your organisation"), and
        the criteria as they would be stored. `criteria` takes any key the Contacts page's Filters
        sidebar sends; keys no filter reads are dropped from the stored criteria.

        These keys follow the Project or Album the tracker is placed on and the reporting period:
        - `project_ids` (with `project_ids_narrow: "true"` to require all of them), in any state
        - `bundle_ids` (Albums) and `narrow_bundle_ids`
        - `projects_states_hash`: `{project_id: beneficiary_state_id}`, current Project State in each
        - `project_beneficiary_states`: `{project_id: {state_id: {enabled: "true", added_from_date, removed_from_date}}}`, dates as `dd/mm/yyyy - dd/mm/yyyy`, matched against status History
        - `project_story_category_ids` (Survey Campaigns completed) with `project_story_category_filter_data: {id: {story_date_from}}`
        - `attendance_rate`: `{change_id, from, to, event_scope}`
        - `same_day_rate` (Same-day rate): `{change_id, event_scope, event_filter_params, qualifying_change_ids, match: all|any, qualifying_event_scope, qualifying_event_filter_params, from, to}`. On the days the `change_id` Engagement Tracker was recorded for a Contact at an event, the percentage of those days on which the `qualifying_change_ids` Engagement Trackers (all of them, or any one) were also recorded for them at an event on the same date, in the Organisation's time zone. A day with no matching record counts as not met; Contacts with no such days never match. E.g. children who received all four meals on every day they attended class: `from: "100", to: "100"`
        - `distance_travelled`: `{trackers: [{indicator_id, directions: [improved|no_change|worsened|reached_top]}], match: any|all|at_least, match_count, same_project, story_category_ids, responses_between}`. Compares each Contact's first and latest answer to each Choice Tracker; `reached_top` means the latest answer is the best on the scale, whatever the first was. `match` says how many of the trackers a Contact must meet: `any` (default), `all`, or `at_least` `match_count` of them. E.g. Contacts who improved or reached the top answer in at least 2 of 3 goals: three trackers with `directions: [improved, reached_top]`, `match: at_least`, `match_count: 2`. With `denominator: enough_data`, a percentage is out of the Contacts with two responses on that many trackers. Optional `story_category_ids` (Survey ids) compares only answers given in those Surveys, e.g. when teachers and parents fill in different versions of the same survey; empty or omitted uses answers from any Survey. Optional `responses_between` (`dd/mm/yyyy - dd/mm/yyyy`, either end may be blank) compares only answers dated in that range; in a Cohort Tracker it narrows the reporting period further
        - `indicator_comparisons`: `{indicator_id: {response: any|latest, op, sub_ratio_ids, values}}`
        - `indicator_sub_ratios_hash`: `{indicator_id: [sub_ratio_id]}`

        The Contacts page's other sections apply as they do there, against the Contacts' current
        details, e.g. `group_ids`, `beneficiary_types`, `age_from` / `age_to` (`{year, month, day}`),
        `date_of_birth_from` and `created_at_from` (`yyyy/mm/dd - yyyy/mm/dd`), `created_by_ids`,
        `story_creator_ids`, `case_owner_ids`, `case_worker_ids`, `open_cases`, `closed_cases`,
        `custom_field_value_hash`, `custom_field_definition_hash`, `changes_hash`, `indicators_hash`,
        `outcome_hash`, `event_ids`, `flag_hash`, `relationship_category_hash` and `beneficiary_roles_hash`.
      operationId: previewCohortTracker
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id]
              properties:
                charity_id:
                  type: integer
                cohort_tracker:
                  type: object
                  properties:
                    criteria:
                      type: object
                    membership:
                      type: string
                      enum: [ever_enrolled, currently_enrolled]
            example:
              charity_id: 913
              cohort_tracker:
                criteria:
                  attendance_rate: { change_id: "412", from: "75", to: "100" }
      responses:
        "200":
          description: The count and the normalised criteria
          content:
            application/json:
              schema:
                type: object
                properties:
                  count:
                    type: integer
                    example: 42
                  criteria:
                    type: object
                  names_projects_or_albums:
                    type: boolean
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Cohort Trackers for this Organisation
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /cohort_trackers/{id}:
    get:
      tags: [Cohort Trackers]
      summary: Get a Cohort Tracker
      description: |
        A Cohort Tracker with where it is used. `names_projects_or_albums` is true when its criteria
        point at specific Projects or Albums, so it counts against those same ones wherever it is placed.
      operationId: getCohortTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Cohort Tracker
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Cohort Trackers]
      summary: Update a Cohort Tracker
      description: |
        Updates the fields sent. Changes apply everywhere the tracker is used. Requires an
        Organisation editor, or the reporter who created it.

        Switching `result_type` between a number of Contacts and a percentage clears the tracker's
        targets on every Project and Album, because the two aren't comparable. While it has targets,
        the switch is refused (422, "Switching result type clears this tracker's N targets. Confirm to
        continue.") unless `confirm_clear_targets` is true.
      operationId: updateCohortTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerRequest'
            example:
              cohort_tracker:
                name: "Children attending 80%+"
      responses:
        "200":
          description: Cohort Tracker updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Cohort Tracker
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Cohort Trackers]
      summary: Delete a Cohort Tracker
      description: Refused (422) while the tracker is used on any Project, Album or Scorecard Template.
      operationId: deleteCohortTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't delete this Cohort Tracker
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /cohort_trackers/{id}/projects/{project_id}:
    get:
      tags: [Cohort Trackers]
      summary: Get a Cohort Tracker's targets on a Project
      description: The one-off target and deadline targets (the Project's Set Targets page). Requires rights to edit the Project's targets.
      operationId: getCohortTrackerProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Cohort Trackers]
      summary: Add a Cohort Tracker to a Project
      description: |
        Places the tracker in a column of the Project's Impact Scorecard (Edit Project Metrics),
        optionally with a one-off target. The Project's Albums pick it up automatically. The tracker
        and Project must belong to the same Organisation, and the user needs rights to edit the
        Project's metrics.
      operationId: addCohortTrackerToProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [column]
              properties:
                column:
                  type: string
                  enum: [activities, engagement, potential, behaviour, growth]
                target:
                  type: integer
            example:
              column: engagement
              target: 40
      responses:
        "201":
          description: Placed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    patch:
      tags: [Cohort Trackers]
      summary: Set a Cohort Tracker's targets on a Project
      description: |
        Sets the one-off target and/or replaces this tracker's deadline targets on the Project (Set
        Targets). A target is a number of Contacts to reach, not a total that adds up across periods.
        `deadlines: []` clears the deadline targets. Requires rights to edit the Project's targets.
      operationId: setCohortTrackerProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerTargetsRequest'
            example:
              target: 40
              deadlines:
                - { date: "2026-06-30", number: 20 }
                - { date: "2026-12-31", number: 40 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Cohort Trackers]
      summary: Remove a Cohort Tracker from a Project
      operationId: removeCohortTrackerFromProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'

  /cohort_trackers/{id}/albums/{bundle_id}:
    get:
      tags: [Cohort Trackers]
      summary: Get a Cohort Tracker's targets on an Album
      description: |
        An Album inherits the Cohort Trackers on its Projects. Returns the Album's one-off and deadline
        targets for the tracker, and `album_target_type`: the Album's Set Targets page shows Cohort
        Tracker targets under manual targets. Requires rights to edit the Album's targets.
      operationId: getCohortTrackerAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerAlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Cohort Trackers]
      summary: Set a Cohort Tracker's targets on an Album
      description: |
        Sets the Album's one-off target and/or replaces its deadline targets (saved as manual targets) for
        the tracker. An Album's target is never the sum of its Projects'. Requires rights to edit the
        Album's targets.
      operationId: setCohortTrackerAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerTargetsRequest'
            example:
              target: 120
              deadlines:
                - { date: "2026-12-31", number: 100 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerAlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /formula_trackers:
    get:
      tags: [Formula Trackers]
      summary: List an Organisation's Formula Trackers
      description: |
        The Formula Trackers of an Organisation (Charity). Visible to the Organisation's editors and
        reporters, and to managers (editors) of its Projects.
      operationId: listFormulaTrackers
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Formula Trackers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFormulaTrackers'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user has no editor or reporter role in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Formula Trackers]
      summary: Create a Formula Tracker
      description: |
        Creates a Formula Tracker (Create a metric > Formula Tracker): a metric worked out from the
        Organisation's other trackers. `expression` is the formula as an ordered list of tokens, never
        free text:

        - `{kind: tracker, type, id}`: one of the Organisation's trackers that has a number. `type` is
          `Change` (Activity or Engagement tracker), `Indicator` (Achievement or Numerical tracker; not a
          Choice tracker), `CohortTracker`, `WorkflowTracker`, `FilteredMetric` (a filtered version) or
          `FormulaTracker`. List them with `GET /formula_trackers/operands`.
        - `{kind: operator, value}`: `+`, `-`, `*` or `/`. × and ÷ are worked out before + and −.
        - `{kind: number, value}`, e.g. 100.
        - `{kind: open}` and `{kind: close}`: brackets, worked out first.

        Refused (422) when the formula is empty, starts or ends with an operator, has two operators
        or two values in a row, unmatched or empty brackets, uses another Organisation's tracker, or
        uses itself (directly or through other Formula Trackers).

        Each timeframe's result is worked out from each tracker's result for the same Project or Album
        and timeframe, then the formula: a Year to Date percentage is Year to Date numerator ÷ Year to
        Date denominator. `result_kind` is `additive` only when the formula adds and subtracts trackers
        that add up, with no numbers; otherwise `snapshot`. Dividing by 0 gives no result (null).
        Requires an editor or reporter of the Organisation.
      operationId: createFormulaTracker
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FormulaTrackerRequest'
            examples:
              referralsCompleted:
                summary: Referrals completed = External referrals + Internal referrals
                value:
                  formula_tracker:
                    charity_id: 913
                    name: "Referrals completed"
                    expression:
                      - { kind: tracker, type: Change, id: 5120 }
                      - { kind: operator, value: "+" }
                      - { kind: tracker, type: WorkflowTracker, id: 41 }
              percentageSupported:
                summary: "% of children receiving support = Children supported ÷ Children enrolled × 100"
                value:
                  formula_tracker:
                    charity_id: 913
                    name: "% of children receiving support"
                    display_format: "percentage"
                    decimal_places: 1
                    expression:
                      - { kind: tracker, type: Change, id: 5121 }
                      - { kind: operator, value: "/" }
                      - { kind: tracker, type: CohortTracker, id: 77 }
                      - { kind: operator, value: "*" }
                      - { kind: number, value: 100 }
      responses:
        "201":
          description: Formula Tracker created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Formula Trackers for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /formula_trackers/operands:
    get:
      tags: [Formula Trackers]
      summary: List the trackers a formula can use
      description: |
        The Organisation's trackers that have a number, by name, with the `type` and `id` to send in a
        tracker token: its Activity, Engagement, Achievement and Numerical trackers (owned by it or used
        on its Projects), Cohort, Workflow and Formula Trackers, and filtered versions. Choice trackers
        aren't listed.
      operationId: listFormulaTrackerOperands
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of trackers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFormulaTrackerOperands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Formula Trackers for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'

  /formula_trackers/preview:
    post:
      tags: [Formula Trackers]
      summary: Preview a Formula Tracker
      description: |
        What a formula gives on one of the Organisation's Projects, before it is saved: the result for
        the current Period (ending at the Project's next deadline, or today when it has none ahead), Year
        to Date and All-time, each tracker's own result, and warnings worth checking (a tracker used
        twice, a Numerical tracker added to a count, different units added together, dividing by a
        tracker that could be 0). A formula with errors is refused (422) with `errors` and `warnings`.
        Send `formula_tracker_id` when editing a tracker, so a formula that uses it is caught.
      operationId: previewFormulaTracker
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, project_id]
              properties:
                charity_id:
                  type: integer
                project_id:
                  type: integer
                formula_tracker_id:
                  type: integer
                  description: The Formula Tracker being edited, if any
                formula_tracker:
                  $ref: '#/components/schemas/FormulaTrackerAttributes'
            example:
              charity_id: 913
              project_id: 4510
              formula_tracker:
                expression:
                  - { kind: tracker, type: Change, id: 5120 }
                  - { kind: operator, value: "+" }
                  - { kind: tracker, type: WorkflowTracker, id: 41 }
      responses:
        "200":
          description: The results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerPreview'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Formula Trackers for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /formula_trackers/{id}:
    get:
      tags: [Formula Trackers]
      summary: Get a Formula Tracker
      description: A Formula Tracker with where it is used and any warnings about its formula.
      operationId: getFormulaTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Formula Tracker
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Formula Trackers]
      summary: Update a Formula Tracker
      description: |
        Updates the fields sent; `expression` replaces the whole formula. Changes apply everywhere the
        tracker is used. Requires an Organisation editor, or the reporter who created it.
      operationId: updateFormulaTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FormulaTrackerRequest'
            example:
              formula_tracker:
                decimal_places: 1
      responses:
        "200":
          description: Formula Tracker updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Formula Tracker
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Formula Trackers]
      summary: Delete a Formula Tracker
      description: Refused (422) while the tracker is used on any Project, Album or Scorecard Template.
      operationId: deleteFormulaTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't delete this Formula Tracker
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /formula_trackers/{id}/projects/{project_id}:
    get:
      tags: [Formula Trackers]
      summary: Get a Formula Tracker's targets on a Project
      description: The one-off target and deadline targets (the Project's Set Targets page). Requires rights to edit the Project's targets.
      operationId: getFormulaTrackerProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Formula Trackers]
      summary: Add a Formula Tracker to a Project
      description: |
        Places the tracker in a column of the Project's Impact Scorecard (Edit Project Metrics),
        optionally with a one-off target. The Project's Albums pick it up automatically. The tracker
        and Project must belong to the same Organisation, and the user needs rights to edit the
        Project's metrics.
      operationId: addFormulaTrackerToProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [column]
              properties:
                column:
                  type: string
                  enum: [activities, engagement, potential, behaviour, growth]
                target:
                  type: integer
            example:
              column: engagement
              target: 40
      responses:
        "201":
          description: Placed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    patch:
      tags: [Formula Trackers]
      summary: Set a Formula Tracker's targets on a Project
      description: |
        Sets the one-off target and/or replaces this tracker's deadline targets on the Project (Set
        Targets). An additive tracker adds its targets up across deadlines; a snapshot uses each
        deadline's target on its own. A percentage tracker's targets are whole percentages from 0 to
        100. `deadlines: []` clears the deadline targets. Requires rights to edit the Project's targets.
      operationId: setFormulaTrackerProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerTargetsRequest'
            example:
              target: 40
              deadlines:
                - { date: "2026-06-30", number: 20 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Formula Trackers]
      summary: Remove a Formula Tracker from a Project
      operationId: removeFormulaTrackerFromProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'

  /formula_trackers/{id}/albums/{bundle_id}:
    get:
      tags: [Formula Trackers]
      summary: Get a Formula Tracker's targets on an Album
      description: |
        An Album inherits the Formula Trackers on its Projects. Returns the Album's one-off and
        deadline targets for the tracker, and `album_target_type`: the Album's Set Targets page shows
        Formula Tracker targets under manual targets. Requires rights to edit the Album's targets.
      operationId: getFormulaTrackerAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerAlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Formula Trackers]
      summary: Set a Formula Tracker's targets on an Album
      description: |
        Sets the Album's one-off target and/or replaces its deadline targets (saved as manual targets)
        for the tracker. An Album's result is worked out from the Album's own results, so its target is
        never the sum of its Projects'. Requires rights to edit the Album's targets.
      operationId: setFormulaTrackerAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerTargetsRequest'
            example:
              target: 120
              deadlines:
                - { date: "2026-12-31", number: 100 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerAlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /contact_automations:
    get:
      tags: [Automations]
      summary: List Contact Automations
      description: |
        The Contact Automations the user can see: those of Organisations where they are an editor or
        observer, those on Projects they manage, and those they made. `active` false means paused.
      operationId: listContactAutomations
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: query
          schema:
            type: integer
          description: Only the Contact Automations on this Project
        - name: flag_id
          in: query
          schema:
            type: integer
          description: |
            Only the Contact Automations whose actions add this Flag to Contacts, as the "Automations that
            add this flag automatically" column on Manage Flags counts them. A Flag of another Organisation
            finds nothing.
          example: 12
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Contact Automations
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedContactAutomations'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Automations]
      summary: Create a Contact Automation
      description: |
        Creates a Contact Automation on a Project, the same as one made on the Contact Automations
        page: when the Project's Contacts meet the `criteria`, the `actions` run, once per Contact until
        that alert is resolved.

        `criteria` names one field: `field` (an `other_fields` key from the options, e.g.
        `minutes_since_contact_enrolled`), `current_field_id` (a Contact or Survey field),
        `relationship_category_id` or `event_state_id`. Then a `condition` from that field's
        conditions and a `value` (minutes, for the "Amount of time" fields), `state_ids` (Ratio Set
        states) or `text`. For `field: survey_verdict_is`, give `survey_id` and `verdict_ids`.

        `actions` can be any of `send_survey`, `in_app_alert`, `change_status` (statuses on this
        Project, or `removed`) and `flags`. Every id must be one that
        `GET /contact_automations/options` offers; any other is refused with 422, naming it.

        `active` defaults to true; send false to save the automation paused, then check who it would
        act on with `GET /contact_automations/{id}/matching_contacts` before resuming it. Requires an
        editor of the Organisation or of the Project.
      operationId: createContactAutomation
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactAutomationRequest'
            examples:
              surveyOnEnrolment:
                summary: Send a Survey an hour after a Contact is enrolled, saved paused
                value:
                  project_id: 821
                  active: false
                  criteria:
                    field: minutes_since_contact_enrolled
                    condition: greater_than_or_equal_to
                    value: 60
                  actions:
                    send_survey:
                      survey_id: 5194
                      via_email: true
                      email_message: "Please tell us how you are getting on."
      responses:
        "201":
          description: Contact Automation created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /contact_automations/options:
    get:
      tags: [Automations]
      summary: What a new Contact Automation can use
      description: |
        For one Project: its criteria fields (Contact fields and Survey fields by `current_field_id`,
        each with its `conditions` and, for a Ratio Set or scale Indicator, its `states`;
        `other_fields` by key with a `value_unit`; `relationships`; `event_states`) and the choices for
        its actions (`surveys` with their verdicts, `statuses`, `flags`, `colleagues`,
        `in_app_alert_recipients`). Built from the same lists as the Contact Automation page.
      operationId: getContactAutomationOptions
      security: [{tokenAuth: []}]
      parameters:
        - name: project_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The options
          content:
            application/json:
              schema:
                type: object
                properties:
                  project_id:
                    type: integer
                  criteria:
                    type: object
                  actions:
                    type: object
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /contact_automations/{id}:
    get:
      tags: [Automations]
      summary: Get a Contact Automation
      operationId: getContactAutomation
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The Contact Automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /contact_automations/{id}/pause:
    post:
      tags: [Automations]
      summary: Pause a Contact Automation
      description: A paused Contact Automation acts on nobody until it is resumed. Requires an editor of the Organisation or of the Project.
      operationId: pauseContactAutomation
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The paused Contact Automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /contact_automations/{id}/resume:
    post:
      tags: [Automations]
      summary: Resume a Contact Automation
      description: Resuming lets it act on every Contact it matches. Requires an editor of the Organisation or of the Project.
      operationId: resumeContactAutomation
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The resumed Contact Automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /contact_automations/{id}/matching_contacts:
    get:
      tags: [Automations]
      summary: Contacts a Contact Automation would act on now
      description: |
        The Contacts the automation would act on if it ran now, limited to those the user can see, the
        same as the page's Test button. It leaves out Contacts the automation has already acted on and
        not resolved. Works on a paused automation.
      operationId: listContactAutomationMatchingContacts
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of Contacts, each with id and name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginationEnvelope'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /project_automations:
    get:
      tags: [Automations]
      summary: List Project Automations
      description: The Project Automations of Organisations where the user is an editor or observer, in priority order.
      operationId: listProjectAutomations
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          schema:
            type: integer
          description: Only this Organisation's
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Project Automations
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedProjectAutomations'
        "401":
          $ref: '#/components/responses/Unauthorized'

    post:
      tags: [Automations]
      summary: Create a Project Automation
      description: |
        Creates a Project Automation, the same as one made on the Project Automations page: whenever a
        Project matching its saved project filter is created or edited, its `settings` are copied onto
        the Project. It goes last in priority.

        `settings` takes true or false for the setting names in the options, `default_story_privacy`,
        and id lists for Contact Forms, Surveys, Event Formats, colleagues and Contact Automation
        Templates. A setting that isn't sent takes the page's own default for a new automation (the
        statuses, Events, Timesheets, Cases and the Survey Progress Board switched on; privacy "Only
        organisation colleagues"). An unknown setting, or an id not in the options, is refused with 422.
        `active` defaults to true. Requires an editor of the Organisation.
      operationId: createProjectAutomation
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProjectAutomationRequest'
            examples:
              youthProjects:
                summary: Cases and a baseline Survey for youth Projects
                value:
                  charity_id: 324
                  name: "Youth project set-up"
                  saved_filter_id: 2493
                  settings:
                    is_creation_of_new_cases_enabled: true
                    default_story_privacy: only_project_colleagues
                    enrolled_state_baseline_survey_ids: [5194]
      responses:
        "201":
          description: Project Automation created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /project_automations/options:
    get:
      tags: [Automations]
      summary: What a new Project Automation can use
      description: |
        For one Organisation: `saved_filters` (the user's saved project filters and those colleagues
        have shared), `contact_forms`, `surveys`, `event_formats`, `colleagues`,
        `contact_automation_templates`, the `settings` names and `default_story_privacy_values`.
      operationId: getProjectAutomationOptions
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The options
          content:
            application/json:
              schema:
                type: object
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /project_automations/{id}:
    get:
      tags: [Automations]
      summary: Get a Project Automation
      operationId: getProjectAutomation
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The Project Automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /project_automations/{id}/pause:
    post:
      tags: [Automations]
      summary: Pause a Project Automation
      description: New and edited Projects skip a paused Project Automation. Requires an editor of the Organisation.
      operationId: pauseProjectAutomation
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The paused Project Automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /project_automations/{id}/resume:
    post:
      tags: [Automations]
      summary: Resume a Project Automation
      operationId: resumeProjectAutomation
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The resumed Project Automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /automation_templates:
    get:
      tags: [Automations]
      summary: List Automation Templates
      description: The Automation Templates of Organisations where the user is an editor or observer, each with the Contact Automation it copies.
      operationId: listAutomationTemplates
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          schema:
            type: integer
        - name: status
          in: query
          schema:
            type: string
            enum: [available, hide]
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Automation Templates
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedAutomationTemplates'
        "401":
          $ref: '#/components/responses/Unauthorized'

  /automation_templates/{id}:
    get:
      tags: [Automations]
      summary: Get an Automation Template
      operationId: getAutomationTemplate
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: The Automation Template
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AutomationTemplate'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /automation_templates/{id}/apply:
    post:
      tags: [Automations]
      summary: Apply an Automation Template to a Project
      description: |
        Copies the template's Contact Automation onto a Project in the template's Organisation, the same
        as "+ Add to Project" on the Automation Templates page. Refused with 422, naming what to add
        first, if the Project hasn't got the template's Survey, or (for an Event criteria) Events switched
        on and its Event Format; and if the template is already on that Project. `active` defaults to
        true. Requires an editor of the Organisation or of the Project.
      operationId: applyAutomationTemplate
      security: [{tokenAuth: []}]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [project_id]
              properties:
                project_id:
                  type: integer
                active:
                  type: boolean
                  default: true
            examples:
              paused:
                summary: Add it to a Project, paused
                value:
                  project_id: 821
                  active: false
      responses:
        "201":
          description: The new Contact Automation on the Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactAutomation'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /formula_trackers/{id}/projects/{project_id}/results:
    get:
      tags: [Formula Trackers]
      summary: Get a Formula Tracker's result on a Project
      description: |
        A Formula Tracker's result on a Project's Results Canvas: what its card shows, and what its popup
        opens. The tracker must be on the Project.

        Each timeframe is worked out from that timeframe's own tracker numbers, so a Year to Date
        percentage is the Year to Date numerator ÷ the Year to Date denominator, never an average of the
        periods. `number` is null, and `display_value` is "–", when a tracker the formula uses has no
        result or it divides by 0 (the canvas says "Not enough data to work this out yet").
        `display_value` is the result as the canvas shows it, from the tracker's display format, decimal
        places and unit label.

        `result_kind` `additive` (only + and − of trackers that add up) adds up across periods.
        `snapshot` (× ÷ or a number) is read as of `as_of`: the window's last day, or today while that is
        still to come. `target` is the deadline targets dated in the window, added up (for a snapshot,
        the one on its last day), or else the one-off target, or null.

        `trackers` lists each tracker the formula uses with its number for the window; `formula` writes
        the formula out in words and `formula_with_values` with those numbers in place.

        When the formula only adds Workflow Trackers that count items (`itemised: true`, e.g. External
        referrals + Internal referrals), `data` lists one page of the items counted, newest first. An item
        the user may not see is counted in `hidden_count` for that page but never listed. Otherwise `data`
        is empty and the counts are 0. Requires the same rights as viewing that Results Canvas.
      operationId: getFormulaTrackerProjectResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
        - $ref: '#/components/parameters/CohortTrackerTimeframe'
        - $ref: '#/components/parameters/CohortTrackerAsOf'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The result and the trackers behind it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerResult'
              example:
                formula_tracker_id: 12
                name: "% of children receiving support"
                project_id: 34
                timeframe: year_to_date
                starts_on: "2026-01-01"
                ends_on: "2026-12-31"
                result_kind: snapshot
                as_of: "2026-10-13"
                display_format: percentage
                decimal_places: 1
                unit: percentage
                number: 50
                display_value: "50.0%"
                target: 60
                formula: "% of children receiving support = Children supported ÷ Children flagged × 100"
                formula_with_values: "4 ÷ 8 × 100"
                trackers:
                  - { type: Change, id: 81, name: Children supported, type_name: Engagement tracker, unit: count, number: 4 }
                  - { type: Change, id: 82, name: Children flagged, type_name: Engagement tracker, unit: count, number: 8 }
                itemised: false
                page: 1
                page_size: 0
                page_count: 0
                total_count: 0
                hidden_count: 0
                data: []
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see this Project's Results Canvas
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /formula_trackers/{id}/albums/{bundle_id}/results:
    get:
      tags: [Formula Trackers]
      summary: Get a Formula Tracker's result on an Album
      description: |
        As for a Project, with each tracker the formula uses worked out on the Album as a whole (its open
        Projects together) before the formula is applied, so an Album percentage is the Album's numerator
        ÷ the Album's denominator, not the Projects' percentages added up. The tracker must be on one of
        the Album's Projects. Requires rights to see the Album.
      operationId: getFormulaTrackerAlbumResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
        - $ref: '#/components/parameters/CohortTrackerTimeframe'
        - $ref: '#/components/parameters/CohortTrackerAsOf'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The result and the trackers behind it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FormulaTrackerResult'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see this Album
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /workflow_trackers:
    get:
      tags: [Workflow Trackers]
      summary: List an Organisation's Workflow Trackers
      description: |
        The Workflow Trackers of an Organisation (Charity). Visible to the Organisation's editors and
        reporters, and to managers (editors) of its Projects.
      operationId: listWorkflowTrackers
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Workflow Trackers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedWorkflowTrackers'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user has no editor or reporter role in the Organisation
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Workflow Trackers]
      summary: Create a Workflow Tracker
      description: |
        Creates a Workflow Tracker (Create a metric > Workflow Tracker): a metric that counts records
        Makerble's own features create, rather than Contacts tagged in updates. `source` says what it counts:

        - `signpostings`: Signpostings made from the Project (or an Album's Projects) it is placed on.
          A signposting counts once whether it names the Organisation signposted to, the Person, or
          both. Signpostings saved without a Project aren't counted on any Project or Album.
        - `internal_referrals`: Contacts in the Project who are added to another of the Organisation's
          Projects, dated by the Status in Projects history. Moving between states of the same Project
          isn't a referral. `settings` choose which Projects count: `{destinations: any}`,
          `{destinations: only, project_ids: [...]}` or `{destinations: except, project_ids: [...]}`
          (the default, with none listed).
        - `cases_created`: Cases (Cases App) created on the Project, or on any of an Album's Projects,
          each Case counted once.
        - `cases_closed`: each time one of those Cases is closed. A Case closed, reopened and closed
          again counts twice, or once when counting each Contact once.
        - `cases_open`: the Cases open at the end of each timeframe (or today, while that is still to
          come). Always a snapshot.
        - `time_spent`: hours logged in Timesheets on the Project, or any of an Album's Projects, each
          entry once, to 1 decimal place. Task and Update Timesheets are dated by their Update (Story),
          or by when their Task was done; Event Timesheets by when the Event started. Timesheets on draft
          Updates aren't counted. `settings` choose `kinds` (any of `updates_and_tasks`, `event_staff`,
          `event_guests`; default the first two) and, optionally, only the time of some colleagues:
          `user_ids` and/or `roles` (`editor`: Organisation Admins and Project Managers, `reporter`:
          Changemakers, `observer`: Observers). These don't narrow Event guests' time. Always counts
          `items`; `unit` is `hours`.

        For the three Cases sources, `settings` can name one Case Form, `{case_form_id: ...}`, to count
        only the Cases created with it; leave it out or send null for any Case Form. Confidential Cases
        are counted, but only listed to people who can see them.

        `count_mode` is `items` (default: each signposting, referral, Case or closing; adds up across
        periods, except for `cases_open`) or `contacts` (each Contact once; a snapshot). Requires an
        editor or reporter of the Organisation.
      operationId: createWorkflowTracker
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowTrackerRequest'
            examples:
              internalReferrals:
                summary: Internal referrals to any Project but two
                value:
                  workflow_tracker:
                    charity_id: 913
                    name: "Internal referrals"
                    source: "internal_referrals"
                    count_mode: "items"
                    settings:
                      destinations: "except"
                      project_ids: [4512, 4513]
              casesOpen:
                summary: Cases open, for one Case Form
                value:
                  workflow_tracker:
                    charity_id: 913
                    name: "Safeguarding cases open"
                    source: "cases_open"
                    count_mode: "items"
                    settings:
                      case_form_id: 2207
      responses:
        "201":
          description: Workflow Tracker created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Workflow Trackers for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /workflow_trackers/preview:
    post:
      tags: [Workflow Trackers]
      summary: Preview a Workflow Tracker
      description: |
        What a Workflow Tracker with these settings gives on one of the Organisation's Projects, before
        it is saved: the result for the current Period (ending at the Project's next deadline, or today
        when it has none ahead), Year to Date and All-time, and the latest records counted.
      operationId: previewWorkflowTracker
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, project_id]
              properties:
                charity_id:
                  type: integer
                project_id:
                  type: integer
                workflow_tracker:
                  $ref: '#/components/schemas/WorkflowTrackerAttributes'
            example:
              charity_id: 913
              project_id: 4510
              workflow_tracker:
                source: "signpostings"
                count_mode: "items"
      responses:
        "200":
          description: The results and the latest records
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerPreview'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't create Workflow Trackers for this Organisation
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /workflow_trackers/{id}:
    get:
      tags: [Workflow Trackers]
      summary: Get a Workflow Tracker
      description: A Workflow Tracker with where it is used.
      operationId: getWorkflowTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The Workflow Tracker
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Workflow Trackers]
      summary: Update a Workflow Tracker
      description: |
        Updates the fields sent. Changes apply everywhere the tracker is used. Requires an
        Organisation editor, or the reporter who created it.
      operationId: updateWorkflowTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowTrackerRequest'
            example:
              workflow_tracker:
                count_mode: "contacts"
      responses:
        "200":
          description: Workflow Tracker updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerDetail'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Workflow Tracker
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Workflow Trackers]
      summary: Delete a Workflow Tracker
      description: Refused (422) while the tracker is used on any Project, Album or Scorecard Template.
      operationId: deleteWorkflowTracker
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "204":
          description: Deleted
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't delete this Workflow Tracker
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /workflow_trackers/{id}/projects/{project_id}:
    get:
      tags: [Workflow Trackers]
      summary: Get a Workflow Tracker's targets on a Project
      description: The one-off target and deadline targets (the Project's Set Targets page). Requires rights to edit the Project's targets.
      operationId: getWorkflowTrackerProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Workflow Trackers]
      summary: Add a Workflow Tracker to a Project
      description: |
        Places the tracker in a column of the Project's Impact Scorecard (Edit Project Metrics),
        optionally with a one-off target. The Project's Albums pick it up automatically. The tracker
        and Project must belong to the same Organisation, and the user needs rights to edit the
        Project's metrics.
      operationId: addWorkflowTrackerToProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [column]
              properties:
                column:
                  type: string
                  enum: [activities, engagement, potential, behaviour, growth]
                target:
                  type: integer
            example:
              column: activities
              target: 40
      responses:
        "201":
          description: Placed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    patch:
      tags: [Workflow Trackers]
      summary: Set a Workflow Tracker's targets on a Project
      description: |
        Sets the one-off target and/or replaces this tracker's deadline targets on the Project (Set
        Targets). A tracker counting items adds its targets up across deadlines; one counting each
        Contact once uses each deadline's target on its own. `deadlines: []` clears the deadline
        targets. Requires rights to edit the Project's targets.
      operationId: setWorkflowTrackerProjectTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerTargetsRequest'
            example:
              target: 40
              deadlines:
                - { date: "2026-06-30", number: 20 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerPlacement'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Workflow Trackers]
      summary: Remove a Workflow Tracker from a Project
      operationId: removeWorkflowTrackerFromProject
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'

  /workflow_trackers/{id}/albums/{bundle_id}:
    get:
      tags: [Workflow Trackers]
      summary: Get a Workflow Tracker's targets on an Album
      description: |
        An Album inherits the Workflow Trackers on its Projects. Returns the Album's one-off and
        deadline targets for the tracker, and `album_target_type`: the Album's Set Targets page shows
        Workflow Tracker targets under manual targets. Requires rights to edit the Album's targets.
      operationId: getWorkflowTrackerAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
      responses:
        "200":
          description: The targets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerAlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Workflow Trackers]
      summary: Set a Workflow Tracker's targets on an Album
      description: |
        Sets the Album's one-off target and/or replaces its deadline targets (saved as manual targets)
        for the tracker. An Album counts each record once across its Projects, so its target is never
        the sum of its Projects'. Requires rights to edit the Album's targets.
      operationId: setWorkflowTrackerAlbumTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CohortTrackerTargetsRequest'
            example:
              target: 120
              deadlines:
                - { date: "2026-12-31", number: 100 }
      responses:
        "200":
          description: Targets saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerAlbumTargets'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit this Album's targets
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /workflow_trackers/{id}/projects/{project_id}/results:
    get:
      tags: [Workflow Trackers]
      summary: Get a Workflow Tracker's result on a Project
      description: |
        A Workflow Tracker's result on a Project's Results Canvas, with the items behind it: what the
        Workflow Tracker card shows, and the list its popup opens. The tracker must be on the Project.

        `result_kind` `additive` (counting each signposting or referral) adds up across periods.
        `snapshot` (counting each Contact once) is worked out for the window on its own and read as of
        `as_of`: the window's last day, or today while that is still to come. `target` is the deadline
        targets dated in the window, added up (for a snapshot, the one on its last day), or else the
        one-off target, or null.

        `data` lists one page of the items counted, newest first: the Contact, `detail` (who they were
        signposted to, or the Project they were referred to), `project_id` (a referral's destination) and
        when it happened. For `time_spent`, `number` is hours to 1 decimal place and each item is a
        Timesheet entry: whose time it is (`user_id`, `user_name`; or the Contact for an Event guest's),
        its `hours`, and the Update, Task or Event it was logged on, which the user must be able to see
        for it to be listed. `total_count` counts every item, whatever the count mode. An item the user may
        not see (a Contact they can't read, or a referral to a Project they can't see) is counted in
        `hidden_count` for that page but never listed. Requires the same rights as viewing that Results
        Canvas.
      operationId: getWorkflowTrackerProjectResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
        - $ref: '#/components/parameters/CohortTrackerTimeframe'
        - $ref: '#/components/parameters/CohortTrackerAsOf'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The result and the items behind it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerResult'
              example:
                workflow_tracker_id: 7
                name: Signpostings made
                project_id: 34
                timeframe: period
                starts_on: "2026-07-01"
                ends_on: "2026-12-31"
                result_kind: additive
                as_of: null
                number: 12
                target: 20
                page: 1
                page_size: 9
                page_count: 2
                total_count: 12
                hidden_count: 1
                data:
                  - { contact_id: 501, contact_name: Thandi Mokoena, detail: "Mfuleni Clinic · Nurse Dlamini", project_id: null, happened_at: "2026-09-01T09:00:00Z" }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see this Project's Results Canvas
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /workflow_trackers/{id}/albums/{bundle_id}/results:
    get:
      tags: [Workflow Trackers]
      summary: Get a Workflow Tracker's result on an Album
      description: |
        As for a Project, across the Album's open Projects: an item, or in `contacts` mode a Contact,
        counts once however many of its Projects it relates to, so the result is never the sum of the
        Projects'. The tracker must be on one of the Album's Projects. Requires rights to see the Album.
      operationId: getWorkflowTrackerAlbumResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
        - $ref: '#/components/parameters/CohortTrackerTimeframe'
        - $ref: '#/components/parameters/CohortTrackerAsOf'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The result and the items behind it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTrackerResult'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see this Album
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /cohort_trackers/{id}/projects/{project_id}/results:
    get:
      tags: [Cohort Trackers]
      summary: Get a Cohort Tracker's result on a Project
      description: |
        A Cohort Tracker's result on a Project's Results Canvas, with the Contacts behind it. Only data saved
        in the Project counts. The tracker must be on the Project.

        The result is the number of distinct Contacts who meet the tracker's membership setting and all
        its criteria, counting only stories, events and survey responses saved in scope and dated in the
        window. Results are worked out afresh for each window, so a Year to Date result is not the sum
        of the period results. `target` is the tracker's deadline target on the window's last day, or
        else its one-off target; targets are never summed across deadlines.

        `data` lists the Contacts in the cohort alphabetically, with `qualifying_value` (named by
        `qualifying_value_label`, e.g. an attendance rate as a percentage) where the criteria have one.
        A Contact the user may not read is listed as `{restricted: true}` with no details, so the
        list always adds up to `count`. Requires the same rights as viewing that Results Canvas.

        A percentage tracker also returns `denominator_count` and `percentage`, as the canvas shows
        "84% Children attending 75%+" with "42 of 50 contacts with enough data". The cohort is always
        within the denominator. `percentage` is a whole number, or null when `denominator_count` is 0
        (the canvas shows "–"). `cohort=not_in` lists the rest of the denominator.
      operationId: getCohortTrackerProjectResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerProjectId'
        - $ref: '#/components/parameters/CohortTrackerTimeframe'
        - $ref: '#/components/parameters/CohortTrackerAsOf'
        - $ref: '#/components/parameters/CohortTrackerCohort'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The result and the Contacts behind it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerResult'
              example:
                cohort_tracker_id: 12
                name: Children attending 75%+
                project_id: 34
                timeframe: year_to_date
                starts_on: "2026-04-01"
                ends_on: "2026-06-30"
                count: 42
                eligible_count: 50
                result_type: percentage
                denominator: enough_data
                denominator_count: 50
                percentage: 84
                target: { number: 75, date: "2026-06-30" }
                qualifying_value_label: Attendance rate
                cohort: in
                page: 1
                page_size: 2
                page_count: 21
                total_count: 42
                data:
                  - { restricted: false, id: 101, name: Aisha Dlamini, qualifying_value: 82.5 }
                  - { restricted: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see this Results Canvas

  /projects/{project_id}/filtered_metrics:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricProjectId'
    get:
      tags: [Filtered Metrics]
      summary: List a Project's filtered versions of metrics
      description: |
        The filtered versions on a Project's Results Canvas. Visible to the Project's or its
        Organisation's managers (editors), changemakers (reporters) and analysts (observers): the
        same people who can see the Results Canvas.
      operationId: listProjectFilteredMetrics
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of filtered versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFilteredMetrics'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see the Project's Results Canvas
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Filtered Metrics]
      summary: Add a filtered version of a metric to a Project
      description: |
        Edit Project Metrics > Add filtered version. The metric being filtered must already be on the
        Project: a Change in one of its columns, or an Indicator under one of its Outcomes. A Change's
        filtered version goes directly after it in its column (or at the end of `column` if given); an
        Indicator's sits under the same Outcome, directly after it. Albums show every filtered version on
        their Projects.

        `response_criteria` filters the responses (stories) the metric was recorded in, as a Progress
        Board's "Filter responses/stories by" does: `story_category_ids` (Surveys), `wave_ids`
        (Intervals), `date_range` ("dd/mm/yyyy - dd/mm/yyyy", Date Happened, either end optional),
        `label_ids` and `author_ids`. Project and Album keys are refused: the responses always come from
        the Project or Album it is on.

        `contact_criteria` filters the Contacts tagged in them, in the Contact Filters format (see
        `POST /cohort_trackers/preview`). Age (`age_from` / `age_to`) is worked out at the date of each
        response; other Bio fields use the Contact's current value; the other sections are judged at the
        end of each reporting period. Either may be sent as a JSON string. Requires the right to edit the
        Project's metrics.
      operationId: createFilteredMetric
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilteredMetricRequest'
            example:
              filtered_metric:
                parent_type: "Change"
                parent_id: 4021
                display_name: "Session attendances — Female, under 21"
                response_criteria:
                  wave_ids: ["12"]
                contact_criteria:
                  sub_ratio_ids: ["881"]
                  age_to: {year: "20", month: "11", day: "30"}
      responses:
        "201":
          description: Filtered version added to the Project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilteredMetric'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit the Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/{project_id}/filtered_metrics/preview:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricProjectId'
    post:
      tags: [Filtered Metrics]
      summary: Preview a filtered version
      description: |
        The Add filtered version dialog's "N of M session attendances in this project currently match",
        before it is added: `count` is how many of the metric's tagged responses on the Project pass
        the filters to date (a Numerical tracker's total), `total` how many there are with no filters.
        Takes the same body as adding one; `display_name` is optional.
      operationId: previewFilteredMetric
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilteredMetricRequest'
            example:
              filtered_metric:
                parent_type: "Change"
                parent_id: 4021
                contact_criteria:
                  sub_ratio_ids: ["881"]
      responses:
        "200":
          description: The count and the unfiltered total
          content:
            application/json:
              schema:
                type: object
                properties:
                  count:
                    type: number
                  total:
                    type: number
              example:
                count: 262
                total: 1540
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit the Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /cohort_trackers/{id}/albums/{bundle_id}/results:
    get:
      tags: [Cohort Trackers]
      summary: Get a Cohort Tracker's result on an Album
      description: |
        A Cohort Tracker's result on an Album's Results Canvas, with the Contacts behind it. The Album's
        Projects are counted together and each Contact once, so the result is never the sum of the
        Projects' results. The tracker must be on one of the Album's Projects.

        The result is the number of distinct Contacts who meet the tracker's membership setting and all
        its criteria, counting only stories, events and survey responses saved in scope and dated in the
        window. Results are worked out afresh for each window, so a Year to Date result is not the sum
        of the period results. `target` is the tracker's deadline target on the window's last day, or
        else its one-off target; targets are never summed across deadlines.

        `data` lists the Contacts in the cohort alphabetically, with `qualifying_value` (named by
        `qualifying_value_label`, e.g. an attendance rate as a percentage) where the criteria have one.
        A Contact the user may not read is listed as `{restricted: true}` with no details, so the
        list always adds up to `count`. Requires the same rights as viewing that Results Canvas.

        A percentage tracker also returns `denominator_count` and `percentage`, as the canvas shows
        "84% Children attending 75%+" with "42 of 50 contacts with enough data". The cohort is always
        within the denominator. `percentage` is a whole number, or null when `denominator_count` is 0
        (the canvas shows "–"). `cohort=not_in` lists the rest of the denominator.
      operationId: getCohortTrackerAlbumResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
        - $ref: '#/components/parameters/CohortTrackerAlbumId'
        - $ref: '#/components/parameters/CohortTrackerTimeframe'
        - $ref: '#/components/parameters/CohortTrackerAsOf'
        - $ref: '#/components/parameters/CohortTrackerCohort'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The result and the Contacts behind it
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortTrackerResult'
              example:
                cohort_tracker_id: 12
                name: Children attending 75%+
                album_id: 34
                timeframe: year_to_date
                starts_on: "2026-04-01"
                ends_on: "2026-06-30"
                count: 42
                eligible_count: 50
                result_type: percentage
                denominator: enough_data
                denominator_count: 50
                percentage: 84
                target: { number: 75, date: "2026-06-30" }
                qualifying_value_label: Attendance rate
                cohort: in
                page: 1
                page_size: 2
                page_count: 21
                total_count: 42
                data:
                  - { restricted: false, id: 101, name: Aisha Dlamini, qualifying_value: 82.5 }
                  - { restricted: true }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see this Results Canvas

  /projects/{project_id}/filtered_metrics/{id}:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricProjectId'
      - $ref: '#/components/parameters/FilteredMetricId'
    get:
      tags: [Filtered Metrics]
      summary: Get a filtered version on a Project
      operationId: getProjectFilteredMetric
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The filtered version
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilteredMetric'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see the Project's Results Canvas
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Filtered Metrics]
      summary: Update a filtered version
      description: |
        Renames it or replaces its filters: `response_criteria` and `contact_criteria`, when sent,
        replace the stored ones (`{}` clears them). The metric it filters and its placement can't be
        changed. The change applies wherever it is used. Requires the right to edit the Project's metrics.
      operationId: updateFilteredMetric
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilteredMetricRequest'
            example:
              filtered_metric:
                display_name: "Session attendances — Female"
                contact_criteria:
                  sub_ratio_ids: ["881"]
      responses:
        "200":
          description: Filtered version updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilteredMetric'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit the Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    delete:
      tags: [Filtered Metrics]
      summary: Remove a filtered version from a Project
      description: |
        Removes it from the Project and its Albums. It is deleted once it is on no other Project or
        Scorecard Template. Requires the right to edit the Project's metrics.
      operationId: removeFilteredMetric
      security: [{tokenAuth: []}]
      responses:
        "204":
          description: Removed
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't edit the Project's metrics
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /projects/{project_id}/filtered_metrics/{id}/results:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricProjectId'
      - $ref: '#/components/parameters/FilteredMetricId'
    get:
      tags: [Filtered Metrics]
      summary: Get a filtered version's result on a Project
      description: |
        The filtered result the Results Canvas shows, for one timeframe ending at `as_of`. Counts only
        the responses the user may read, as the canvas does.
      operationId: getProjectFilteredMetricResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/FilteredMetricTimeframe'
        - $ref: '#/components/parameters/FilteredMetricAsOf'
      responses:
        "200":
          description: The result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilteredMetricResult'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see the Project's Results Canvas
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /albums/{bundle_id}/filtered_metrics:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricBundleId'
    get:
      tags: [Filtered Metrics]
      summary: List an Album's filtered versions of metrics
      description: Every filtered version on any of the Album's Projects. Visible to anyone who can see the Album.
      operationId: listAlbumFilteredMetrics
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of filtered versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedFilteredMetrics'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see the Album
        "404":
          $ref: '#/components/responses/NotFound'

  /albums/{bundle_id}/filtered_metrics/{id}:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricBundleId'
      - $ref: '#/components/parameters/FilteredMetricId'
    get:
      tags: [Filtered Metrics]
      summary: Get a filtered version on an Album
      operationId: getAlbumFilteredMetric
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The filtered version
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilteredMetric'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see the Album
        "404":
          $ref: '#/components/responses/NotFound'

  /albums/{bundle_id}/filtered_metrics/{id}/results:
    parameters:
      - $ref: '#/components/parameters/FilteredMetricBundleId'
      - $ref: '#/components/parameters/FilteredMetricId'
    get:
      tags: [Filtered Metrics]
      summary: Get a filtered version's result on an Album
      description: The filtered result for the Album's open Projects together, as its Results Canvas shows it.
      operationId: getAlbumFilteredMetricResults
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/FilteredMetricTimeframe'
        - $ref: '#/components/parameters/FilteredMetricAsOf'
      responses:
        "200":
          description: The result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FilteredMetricResult'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user can't see the Album
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /media_items:
    get:
      tags: [Media Gallery]
      summary: List Media Gallery files
      description: |
        Lists every photo, video, audio file and document attached to Stories and to Contacts' bios in one organisation — the files shown on the **Media Gallery** page (Impact → Media Gallery).

        Only files from Stories and Contacts the user is already allowed to view are returned, so two users can get different results for the same organisation. Filters combine with AND.

        `kind_counts` gives the number of files of each kind for the same filters, ignoring `kind` — the counts on the File type buttons.
      operationId: listMediaItems
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: Organisation ID
        - name: kind
          in: query
          schema:
            type: string
            enum: [photo, video, audio, document]
          description: File type
        - name: search
          in: query
          schema:
            type: string
          description: Matches the start of words in the file name, Story title, Contact name and caption
        - name: source[]
          in: query
          schema:
            type: array
            items:
              type: string
              enum: [stories, contacts]
          style: form
          explode: true
          description: Story files, Contact bio files, or both (default both)
        - name: sort
          in: query
          schema:
            type: string
            enum: [newest, oldest]
            default: newest
          description: By upload date
        - name: story_filters
          in: query
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties: true
          example: { project_ids: [19], story_category_ids: [327] }
          description: |
            Timeline (Story) Filters, as on the homepage. Keys (arrays of ids unless noted): `project_ids`, `story_category_ids` (Surveys), `bundle_ids` (Albums), `beneficiary_ids` (Contacts tagged in the Story), `label_ids`, `outcome_ids`, `change_ids` (Engagement), `indicator_ids`, `user_ids` (Authors), `charity_ids`, and `created_at_from` (Date Happened range, `YYYY/MM/DD - YYYY/MM/DD`).

            Story files must match them. For Contact bio files, `project_ids` matches the Contact's Project memberships, and any other key means the Contact must appear in at least one matching Story.
        - name: contact_filters
          in: query
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties: true
          example: { group_ids: [4], beneficiary_types: [1] }
          description: |
            Contact Filters, as on Manage Contacts. Common keys (arrays of ids): `project_ids`, `group_ids`, `beneficiary_types` (Contact types: 1 Person, 2 Object, 3 Organisation, 4 Animal), `beneficiary_state_ids`, `created_by_ids`, `bundle_ids`.

            Contact bio files must match them, and Story files must involve at least one matching Contact.
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Media Gallery files
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedMediaItems'
              example:
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                kind_counts: { all: 1, photo: 1, video: 0, audio: 0, document: 0 }
                data:
                  - id: 512
                    kind: photo
                    file_name: harvest_day.jpg
                    content_type: image/jpeg
                    file_size: 248310
                    caption: Volunteers at the allotment
                    source_type: story
                    source_id: 90211
                    source_title: Harvest day at the allotment
                    project_id: 19
                    project_name: Growing Together
                    uploaded_by_id: 6207
                    uploaded_at: "2026-09-12T10:14:00Z"
                    updated_at: "2026-09-12T10:15:02Z"
                    thumbnail_url: https://makerble.s3.amazonaws.com/medias/files/000/000/512/thumbnail/harvest_day.jpg
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The user is not a member of that organisation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: forbidden
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /media_items/{id}:
    get:
      tags: [Media Gallery]
      summary: Get one Media Gallery file, with a download link
      description: |
        Returns one file from the **Media Gallery**, as shown in its preview panel, with a signed `download_url` that downloads the file.

        Permissions are checked again on every request. The user must still be able to view the Story or Contact the file belongs to.

        The link expires after `download_url_expires_in` seconds, so request the file again for a fresh link rather than storing it.
      operationId: getMediaItem
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        "200":
          description: The file, its field name and a short-lived download link
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaItemDetail'
              example:
                id: 512
                kind: document
                file_name: consent_form.pdf
                content_type: application/pdf
                file_size: 84211
                caption: null
                source_type: contact
                source_id: 30144
                source_title: Jordan T.
                project_id: null
                project_name: null
                uploaded_by_id: 6207
                uploaded_at: "2026-09-12T10:14:00Z"
                updated_at: "2026-09-12T10:15:02Z"
                thumbnail_url: null
                field_name: Consent form (file field)
                download_url: https://files.example.com/medias/files/000/000/512/original/consent_form.pdf?X-Amz-Expires=300&X-Amz-Signature=...
                download_url_expires_in: 300
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          description: The file exists, but the user can't view its Story or Contact
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: forbidden
        "404":
          $ref: '#/components/responses/NotFound'

  /organisations/{organisation_id}/seats:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Seats]
      summary: List an Organisation's seats per colleague
      description: |
        The Organisation's (Charity's) current Contracts, with seats bought and used per Billing Role
        (Organiser, Practitioner, Helper) on Role-based Pricing or in total on Flat Pricing, and a page
        of colleagues. Each colleague has the seat they hold on each Contract, the lowest seat their
        roles allow, and a status: `covered`, `no_seat` (a role that needs a seat but no seat),
        `seat_too_low` (a seat below what their roles need) or `no_seat_needed` (they still hold a
        seat but no longer have a role that needs one).

        This is the Seats per Colleague page under Our Account › Seats. Organisation Admins and
        Makerble staff can read it. Nobody loses access because of their seat.
      operationId: listSeats
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The Contracts and a page of colleagues
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedSeats'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /organisations/{organisation_id}/seats/{user_id}:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
      - name: user_id
        in: path
        required: true
        schema:
          type: integer
        description: The colleague's user ID
    put:
      tags: [Seats]
      summary: Change a colleague's seat on one Contract
      description: |
        Gives a colleague a seat on one of the Organisation's current Contracts, changes it or takes it
        away. On a Role-based Pricing Contract send the Billing Role to give, or `null` to take the seat
        away. On a Flat Pricing Contract send `has_seat` instead. The old seat is kept in Seat History.
        Nothing stops you going over the seats bought; the Organisation then shows as over its seat count.

        Only the Organisation's admins (and Makerble admins) can change seats. The colleague must have a
        role in the Organisation or still hold a seat there. Returns the colleague as the list does.
      operationId: changeSeat
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeatChangeRequest'
            examples:
              roleBased:
                value:
                  contract_id: 31
                  billing_role_id: 2
              takeAway:
                value:
                  contract_id: 31
                  billing_role_id: null
              flat:
                value:
                  contract_id: 32
                  has_seat: true
      responses:
        "200":
          description: The colleague's seats after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeatColleague'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /organisations/{organisation_id}/usage:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Usage]
      summary: Get an Organisation's usage this month
      description: |
        This calendar month's usage (UK time) of each thing an Organisation (Charity) is charged for
        when it goes over an allowance, with the allowance, how much of it is used, the usage expected
        by the end of the month if it carries on at the same rate, the price over the allowance, and the
        charge so far and expected. Amounts are in the currency the Organisation is billed in, before VAT.

        A usage type is listed when the Organisation used it this month or has an allowance for it.
        `status` is `within`, `near` (80% or more of the allowance), `over`, `waived` (a waiver means it
        isn't charged this month), or null when there is no allowance (charged from the first one).
        File storage is what was uploaded this month, in GB, not what is stored. Contacts are the
        current total, archived ones included; while it is over the allowance the bundle is charged
        every month. A charge is null when no price is set for usage over the allowance, and then
        `unpriced` is true and the totals leave it out.

        This is the Usage page under Our Account › Usage. Organisation Admins and Makerble staff can
        read it. Going over an allowance never stops anyone working.
      operationId: getOrganisationUsage
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: This month's usage
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganisationUsage'
              example:
                organisation_id: 42
                month: "2026-11"
                currency: GBP
                charge_so_far: 50
                expected_charge: 1060
                unpriced: false
                data:
                  - usage_type: story_created
                    name: Stories (survey responses)
                    unit: Stories
                    quantity: 5000
                    allowance: 6000
                    percent_used: 83
                    status: near
                    expected_quantity: 15000
                    unit_price: 0.1
                    per_quantity: 1
                    tier_min: null
                    tier_max: null
                    charge_so_far: 0
                    expected_charge: 900
                    note: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /organisations/{organisation_id}/usage/history:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Usage]
      summary: Get an Organisation's usage in the previous 12 months
      description: |
        The 12 calendar months before this one, newest first, from the usage charges worked out at the
        end of each month: each usage type the Organisation was charged for, its usage, allowance and
        charge, after any waivers. A month with no usage charges has an empty `usage` list. Amounts are
        in the currency the Organisation is billed in, before VAT; the usage bills show what was invoiced.
        Organisation Admins and Makerble staff can read it.
      operationId: getOrganisationUsageHistory
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The previous 12 months
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganisationUsageHistory'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /organisations/{organisation_id}/onboarding_journeys:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    post:
      tags: [Onboarding]
      summary: Set up an area of work from a Toolkit or your own stages
      description: |
        Sets up an area of work as the onboarding journey's "Start from a toolkit designed for an
        organisation like mine" path does, with the same checks: one workspace (Project) per name in
        `workspace_names` with the Toolkit installed, one workspace per extra in `extra_ids` with that
        extra's Project Type (see GET /onboarding_extras), and a Checklist that every contact in the
        area's workspaces gets.

        Or give `stages` instead of `toolkit_id`, as the "Personalise the platform to my organisation"
        path does: the stages of the Organisation's own process, each with a `name` and the `action` that
        happens at it. Each stage becomes one step of the same name in the Checklist. Content for the
        stages (forms, surveys, flags and so on) isn't set up this way; add it in Makerble afterwards.

        `spacing` says how the area is split into workspaces: `facilitator` (one per coach, mentor or
        practitioner), `site` (one per location), `cohort` (one per intake of a group or class) or
        `single` (one workspace, named after the area of work when `workspace_names` is empty). Up to
        50 workspace names of up to 100 characters each. `workspace_colours` optionally gives each
        workspace its colour, in the same order. `toolkit_id` must be a listed Toolkit.

        The workspaces are made in the background, so this answers 202 with `status: building`. Ask
        GET /onboarding_journeys/{id} until `status` is `completed` (then `workspace_ids` and
        `checklist_id` are filled in) or `failed` (nothing was made). Needs a Charity Editor or Charity
        Reporter of the Organisation.
      operationId: createOnboardingJourney
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [area_of_work, spacing]
              properties:
                area_of_work:
                  type: string
                  maxLength: 100
                toolkit_id:
                  type: integer
                  description: A listed Toolkit. Leave out when giving `stages`.
                stages:
                  type: array
                  description: Instead of `toolkit_id`, the stages of the Organisation's process, in order.
                  minItems: 1
                  maxItems: 20
                  items:
                    $ref: '#/components/schemas/OnboardingStage'
                spacing:
                  type: string
                  enum: [facilitator, site, cohort, single]
                workspace_names:
                  type: array
                  maxItems: 50
                  items:
                    type: string
                    maxLength: 100
                workspace_colours:
                  type: array
                  description: >-
                    The colour of each workspace, in the same order as `workspace_names`, as a six-digit hex
                    colour. A missing or invalid colour is replaced with the next Makerble brand colour.
                  items:
                    type: string
                    pattern: '^#[0-9A-Fa-f]{6}$'
                extra_ids:
                  type: array
                  items:
                    type: integer
            examples:
              toolkit:
                summary: From a Toolkit
                value:
                  area_of_work: Youth mentoring
                  toolkit_id: 62
                  spacing: site
                  workspace_names: [Leeds, York]
                  workspace_colours: ['#22B573', '#7E6CB0']
                  extra_ids: [1, 4]
              stages:
                summary: From your own stages
                value:
                  area_of_work: Youth mentoring
                  stages:
                    - {name: Sign up, action: complete_form_external}
                    - {name: Assessment, action: complete_survey}
                    - {name: Achieve the goal, action: add_flag}
                  spacing: single
      responses:
        "202":
          description: The set-up, building in the background
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OnboardingJourney'
              example:
                id: 318
                organisation_id: 42
                area_of_work: Youth mentoring
                toolkit_id: 62
                path: toolkit
                stages: []
                spacing: site
                workspace_names: [Leeds, York]
                workspace_colours: ['#22B573', '#7E6CB0']
                extra_ids: [1, 4]
                status: building
                workspace_ids: []
                checklist_id: null
                created_at: "2026-11-24T10:15:00Z"
                completed_at: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /onboarding_journeys/{id}:
    parameters:
      - name: id
        in: path
        required: true
        description: The set-up's id, from POST /organisations/{organisation_id}/onboarding_journeys.
        schema:
          type: integer
    get:
      tags: [Onboarding]
      summary: Get an area of work set-up
      description: |
        How a set-up is going: `status` is `building`, `completed` or `failed`. Once completed,
        `workspace_ids` lists the workspaces (Projects) it made, the area's own first, then the
        extras', and `checklist_id` is its Checklist. Only the person who set it up can see it.
      operationId: getOnboardingJourney
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The set-up
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OnboardingJourney'
              example:
                id: 318
                organisation_id: 42
                area_of_work: Youth mentoring
                toolkit_id: 62
                spacing: site
                workspace_names: [Leeds, York]
                workspace_colours: ['#22B573', '#7E6CB0']
                extra_ids: [1, 4]
                status: completed
                workspace_ids: [901, 902, 903, 904]
                checklist_id: 77
                created_at: "2026-11-24T10:15:00Z"
                completed_at: "2026-11-24T10:15:20Z"
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
  /onboarding_extras:
    get:
      tags: [Onboarding]
      summary: List the extra workspaces an area of work can have
      description: |
        The extras offered on the onboarding journey's Add extras step, in order: Referrals, Parents,
        Referees, Volunteers, Fundraising and any others Makerble offers. Each one makes a workspace
        with its own Project Type, and `icon` names the icon it is shown with (chosen by Makerble from a
        fixed set, or null). Pass their ids as `extra_ids` when setting up an area of work.
      operationId: listOnboardingExtras
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: The extras offered
          content:
            application/json:
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - id: 1
                    name: Referrals
                    description: Take in referrals from other organisations and professionals.
                    project_type_id: 12
                    project_type_name: Referrals
                    icon: referrals
                  - id: 4
                    name: Volunteers
                    description: Recruit, support and keep track of your volunteers.
                    project_type_id: null
                    project_type_name: null
                    icon: volunteers
        "401":
          $ref: '#/components/responses/Unauthorized'
  /organisations/{organisation_id}/setup_guide:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Setup guide]
      summary: Get an Organisation's Setup guide
      description: |
        The Setup guide's items for an Organisation (Charity), in order, with how far each has got in
        words (`progress`), what counts as done (`done_when`), and whether it is done or marked "Not
        relevant to us". `done_count` and `total_count` leave out items marked not relevant; `finished`
        is true once every item is done or not relevant.

        Items (`key`): `teams` (Create your teams; only for Organisations with 11 or more staff),
        `workspaces` (Add your workspaces), `another_area` (Set up another area of work; done once an
        area of work started from the Setup guide or the Create menu has been built; only while the
        onboarding journey is on), `welcome_tour` (Set up your team's Welcome Tour), `welcome_journey`
        (Go through the Welcome Journey; only for the person who created the Organisation),
        `specialisms` (Link your Specialisms to Ratio Sets; shown once a Specialism isn't linked to
        answers of a Ratio Set on the Contact forms, done when every one is), `checklists` (Set up a
        checklist on each workspace), and under "Automate your reporting" (`section`):
        `reporting_requirements`, `demographics` and `metrics`. Workspaces are Projects; closed ones,
        and the one Makerble creates with the Organisation, never count.

        This is the Setup guide page, under Help › Setup guide. The guide is a short, fixed list of
        items, so it isn't paginated.
      operationId: getSetupGuide
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Setup guide
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetupGuide'
              example:
                organisation_id: 42
                done_count: 3
                total_count: 6
                finished: false
                data:
                  - key: workspaces
                    title: Add your workspaces
                    section: null
                    progress: 2 of 2 workspaces
                    done_when: Done when you've created at least 2. The one Makerble makes for you doesn't count.
                    done: true
                    not_relevant: false
                  - key: checklists
                    title: Set up a checklist on each workspace
                    section: null
                    progress: 4 of 18 workspaces
                    done_when: Done when each open workspace has a checklist. Closed workspaces are left out.
                    done: false
                    not_relevant: false
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/SetupGuideForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
  /organisations/{organisation_id}/setup_guide/items/{item_key}:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
      - name: item_key
        in: path
        required: true
        description: The item's `key`, e.g. `checklists`.
        schema:
          type: string
          enum: [teams, workspaces, another_area, welcome_tour, welcome_journey, specialisms, checklists, reporting_requirements, demographics, metrics]
    patch:
      tags: [Setup guide]
      summary: Mark a Setup guide item Not relevant, or undo it
      description: |
        "Not relevant to us" (`not_relevant: true`) takes the item out of the Organisation's total and
        records who chose it and when; `not_relevant: false` is Undo and puts it back. Whether the item
        is done is unchanged: Makerble ticks items, nobody ticks them by hand. Answers with the whole
        Setup guide, as GET does.
      operationId: updateSetupGuideItem
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [not_relevant]
              properties:
                not_relevant:
                  type: boolean
            example:
              not_relevant: true
      responses:
        "200":
          description: The Setup guide after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetupGuide'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/SetupGuideForbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /organisations/{organisation_id}/age_bands:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Age Bands]
      summary: Get an Organisation's age bands
      description: |
        The Organisation's (Charity's) age bands, as set in Organisation Preferences › Age bands. Every
        Album and Project without its own bands uses these. Anyone in the Organisation can read them.
      operationId: getOrganisationAgeBands
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The age bands
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Age Bands]
      summary: Set an Organisation's age bands
      description: |
        Replaces the Organisation's age bands with the starting ages sent (whole numbers from 0 to
        120, saved sorted and unique; at least one). Only the Organisation's admins (Charity Editors)
        can change them. Every Album and Project without its own bands follows the change.
      operationId: setOrganisationAgeBands
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgeBandsRequest'
            example:
              starts: [0, 13, 18, 25]
      responses:
        "200":
          description: The age bands after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /organisations/{organisation_id}/age_band_counts:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Age Bands]
      summary: Count an Organisation's Contacts by age band
      description: |
        What the Age band panel on the Demographics tab of Manage Contacts shows: how many of the
        Organisation's Contacts (Beneficiaries) are in each age band, with ages worked out from Date of
        Birth as of today. Send `album_id` or `project_id` to count only that Album's or Project's
        Contacts by its age bands (`source` says whose bands were used).

        "Under X" appears only when a Contact is younger than the first band, "Date of birth in the
        future" only when a Contact's Date of Birth is after today (a data-entry error worth fixing),
        and "No date of birth" only when a Contact has none (and not at all when the Organisation
        hides untagged Contacts from demographics charts). Bands with fewer Contacts than the Organisation's Minimum Results
        Threshold have `contacts: null` and are added up under "Below Threshold". Anyone in the
        Organisation can read the counts.
      operationId: countContactsByAgeBand
      security: [{tokenAuth: []}]
      parameters:
        - name: album_id
          in: query
          schema:
            type: integer
          description: Count only this Album's (Bundle's) Contacts, by its age bands
        - name: project_id
          in: query
          schema:
            type: integer
          description: Count only this Project's Contacts, by its age bands
      responses:
        "200":
          description: Contacts per age band
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBandCounts'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /organisations/{organisation_id}/household_counts:
    parameters:
      - $ref: '#/components/parameters/OrganisationId'
    get:
      tags: [Beneficiaries]
      summary: Count the households an Organisation's Contacts are in
      description: |
        What the households panel on Manage Contacts shows: how many households (families) the
        Organisation's Contacts are in, and what those households are made up of. A household is a
        group of Contacts linked, directly or through other Contacts, by Relationships in Relationship
        Categories that count as a household (`counts_as_household`). Households reflect the
        relationships ongoing today.

        Send `filter_data` (the same filters as Manage Contacts) or `project_id` to count only those
        Contacts' households, e.g. `filter_data[created_at_from]=01/01/2026 - 31/03/2026` for Contacts
        added in a date range, or `filter_data[stories_created_at_from]=…` for Contacts with activity in
        it. A household counts when at least one of its members matches, and only Contacts you may see
        are matched. Each make-up counts every member, so the numbers are right; `hidden_contacts`
        says how many of them you don't have permission to see.
      operationId: countHouseholds
      security: [{tokenAuth: []}]
      parameters:
        - name: filter_data
          in: query
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties: true
          description: Manage Contacts filters choosing the Contacts, e.g. `filter_data[project_ids][]=572`
        - name: project_id
          in: query
          schema:
            type: integer
          description: Count only this Project's Contacts
      responses:
        "200":
          description: Households and their make-up, most common make-up first
          content:
            application/json:
              schema:
                type: object
                properties:
                  total_households: { type: integer }
                  contacts_in_households:
                    type: integer
                    description: How many of the matching Contacts are in a household
                  hidden_contacts:
                    type: integer
                    description: |
                      How many members of the counted households you don't have permission to see. They
                      are included in each make-up, so the numbers are right, but never named.
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        make_up:
                          type: string
                          example: 1 Child + 2 Parents
                        roles:
                          type: object
                          additionalProperties: { type: integer }
                          example: { Child: 1, Parent: 2 }
                        households: { type: integer }
                        hidden_contacts:
                          type: integer
                          description: Members of these households you don't have permission to see
              example:
                total_households: 9
                contacts_in_households: 27
                hidden_contacts: 1
                data:
                  - make_up: 1 Child + 1 Parent
                    roles: { Child: 1, Parent: 1 }
                    households: 6
                    hidden_contacts: 0
                  - make_up: 2 Children + 2 Parents
                    roles: { Child: 2, Parent: 2 }
                    households: 3
                    hidden_contacts: 1
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /albums/{album_id}/age_bands:
    parameters:
      - name: album_id
        in: path
        required: true
        schema:
          type: integer
        description: The Album's (Bundle's) ID
    get:
      tags: [Age Bands]
      summary: Get an Album (Portfolio)'s age bands
      description: |
        The age bands an Album (Portfolio) uses, as on its Preferences page: its own, or its Organisation's when it
        has none (`source` says which). Anyone who can see the Album can read them.
      operationId: getAlbumAgeBands
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The age bands
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Age Bands]
      summary: Set an Album (Portfolio)'s age bands
      description: |
        Gives the Album its own age bands, or (with `use_organisation_bands: true`) puts it back on
        its Organisation's. Starting ages are whole numbers from 0 to 120, saved sorted and unique.
        Only the Album's managers can change them.
      operationId: setAlbumAgeBands
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgeBandsRequest'
            examples:
              ownBands:
                value:
                  starts: [10, 14, 18, 22]
              organisationBands:
                value:
                  use_organisation_bands: true
      responses:
        "200":
          description: The age bands after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /projects/{project_id}/age_bands:
    parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: integer
        description: The Project's ID
    get:
      tags: [Age Bands]
      summary: Get a Project's age bands
      description: |
        The age bands a Project uses, as on its Preferences page: its own, or its Organisation's when it
        has none (`source` says which). Anyone who can see the Project can read them.
      operationId: getProjectAgeBands
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The age bands
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Age Bands]
      summary: Set a Project's age bands
      description: |
        Gives the Project its own age bands, or (with `use_organisation_bands: true`) puts it back on
        its Organisation's. Starting ages are whole numbers from 0 to 120, saved sorted and unique.
        Only Project Managers and Organisation Admins (whoever can change Project Preferences) can change them.
      operationId: setProjectAgeBands
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgeBandsRequest'
            examples:
              ownBands:
                value:
                  starts: [10, 14, 18, 22]
              organisationBands:
                value:
                  use_organisation_bands: true
      responses:
        "200":
          description: The age bands after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgeBands'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /albums/{album_id}/snapshot_settings:
    parameters:
      - name: album_id
        in: path
        required: true
        schema:
          type: integer
        description: The Album's (Bundle's) ID
    get:
      tags: [Snapshot]
      summary: Get what an Album (Portfolio)'s Snapshot shows
      description: |
        What the Album's Snapshot shows, as on the Snapshot tab of its Preferences, and every choice
        there is: the panels for "Who we're working with" (the Ratio Sets its Contacts are tagged
        with, Age band and Split by project), the metrics in each Results Canvas column for "How the
        work is going", and the Workflow, Cohort and Formula Trackers, which can go on any tile and on
        Workload. Until its managers choose, `customised` is false and the defaults are shown. Anyone
        who can see the Album can read it.
      operationId: getAlbumSnapshotSettings
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: What the Snapshot shows, and the choices
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SnapshotSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Snapshot]
      summary: Choose what an Album (Portfolio)'s Snapshot shows
      description: |
        Sets the Snapshot's panels (in display order), its tiles (one per Results Canvas column; null
        hides a tile) and up to three Workload tiles, using the `key`s that GET lists under `choices`.
        Whatever you don't send stays as it is. Only the Album's managers can change it.
      operationId: setAlbumSnapshotSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SnapshotSettingsRequest'
            examples:
              panels:
                value:
                  panels: [age_band, split_by_project, "ratio_set:12"]
              tiles:
                value:
                  tiles: {activities: "Change:31", engagement: null, potential: "WorkflowTracker:4"}
                  workload: ["CohortTracker:2", null, null]
      responses:
        "200":
          description: What the Snapshot shows after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SnapshotSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /projects/{project_id}/snapshot_settings:
    parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: integer
        description: The Project's ID
    get:
      tags: [Snapshot]
      summary: Get what a Project's Snapshot shows
      description: |
        What the Project's Snapshot shows, as on the Snapshot tab of its Preferences, and every choice
        there is: the panels for "Who we're working with" (the Ratio Sets its Contacts are tagged
        with, and Age band), the metrics in each Results Canvas column for "How the work is going",
        and the Workflow, Cohort and Formula Trackers, which can go on any tile and on Workload. Until
        its editors choose, `customised` is false and the defaults are shown. Anyone in the Project's
        Organisation can read it.
      operationId: getProjectSnapshotSettings
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: What the Snapshot shows, and the choices
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SnapshotSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    put:
      tags: [Snapshot]
      summary: Choose what a Project's Snapshot shows
      description: |
        Sets the Snapshot's panels (in display order), its tiles (one per Results Canvas column; null
        hides a tile) and up to three Workload tiles, using the `key`s that GET lists under `choices`.
        Whatever you don't send stays as it is. Only Project Managers and Organisation Admins (whoever
        can change Project Preferences) can change it.
      operationId: setProjectSnapshotSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SnapshotSettingsRequest'
            examples:
              panels:
                value:
                  panels: [age_band, "ratio_set:12"]
              tiles:
                value:
                  tiles: {activities: "Change:31", engagement: null}
                  workload: ["WorkflowTracker:4", null, null]
      responses:
        "200":
          description: What the Snapshot shows after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SnapshotSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /projects/{project_id}/celebration_settings:
    parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: integer
        description: The Workspace's (Project's) ID
    get:
      tags: [Impact Celebrations]
      summary: Get a Workspace's Impact Celebrations settings
      description: |
        Whether Impact Celebrations are switched on for the Workspace (Project), and every metric that
        can celebrate there, as on the Impact Celebrations tab of its Preferences: each Activity,
        Engagement, Achievement or Numerical tracker (Change or Indicator) with a target over 0, and
        each Choice tracker (Scale Indicator), which celebrates when 80% of Contacts improve. A Choice
        tracker without a success direction is listed with `can_tick: false` and the `reason`.
        Only the Workspace's editors and its Organisation Admins (whoever may edit its targets) can read it.
      operationId: getProjectCelebrationSettings
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Workspace's Impact Celebrations settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CelebrationSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Impact Celebrations]
      summary: Switch a Workspace's Impact Celebrations on or off, and choose the metrics
      description: |
        Sets whether Impact Celebrations are on (`enabled`) and which metrics celebrate
        (`metric_keys`, the `key`s GET lists, all of which must have `can_tick: true`). Whatever you
        don't send stays as it is; `metric_keys: []` unticks every metric. Switching off stops new
        celebrations; any popup already showing carries on until it ends.
      operationId: setProjectCelebrationSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CelebrationSettingsInput'
            example:
              enabled: true
              metric_keys: ["Change-12", "Indicator-7"]
      responses:
        "200":
          description: The saved settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CelebrationSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /projects/{project_id}/celebrations:
    parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: integer
        description: The Workspace's (Project's) ID
    get:
      tags: [Impact Celebrations]
      summary: List a Workspace's Impact Celebrations so far
      description: |
        The targets and improvements the Workspace (Project) has reached, newest first, with what
        happened: the popup announcement Makerble made, or `recorded_silently` when it was already
        reached when first checked. Only whoever may edit the Workspace's targets can list them.
      operationId: listProjectCelebrations
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of celebrations
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CelebrationPage'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /albums/{album_id}/celebration_settings:
    parameters:
      - name: album_id
        in: path
        required: true
        schema:
          type: integer
        description: The Portfolio's (Album's, Bundle's) ID
    get:
      tags: [Impact Celebrations]
      summary: Get a Portfolio's Impact Celebrations settings
      description: |
        As for a Workspace, for a Portfolio (Album): its own targets (one-off, or dated targets set on
        the Portfolio, automatic or manual) and the Choice trackers used on its open Workspaces. Its
        popups are seen by colleagues on its open Workspaces and its editors. Only the Portfolio's owner
        and its Organisation Admins can read it.
      operationId: getAlbumCelebrationSettings
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Portfolio's Impact Celebrations settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CelebrationSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Impact Celebrations]
      summary: Switch a Portfolio's Impact Celebrations on or off, and choose the metrics
      description: As for a Workspace, for a Portfolio (Album).
      operationId: setAlbumCelebrationSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CelebrationSettingsInput'
            example:
              enabled: true
              metric_keys: ["Change-12"]
      responses:
        "200":
          description: The saved settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CelebrationSettings'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'
  /albums/{album_id}/celebrations:
    parameters:
      - name: album_id
        in: path
        required: true
        schema:
          type: integer
        description: The Portfolio's (Album's, Bundle's) ID
    get:
      tags: [Impact Celebrations]
      summary: List a Portfolio's Impact Celebrations so far
      description: As for a Workspace, for a Portfolio (Album).
      operationId: listAlbumCelebrations
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: A page of celebrations
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CelebrationPage'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
  /celebrations/{id}/end:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: The celebration's ID, from the list of celebrations
    post:
      tags: [Impact Celebrations]
      summary: End an Impact Celebration's popup now
      description: |
        Stops a celebration's popup announcement showing, as End now does on the Impact Celebrations
        tab: its last day becomes yesterday. Only one whose announcement is still showing can be ended
        (422 otherwise). Only whoever may edit the Workspace's or Portfolio's targets can end it.
      operationId: endCelebration
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The celebration, with its announcement now ended
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Celebration'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /focus:
    get:
      tags: [Focus]
      summary: Get what needs you, as on your Focus page
      description: |
        Everything that needs you, from every source you haven't switched off, most overdue first,
        as on Today › Focus. Today the only source is **Checklist Actions** (`type: checklist_actions`):
        for each Contact and Checklist, the first step not yet done, when you are responsible for it
        (the Checklist's "Who is responsible?", or the Contact's own choice in its place). "The
        colleague who added this checklist" counts when that was you.

        `scope=me` (the default) gives what you are responsible for; `scope=teams` adds what your
        Teams are responsible for, and is only available when you are in a Team (`teams: true`).
        There is no view of everyone's work: a Checklist's progress gives that.

        Each item has `id`, `type`, `title`, `contact` ({id, name}), `context` (e.g. "Checklist Action ·
        Intake · step 2 of 5", plus who is responsible when it isn't you), `url`, `due_on` (the day the
        Checklist was added plus the step's due days, or null), `due_text`, `section` (`overdue`,
        `today`, `this_week` for the next 7 days, or `later` for later or undated) and `action`
        ({label, url, method}), the row's button. `counts`, `sections` and `sources` describe the whole
        list, whatever `section` or page you ask for. Only Contacts you can see are included.
      operationId: getFocus
      security: [{tokenAuth: []}]
      parameters:
        - name: scope
          in: query
          required: false
          schema:
            type: string
            enum: [me, teams]
          description: "`teams` adds what your Teams are responsible for. Falls back to `me` when you are in no Team."
        - name: type
          in: query
          required: false
          schema:
            type: string
          description: Only items from this source, e.g. `checklist_actions`. A type with no items gives every item.
        - name: section
          in: query
          required: false
          schema:
            type: string
            enum: [overdue, today, this_week, later]
          description: Only items in this section.
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: What needs you
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FocusFeed'
              example:
                scope: me
                teams: true
                type: null
                sources: [{key: checklist_actions, label: Checklist Actions, shown: true}]
                counts: {all: 1, checklist_actions: 1}
                sections: [{key: overdue, label: Overdue, count: 1}]
                page: 1
                page_size: 1
                page_count: 1
                total_count: 1
                data:
                  - id: checklist_actions-812
                    type: checklist_actions
                    title: Consent form
                    contact: {id: 4021, name: Ayanda Dlamini}
                    context: Checklist Action · Youth Programme Intake · step 3 of 6
                    url: /beneficiaries/4021
                    due_on: "2026-10-11"
                    raised_on: null
                    due_text: 15 days overdue
                    section: overdue
                    action: {label: Open, url: /beneficiaries/4021, method: get}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /focus/settings:
    patch:
      tags: [Focus]
      summary: Choose what your Focus page shows
      description: |
        The sources your Focus page shows, as chosen under its ⚙ "What Focus shows you". Send the keys
        of the sources to show; every other source is switched off. Saved for you only: your email and
        web notification settings are unchanged.
      operationId: updateFocusSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [shown_sources]
              properties:
                shown_sources:
                  type: array
                  items:
                    type: string
                  description: Source keys from `sources` in GET /focus; `[]` shows none.
            example:
              shown_sources: [checklist_actions]
      responses:
        "200":
          description: The sources after the change
          content:
            application/json:
              schema:
                type: object
                required: [sources]
                properties:
                  sources:
                    type: array
                    items:
                      $ref: '#/components/schemas/FocusSource'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /my_apps_menu:
    get:
      tags: [My Apps menu]
      summary: Get whether My Apps shows in your top menu
      description: |
        Whether the My Apps button shows in your top menu, as chosen under Personal Settings › Preferences
        › Show My Apps in the top menu. Colleagues who joined before this setting existed have it on; new
        colleagues start with it off. `offered` is false for Contacts with a login and Survey Portal users,
        who have no My Apps menu.
      operationId: getMyAppsMenu
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Whether My Apps shows in your top menu
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MyAppsMenu'
              example:
                offered: true
                shown: false
        "401":
          $ref: '#/components/responses/Unauthorized'
    patch:
      tags: [My Apps menu]
      summary: Show or hide My Apps in your top menu
      description: |
        Show or hide the My Apps button in your top menu, as Personal Settings › Preferences › Show My Apps
        in the top menu does. Saved for you only; it takes effect the next time a page loads in full.
        Refused for Contacts with a login and Survey Portal users, who have no My Apps menu.
      operationId: updateMyAppsMenu
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [shown]
              properties:
                shown:
                  type: boolean
                  description: true to show My Apps in your top menu, false to hide it
            example:
              shown: false
      responses:
        "200":
          description: The setting after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MyAppsMenu'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /start_page:
    get:
      tags: [Start page]
      summary: Get your start page
      description: |
        The Today page you land on after signing in, and whenever you click Home or the Makerble logo,
        as chosen under Personal Settings › Preferences › Start page, and the pages you can choose.
        Newsfeed (formerly My Home) is the default. Focus and Snapshot are offered while they are in
        the Today section of your sidebar, and Autopilot while it is on for one of your organisations.
        If you chose a page that is no longer offered to you, `start_page` is `newsfeed`.
      operationId: getStartPage
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Your start page and the pages you can choose
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartPage'
              example:
                start_page: focus
                options:
                  - {key: newsfeed, label: Newsfeed, description: "What’s happened across your projects. Formerly My Home."}
                  - {key: focus, label: Focus, description: "Your next steps across checklists, overdue first."}
        "401":
          $ref: '#/components/responses/Unauthorized'
    patch:
      tags: [Start page]
      summary: Choose your start page
      description: |
        Choose the Today page you land on after signing in and when you click Home or the Makerble logo,
        as Personal Settings › Preferences › Start page does. Saved for you only. If you choose Focus
        but can neither see nor create a Checklist, Home takes you to Newsfeed with a note saying why.
      operationId: updateStartPage
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [start_page]
              properties:
                start_page:
                  type: string
                  enum: [newsfeed, focus, snapshot, autopilot]
                  description: The key of one of the `options` GET /start_page returns.
            example:
              start_page: focus
      responses:
        "200":
          description: Your start page after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartPage'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /snapshot:
    get:
      tags: [Snapshot]
      summary: Get an Album (Portfolio)'s or Project's Snapshot
      description: |
        The numbers Today › Snapshot shows for one Album or Project. **panels** ("Who we're working
        with") count its Contacts by Ratio Set, age band or Project, by the Demographics tab's rules:
        only Contacts you can view are counted, Contacts without a value are under "No Data" or "No
        date of birth" (left out if the Organisation hides untagged Contacts from charts), and groups
        below the Organisation's Minimum Results Threshold have `contacts: null` and are added up under
        "Below Threshold". `percent` is of all the Album's or Project's Contacts. **tiles** ("How the
        work is going", one per Results Canvas column not hidden) and **workload** give each chosen
        metric's or tracker's result for the Results Canvas's current period, or all time when there are
        no deadlines (`timeframe` says which); `value` is null for a tracker with no single number.

        Name the Album or Project with `album_id` or `project_id`; without either, you get your pinned
        one, or else the last one you viewed in Makerble (`404` when there's neither). What appears is
        chosen with PUT /albums/{album_id}/snapshot_settings or /projects/{project_id}/snapshot_settings.
      operationId: getSnapshot
      security: [{tokenAuth: []}]
      parameters:
        - name: album_id
          in: query
          required: false
          schema:
            type: integer
          description: The Album's (Bundle's) ID
        - name: project_id
          in: query
          required: false
          schema:
            type: integer
          description: The Project's ID
      responses:
        "200":
          description: The Snapshot
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Snapshot'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /snapshot/pin:
    put:
      tags: [Snapshot]
      summary: Pin an Album (Portfolio) or Project as your Snapshot
      description: |
        Makes Today › Snapshot (and GET /snapshot without an id) open this Album or Project for you,
        as the **Pin as my Snapshot** button does. It only changes your own Snapshot.
      operationId: pinSnapshot
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                album_id:
                  type: integer
                project_id:
                  type: integer
            examples:
              project:
                value:
                  project_id: 412
      responses:
        "200":
          description: What is now pinned
          content:
            application/json:
              schema:
                type: object
                required: [pinned]
                properties:
                  pinned:
                    $ref: '#/components/schemas/SnapshotOwner'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /snapshot/share_link:
    parameters:
      - name: album_id
        in: query
        required: false
        schema:
          type: integer
        description: The Album's (Bundle's) ID. Give this or project_id.
      - name: project_id
        in: query
        required: false
        schema:
          type: integer
        description: The Project's ID. Give this or album_id.
    get:
      tags: [Snapshot]
      summary: Get your share link to an Album's (Portfolio's) or Project's Snapshot
      description: |
        Your working read-only link to the Snapshot of one Album or Project, made with POST or the
        **Share** button on Today › Snapshot. `404` when you have no working link to it, or can't see it.
      operationId: getSnapshotShareLink
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Your working link
          content:
            application/json:
              schema:
                type: object
                required: [share_link]
                properties:
                  share_link:
                    $ref: '#/components/schemas/SnapshotShareLink'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    post:
      tags: [Snapshot]
      summary: Share an Album's (Portfolio's) or Project's Snapshot
      description: |
        Makes a read-only link to the Snapshot of an Album or Project you can see, as the **Share**
        button on Today › Snapshot does, or returns the working one you already have. Anyone with the
        link can open the Snapshot without a Makerble account. It shows the numbers as you see them
        (only Contacts you can view are counted, and groups below the Minimum Results Threshold stay
        hidden), and it stops working when you turn it off with DELETE or can no longer see the Album
        or Project. Each user has their own link to each Album or Project. Give `album_id` or
        `project_id` in the query or the body.
      operationId: createSnapshotShareLink
      security: [{tokenAuth: []}]
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                album_id:
                  type: integer
                project_id:
                  type: integer
            examples:
              project:
                value:
                  project_id: 412
      responses:
        "201":
          description: Your working link
          content:
            application/json:
              schema:
                type: object
                required: [share_link]
                properties:
                  share_link:
                    $ref: '#/components/schemas/SnapshotShareLink'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
    delete:
      tags: [Snapshot]
      summary: Turn off your share link to an Album's (Portfolio's) or Project's Snapshot
      description: |
        Turns off your working link to the Snapshot of an Album or Project, as **Turn off link** on
        Today › Snapshot does. Anyone who opens it afterwards is told it isn't working. Only turns off
        your own link. `404` when you have no working link to it.
      operationId: deleteSnapshotShareLink
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The link is turned off
          content:
            application/json:
              schema:
                type: object
                required: [disabled]
                properties:
                  disabled:
                    type: boolean
                    example: true
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /guidance_panels:
    get:
      tags: [Guidance Panels]
      summary: List the Guidance Panels
      description: |
        Every Guidance Panel: the Show/Hide Guidance introduction at the top of a Manage page (such as
        Manage Events or Manage Contact Groups), with its eyebrow, headline, 2 to 5 points, the text shown to
        people who can't use the page's main action, the link to its article in the Makerble User Guide,
        and its video. Panels are the same for every Organisation. Only Makerble staff with System Access
        can read or change them (otherwise `403`), and only with their own token: an API key or a
        connected app gets `403`.
      operationId: listGuidancePanels
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of Guidance Panels, by page name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGuidancePanels'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'

  /guidance_panels/illustrations:
    get:
      tags: [Guidance Panels]
      summary: List the illustrations an animation can play
      description: |
        The flat illustrations of a feature's screens that an Intro's or announcement's animation can play
        (an illustration storyboard; see `GuidancePanelStoryboard`). Developers add them to Makerble; they
        can't be uploaded through the API. Each has its `name` (the storyboard's `illustration`, or a
        `scene` step's), its `view_box` (`[x, y, width, height]`, the units a `crop` is given in) and its
        `parts`, which steps target: a `field` is filled in by `type` and `swap`, a `scroll` part is
        scrolled by `scroll`, and any part can appear, be pointed at, highlighted, clicked or zoomed on.
        Only Makerble staff with System Access, with their own token.
      operationId: listGuidancePanelIllustrations
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated list of illustrations, by name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedGuidancePanelIllustrations'
              example:
                page: 1
                page_size: 1
                page_count: 3
                total_count: 3
                data:
                  - name: event_booking
                    view_box: [0, 0, 1600, 1000]
                    parts:
                      - { name: content, kind: part }
                      - { name: first_name, kind: field }
                      - { name: confirmation, kind: part }
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'

  /guidance_panels/{key}:
    parameters:
      - name: key
        in: path
        required: true
        schema:
          type: string
        description: The panel's key, e.g. `events` or `contact_groups` (see `GET /guidance_panels`)
        example: events
    get:
      tags: [Guidance Panels]
      summary: Get a Guidance Panel and its recent changes
      description: |
        One Guidance Panel, with its last 10 versions, newest first: who changed it, when, and what changed
        from what to what. Changes made in Site Overview › Guidance Panels, through this API and through
        the MCP all appear here.
      operationId: getGuidancePanel
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The Guidance Panel and its last 10 versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuidancePanelWithVersions'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Guidance Panels]
      summary: Change a Guidance Panel's wording or video
      description: |
        Changes any of the panel's eyebrow, headline, points, staff text, user guide link and Vimeo link.
        Fields you leave out stay as they are. `points` replaces the whole list, in the order given. The
        page shows the change from its next load, and the change is kept as a version attributed to you.

        The same rules apply as in Site Overview: a headline of at most 80 characters; 2 to 5 points, each
        with a `lead` (up to 40 characters, shown in bold) and `text` (up to 200); a `user_guide_url` on a
        page in the Makerble User Guide (`https://makerble.atlassian.net/wiki/spaces/MCPD/...`); and a
        `vimeo_url` that is empty or one of `https://vimeo.com/<id>`, `https://vimeo.com/<id>/<hash>`
        (unlisted videos) or `https://player.vimeo.com/video/<id>?h=<hash>`. An empty `vimeo_url` puts the
        page back to its fallback visual.

        `storyboard` is the Intro's animation, drawn from Makerble building blocks, or from one of the
        feature's illustrations (`GET /guidance_panels/illustrations`), when there is no Vimeo link (see
        `GuidancePanelStoryboard` for its rules). Send it as an object, or `null` to remove it.

        `feature_tour_id` chooses the feature tour the Intro offers with "Take the tour" (`null` for none).
        It sets that tour's `page_key` to this Intro and unlinks any other tour that pointed here, naming it in
        `notices`. It is refused when the chosen tour is live and another live tour is already on this Intro:
        choose `null` first to take that one off.
        A broken rule answers `422` with every message in `errors`, and nothing is changed.
      operationId: updateGuidancePanel
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GuidancePanelRequest'
            example:
              guidance_panel:
                headline: "Plan every session in one place"
                points:
                  - lead: "Plan events"
                    text: "set rotas and track attendance for every session."
                  - lead: "Count the time"
                    text: "spent by contact, coworker, task, event or case."
                vimeo_url: "https://vimeo.com/76979871"
      responses:
        "200":
          description: The changed Guidance Panel and its last 10 versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuidancePanelWithVersions'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntityList'

  /ai_assistant_link:
    get:
      tags: [AI assistants]
      summary: Read your AI assistant link
      description: |
        Your own link for connecting an AI assistant such as Claude or ChatGPT to Makerble through the
        Makerble MCP, without the link itself, which is shown only when it is made. `link` is null if
        you have none. `organisations` are the Organisations you can choose to bill it to. Every call
        an assistant makes with the link counts as API usage for the Organisation you chose, and acts
        as you, with what you can see and do. The same as User Settings, then AI assistants. These
        endpoints need your own token: an API key, an AI assistant link or a connected app gets `403`.
      operationId: getAiAssistantLink
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Your link, if you have one, and the Organisations it can be billed to
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiAssistantLinkStatus'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'

    post:
      tags: [AI assistants]
      summary: Get a new AI assistant link
      description: |
        Makes your link for connecting an AI assistant to Makerble, billed to `charity_id`, an
        Organisation you work in. The response includes the link in `url`, shown only this once: paste
        it into your AI assistant as a custom connector (in Claude, Settings then Connectors; in
        ChatGPT, Settings then Connectors). Treat it like a password. Any link you had before stops
        working.
      operationId: createAiAssistantLink
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id]
              properties:
                charity_id:
                  type: integer
                  description: The Organisation (Charity) the link's API usage is billed to
            example:
              charity_id: 913
      responses:
        "201":
          description: Link made
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiAssistantLinkWithUrl'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [AI assistants]
      summary: Turn off your AI assistant link
      description: Any AI assistant using your link stops working straight away.
      operationId: deleteAiAssistantLink
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: Link turned off
          content:
            application/json:
              schema:
                type: object
                required: [link]
                properties:
                  link:
                    type: object
                    nullable: true
                    example: null
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'

  /api_keys:
    get:
      tags: [API keys]
      summary: List an Organisation's API keys
      description: |
        The Organisation's (Charity's) API keys, including revoked ones, without their secrets. Each key
        shows the start of its secret (`secret_hint`) so it can be recognised. Only the Organisation's
        admins can manage API keys (otherwise `403`). These endpoints need a person's own token: an API
        key or a connected app gets `403`, so a key can't create or revoke keys.
      operationId: listApiKeys
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of API keys
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedApiKeys'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'

    post:
      tags: [API keys]
      summary: Create an API key
      description: |
        Creates a key for a custom integration. It acts as `user_id`, who must be a colleague in the
        Organisation (a User with a role in it; see `GET /users`), and can see and do only what they can.
        The response includes the key itself in `secret`, which is shown only this once: store it
        somewhere safe. Send it as `Authorization: Bearer <secret>`.
      operationId: createApiKey
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyRequest'
            example:
              charity_id: 913
              api_key:
                name: "Finance dashboard"
                user_id: 4521
      responses:
        "201":
          description: Key created, with its secret
          headers:
            Location:
              description: Full address of the new key, e.g. `https://app.makerble.com/api/v2/api_keys/42`
              schema:
                type: string
                format: uri
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyWithSecret'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/ForbiddenError'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /api_keys/{id}:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    get:
      tags: [API keys]
      summary: Get an API key
      description: The key, without its secret. Another Organisation's key answers `404`.
      operationId: getApiKey
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The key, without its secret
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKey'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    delete:
      tags: [API keys]
      summary: Revoke an API key
      description: |
        Revokes the key straight away: requests made with it get `401` from then on. This can't be
        undone. The key stays in the list, with `active: false` and `revoked_at` set.
      operationId: revokeApiKey
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The revoked key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKey'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /eventbrite_connection:
    get:
      tags: [Eventbrite]
      summary: Get the Organisation's Eventbrite connection
      description: |
        Whether the Organisation (Charity) is connected to Eventbrite. `status` is `not_connected`,
        `choosing_organisation` (signed in, but the Eventbrite sign-in belongs to several Eventbrite
        organisations; choose one with `PATCH /eventbrite_connection`), `active`, or `reconnect_required`
        (Eventbrite no longer accepts the sign-in, and the Organisation's admins have been emailed).
        Signing in to Eventbrite needs a browser, so connecting and reconnecting happen on the
        Connect > Eventbrite page in Makerble, given as `page_url`. The Eventbrite token is never returned.
      operationId: getEventbriteConnection
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: The connection, or `status` `not_connected`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteConnection'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

    patch:
      tags: [Eventbrite]
      summary: Choose the Eventbrite organisation
      description: |
        While `status` is `choosing_organisation`, chooses which of `available_organizations` the
        connection uses. The connection becomes `active`.
      operationId: chooseEventbriteOrganization
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, eventbrite_connection]
              properties:
                charity_id:
                  type: integer
                eventbrite_connection:
                  type: object
                  required: [eventbrite_organization_id]
                  properties:
                    eventbrite_organization_id:
                      type: string
            example:
              charity_id: 913
              eventbrite_connection:
                eventbrite_organization_id: "2"
      responses:
        "200":
          description: The connection, now active
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteConnection'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

    delete:
      tags: [Eventbrite]
      summary: Disconnect Eventbrite
      description: |
        Makerble stops bringing in changes from Eventbrite. Events, Contacts and Stories already brought
        in stay, with their links to Eventbrite. Succeeds again when already disconnected.
      operationId: disconnectEventbrite
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "204":
          description: Disconnected
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /eventbrite_connection/test:
    post:
      tags: [Eventbrite]
      summary: Test the Eventbrite connection
      description: |
        Checks with Eventbrite that the sign-in still works. `test_succeeded` says whether it did. A
        revoked sign-in moves `status` to `reconnect_required`.
      operationId: testEventbriteConnection
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: The connection, with `test_succeeded`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteConnection'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /eventbrite_connection/sync:
    post:
      tags: [Eventbrite]
      summary: Sync with Eventbrite now
      description: |
        Queues a full catch-up with the Organisation's Eventbrite account, instead of waiting for the one
        every 3 hours (changes normally arrive within seconds by webhook). `syncing` is true until it has run;
        see `GET /eventbrite_connection/sync_log` for what came in.
      operationId: syncEventbriteNow
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "202":
          description: Queued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteConnection'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /eventbrite_connection/sync_log:
    get:
      tags: [Eventbrite]
      summary: List the Eventbrite sync log
      description: |
        What Makerble brought in from Eventbrite, updated, skipped or removed, and why, newest first, kept for
        90 days. `needs_review` means a ticket holder's email matched existing Contacts unclearly: a new Contact
        was made and the possible duplicates are on the Suggested Merges list (source `eventbrite`).
      operationId: listEventbriteSyncLog
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated sync log
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedEventbriteSyncLog'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /eventbrite_connection/settings:
    patch:
      tags: [Eventbrite]
      summary: Choose what to bring in from Eventbrite
      description: |
        The Workspace (`project_id`) and Event format (`event_category_id`, one of the Workspace's) new Events go
        into; `import_mode` `all_upcoming` (every upcoming Eventbrite event, new ones included) or `selected`
        (only picked events, drafts included); the Workspace (`contact_project_id`, or each Event's Workspace when
        blank) and Contact Bio Form (`beneficiary_category_id`, one the Workspace uses for creating Contacts) new
        Contacts get; and the engagement tracker (`change_id`) and Event attendance survey (`story_category_id`, a
        survey running on the Workspace for new Events) check-ins are recorded with. Send only the settings to
        change. Saving starts a sync. Nothing comes in until `project_id` and `event_category_id` are set.
      operationId: updateEventbriteSettings
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, eventbrite_connection]
              properties:
                charity_id:
                  type: integer
                eventbrite_connection:
                  $ref: '#/components/schemas/EventbriteSettings'
            example:
              charity_id: 913
              eventbrite_connection:
                project_id: 120
                event_category_id: 44
                import_mode: all_upcoming
                change_id: 3021
                story_category_id: 812
      responses:
        "200":
          description: The connection with its new settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteConnection'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /eventbrite_connection/events:
    get:
      tags: [Eventbrite]
      summary: List the Eventbrite events to pick from
      description: |
        The upcoming events in the connected Eventbrite organisation, with whether each is (or would be)
        brought in, and the Makerble Event it came in as. Drafts and cancelled events are listed but not
        selected unless picked.
      operationId: listEventbriteEvents
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: The Eventbrite events
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/EventbriteEventChoice'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "502":
          description: Eventbrite couldn't list the events
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      tags: [Eventbrite]
      summary: Pick the Eventbrite events to bring in
      description: Switches `import_mode` to `selected` and brings in only these Eventbrite events.
      operationId: chooseEventbriteEvents
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, eventbrite_event_ids]
              properties:
                charity_id:
                  type: integer
                eventbrite_event_ids:
                  type: array
                  items:
                    type: string
            example:
              charity_id: 913
              eventbrite_event_ids: ["750011223344"]
      responses:
        "200":
          description: The connection, with the picked events in settings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteConnection'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /eventbrite_connection/mappings/{object_type}:
    parameters:
      - name: object_type
        in: path
        required: true
        schema:
          type: string
          enum: [event, attendee]
        description: "`event` for Eventbrite events onto Makerble Events; `attendee` for ticket holders onto Contacts"
    get:
      tags: [Eventbrite]
      summary: Get an Eventbrite field mapping
      description: |
        Which Makerble field each Eventbrite field is copied into. Defaults are filled in on first use. For
        `attendee`, order form questions appear as `answer:<question>` fields once Eventbrite has been read
        (see `POST /eventbrite_connection/refresh_questions`).
      operationId: getEventbriteFieldMapping
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: The mapping, with the fields each Eventbrite field can go into
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteFieldMapping'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

    put:
      tags: [Eventbrite]
      summary: Replace an Eventbrite field mapping
      description: |
        Only compatible types can be paired, each field can be in only one pair, and a pair can be paused.
        Eventbrite fields left out are not copied. Event fields replace the Makerble value; Contact fields
        only fill in blanks.
      operationId: setEventbriteFieldMapping
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [charity_id, mappings]
              properties:
                charity_id:
                  type: integer
                mappings:
                  type: array
                  items:
                    $ref: '#/components/schemas/EventbriteFieldPair'
            example:
              charity_id: 913
              mappings:
                - eventbrite_field: name
                  makerble_field: name
                - eventbrite_field: venue
                  makerble_field: location
                  paused: true
      responses:
        "200":
          description: The mapping, with the fields each Eventbrite field can go into
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteFieldMapping'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /eventbrite_connection/refresh_questions:
    post:
      tags: [Eventbrite]
      summary: Re-read the order form questions from Eventbrite
      description: Reads the questions on the order forms of recent events brought in, and returns the ticket holder mapping.
      operationId: refreshEventbriteQuestions
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
      responses:
        "200":
          description: The mapping, with the fields each Eventbrite field can go into
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventbriteFieldMapping'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/Forbidden'
        "404":
          $ref: '#/components/responses/NotFound'

  /webhook_endpoints:
    get:
      tags: [Webhooks]
      summary: List an Organisation's webhook endpoints
      description: |
        The Organisation's (Charity's) webhook endpoints, without their secrets. Only the
        Organisation's admins can manage webhooks, and only once an admin has ticked **Turn on Webhooks**
        in the Organisation's Settings (otherwise `403`).
      operationId: listWebhookEndpoints
      security: [{tokenAuth: []}]
      parameters:
        - name: charity_id
          in: query
          required: true
          schema:
            type: integer
          description: The Organisation (Charity) ID
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of webhook endpoints
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedWebhookEndpoints'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Webhooks]
      summary: Register a webhook endpoint
      description: |
        Starts sending the chosen events to an HTTPS URL. Leave out `event_types` to send every
        event, or give one event for a trigger that fires on that event only. An Organisation can
        have at most 10 endpoints added this way, and separately at most 100 created by automation
        platforms such as Power Automate (one per flow). The response includes the signing `secret`,
        which is shown only this once, and a `Location` header with the endpoint's full address:
        send `DELETE` to it to unsubscribe.

        Power Automate flows can't check the signature themselves. They rely instead on the callback
        address being secret, which Microsoft generates for each flow.
      operationId: createWebhookEndpoint
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEndpointRequest'
            example:
              webhook_endpoint:
                charity_id: 913
                url: "https://crm.example.org/makerble"
                description: "Dynamics sync"
                event_types: ["contact.created", "contact.updated"]
      responses:
        "201":
          description: Endpoint created, with its secret
          headers:
            Location:
              description: Full address of the new endpoint, e.g. `https://app.makerble.com/api/v2/webhook_endpoints/42`
              schema:
                type: string
                format: uri
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpointWithSecret'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /webhook_endpoints/{id}:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    get:
      tags: [Webhooks]
      summary: Get a webhook endpoint
      operationId: getWebhookEndpoint
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The endpoint, without its secret
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'
    patch:
      tags: [Webhooks]
      summary: Change, pause or resume a webhook endpoint
      description: |
        Send only the fields to change. `active: false` pauses the endpoint; `active: true`
        resumes it, and also turns back on an endpoint Makerble switched off after repeated
        failure (clearing `disabled_at` and `failure_count`). Changes made while it was off are
        not sent afterwards.
      operationId: updateWebhookEndpoint
      security: [{tokenAuth: []}]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEndpointRequest'
            example:
              webhook_endpoint:
                active: true
      responses:
        "200":
          description: The updated endpoint
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    delete:
      tags: [Webhooks]
      summary: Delete a webhook endpoint
      description: |
        Deletes the endpoint and its delivery log. Makerble stops sending to it at once. Deleting is
        idempotent: an endpoint that is already deleted, or that the user can't see, also answers
        `204`, so an automation platform can unsubscribe safely more than once.
      operationId: deleteWebhookEndpoint
      security: [{tokenAuth: []}]
      responses:
        "204":
          description: Deleted, or already gone
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'

  /webhook_endpoints/{id}/rotate_secret:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    post:
      tags: [Webhooks]
      summary: Rotate a webhook endpoint's secret
      description: |
        Replaces the signing secret and returns the new one, shown only this once. Deliveries
        are signed with it straight away.
      operationId: rotateWebhookEndpointSecret
      security: [{tokenAuth: []}]
      responses:
        "200":
          description: The endpoint with its new secret
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpointWithSecret'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'

  /webhook_endpoints/{id}/test:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    post:
      tags: [Webhooks]
      summary: Send a test event
      description: |
        Queues a `webhook.test` event (`data: { "test": true, "message": "This is a test event from Makerble." }`) for the endpoint. Check the
        delivery log a few seconds later for the result.
      operationId: sendWebhookTestEvent
      security: [{tokenAuth: []}]
      responses:
        "202":
          description: The queued delivery
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookDelivery'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'

  /webhook_endpoints/{id}/deliveries:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
    get:
      tags: [Webhooks]
      summary: List a webhook endpoint's deliveries
      description: The delivery log, newest first, kept for 30 days. Payloads are not included.
      operationId: listWebhookDeliveries
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
        - $ref: '#/components/parameters/LastSyncDatetime'
      responses:
        "200":
          description: Paginated list of deliveries
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedWebhookDeliveries'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'

  /webhook_endpoints/{id}/deliveries/{delivery_id}/replay:
    parameters:
      - $ref: '#/components/parameters/ResourceId'
      - name: delivery_id
        in: path
        required: true
        schema:
          type: integer
        description: The delivery's ID
    post:
      tags: [Webhooks]
      summary: Send a delivery again
      description: |
        Sends the delivery again with the same event `id`, so a receiver that already processed
        it can ignore it. `data` shows the record as it is now.
      operationId: replayWebhookDelivery
      security: [{tokenAuth: []}]
      responses:
        "202":
          description: The delivery, queued again
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookDelivery'
        "401":
          $ref: '#/components/responses/Unauthorized'
        "403":
          $ref: '#/components/responses/WebhooksNotTurnedOn'
        "404":
          $ref: '#/components/responses/NotFound'

  /metrics/{metric_type}/{metric_id}/destinations:
    get:
      tags: [Add Metric To]
      summary: List where a metric can be added
      description: |
        The options of "What would you like to add this to?" in the Add metric to popup, for a Change,
        Outcome or Indicator the user can see. An Indicator has no Projects option: it reaches a
        Project only through one of its Outcomes. A Cohort or Workflow Tracker gets `projects` (its own
        Organisation's) and `impact_frameworks`. `progress_boards` is offered for a Change or an Indicator only with `project_id`
        or `bundle_id`, as the popup offers Progress Boards only from a Project's or Album's Results Canvas.
      operationId: listMetricDestinations
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/MetricType'
        - $ref: '#/components/parameters/MetricId'
        - $ref: '#/components/parameters/MetricDestinationProjectId'
        - $ref: '#/components/parameters/MetricDestinationBundleId'
      responses:
        "200":
          description: The destination types offered
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        key: {type: string, example: projects}
                        label: {type: string, example: Projects}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

  /metrics/{metric_type}/{metric_id}/destinations/{destination}:
    get:
      tags: [Add Metric To]
      summary: List the places a metric can be added to
      description: |
        A page of the places of one destination type the user can add the metric to, alphabetically,
        each with `added: true` if the metric is already there. For `projects`: the open Projects whose
        metrics the user can edit (as a Project editor or an editor of its Organisation), with their
        Organisation. For `impact_frameworks`: the Impact Frameworks the user created, the only ones
        they can edit. For `collections`: the user's own Collections and those of Organisations they
        are an editor of; each item has `owner` ({type, id, name}) instead of `organisation`, as do
        `surveys` (the Surveys the user can edit; `removable` is false once the Survey asks the metric). For
        `outcomes` (an Indicator's): the Outcomes the user can edit, with `stage_id`. For `indicators`
        (an Outcome's, offered only if the user can edit it): the Indicators they can see, including the
        public library, with `indicator_type`. For `progress_boards`: the open Progress Boards the user
        created or is a Board Admin of, with `board_type` (`managed` or `basic`); `added` is for the given
        Project's or Album's card. For a tracker, each item has `column`: the Impact Scorecard column it is
        in, or null.
      operationId: listMetricDestinationTargets
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/MetricType'
        - $ref: '#/components/parameters/MetricId'
        - $ref: '#/components/parameters/MetricDestinationProjectId'
        - $ref: '#/components/parameters/MetricDestinationBundleId'
        - $ref: '#/components/parameters/MetricDestination'
        - name: q
          in: query
          required: false
          schema: {type: string}
          description: Search by name (`outcomes` and `indicators` only)
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/PerPage'
      responses:
        "200":
          description: Paginated places
          content:
            application/json:
              schema:
                type: object
                properties:
                  page: {type: integer}
                  page_size: {type: integer}
                  page_count: {type: integer}
                  total_count: {type: integer}
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id: {type: integer}
                        name: {type: string}
                        added: {type: boolean}
                        removable:
                          type: boolean
                          description: False when it can't be removed here (a Survey that asks the metric, or an Outcome/Indicator link that stories have used)
                        organisation:
                          type: object
                          properties:
                            id: {type: integer}
                            name: {type: string}
              example:
                page: 1
                page_size: 2
                page_count: 1
                total_count: 2
                data:
                  - {id: 41, name: Albany, added: false, organisation: {id: 7, name: Bambanani Trust}}
                  - {id: 12, name: Bambanani, added: true, organisation: {id: 7, name: Bambanani Trust}}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'

    post:
      tags: [Add Metric To]
      summary: Create a Progress Board with a metric on it
      description: |
        "+ Create a new Progress Board and add this to it" in the Add metric to popup. Creates a Managed
        Progress Board named "<your name>'s Progress Board" for the Organisation of the Project (or Album)
        given by `project_id` or `bundle_id`, with that Project (or the Album's Projects) on it, "Colleagues
        have their own personalised version of the board" ticked, and the metric as its card. Only
        `progress_boards` supports this. There is no request body.
      operationId: createMetricDestination
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/MetricType'
        - $ref: '#/components/parameters/MetricId'
        - $ref: '#/components/parameters/MetricDestinationProjectId'
        - $ref: '#/components/parameters/MetricDestinationBundleId'
        - $ref: '#/components/parameters/MetricDestination'
      responses:
        "201":
          description: Created, with the card on it
          content:
            application/json:
              example: {added: true, data: {id: 88, name: "Thandi Mokoena's Progress Board"}}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'

  /metrics/{metric_type}/{metric_id}/destinations/{destination}/{target_id}:
    post:
      tags: [Add Metric To]
      summary: Add a metric to a Project, Impact Framework or Collection
      description: |
        Adds a Change or Outcome. To a Project, as Edit Project Metrics does: in the Impact Scorecard column
        of the metric's own stage, after the metrics already there; it is also added to the Project's
        Default Survey and, if the Organisation uses one, its default Progress Board. Requires rights to
        edit the Project's metrics. To an Impact Framework: in the metric's own stage, which is added to
        the framework if missing; only the framework's creator can. To a Collection (which also takes an
        Indicator): at the end; you must own the Collection or edit the Organisation that owns it. With
        `outcomes` or `indicators`: makes the Outcome a parent of the Indicator; you must be able to edit
        the Outcome. To a Survey: as its last, optional question (a scale Indicator is Single Choice;
        an Outcome adds each of its Indicators, as a grid when they share answer choices). To a Progress
        Board (with `project_id` or `bundle_id`): as its last card, showing that Project's or Album's
        results; you must have created the board or be a Board Admin. A Cohort or Workflow Tracker goes in
        the `column` given (default `engagement`) of a Project in its own Organisation or of an Impact
        Framework you created.

        An Outcome added to a Project or Impact Framework brings every one of its Indicators unless
        the body gives `indicator_ids`: then only those Indicators of the Outcome are added, and an
        Indicator added to the Outcome later doesn't join that Project. Each id must be an Indicator of
        the Outcome that you can see, or nothing is added (422). `indicator_ids` is refused for any
        other metric or destination. Otherwise there is no request body.
      operationId: addMetricToDestination
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/MetricDestinationColumn'
        - $ref: '#/components/parameters/MetricType'
        - $ref: '#/components/parameters/MetricId'
        - $ref: '#/components/parameters/MetricDestinationProjectId'
        - $ref: '#/components/parameters/MetricDestinationBundleId'
        - $ref: '#/components/parameters/MetricDestination'
        - $ref: '#/components/parameters/MetricDestinationTargetId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                indicator_ids:
                  type: array
                  items: {type: integer}
                  minItems: 1
                  description: For an Outcome added to `projects` or `impact_frameworks`, only these of its Indicators. Leave out to add all of them.
            example:
              indicator_ids: [5521, 5524, 5530]
      responses:
        "201":
          description: Added
          content:
            application/json:
              example: {added: true}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
    delete:
      tags: [Add Metric To]
      summary: Remove a metric from a Project, Impact Framework or Collection
      description: Removes a metric from a Project's metrics, an Impact Framework, a Collection or a Progress Board (only the card for the given `project_id` or `bundle_id`), or unlinks an Indicator from an Outcome (refused with 422 once stories have recorded the Indicator under that Outcome). A Survey's questions are removed by editing the Survey, so `surveys` always answers 422. Requires the same rights as adding it.
      operationId: removeMetricFromDestination
      security: [{tokenAuth: []}]
      parameters:
        - $ref: '#/components/parameters/MetricType'
        - $ref: '#/components/parameters/MetricId'
        - $ref: '#/components/parameters/MetricDestinationProjectId'
        - $ref: '#/components/parameters/MetricDestinationBundleId'
        - $ref: '#/components/parameters/MetricDestination'
        - $ref: '#/components/parameters/MetricDestinationTargetId'
      responses:
        "200":
          description: Removed
          content:
            application/json:
              example: {added: false}
        "401":
          $ref: '#/components/responses/Unauthorized'
        "404":
          $ref: '#/components/responses/NotFound'
        "422":
          $ref: '#/components/responses/UnprocessableEntity'
  /health:
    get:
      tags: [Health]
      summary: Check the service is up and which build is running
      operationId: getHealth
      description: |
        Reports whether the service and its database are answering, and which build
        is running. No sign-in is needed: send no `X-User-Email` / `X-User-Token`.

        Use `commit` to tell when a new release is live: after a deploy finishes it
        changes to the new build's commit, and `uptime_seconds` starts again from a
        small number. `commit` and `built_at` are `null` when the build didn't record
        them. Always answers `200` while the service is running; check `database`
        to see whether the database is reachable.
      security: []
      responses:
        "200":
          description: The service is running
          content:
            application/json:
              schema:
                type: object
                required: [status, database, commit, built_at, environment]
                properties:
                  status:
                    type: string
                    enum: [ok]
                    description: Always `ok` when the service answers
                  database:
                    type: boolean
                    description: Whether the database answered a trivial query
                  uptime_seconds:
                    type: integer
                    description: Seconds since the running app started
                  commit:
                    type: string
                    nullable: true
                    description: Full git commit SHA the running build was made from
                  built_at:
                    type: string
                    format: date-time
                    nullable: true
                    description: When the running build was made, ISO 8601 in UTC
                  environment:
                    type: string
                    description: Which environment answered, e.g. `production`, `pre-production`, `qa`, `preview`
              example:
                status: ok
                database: true
                uptime_seconds: 312
                commit: "0123456789abcdef0123456789abcdef01234567"
                built_at: "2026-10-12T13:05:09Z"
                environment: production

components:

  securitySchemes:
    tokenAuth:
      type: apiKey
      in: header
      name: X-User-Token
      description: |
        Long-lived token from `POST /users/sign_in`. Does not expire.
        Must be accompanied by `X-User-Email` header.
    apiKeyAuth:
      type: http
      scheme: bearer
      description: |
        An Organisation API key (`mk_live_...`), sent as `Authorization: Bearer mk_live_...`. It acts
        as the colleague chosen when it was created, in its Organisation only. See "Organisation API keys" above.
    oauth2:
      type: oauth2
      description: |
        OAuth 2.0 authorisation code flow for connected apps. The token is limited to the
        organisation the user chose on the consent screen, with that user's permissions.
        See "Connecting an app with OAuth 2.0" above.
      flows:
        authorizationCode:
          authorizationUrl: https://makerble.com/oauth/authorize
          tokenUrl: https://makerble.com/oauth/token
          refreshUrl: https://makerble.com/oauth/token
          scopes:
            api: The same access as the user who connected the app, in the organisation they chose
    submissionBearerAuth:
      type: http
      scheme: bearer
      description: |
        A `ReferralLinkSubmissionCredential` token, scoped to a single Signup Page —
        obtained from `submission_credential.token` in the Offline Collector's Form
        Definition response, **not** a Devise session or `X-User-Email`/`X-User-Token`
        pair. Used only by `POST /referral_submissions`.

  parameters:
    ResourceId:
      name: id
      in: path
      required: true
      schema:
        type: integer
      description: Unique integer identifier
    MetricType:
      name: metric_type
      in: path
      required: true
      schema:
        type: string
        enum: [change, outcome, indicator, cohort_tracker, workflow_tracker]
      description: The kind of metric. A Cohort or Workflow Tracker can go to `projects` and `impact_frameworks` only.
    MetricDestinationColumn:
      name: column
      in: query
      required: false
      schema:
        type: string
        enum: [activities, engagement, potential, behaviour, growth]
        default: engagement
      description: For a Cohort or Workflow Tracker, the Impact Scorecard column to put it in.
    MetricId:
      name: metric_id
      in: path
      required: true
      schema:
        type: integer
      description: The Change, Outcome or Indicator ID
    MetricDestination:
      name: destination
      in: path
      required: true
      schema:
        type: string
        enum: [projects, impact_frameworks, surveys, collections, outcomes, indicators, progress_boards]
      description: Where to add the metric (`impact_frameworks` are Templates, `surveys` are Story Categories; `outcomes` is for an Indicator, `indicators` for an Outcome; `progress_boards` needs `project_id` or `bundle_id`)
    MetricDestinationProjectId:
      name: project_id
      in: query
      required: false
      schema: {type: integer}
      description: The Project whose results a Progress Board card shows. Offers `progress_boards`; you need a role on the Project.
    MetricDestinationBundleId:
      name: bundle_id
      in: query
      required: false
      schema: {type: integer}
      description: The Album (Bundle) whose results a Progress Board card shows, instead of a Project. You must be able to see the Album.
    MetricDestinationTargetId:
      name: target_id
      in: path
      required: true
      schema:
        type: integer
      description: The ID of the Project (or other destination) to add the metric to
    CohortTrackerAlbumId:
      name: bundle_id
      in: path
      required: true
      schema:
        type: integer
      description: The Album (Bundle) ID
    CohortTrackerProjectId:
      name: project_id
      in: path
      required: true
      schema:
        type: integer
      description: The Project ID
    CohortTrackerTimeframe:
      name: timeframe
      in: query
      required: false
      schema:
        type: string
        enum: [period, year_to_date, all_time]
        default: all_time
      description: |
        period: the day after the previous Target Deadline up to the deadline. year_to_date: the
        start of the Project's or Album's year up to the deadline. all_time: everything up to the deadline.
    CohortTrackerCohort:
      name: cohort
      in: query
      required: false
      schema:
        type: string
        enum: [in, not_in]
        default: in
      description: Which Contacts `data` lists. `in` the cohort; for a percentage, `not_in` lists the Contacts in the denominator who aren't in the cohort (the popup's Not in cohort tab).
    CohortTrackerAsOf:
      name: as_of
      in: query
      required: false
      schema:
        type: string
        format: date
      description: The deadline the window ends on. Defaults to the next Target Deadline, or today when there is none.
    OrganisationId:
      name: organisation_id
      in: path
      required: true
      schema:
        type: integer
      description: The Organisation (Charity) ID
    WeeklyEmailWeek:
      name: week
      in: query
      required: false
      description: Any date in the week (weeks start on Monday). Without it, the coming week's email.
      schema:
        type: string
        format: date
    Page:
      name: page
      in: query
      schema:
        type: integer
        default: 1
        minimum: 1
      description: Page number (default 1)
    PerPage:
      name: per_page
      in: query
      schema:
        type: integer
        default: 10
        maximum: 200
      description: Records per page (default 10, max 200)
    LastSyncDatetime:
      name: last_sync_datetime
      in: query
      schema:
        type: string
        example: "2023-07-30 08:48:55.781228"
      description: ISO 8601 datetime — returns only records updated after this value
    FilteredMetricProjectId:
      name: project_id
      in: path
      required: true
      schema:
        type: integer
      description: The Project ID
    FilteredMetricBundleId:
      name: bundle_id
      in: path
      required: true
      schema:
        type: integer
      description: The Album (Bundle) ID
    FilteredMetricId:
      name: id
      in: path
      required: true
      schema:
        type: integer
      description: The filtered version's ID
    FilteredMetricTimeframe:
      name: timeframe
      in: query
      schema:
        type: string
        enum: [period, year_to_date, all_time]
        default: all_time
      description: |
        `period`: from the day after the previous Target Deadline; `year_to_date`: from the Year
        Start; `all_time`: everything. Each ends at `as_of`.
    FilteredMetricAsOf:
      name: as_of
      in: query
      schema:
        type: string
        format: date
      description: The date the timeframe ends (YYYY-MM-DD). Defaults to the next Target Deadline, or today.
    IncludePublicLibrary:
      name: include_public_library
      in: query
      schema:
        type: boolean
        default: false
      example: true
      description: Also include Indicators or Outcomes from the public library shared by all organisations (default false)

  responses:
    MeasurementPlan:
      description: The Measurement Plan's rows, in the framework's order
      content:
        application/json:
          schema:
            type: object
            properties:
              impact_framework: { $ref: '#/components/schemas/MeasurementPlanFramework' }
              page: { type: integer }
              page_size: { type: integer }
              page_count: { type: integer }
              total_count: { type: integer }
              data:
                type: array
                items: { $ref: '#/components/schemas/MeasurementPlanRow' }
          example:
            impact_framework: { id: 7174, name: Youth Club Theory of Change, project_id: 2210, can_edit: true }
            page: 1
            page_size: 1
            page_count: 1
            total_count: 1
            data:
              - metric: { type: Indicator, id: 9921, name: Feels confident speaking up }
                stage: { id: 3, name: Short-term outcomes }
                outcome: { id: 5521, title: Improved confidence }
                kind: scale
                description: Shows whether the sessions build confidence
                frequency: start_and_end
                custom_frequency: null
                methods:
                  - { type: survey, survey: { id: 812, name: Confidence check-in } }
                  - { type: event_register, survey: null }
                assignees:
                  - { id: 4410, name: Thandi Mokoena }

    EventFormatAdminOnly:
      description: You are not an Organisation Admin of the organisation that owns the Event Format
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "Only an Organisation Admin can manage Event Formats."

    PortalLinksForbidden:
      description: You don't have permission for this project's Portal links
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "You don't have permission to send Portal links in this project."

    EventCatalogueForbidden:
      description: You don't have permission for this organisation's or project's Event Catalogues
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "You don't have permission to manage this organisation's Event Catalogues."
    SetupGuideForbidden:
      description: You aren't an Organisation Admin of this Organisation, or its Setup guide is switched off
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Only an Organisation Admin can see the Setup guide.
    LibraryItemCreated:
      description: Created. The new item as **Get a library item** shows it, and whether it is approved for the public library
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                allOf:
                  - $ref: '#/components/schemas/LibraryItem'
                  - type: object
                    properties:
                      approved:
                        type: boolean
          example:
            data:
              id: 5521
              type: list
              name: "Agree - Disagree"
              owner: your organisation
              choices:
                - {id: 90101, name: "Agree", points: null}
                - {id: 90102, name: "Disagree", points: null}
              approved: false
    LibraryItemUpdated:
      description: Changed. The item as **Get a library item** shows it
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/LibraryItem'
          example:
            data:
              id: 5521
              type: list
              name: "Interview confidence scale"
              owner: your organisation
              choices:
                - {id: 90101, name: "Very confident", points: null}
                - {id: 90102, name: "Not confident", points: null}
    LibraryDuplicates:
      description: |
        Nothing was created: items you can reuse already have the same or a near-identical name. Reuse
        one, or send `force: true` to create it anyway. An exact duplicate in your own organisation is
        refused even with `force`, and is listed by `id` and `type` only.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              duplicates:
                type: array
                items:
                  type: object
                  required: [id, type]
                  properties:
                    id:
                      type: integer
                    type:
                      type: string
                    name:
                      type: string
                    owner:
                      type: string
                      enum: [your organisation, public library, Makerble]
          example:
            error: "A List with this name already exists. Reuse it, or send force: true to create another."
            duplicates:
              - {id: 4410, type: list, name: "Agree – Disagree", owner: your organisation}
    LibraryCreateForbidden:
      description: You may not create this kind of item, as in the Makerble app (e.g. only Makerble staff create Units)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "You do not have permission to create ratio sets."
    Unauthorized:
      description: Missing or invalid authentication credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "You need to sign in before continuing."
    TooManyRequests:
      description: Over a rate limit (see Rate limits). Retry after the number of seconds in the Retry-After header.
      headers:
        Retry-After:
          description: Seconds until the limit resets
          schema:
            type: integer
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              scope:
                type: string
                enum: [api_key, organisation]
              limit:
                type: integer
              retry_after:
                type: integer
              resets_at:
                type: string
                format: date-time
              documentation:
                type: string
          example:
            error: "Too many requests: this API key or token has made more than 120 requests in a minute. The limit resets at 17:31:00 UTC, in 23 seconds; try again then. To stay within it, space your requests out (about 0.5 seconds apart), and fetch lists a page at a time with per_page (up to 200) and last_synced_datetime, to get only what has changed, rather than one record per request. See https://api-docs.makerble.com/#rate-limits"
            scope: api_key
            limit: 120
            retry_after: 23
            resets_at: "2026-11-25T17:31:00Z"
            documentation: "https://api-docs.makerble.com/#rate-limits"
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "Record not found."
    Forbidden:
      description: The user doesn't have permission for this Project or organisation
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
              errors:
                type: string
          example:
            success: false
            errors: "Permission denied."
    AddColleagueForbidden:
      description: You aren't a Project Manager of one of the listed Projects or an Organisation Admin of its Organisation. Nobody is added to any of them.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: "You don't have permission to add users to project 619."
    UnprocessableEntity:
      description: Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnprocessableEntityList:
      description: Validation failed
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: string
          example:
            errors: ["Name can't be blank"]
    ForbiddenError:
      description: The user may not do this
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: forbidden
    WebhooksNotTurnedOn:
      description: |
        The user is a member of the Organisation but not an Organisation Admin, or webhooks are not
        turned on for the Organisation yet. `error` says which, in words that can be shown to the
        user. For a request from an automation platform such as Power Automate, the first reads
        "Only an Organisation Admin can create Makerble triggers".
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            notAnAdmin:
              value:
                error: "Only an Organisation Admin can manage Webhooks"
            notTurnedOn:
              value:
                error: "Webhooks are not turned on for this organisation"

  schemas:
    MeasurementPlanFramework:
      type: object
      properties:
        id: { type: integer }
        name: { type: string }
        project_id: { type: integer, nullable: true, description: The project whose Theory of Change this is, or null for a framework }
        can_edit: { type: boolean, description: Whether you may change this plan }
    MeasurementPlanRow:
      type: object
      properties:
        metric:
          type: object
          properties:
            type: { type: string, enum: [Change, Indicator, CohortTracker, WorkflowTracker, FormulaTracker] }
            id: { type: integer }
            name: { type: string }
        stage:
          type: object
          nullable: true
          description: The Impact Scorecard column the framework puts the metric in
          properties:
            id: { type: integer }
            name: { type: string }
        outcome:
          type: object
          nullable: true
          description: The Outcome an Indicator is measured under; null for other metrics
          properties:
            id: { type: integer }
            title: { type: string }
        kind: { type: string, enum: [count, achievement, scale, quantity, indicator, tracker] }
        description: { type: string, nullable: true, description: Why the framework measures this metric }
        frequency:
          type: string
          nullable: true
          enum: [every_occasion, start_and_end, start, end, weekly, monthly, quarterly, yearly, custom, null]
        custom_frequency: { type: string, nullable: true, description: The frequency in the plan's own words, when frequency is custom }
        methods:
          type: array
          items:
            type: object
            properties:
              type: { type: string, enum: [survey, timeline, event_register, spreadsheet, integration] }
              survey:
                type: object
                nullable: true
                description: The Survey (Story Category) used, for a survey method
                properties:
                  id: { type: integer }
                  name: { type: string }
        assignees:
          type: array
          description: Who measures the metric, on a project's plan. Always empty on a framework, whose colleagues are assigned on each project.
          items:
            type: object
            properties:
              id: { type: integer }
              name: { type: string }
    MeasurementPlanChange:
      type: object
      required: [metric_type, metric_id]
      properties:
        metric_type: { type: string, enum: [Change, Indicator, CohortTracker, WorkflowTracker, FormulaTracker] }
        metric_id: { type: integer }
        description: { type: string, nullable: true, maxLength: 2000, description: Why the framework measures the metric. Empty clears it. }
        frequency:
          type: string
          nullable: true
          enum: [every_occasion, start_and_end, start, end, weekly, monthly, quarterly, yearly, custom, null]
          description: Empty clears it
        custom_frequency: { type: string, maxLength: 255, description: Required when frequency is custom }
        methods:
          type: object
          description: Replaces how the metric is collected
          properties:
            survey_ids: { type: array, items: { type: integer } }
            types:
              type: array
              items: { type: string, enum: [timeline, event_register, spreadsheet, integration] }
        assignee_user_ids:
          type: array
          description: Replaces who measures the metric (a project's plan only)
          items: { type: integer }
    OnboardingJourney:
      type: object
      properties:
        id: {type: integer}
        organisation_id: {type: integer}
        area_of_work: {type: string}
        toolkit_id: {type: integer, nullable: true}
        path:
          type: string
          enum: [toolkit, personalise]
          description: How the area was set up, from a Toolkit or from the Organisation's own stages.
        stages:
          type: array
          description: The stages given, on the personalise path; empty for a Toolkit.
          items:
            $ref: '#/components/schemas/OnboardingStage'
        spacing: {type: string, enum: [facilitator, site, cohort, single], nullable: true}
        workspace_names: {type: array, items: {type: string}}
        workspace_colours:
          type: array
          description: The colour each workspace is made in, in the same order as workspace_names.
          items: {type: string}
        extra_ids: {type: array, items: {type: integer}}
        status: {type: string, enum: [in_progress, exited, building, failed, completed]}
        workspace_ids: {type: array, items: {type: integer}}
        checklist_id: {type: integer, nullable: true}
        created_at: {type: string, format: date-time}
        completed_at: {type: string, format: date-time, nullable: true}
    OnboardingStage:
      type: object
      required: [name, action]
      properties:
        name:
          type: string
          maxLength: 100
          description: The stage's name, which is also its step's name, e.g. Assessment.
        action:
          type: string
          description: >-
            What happens at the stage. complete_form_external is a form the contact fills in and
            complete_form_internal one a colleague fills in; add_role adds to an audience and add_skill a
            specialist need.
          enum: [complete_form_external, complete_form_internal, complete_survey, add_to_project, add_flag, invite_to_event, add_observer, add_relationship, add_role, add_skill, add_to_group, complete_form_for_relative, complete_survey_for_relative, create_case, create_task, invite_to_participate, send_sms, send_email, receive_sms, receive_email, send_survey, send_360_survey, create_labelled_story]
    SetupGuide:
      type: object
      properties:
        organisation_id:
          type: integer
        done_count:
          type: integer
          description: Items done, leaving out those marked not relevant.
        total_count:
          type: integer
          description: Items shown, leaving out those marked not relevant.
        finished:
          type: boolean
          description: True once every item is done or marked not relevant.
        data:
          type: array
          items:
            $ref: '#/components/schemas/SetupGuideItem'
    SetupGuideItem:
      type: object
      properties:
        key:
          type: string
          enum: [teams, workspaces, another_area, welcome_tour, welcome_journey, specialisms, checklists, reporting_requirements, demographics, metrics]
        title:
          type: string
        section:
          type: string
          nullable: true
          description: The heading the item sits under, e.g. "Automate your reporting", or null.
        progress:
          type: string
          description: How far it has got, in words, e.g. "3 of 5 workspaces". Always the current picture, even once done.
        done_when:
          type: string
        done:
          type: boolean
          description: True once Makerble has seen it done. It stays done.
        not_relevant:
          type: boolean
    SavedFilter:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        type:
          type: string
          enum: [contacts, events, cases]
          description: What the filter filters
        organisation_id:
          type: integer
          nullable: true
        shared:
          type: boolean
          description: Whether the owner shared it with colleagues
        project_ids:
          type: array
          items:
            type: integer
          description: The projects named in the filter's criteria. The filter can be added only to these projects' toolbars.
        can_add_shortcut:
          type: boolean
          description: Whether you can add it to a project's toolbar
        can_edit:
          type: boolean
          description: Whether you can change or delete it
        who_can_edit:
          type: string
          enum: [individuals, organisation_admins]
          description: The people in `editor_ids`, or the Organisation Admins of its organisation. Its owner can always edit it.
        editor_ids:
          type: array
          items:
            type: integer
          description: The users who can edit it when `who_can_edit` is `individuals`; empty otherwise
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    SavedFilterInput:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
          enum: [contacts, events, cases]
          description: What the filter filters. Can't be changed later.
        organisation_id:
          type: integer
          description: Required only if you belong to more than one organisation. Can't be changed later.
        criteria:
          type: object
          additionalProperties: true
          description: |
            The filter settings, in the shape the page's filters send them. They replace the filter's criteria. A
            filter with conditions on contact fields you don't have permission to see keeps its criteria: changing
            them is refused (422), since it would delete conditions you can't see.
        shared:
          type: boolean
          description: true to let colleagues use it; false (the default) for only you. Any other value is refused (422).
        who_can_edit:
          type: string
          enum: [individuals, organisation_admins]
          description: Defaults to `individuals`
        editor_ids:
          type: array
          items:
            type: integer
          description: Users in the filter's organisation who can edit it, when `who_can_edit` is `individuals`. Defaults to you.
    PaginatedSavedFilters:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/SavedFilter'
    SavedFilterDetail:
      allOf:
        - $ref: '#/components/schemas/SavedFilter'
        - type: object
          properties:
            criteria:
              type: object
              additionalProperties: true
              description: |
                The filter settings, in the shape the page's filters send them. Conditions on contact fields you
                don't have permission to see are left out.
            shortcut_views:
              type: array
              description: The views a shortcut to this filter can open
              items:
                type: object
                properties:
                  key:
                    type: string
                    example: contacts_overview
                  label:
                    type: string
                    example: Overview
                  group:
                    type: string
                    description: In-built views, or Custom tables
            shortcut_projects:
              type: array
              description: The projects you can add this filter to
              items:
                type: object
                properties:
                  id:
                    type: integer
                  name:
                    type: string
    SavedFilterShortcutInput:
      type: object
      required: [project_id, view_key]
      properties:
        project_id:
          type: integer
          description: One of the Saved Filter's `shortcut_projects`
        view_key:
          type: string
          description: One of the Saved Filter's `shortcut_views`
        name:
          type: string
          description: The shortcut's label on the toolbar. Defaults to the Saved Filter's name.
    SavedFilterShortcut:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        project_id:
          type: integer
        saved_filter_id:
          type: integer
        view_key:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    AnnouncementNameChange:
      type: object
      required: [old_name, new_name]
      properties:
        old_name:
          type: string
          maxLength: 40
          example: Projects
        new_name:
          type: string
          maxLength: 40
          example: Workspaces
    AnnouncementImageUpload:
      type: object
      required: [filename, data]
      properties:
        filename:
          type: string
          example: workspaces.png
        data:
          type: string
          format: byte
          description: The file's contents in base64.
    AnnouncementInput:
      type: object
      properties:
        scope_type:
          type: string
          enum: [Charity, Project, Team]
          description: |
            On create only: whose announcement it is, an Organisation (`Charity`), a Workspace
            (`Project`) or a Team, with `scope_id`. Leave out for one of Makerble's own.
        scope_id:
          type: integer
          description: On create only, with `scope_type`.
        training_material_id:
          type: integer
          nullable: true
          description: >-
            For an Organisation's, Workspace's or Team's announcement: one of that Organisation's Training materials
            to link to. Send null to clear it.
        feature_tour_id:
          type: integer
          nullable: true
          description: >-
            For one of Makerble's own announcements: a feature tour (from GET /feature_tours). While the tour is live,
            the popup's button is "Take the tour", which starts it on its first page instead of showing `button_label`.
            Send null to clear it.
        feature_launch_id:
          type: integer
          nullable: true
          description: >-
            For one of Makerble's own announcements: the feature launch it announces (from GET /feature_launches).
            Wherever the announcement leaves `body`, `learn_more_url`, `button_deep_link` or `feature_tour_id` empty,
            the popup and What's new use the launch's `short_description`, `user_guide_url`, `deep_link` and
            `feature_tour_id`. Send null to clear it.
        title:
          type: string
          maxLength: 90
          description: The headline, in sentence case. Required.
        body:
          type: string
          nullable: true
          maxLength: 280
          description: >-
            The message. Required, unless the announcement is for a feature launch (`feature_launch_id`) that has a
            `short_description`, which is shown instead while this is empty.
        visual_type:
          type: string
          enum: [name_change, vimeo, image, intro_animation, storyboard, none]
          description: >-
            The name-change animation (Makerble's own only), a Vimeo video, an uploaded image (with `image` and
            `image_alt`), a feature's Intro animation (`intro_animation`, with `intro_key`; Makerble's own only), an
            animation of its own (`storyboard`; Makerble's own only), or nothing. Changing it from `image` removes the
            image and its alt text.
        name_changes:
          type: array
          minItems: 1
          maxItems: 3
          description: For `name_change`, 1 to 3 old and new names, played in this order. Ignored for the other visuals.
          items:
            $ref: '#/components/schemas/AnnouncementNameChange'
        vimeo_url:
          type: string
          description: For `vimeo`, https://vimeo.com/<id>, https://vimeo.com/<id>/<hash> or https://player.vimeo.com/video/<id>?h=<hash>. Ignored for the other visuals.
        image:
          description: |
            For `image`: a screenshot or illustration shown whole (never cropped) in the popup. A PNG, JPG, GIF or
            WebP file of up to 5 MB; the type is read from the file itself. Send it as a file in a
            `multipart/form-data` request, or in JSON as `{ "filename": "workspaces.png", "data": "<base64>" }`.
            Required when creating an `image` announcement; leave it out on update to keep the saved image.
          oneOf:
            - type: string
              format: binary
            - $ref: '#/components/schemas/AnnouncementImageUpload'
        image_alt:
          type: string
          maxLength: 250
          description: For `image`, required. What the image shows, read out by screen readers.
        intro_key:
          type: string
          description: |
            For `intro_animation`: the key of the Intro (guidance panel) whose animation the popup plays, such as
            `checklists`. It must have a storyboard. The popup plays the Intro's storyboard as it is when shown, so a
            later change to the Intro's animation changes the announcement's too; if the Intro loses its animation, the
            popup shows no visual. The usual choice for a feature's announcement.
        storyboard:
          type: object
          additionalProperties: true
          description: |
            For `storyboard`: an animation of the announcement's own, for when the Intro's doesn't fit (for example when
            only one part of a feature is new). The same format and rules as an Intro's storyboard (`archetype`,
            `loop_seconds`, `alt`, `steps`); one that breaks them is refused with 422, naming the problem.
        learn_more_url:
          type: string
          nullable: true
          description: |
            Optional. For Makerble's own, a page in the Makerble User Guide
            (https://makerble.atlassian.net/wiki/spaces/MCPD/...). For a place's, any https page; one
            outside the User Guide is marked as opening outside Makerble.
        button_label:
          type: string
          maxLength: 24
          description: Defaults to "Got it".
        button_deep_link:
          type: string
          nullable: true
          description: |
            Makerble's own only. Where the button goes: the `name` of a deep link from List Deep Links, such as
            `checklists`. The button then opens that page in the person's own organisation and closes the popup; give it a
            label that says where it goes ("Explore Checklists"). For someone who can't open the page, it only closes the
            popup. A live `feature_tour_id` takes priority. Send null to clear it.
        placement:
          type: string
          enum: [popup, during_build]
          description: |
            Makerble's own only. Where it shows: `popup` (the default), the "What's new in Makerble" popup and What's new;
            or `during_build`, the screen a new organisation sees while Makerble builds its first workspaces after the
            onboarding journey. "During build" announcements never pop up and aren't listed in What's new: while live,
            they take turns on that screen in `priority` order, each for `display_seconds`.
        priority:
          type: integer
          minimum: 1
          description: The order "During build" announcements show in, 1 first. Defaults to 1.
        display_seconds:
          type: integer
          minimum: 3
          maximum: 120
          description: How many seconds a "During build" announcement shows before the next. Defaults to 10.
        audience:
          type: string
          enum: [everyone, colleagues, administrators]
          description: |
            `everyone`: every signed-in user. `colleagues`: everyone except Contacts with a login
            (active participants). `administrators`: Organisation Admins of at least one organisation.
            Ignored for a place's announcement, which is always for the colleagues there. Ignored too
            when `roles` has any.
        roles:
          type: array
          items:
            type: string
            enum: [organisation_admin, editor, reporter, observer, team_leader, active_participant, survey_portal_user]
          description: |
            Makerble's own only (System Access users). Narrows who sees it to anyone holding at least one
            of these roles, in place of `audience`: `organisation_admin` (Organisation Admin), `editor`
            (Workspace editor, Project Editor), `reporter`, `observer` (of an Organisation or a
            Workspace), `team_leader`, `active_participant` (Contact with a login) and
            `survey_portal_user`. Contacts with a login and Survey Portal users are left out unless their
            own role is listed, even when they hold another. An empty list (the default) leaves it to
            `audience`. Sent, it replaces the list.
        audience_rules:
          type: object
          additionalProperties: true
          description: |
            Makerble's own only (System Access users). Behaviour rules: a JSON expression over the named
            facts from List Announcement Facts, saying who sees it beyond its audience or roles, e.g.
            only people whose organisation hasn't set up Distance Travelled. Each rule is exactly one of
            `{"fact": key, "params": {...}}` (params optional), `{"all": [rules]}`, `{"any": [rules]}`
            or `{"not": rule}`; at most 5 deep and 10 facts. `{}` (the default) means no rules. An
            unknown fact, param or shape is refused with 422, naming the rule.
          example:
            all:
              - fact: distance_travelled_not_set_up
                params:
                  across: all_organisations
        page_keys:
          type: array
          items:
            type: string
          description: |
            Makerble's own only (System Access users). The pages it shows on, by the key of each page's
            Show/Hide Guidance panel: for example `contacts` (Manage Contacts), `events`, `checklists` or
            `surveys`. Someone sees it when they open one of those pages, including when they move between
            pages without reloading. Pages without a guidance panel have no key and can't be chosen. An
            empty list (the default) means any page. An unknown key is refused with 422, listing the keys
            available. Sent, it replaces
            the list.
          example: [contacts]
        starts_on:
          type: string
          format: date
          description: Required to schedule.
        ends_on:
          type: string
          format: date
          description: Required to schedule; not before `starts_on`.
        status:
          type: string
          enum: [draft, scheduled]
          description: On create, defaults to `draft`. On update, defaults to the current status.
        schedule_on_next_free_days:
          type: boolean
          description: |
            Makerble's own only (422 for an Organisation's, Workspace's or Team's). Schedules the
            announcement from the first day, from today, on which no other Makerble announcement starts,
            keeping its own length (14 days if it has no dates yet). Any `status`, `starts_on` and `ends_on`
            sent are replaced. People see at most one Makerble announcement a day, so this keeps
            announcements from queuing behind each other. Use it to schedule a feature's announcement
            once the feature is live on production.
    AnnouncementFact:
      type: object
      properties:
        key:
          type: string
          description: 'What a rule names, e.g. `{"fact": "distance_travelled_not_set_up"}`'
        label:
          type: string
          description: Completes "people ..." in Site Overview's "Who sees this"
        description:
          type: string
        params:
          type: object
          description: Each param by name, with the values it accepts, its default and what it means
          additionalProperties:
            type: object
            properties:
              values:
                type: array
                items:
                  type: string
              default:
                type: string
              description:
                type: string
    DeepLink:
      type: object
      properties:
        name:
          type: string
          example: checklists
          description: The link's name. Never changes, since User Guide articles link to it.
        label:
          type: string
          example: Checklists
        group:
          type: string
          example: Checklists
        role:
          type: string
          enum: [user, member, editor]
          description: The role the person needs in their organisation to open the page.
        record:
          type: boolean
          description: True when the link opens one record (the first the person can see), falling back to a page.
    PaginatedDeepLinks:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/DeepLink'
    PaginatedAnnouncementFacts:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/AnnouncementFact'
    Announcement:
      type: object
      properties:
        id:
          type: integer
        scope_type:
          type: string
          enum: [Charity, Project, Team, null]
          nullable: true
          description: |
            Whose announcement it is: an Organisation (`Charity`), a Workspace (`Project`) or a Team.
            Null for Makerble's own. Its audience is that place's colleagues: an Organisation's
            colleagues, a Workspace's editors, reporters and observers, or a Team's members and leaders.
        scope_id:
          type: integer
          nullable: true
        training_material_id:
          type: integer
          nullable: true
          description: >-
            One of the place's Organisation's Training materials that the announcement links to (shown only to
            colleagues it is shared with), or null
        feature_tour_id:
          type: integer
          nullable: true
          description: >-
            The feature tour the popup's button starts with "Take the tour" while the tour is live, or null
        feature_launch_id:
          type: integer
          nullable: true
          description: >-
            The feature launch the announcement is for, or null. Its message, User Guide link, deep link and feature tour
            are shown wherever the announcement's own are empty.
        title:
          type: string
        body:
          type: string
          nullable: true
          description: The announcement's own message; null when it shows its feature launch's short description
        visual_type:
          type: string
          enum: [name_change, vimeo, image, intro_animation, storyboard, none]
        name_changes:
          type: array
          items:
            $ref: '#/components/schemas/AnnouncementNameChange'
        vimeo_url:
          type: string
          nullable: true
        learn_more_url:
          type: string
          nullable: true
        button_label:
          type: string
        audience:
          type: string
          enum: [everyone, colleagues, administrators]
        roles:
          type: array
          items:
            type: string
          description: The roles that narrow who sees it, in place of `audience`; empty for none. See Create an Announcement.
        audience_rules:
          type: object
          additionalProperties: true
          description: Behaviour rules over named facts; `{}` for none. See Create an Announcement.
        page_keys:
          type: array
          items:
            type: string
          description: The guidance panel keys of the pages it shows on; empty for any page. See Create an Announcement.
        image_url:
          type: string
          nullable: true
          description: For the `image` visual, a link to the uploaded image; null otherwise.
        image_alt:
          type: string
          nullable: true
          description: For the `image` visual, the image's alt text; null otherwise.
        intro_key:
          type: string
          nullable: true
          description: For `intro_animation`, the key of the Intro whose animation it plays; null otherwise.
        storyboard:
          type: object
          nullable: true
          additionalProperties: true
          description: For `storyboard`, the announcement's own animation storyboard; null otherwise.
        starts_on:
          type: string
          format: date
          nullable: true
        ends_on:
          type: string
          format: date
          nullable: true
        status:
          type: string
          enum: [draft, scheduled]
          description: What is stored. See `current_status` for whether it is showing.
        current_status:
          type: string
          enum: [draft, scheduled, live, ended]
          description: "`live` while today is within the dates of a scheduled announcement, `ended` after them."
        seen_count:
          type: integer
          description: People who have closed it.
        seen_counts_by_source:
          type: object
          description: >-
            Of those who have seen it, how many first saw it in the popup and how many by opening it in
            Wishlist › What's new.
          properties:
            popup:
              type: integer
            whats_new:
              type: integer
          required: [popup, whats_new]
        learn_more_click_count:
          type: integer
          description: People who clicked its "Learn more" link.
        button_deep_link:
          type: string
          nullable: true
          description: The deep link the button opens, or null when it only closes the popup.
        placement:
          type: string
          enum: [popup, during_build]
          description: Where it shows, the popup or the onboarding journey's building screen ("During build").
        priority:
          type: integer
          description: The order "During build" announcements show in, 1 first.
        display_seconds:
          type: integer
          description: How many seconds a "During build" announcement shows before the next.
        button_click_count:
          type: integer
          description: People who clicked the button through to its page.
        created_by_id:
          type: integer
          nullable: true
        updated_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    TrainingMaterialInput:
      type: object
      properties:
        name:
          type: string
          maxLength: 120
          description: For example "How to add a new school". Required.
        url:
          type: string
          maxLength: 2048
          description: The document's link, starting https://. Required.
        description:
          type: string
          maxLength: 280
          nullable: true
          description: One or two lines saying who it is for
        material_type:
          type: string
          enum: [document, video]
          description: Shown as an icon. Defaults to document.
        all_organisation:
          type: boolean
          description: For everyone in the Organisation
        team_ids:
          type: array
          items: { type: integer }
          description: The Organisation's Teams it is for
        project_ids:
          type: array
          items: { type: integer }
          description: The Organisation's Workspaces (Projects) it is for
        owner_id:
          type: integer
          description: The person to ask about it. An Organisation Admin of the Organisation, or the caller.
    Unavailability:
      type: object
      description: A range when a colleague can't work for an Organisation (Staff availability page)
      properties:
        id: { type: integer }
        user_id: { type: integer }
        charity_id: { type: integer }
        starts_at: { type: string, format: date-time }
        ends_at:
          type: string
          format: date-time
          description: For an all-day range, the end of `to_date` in the Organisation's timezone
        all_day: { type: boolean }
        from_date: { type: string, format: date, description: In the Organisation's timezone }
        to_date: { type: string, format: date }
        from_time: { type: string, nullable: true, description: 'HH:MM, or null for an all-day range' }
        to_time: { type: string, nullable: true }
        timezone: { type: string, example: Europe/London }
        reason_type: { type: string, enum: [annual_leave, sick_leave, training, other] }
        reason_label: { type: string, example: Annual leave }
        summary: { type: string, example: '3/12/2026 13:00–17:30 · Training' }
        private_note:
          type: string
          nullable: true
          description: Only returned to the colleague themselves and to Charity Editors
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
    UnavailabilityInput:
      type: object
      properties:
        from_date: { type: string, format: date }
        to_date: { type: string, format: date }
        all_day: { type: boolean, default: true }
        from_time: { type: string, description: 'HH:MM, for a part day' }
        to_time: { type: string, description: 'HH:MM, for a part day' }
        reason_type: { type: string, enum: [annual_leave, sick_leave, training, other] }
        private_note: { type: string, maxLength: 150 }
        unassign_event_ids:
          type: array
          items: { type: integer }
          description: Events from `conflicting_events` to take the colleague off in the same call
    UnavailabilityWithConflicts:
      allOf:
        - $ref: '#/components/schemas/Unavailability'
        - type: object
          properties:
            conflicting_events:
              type: array
              description: Upcoming events the colleague is an Event Worker on during this range
              items:
                type: object
                properties:
                  id: { type: integer }
                  name: { type: string }
                  start_datetime: { type: string, format: date-time }
                  end_datetime: { type: string, format: date-time }
                  event_category_name: { type: string, nullable: true, description: The Event Format }
                  project_id: { type: integer }
                  project_name: { type: string, nullable: true }
                  editable: { type: boolean, description: Whether the caller may edit the event, and so unassign the colleague }
                  unassigned: { type: boolean, description: Whether this call took the colleague off the event }
    PickedTour:
      type: object
      required: [id, name, team, stop_count, status]
      properties:
        id: { type: integer }
        name: { type: string }
        team:
          type: object
          nullable: true
          description: The Team the tour is for; null for the Organisation's tour for everyone
          properties:
            id: { type: integer }
            name: { type: string }
        stop_count: { type: integer, description: How many stops the tour has }
        status:
          type: string
          enum: [not_started, started, finished]
          description: started includes a tour you put off; finished includes one you ended early
    TrainingTour:
      type: object
      required: [id, name, stop_count, status]
      properties:
        id: { type: integer }
        name: { type: string }
        stop_count: { type: integer, description: How many stops the tour has }
        status:
          type: string
          enum: [ready_to_watch, started, completed]
    StartedTour:
      type: object
      required: [id, status, url]
      properties:
        id: { type: integer }
        status: { type: string, enum: [started] }
        url:
          type: string
          nullable: true
          description: The page the tour's first stop opens; null when it starts on any page
    TrainingMaterial:
      type: object
      description: A link to one of an Organisation's own training documents or videos, and who it is for
      properties:
        id:
          type: integer
        organisation_id:
          type: integer
        name:
          type: string
        url:
          type: string
        description:
          type: string
          nullable: true
        material_type:
          type: string
          enum: [document, video]
        all_organisation:
          type: boolean
        team_ids:
          type: array
          items: { type: integer }
        project_ids:
          type: array
          items: { type: integer }
          description: The Workspaces (Projects) it is for
        owner_id:
          type: integer
          nullable: true
        owner_name:
          type: string
          nullable: true
          description: Shown to viewers as "Questions? Ask [name]"
        reviewed_at:
          type: string
          format: date-time
          description: When it was added or last marked as reviewed
        review_due:
          type: boolean
          nullable: true
          description: Last reviewed more than 12 months ago. Null unless the caller can change this Training material.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Tour:
      type: object
      description: A Welcome Tour and its stops in order
      properties:
        id:
          type: integer
        name:
          type: string
        organisation_id:
          type: integer
        team_id:
          type: integer
          nullable: true
          description: The Team it is for; null for the Organisation's default tour
        audience:
          type: string
          description: The Team's name, or "Everyone in the organisation (default)"
        watch_checklist_ids:
          type: array
          items:
            type: integer
          description: >-
            The Checklists that Watch the journey shows straight after the tour, in order (up to 2). Empty means
            people see up to 2 Checklists on their workspaces, most recently updated first.
        training_material_id:
          type: integer
          nullable: true
          description: >-
            The Training material the tour's last stop links to as the Full guide (shown only to people it is shared
            with), or null
        mode:
          type: string
          enum: [required, optional]
          description: required is shown as Mandatory
        status:
          type: string
          enum: [draft, live]
        start_skippable:
          type: boolean
          description: Whether people can skip the tour when it is first offered
        later_limit:
          type: integer
          minimum: 1
          maximum: 10
          description: How many times someone can choose "I'll do this later" on a mandatory tour
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        stops:
          type: array
          items:
            $ref: '#/components/schemas/TourStop'
    TourStop:
      type: object
      properties:
        id:
          type: integer
        position:
          type: integer
        group_name:
          type: string
          nullable: true
        stop_key:
          type: string
          enum: [navbar_spaces, navbar_user, focus_table, contacts_table, contacts_search, contacts_filters, events_table, event_guests]
        stop_label:
          type: string
          nullable: true
          description: Which part of which page the stop focuses on
        action:
          type: string
          enum: [next, click, ""]
          description: Whether the stop waits for Next or asks the person to click something
        title:
          type: string
        body:
          type: string
          nullable: true
        action_text:
          type: string
          nullable: true
          description: What to click, on a click stop
        after_text:
          type: string
          nullable: true
          description: Shown after the click
        skippable:
          type: boolean
          description: Whether a click stop shows Skip this stop
        included:
          type: boolean
          description: Whether the tour shows this stop. An unticked stop keeps its wording for when it is ticked again.
        default_body:
          type: string
          nullable: true
          description: Makerble's wording for this stop, shown when `body` is empty
    TourInput:
      type: object
      properties:
        name:
          type: string
        organisation_id:
          type: integer
        team_id:
          type: integer
          nullable: true
        mode:
          type: string
          enum: [required, optional]
        status:
          type: string
          enum: [draft, live]
        start_skippable:
          type: boolean
        later_limit:
          type: integer
          minimum: 1
          maximum: 10
        watch_checklist_ids:
          type: array
          maxItems: 2
          items:
            type: integer
          description: Up to 2 Checklists of the tour's Organisation for Watch the journey, in order. Send [] to clear them.
        training_material_id:
          type: integer
          nullable: true
          description: >-
            One of the Organisation's Training materials, linked as the Full guide on the tour's last stop. Send null to
            clear it.
        stops:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              position:
                type: integer
              group_name:
                type: string
              stop_key:
                type: string
                description: For an Organisation Admin, names the stop instead of `id`, and adds it if the tour doesn't have it
              title:
                type: string
              body:
                type: string
                nullable: true
                description: The stop's wording; empty means Makerble's default. Up to 280 characters for an Organisation Admin.
              included:
                type: boolean
                description: Whether the tour shows this stop
              action_text:
                type: string
              after_text:
                type: string
              skippable:
                type: boolean
              _destroy:
                type: boolean
    PaginatedTours:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Tour'
    FeatureTourFunnel:
      type: object
      description: A feature tour's funnel
      properties:
        id:
          type: integer
        name:
          type: string
        status:
          type: string
          enum: [draft, amends_needed, live]
        counts_since:
          type: string
          format: date
          nullable: true
          description: The day stop-by-stop counts were first recorded; null until anyone has taken a step
        totals:
          type: object
          properties:
            started:
              type: integer
              description: Everyone who has taken the tour
            completed:
              type: integer
            in_progress:
              type: integer
            ended_early:
              type: integer
        stops:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              position:
                type: integer
              stop_key:
                type: string
              title:
                type: string
                description: The stop's own title, or Makerble's default
              reached:
                type: integer
              completed:
                type: integer
              skipped_by_user:
                type: integer
              skipped_by_system:
                type: integer
    FeatureLaunchEmailInput:
      type: object
      required: [feature_launch_ids]
      properties:
        feature_launch_ids:
          type: array
          description: The feature launches to show, 1 to 10, in this order (from GET /feature_launches).
          items:
            type: integer
        user_email:
          type: string
          description: Show it as this Makerble user gets it. Leave it out for someone without a Makerble account.
        intro:
          type: string
          description: An opening paragraph, shown before the feature launches.
        subject:
          type: string
          description: The subject. Leave it out to name the features ("What’s new in Makerble - Registers and Albums").
    FeatureLaunchEmailPreview:
      type: object
      required: [subject, to, html, text]
      properties:
        subject:
          type: string
        to:
          type: string
          description: Who it would go to.
        html:
          type: string
          description: The HTML version, a 600px email with inline styles.
        text:
          type: string
          description: The plain-text version.
    FeatureLaunch:
      type: object
      description: A feature launch and its launch content
      properties:
        id:
          type: integer
        name:
          type: string
          maxLength: 80
          description: The feature's name as people see it in Makerble, such as Registers. Unique, ignoring case.
        tier:
          type: string
          enum: [minor, standard, major]
          description: How big the launch is. Major is a new feature or a substantial new capability.
        short_description:
          type: string
          nullable: true
          maxLength: 280
          description: The announcement message. An announcement for the launch shows it when its own `body` is empty.
        email_description:
          type: string
          nullable: true
          maxLength: 600
          description: >-
            2 to 4 sentences for the feature launch emails, in the words people see in Makerble: what it is, why it
            matters and how to start.
        user_guide_url:
          type: string
          nullable: true
          maxLength: 2048
          description: A page in the Makerble User Guide (https://makerble.atlassian.net/wiki/spaces/MCPD/...).
        blog_url:
          type: string
          nullable: true
          maxLength: 2048
          description: The blog post about the feature, a web address starting https://.
        deep_link:
          type: string
          nullable: true
          description: The name of a deep link (from GET /deep_links) that opens the feature in the person's own organisation.
        feature_tour_id:
          type: integer
          nullable: true
          description: The feature tour (from GET /feature_tours) that introduces it.
        intro_key:
          type: string
          nullable: true
          description: The key of the feature's Intro (from GET /guidance_panels).
        email_visual:
          type: string
          enum: [gif, still_frame, image, none]
          description: >-
            What the email shows: a GIF or a still frame made from the feature's animation, an uploaded image
            (`email_image`), or nothing.
        email_visual_alt:
          type: string
          nullable: true
          maxLength: 250
          description: What the visual shows, for screen readers. Required unless `email_visual` is `none`.
        email_primary_link:
          type: string
          nullable: true
          enum: [deep_link, tour, user_guide, blog, null]
          description: >-
            Which link the email's main button uses: the deep link, Take the tour, the User Guide page or the blog
            post. The launch must have that link.
        email_text_links:
          type: array
          maxItems: 2
          items:
            type: string
            enum: [deep_link, tour, user_guide, blog]
          description: Up to two more links the email shows as text, each one the launch has and not the main button.
        jira_keys:
          type: array
          items:
            type: string
            example: CP-9271
          description: The Jira issues that built the feature.
        released_on:
          type: string
          format: date
          nullable: true
          description: The day the feature reached production.
        email_image_url:
          type: string
          nullable: true
          description: The uploaded image for an `image` visual, or null
        email_gif_url:
          type: string
          nullable: true
          description: The GIF made from the feature's animation, or null until it is made
        email_still_frame_url:
          type: string
          nullable: true
          description: The still frame made from the feature's animation, or null until it is made
        video_url:
          type: string
          nullable: true
          description: >-
            An MP4 of the feature's animation (1920 by 1080, or its crop's shape at 1920 wide, 30 frames a second), to
            download for Vimeo, the website or social posts. Null until one is made with `make_video`.
        announcement_ids:
          type: array
          items:
            type: integer
          description: The announcements for this launch
        created_by_id:
          type: integer
          nullable: true
        updated_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    FeatureLaunchWithNotices:
      allOf:
        - $ref: '#/components/schemas/FeatureLaunch'
        - type: object
          properties:
            notices:
              type: array
              items:
                type: string
              description: >-
                Empty, unless `make_video` was sent, when it says whether the video is being made or why it can't be
                (the launch has no animation). The rest of the change is saved either way.
    FeatureLaunchInput:
      type: object
      properties:
        make_video:
          type: boolean
          description: >-
            Make an MP4 of the feature's animation (the one its email GIF is made from) in the background. It takes a
            few minutes; `video_url` gives it when it is ready. Making it again replaces the last one.
        name:
          type: string
          maxLength: 80
          description: >-
            The feature's name as people see it in Makerble, such as Registers. Unique, ignoring case. Required on
            create.
        tier:
          type: string
          enum: [minor, standard, major]
          description: How big the launch is. Major is a new feature or a substantial new capability.
        short_description:
          type: string
          nullable: true
          maxLength: 280
          description: The announcement message. An announcement for the launch shows it when its own `body` is empty.
        email_description:
          type: string
          nullable: true
          maxLength: 600
          description: >-
            2 to 4 sentences for the feature launch emails, in the words people see in Makerble: what it is, why it
            matters and how to start.
        user_guide_url:
          type: string
          nullable: true
          maxLength: 2048
          description: A page in the Makerble User Guide (https://makerble.atlassian.net/wiki/spaces/MCPD/...).
        blog_url:
          type: string
          nullable: true
          maxLength: 2048
          description: The blog post about the feature, a web address starting https://.
        deep_link:
          type: string
          nullable: true
          description: The name of a deep link (from GET /deep_links) that opens the feature in the person's own organisation.
        feature_tour_id:
          type: integer
          nullable: true
          description: The feature tour (from GET /feature_tours) that introduces it.
        intro_key:
          type: string
          nullable: true
          description: The key of the feature's Intro (from GET /guidance_panels).
        email_visual:
          type: string
          enum: [gif, still_frame, image, none]
          description: >-
            What the email shows: a GIF or a still frame made from the feature's animation, an uploaded image
            (`email_image`), or nothing.
        email_visual_alt:
          type: string
          nullable: true
          maxLength: 250
          description: What the visual shows, for screen readers. Required unless `email_visual` is `none`.
        email_primary_link:
          type: string
          nullable: true
          enum: [deep_link, tour, user_guide, blog, null]
          description: >-
            Which link the email's main button uses: the deep link, Take the tour, the User Guide page or the blog
            post. The launch must have that link.
        email_text_links:
          type: array
          maxItems: 2
          items:
            type: string
            enum: [deep_link, tour, user_guide, blog]
          description: Up to two more links the email shows as text, each one the launch has and not the main button.
        jira_keys:
          type: array
          items:
            type: string
            example: CP-9271
          description: The Jira issues that built the feature.
        released_on:
          type: string
          format: date
          nullable: true
          description: The day the feature reached production.
        email_image:
          description: >-
            For an `image` visual: a PNG, JPG, GIF or WebP file of up to 5 MB, as a multipart file or as base64 data
            with a filename.
          oneOf:
            - type: string
              format: binary
            - $ref: '#/components/schemas/AnnouncementImageUpload'
    WeeklyFeatureEmail:
      type: object
      description: One week's weekly email of feature announcements (Site Overview › Weekly email)
      properties:
        week_starts_on: { type: string, format: date, description: The Monday the week starts on }
        week_ends_on: { type: string, format: date }
        status: { type: string, enum: [open, sent] }
        editable: { type: boolean, description: False once it has been sent or its week is over }
        paused: { type: boolean }
        subject: { type: string, nullable: true, description: Empty to name the features }
        intro: { type: string, nullable: true, description: The opening paragraph }
        send_at: { type: string, format: date-time, nullable: true, description: When it sends automatically; null once sent }
        waiting_for_approval: { type: boolean, description: True while it needs Approve and send before it can go }
        approved_at: { type: string, format: date-time, nullable: true }
        approved_by_id: { type: integer, nullable: true }
        sent_at: { type: string, format: date-time, nullable: true }
        recipients_count: { type: integer, description: How many people it was sent to }
        items:
          type: array
          description: The feature launches it shows, in order
          items:
            type: object
            properties:
              feature_launch_id: { type: integer }
              name: { type: string }
              position: { type: integer }
              source: { type: string, enum: [announcement, added], description: From the week's announcements, or added by someone }
        updated_at: { type: string, format: date-time }
    WeeklyFeatureEmailSetting:
      type: object
      description: How the weekly email is sent
      properties:
        send_mode: { type: string, enum: [automatic, approval] }
        send_day: { type: integer, description: 1 (Monday) to 7 (Sunday) }
        send_hour: { type: integer, description: 0 to 23 }
        time_zone: { type: string, example: Europe/London }
    WeeklyFeatureEmailWithSetting:
      allOf:
        - $ref: '#/components/schemas/WeeklyFeatureEmail'
        - type: object
          properties:
            setting:
              $ref: '#/components/schemas/WeeklyFeatureEmailSetting'
    PaginatedWeeklyFeatureEmails:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/WeeklyFeatureEmail'
    WeeklyFeatureEmailPreview:
      type: object
      properties:
        to: { type: string }
        gets_email: { type: boolean }
        left_out: { type: string, nullable: true, description: Why they get no email, when gets_email is false }
        subject: { type: string, nullable: true }
        feature_launch_ids: { type: array, items: { type: integer }, description: The items they get }
        html: { type: string, nullable: true }
        text: { type: string, nullable: true }
    PaginatedFeatureLaunches:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FeatureLaunch'
    SocialPost:
      type: object
      description: A feature launch's post for one of Makerble's social channels
      properties:
        id:
          type: integer
        feature_launch_id:
          type: integer
        feature_launch_name:
          type: string
        channel:
          type: string
          enum: [linkedin, instagram, x]
          description: LinkedIn (Makerble's company page), Instagram or X.
        body:
          type: string
          description: The post's copy.
        media:
          type: string
          enum: [none, still_frame, gif, video, image]
          description: >-
            What the post shows: the feature launch's still frame, GIF or video (made from its animation), an image
            uploaded for the post, or nothing.
        media_alt:
          type: string
          nullable: true
          maxLength: 250
          description: What the media shows, for screen readers. Required unless `media` is `none`.
        media_url:
          type: string
          nullable: true
          description: The media file, once there is one.
        link_url:
          type: string
          nullable: true
          maxLength: 2048
        planned_at:
          type: string
          format: date-time
          nullable: true
          description: When the post is planned to go out. Needed before it can be approved.
        status:
          type: string
          enum: [draft, approved, scheduled, published, failed]
        approved_by_id:
          type: integer
          nullable: true
        approved_at:
          type: string
          format: date-time
          nullable: true
        created_by_id:
          type: integer
          nullable: true
        updated_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required: [id, feature_launch_id, feature_launch_name, channel, body, media, media_alt, media_url, link_url, planned_at, status,
                 approved_by_id, approved_at, created_by_id, updated_by_id, created_at, updated_at]
    SocialPostInput:
      type: object
      properties:
        body:
          type: string
          description: The post's copy, within the channel's limit.
        media:
          type: string
          enum: [none, still_frame, gif, video, image]
          description: >-
            The feature launch's still frame, GIF or video (the launch must have it already), an uploaded `image`, or
            nothing. Instagram needs media; LinkedIn takes an image or GIF, not a video.
        media_alt:
          type: string
          nullable: true
          maxLength: 250
        image:
          description: >-
            The image for `media: image`: a PNG, JPG, GIF or WebP of up to 5 MB, as a multipart file or as an object
            with `filename` and base64 `data`.
          oneOf:
            - type: string
              format: binary
            - type: object
              properties:
                filename:
                  type: string
                data:
                  type: string
                  format: byte
              required: [filename, data]
        link_url:
          type: string
          nullable: true
          maxLength: 2048
          description: A web address starting https://.
        planned_at:
          type: string
          format: date-time
          nullable: true
    SocialPostCreateInput:
      allOf:
        - $ref: '#/components/schemas/SocialPostInput'
        - type: object
          properties:
            feature_launch_id:
              type: integer
              description: The feature launch (from GET /feature_launches) the post is for.
            channel:
              type: string
              enum: [linkedin, instagram, x]
          required: [feature_launch_id, channel, body]
    PaginatedSocialPosts:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/SocialPost'
    SocialPostSettings:
      type: object
      properties:
        publish_mode:
          type: string
          enum: [once_approved, automatically]
          description: once_approved publishes only approved posts; automatically publishes drafts too.
        instagram_link_wording:
          type: string
          maxLength: 60
          description: What an Instagram caption with a link must say, since its link isn't clickable.
        updated_by_id:
          type: integer
          nullable: true
        updated_at:
          type: string
          format: date-time
      required: [publish_mode, instagram_link_wording, updated_by_id, updated_at]
    SocialPostSettingsInput:
      type: object
      properties:
        publish_mode:
          type: string
          enum: [once_approved, automatically]
        instagram_link_wording:
          type: string
          maxLength: 60
    FeatureTour:
      type: object
      description: A feature tour and its stops in order
      properties:
        id:
          type: integer
        key:
          type: string
          description: A unique name in lowercase words joined by underscores, used by announcements and agents
        name:
          type: string
        status:
          type: string
          enum: [draft, amends_needed, live]
          description: Only a live tour is shown to anyone. `amends_needed` is a draft that came back from review
        page_key:
          type: string
          nullable: true
          description: The page whose Intro offers the tour with "Take the tour" while it is live; null for none
        auto_prompt:
          type: boolean
          description: Whether the tour is offered once, the first time someone opens its page
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        stops:
          type: array
          items:
            $ref: '#/components/schemas/FeatureTourStop'
    FeatureTourStop:
      type: object
      properties:
        id:
          type: integer
        position:
          type: integer
        stop_key:
          type: string
          description: One of the stops Makerble knows, the same stops Welcome Tours use
        stop_label:
          type: string
          nullable: true
          description: Which part of which page the stop focuses on
        group_name:
          type: string
          nullable: true
          description: The feature the stop belongs to, such as Contacts or Registers; "Other" when it has none, null for a stop Makerble no longer knows
        action:
          type: string
          enum: [next, click, ""]
          description: Whether the stop waits for Next or asks the person to click something
        title:
          type: string
          nullable: true
          description: The stop's own title; null shows `default_title`
        body:
          type: string
          nullable: true
          description: The stop's own wording; null shows `default_body`
        default_title:
          type: string
          nullable: true
          description: Makerble's title for this stop
        default_body:
          type: string
          nullable: true
          description: Makerble's wording for this stop
    FeatureTourInput:
      type: object
      properties:
        key:
          type: string
        name:
          type: string
        status:
          type: string
          enum: [draft, amends_needed, live]
          description: Only a live tour is shown to anyone. `amends_needed` is a draft that came back from review
        page_key:
          type: string
          nullable: true
          description: The key of a page's Intro, such as contacts. Send null or "" for none.
        auto_prompt:
          type: boolean
        stops:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                description: Changes this stop; leave it out to add a stop
              position:
                type: integer
              stop_key:
                type: string
              title:
                type: string
                nullable: true
                description: Up to 120 characters; empty means Makerble's default
              body:
                type: string
                nullable: true
                description: Up to 600 characters; empty means Makerble's default
              _destroy:
                type: boolean
    TourStopDefinition:
      type: object
      description: One of the stops Makerble knows, for building a Welcome Tour or a feature tour
      properties:
        key:
          type: string
          description: The stop's key, sent as `stop_key` when adding it to a tour
        label:
          type: string
          description: Which part of which page the stop focuses on
        group_name:
          type: string
          description: The feature the stop belongs to, such as Contacts or Registers; "Other" when it has none
        page:
          type: string
          description: The page the stop opens, as a page name and its key, a path, or in words when it is worked out for each person
        action:
          type: string
          enum: [next, click]
          description: Whether the stop waits for Next or asks the person to click something
        action_label:
          type: string
          description: '`action` in words: "Next button" or "Waits for a click"'
        default_title:
          type: string
          nullable: true
          description: Makerble's title for the stop
        default_body:
          type: string
          nullable: true
          description: Makerble's wording for the stop
        empty:
          type: object
          nullable: true
          description: What the stop shows someone who can open its page but has nothing on it yet; null when it is skipped instead
          properties:
            title:
              type: string
            body:
              type: string
            page:
              type: string
              nullable: true
              description: The page the empty variant opens, when it isn't the stop's own page
        shown_to:
          type: string
          description: Who sees the stop, e.g. "Only for Organisation Editors" or "Skipped for someone without a Checklist"
        feature_tour_count:
          type: integer
          description: How many feature tours use the stop
        welcome_tour_count:
          type: integer
          description: How many Welcome Tours use the stop
    TourStopWordingInput:
      type: object
      properties:
        default_title:
          type: string
          maxLength: 120
          description: Makerble's title for the stop; empty goes back to the original
        default_body:
          type: string
          maxLength: 600
          description: Makerble's text for the stop; empty goes back to the original
    PaginatedTourStopDefinitions:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/TourStopDefinition'
    PaginatedFeatureTours:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FeatureTour'
    PaginatedTourProgress:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            summary:
              $ref: '#/components/schemas/TourProgressSummary'
            data:
              type: array
              items:
                $ref: '#/components/schemas/TourProgress'
    TourProgressSummary:
      type: object
      description: The tiles on the Who has finished page
      properties:
        finished:
          type: integer
        part_way:
          type: integer
        not_started:
          type: integer
          description: Not started, or skipped an optional tour
        average_minutes:
          type: number
          nullable: true
          description: Average minutes to finish, counting only tours finished without "I'll do this later"
    TourProgress:
      type: object
      description: One colleague and how far they have got
      properties:
        user_id:
          type: integer
        name:
          type: string
        team:
          type: string
          nullable: true
          description: The first of the Organisation's Teams they joined
        status:
          type: string
          enum: [not_started, in_progress, deferred, completed, skipped]
          description: deferred means they chose "I'll do this later"
        tour:
          type: string
          description: As the page shows it, for example "Paused at stop 3 of 7" or "Finished"
        later_used:
          type: string
          nullable: true
          description: How many times they chose "I'll do this later" of how many allowed, on a mandatory tour
        last_active_at:
          type: string
          format: date-time
          nullable: true
        reminded_at:
          type: string
          format: date-time
          nullable: true
          description: When they were last sent a reminder
    TourReminder:
      type: object
      properties:
        user_id:
          type: integer
        reminded_at:
          type: string
          format: date-time
        next_reminder_from:
          type: string
          format: date-time
          description: The earliest another reminder can be sent to them
    WelcomeJourneySettings:
      type: object
      properties:
        organisation_id:
          type: integer
        photo_skippable:
          type: boolean
          description: Whether people can skip adding a profile picture
        watch_skippable:
          type: boolean
          description: Whether people can skip Watch the journey, the Checklists shown after the Welcome Tour
        tour_ids:
          type: array
          items:
            type: integer
    PaginatedAnnouncements:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Announcement'
    WhatsNewItem:
      type: object
      description: An announcement in the signed-in user's Wishlist › What's new, with whether they have seen it
      properties:
        id:
          type: integer
        title:
          type: string
          description: The headline.
        body:
          type: string
        starts_on:
          type: string
          format: date
        ends_on:
          type: string
          format: date
        section:
          type: string
          enum: [new_since_joined, before_joined]
        visual_type:
          type: string
          enum: [name_change, vimeo, image, intro_animation, storyboard, none]
        image_url:
          type: string
          nullable: true
        image_alt:
          type: string
          nullable: true
        vimeo_url:
          type: string
          nullable: true
        learn_more_url:
          type: string
          nullable: true
          description: A page in the Makerble User Guide.
        button_label:
          type: string
        includes_tour:
          type: boolean
          description: Whether its button starts a feature tour, which it does while the tour is live.
        feature_tour_id:
          type: integer
          nullable: true
          description: The live feature tour its button starts, or null.
        asked_for:
          type: boolean
          description: Whether it answered one of the user's requests in Wishlist › Your wishlist.
        seen:
          type: boolean
          description: Whether the user has seen it, in the popup or by opening it in What's new.
        seen_at:
          type: string
          format: date-time
          nullable: true
        updated_at:
          type: string
          format: date-time
      required: [id, title, body, starts_on, section, visual_type, includes_tour, asked_for, seen, seen_at]
    PaginatedWhatsNew:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/WhatsNewItem'
    Wish:
      type: object
      description: A feature request or feedback from Wishlist › Your wishlist
      properties:
        id:
          type: integer
        kind:
          type: string
          enum: [feature_request, feedback]
        body:
          type: string
        status:
          type: string
          description: Where it is, as the person sees it, e.g. "Received", "Read by the Makerble team" or "Shipped".
        helpdesk_key:
          type: string
          nullable: true
          description: The Helpdesk ticket a feature request became (e.g. MC-2501), once it exists.
        charity_id:
          type: integer
          nullable: true
          description: The organisation it's about.
        announcement_id:
          type: integer
          nullable: true
          description: The Announcement that answered it, if one has.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    WishInput:
      type: object
      required: [kind, body]
      properties:
        kind:
          type: string
          enum: [feature_request, feedback]
        body:
          type: string
          maxLength: 2000
        charity_id:
          type: integer
          description: One of your organisations. Needed only if you belong to more than one.
    PaginatedWishes:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Wish'
    RoadmapItem:
      type: object
      description: Something in Wishlist › Coming soon
      properties:
        id:
          type: integer
        title:
          type: string
        body:
          type: string
        stage:
          type: string
          enum: [building_now, up_next]
        stage_label:
          type: string
          enum: [Building now, Up next]
        position:
          type: integer
          description: Its order within its stage.
        published:
          type: boolean
        stale:
          type: boolean
          description: Unchanged for 60 days.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    RoadmapItemInput:
      type: object
      properties:
        title:
          type: string
          maxLength: 90
        body:
          type: string
          maxLength: 280
        stage:
          type: string
          enum: [building_now, up_next]
        published:
          type: boolean
    PaginatedRoadmapItems:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/RoadmapItem'
    BulkProjectMove:
      type: object
      description: A move of many Contacts through Projects, and how far it has got
      properties:
        id:
          type: integer
        status:
          type: string
          enum: [pending, running, completed, failed, undone]
        total_count:
          type: integer
          description: Contacts the move will try to change (the selection, less Headline Only Contacts)
        processed_count:
          type: integer
          description: Contacts reached so far
        changed_count:
          type: integer
          description: Contacts whose Projects or status changed
        skip_counts:
          type: object
          additionalProperties: { type: integer }
          description: Skipped Contacts by reason, e.g. headline_only, not_allowed or error
        background:
          type: boolean
          description: True when the move runs in the background (more than 50 Contacts)
        summary:
          type: string
          nullable: true
          description: The finished message, e.g. "12 contacts changed. 3 skipped …"; null until it has finished
    MyAppsMenu:
      type: object
      required: [offered, shown]
      properties:
        offered:
          type: boolean
          description: False for Contacts with a login and Survey Portal users, who have no My Apps menu
        shown:
          type: boolean
          description: True while the My Apps button shows in your top menu
    StartPage:
      type: object
      required: [start_page, options]
      properties:
        start_page:
          type: string
          enum: [newsfeed, focus, snapshot, autopilot]
          description: The key of your start page; newsfeed when you have never chosen
        options:
          type: array
          description: The pages you can choose, in the order the Today section lists them
          items:
            type: object
            required: [key, label, description]
            properties:
              key:
                type: string
                description: e.g. focus
              label:
                type: string
                description: Its name under Today, e.g. Focus
              description:
                type: string
                description: The line under it in Personal Settings › Preferences
    FocusSource:
      type: object
      required: [key, label, shown]
      properties:
        key:
          type: string
          description: e.g. checklist_actions
        label:
          type: string
          description: Its name under ⚙ What Focus shows you, e.g. Checklist Actions
        shown:
          type: boolean
          description: False when you have switched it off
    FocusItem:
      type: object
      required: [id, type, title, context, contact, url, due_on, raised_on, due_text, section, action]
      properties:
        id:
          type: string
          description: Unique across every source, e.g. checklist_actions-812
        type:
          type: string
          description: The source it came from, e.g. checklist_actions
        title:
          type: string
          description: What it is, e.g. the Checklist step
        context:
          type: string
          description: Where it belongs, e.g. "Checklist Action · Intake · step 2 of 5", plus who is responsible when it isn't you
        contact:
          type: object
          nullable: true
          description: The Contact it is about, when there is one
          required: [id, name]
          properties:
            id:
              type: integer
            name:
              type: string
        url:
          type: string
          description: Where the row leads
        due_on:
          type: string
          format: date
          nullable: true
          description: The day it is due, or null
        raised_on:
          type: string
          format: date
          nullable: true
          description: For something with no due date, the day it was raised
        due_text:
          type: string
          description: e.g. "15 days overdue", "Due today", "Due in 4 days", "No due date"
        section:
          type: string
          enum: [overdue, today, this_week, later]
        action:
          type: object
          description: The row's one button
          required: [label, url, method]
          properties:
            label:
              type: string
              description: e.g. Open
            url:
              type: string
            method:
              type: string
              description: The HTTP method, e.g. get
    FocusFeed:
      type: object
      required: [scope, teams, type, sources, counts, sections, page, page_size, page_count, total_count, data]
      properties:
        scope:
          type: string
          enum: [me, teams]
        teams:
          type: boolean
          description: You are in a Team, so scope=teams is available
        type:
          type: string
          nullable: true
          description: The type filtered by, or null for every type
        sources:
          type: array
          items:
            $ref: '#/components/schemas/FocusSource'
        counts:
          type: object
          description: "`all`, and the number of items of each type that has any, e.g. {all: 4, checklist_actions: 4}"
          required: [all]
          additionalProperties:
            type: integer
          properties:
            all:
              type: integer
        sections:
          type: array
          description: The sections that have items, in order
          items:
            type: object
            required: [key, label, count]
            properties:
              key:
                type: string
                enum: [overdue, today, this_week, later]
              label:
                type: string
              count:
                type: integer
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/FocusItem'

    ImpactStoreSearchResult:
      type: object
      description: A published ImpactStore item found by **Search the ImpactStore**.
      properties:
        id:
          type: integer
        type:
          type: string
          enum: [survey, contact_form, case_form, impact_framework, report_template, toolkit, project_type]
        type_label:
          type: string
          description: The front-end name of the type, e.g. Contact Form
        name:
          type: string
        description:
          type: string
          nullable: true
          description: One line of plain text (always null for a Case Form)
        causes:
          type: array
          items:
            type: string
          description: Cause and subcause names, causes first
        used_by_count:
          type: integer
          description: How many organisations use it
        explore_url:
          type: string
          nullable: true
          description: Its page on Explore (null for a Project Type)
        matched_words:
          type: integer
          description: How many of the query's words it matched

    PaginatedImpactStoreSearch:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImpactStoreSearchResult'

    LibrarySearchResult:
      type: object
      description: A library item found by **Search the library**. Metrics also have `metric_type` and `choices`; Lists have `choices`.
      additionalProperties: true
      properties:
        id:
          type: integer
        type:
          type: string
          enum: [survey, metric, activity_tracker, outcome, list, unit, field, contact_form, case_form, impact_framework, toolkit, project_type, idea]
        name:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
          description: One line of plain text
        owner:
          type: string
          enum: [your organisation, public library, Makerble]

    ExploreSurvey:
      type: object
      description: A Survey (Story Category) listed on Explore Surveys
      properties:
        id:
          type: integer
        name:
          type: string
        description:
          type: string
          nullable: true
        shared_by:
          type: string
          nullable: true
          description: The organisation (or person) that published it
        tag:
          type: string
          nullable: true
          enum: [Verdicts, Validated, null]
        question_count:
          type: integer
        estimated_minutes:
          type: integer
          nullable: true
          description: About how long it takes to answer, worked out from its questions
        themes:
          type: array
          items:
            type: string
        audiences:
          type: array
          description: Who answers it
          items:
            type: string
        contact_mode:
          type: string
          enum: [one_contact, several_contacts]
          description: How the survey is shown when someone tries it on a toolkit page, About one contact (`one_contact`) or for Several or no contacts (`several_contacts`)
        repeats_at_intervals:
          type: boolean
        validated:
          type: boolean
          description: An industry-recognised, validated scale
        verdicts:
          type: boolean
          description: Verdicts are set up, so it classifies each respondent automatically
        libraries_count:
          type: integer
          description: How many organisations have it in one of their projects
        yours:
          type: boolean
          description: Your organisation published it
        added_to_a_project:
          type: boolean
          description: It is already in one of your organisation's projects

    ExploreFacetGroup:
      type: object
      properties:
        key:
          type: string
          description: The filter's query parameter, e.g. theme. Each Explore endpoint lists its own.
        label:
          type: string
        options:
          type: array
          items:
            type: object
            properties:
              value:
                type: string
              label:
                type: string
              count:
                type: integer
                description: How many Surveys this option would return, given the other filters already chosen
              selected:
                type: boolean

    PaginatedExploreSurveys:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreSurvey'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExploreReportTemplatePreview:
      allOf:
        - $ref: '#/components/schemas/ExploreReportTemplate'
        - type: object
          properties:
            questions:
              type: array
              items:
                type: object
                properties:
                  title:
                    type: string
                  answer_formats:
                    type: array
                    items:
                      type: string
                      enum: [narrative, number, chart, table]

    ExploreReportTemplate:
      type: object
      properties:
        id:
          type: integer
        slug:
          type: string
        name:
          type: string
        description:
          type: string
          nullable: true
        recipient:
          type: string
          nullable: true
          enum: [funder, trustees, local_authority, corporate_partner, internal, null]
        theme:
          type: string
          nullable: true
        question_count:
          type: integer
        answer_formats:
          type: array
          items:
            type: string
            enum: [narrative, number, chart, table]
        shared_by:
          type: string
        libraries_count:
          type: integer
          description: How many organisations have it in their library
        yours:
          type: boolean
          description: Whether one of the caller's organisations owns it
        in_your_library:
          type: boolean
          description: Whether it is in the library of one of the caller's organisations

    ReportOutputSettings:
      type: object
      description: The settings of a question's Expected Outputs
      properties:
        word_limit:
          type: integer
          minimum: 1
          maximum: 100000
          description: Narrative word limit
        table:
          type: object
          properties:
            columns:
              type: array
              items:
                type: object
                properties:
                  heading:
                    type: string
                  type:
                    type: string
                    enum: [text, number]
            row_mode:
              type: string
              enum: [reporter_adds, fixed]
            fixed_row_labels:
              type: array
              items:
                type: string
        makerble_data:
          $ref: '#/components/schemas/DataBlockSettings'
    DataBlockSettings:
      type: object
      description: |
        A Makerble data block: figures each Report fills from its own data (its timeframe,
        projects and albums, and Exclusive Focus). Only the chosen preset's settings are kept.
        See GET /report_data_presets for each preset's settings and answer shapes.
      required: [preset]
      properties:
        preset:
          type: string
          enum: [target_vs_actual, key_figures, contact_breakdown, distance_travelled, sessions_and_attendance]
        display:
          type: string
          enum: [table, bar_chart, pie_chart, line_chart, figures]
          description: One the preset allows; defaults to its first
        metrics:
          type: array
          description: |
            Target vs actual (1 to 20) and Key figures (1 to 6). Each is "Type:id" or {type, id},
            with type Change, Indicator, CohortTracker, WorkflowTracker, FilteredMetric or
            FormulaTracker. Saved with each metric's name. For a group of people, choose a filtered
            version or a Cohort Tracker with that filter.
          items:
            oneOf:
              - type: string
                example: "Change:12"
              - type: object
                properties:
                  type:
                    type: string
                  id:
                    type: integer
                  name:
                    type: string
        thresholds:
          type: object
          description: Target vs actual's status thresholds, as % of target
          properties:
            on_track:
              type: integer
              default: 100
            close:
              type: integer
              default: 75
        breakdown_by:
          type: string
          description: Contact breakdown; "age_band" or a Bio form Dropdown field's ID
        second_breakdown_by:
          type: string
          description: Contact breakdown; an optional second field
        tracker_id:
          type: integer
          description: Distance travelled; a Choice metric with a success direction
        group_by:
          type: string
          enum: [total, month]
          description: Sessions and attendance
    DataBlockPreset:
      type: object
      properties:
        key:
          type: string
        name:
          type: string
        answers_questions_like:
          type: string
        answer_shapes:
          type: array
          items:
            $ref: '#/components/schemas/AnswerShape'
        displays:
          type: array
          items:
            type: string
        settings:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              label:
                type: string
              type:
                type: string
              min:
                type: integer
              max:
                type: integer
              required:
                type: boolean
              options:
                type: array
                items:
                  type: string
              default: {}
    AnswerShape:
      type: string
      description: The kind of answer a requirement asks for and a preset or metric gives
      enum: [count, sum, average, ratio, share_meeting_threshold, change_over_time, breakdown, quote]
    ReportTemplateQuestion:
      type: object
      properties:
        id:
          type: integer
        question_title:
          type: string
        guidance_notes:
          type: string
          nullable: true
        nuance:
          type: string
          nullable: true
        position:
          type: integer
        expected_output_types:
          type: array
          items:
            type: string
            enum: [narrative, number, chart, table, makerble_data]
        output_settings:
          $ref: '#/components/schemas/ReportOutputSettings'
    ReportTemplate:
      type: object
      properties:
        id:
          type: integer
        charity_id:
          type: integer
        name:
          type: string
        description:
          type: string
          nullable: true
        recipient_type:
          type: string
          nullable: true
          enum: [funder, trustees, local_authority, corporate_partner, internal, null]
        theme:
          type: string
          nullable: true
        created_for_report_id:
          type: integer
          nullable: true
          description: The Report ReportMaker made this template for, when it was made for a single report
        updated_at:
          type: string
          format: date-time
        questions:
          type: array
          items:
            $ref: '#/components/schemas/ReportTemplateQuestion'
    ReportTemplateInput:
      type: object
      properties:
        charity_id:
          type: integer
          description: The organisation, when creating
        name:
          type: string
        description:
          type: string
        recipient_type:
          type: string
          enum: [funder, trustees, local_authority, corporate_partner, internal]
        theme:
          type: string
          enum: [children_and_young_people, community, employment, governance, health_and_wellbeing, volunteering]
        questions:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                description: An existing question, to change it
              question_title:
                type: string
              guidance_notes:
                type: string
              nuance:
                type: string
              position:
                type: integer
                description: Defaults to the question's place in the list
              expected_output_types:
                type: array
                items:
                  type: string
                  enum: [narrative, number, chart, table]
              output_settings:
                $ref: '#/components/schemas/ReportOutputSettings'
              _destroy:
                type: boolean
    PaginatedReportTemplates:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ReportTemplate'
    NamedRecord:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
    ReportingCycleSummary:
      type: object
      properties:
        id:
          type: integer
        charity_id:
          type: integer
        name:
          type: string
        recipient:
          type: string
          nullable: true
        editor_ids:
          type: array
          items:
            type: integer
        reporter_ids:
          type: array
          items:
            type: integer
        deadline_count:
          type: integer
        next_deadline:
          type: object
          nullable: true
          description: The earliest Deadline due today or later
          properties:
            id:
              type: integer
            name:
              type: string
            submission_deadline:
              type: string
              format: date
        updated_at:
          type: string
          format: date-time
    PaginatedReportingCycles:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ReportingCycleSummary'
    Deadline:
      type: object
      description: One report owed in a Reporting Cycle
      properties:
        id:
          type: integer
        name:
          type: string
        report_template:
          allOf:
            - $ref: '#/components/schemas/NamedRecord'
          nullable: true
        timeframe_from:
          type: string
          format: date
          nullable: true
        timeframe_to:
          type: string
          format: date
          nullable: true
        submission_deadline:
          type: string
          format: date
          nullable: true
        projects:
          type: array
          description: Work to include
          items:
            $ref: '#/components/schemas/NamedRecord'
        albums:
          type: array
          description: Work to include
          items:
            $ref: '#/components/schemas/NamedRecord'
        exclusive_focus_filter_data:
          type: object
          description: Exclusive Focus, the Contact filters the report is limited to
        reporting_guidance:
          type: string
          nullable: true
        nuance:
          type: string
          nullable: true
        editors:
          type: array
          items:
            $ref: '#/components/schemas/NamedRecord'
        reporters:
          type: array
          items:
            $ref: '#/components/schemas/NamedRecord'
    ReportingCycle:
      type: object
      description: A series of reports owed to one recipient
      properties:
        id:
          type: integer
        charity_id:
          type: integer
        name:
          type: string
        recipient:
          type: string
          nullable: true
        reporting_guidance:
          type: string
          nullable: true
        nuance:
          type: string
          nullable: true
        editors:
          type: array
          items:
            $ref: '#/components/schemas/NamedRecord'
        reporters:
          type: array
          items:
            $ref: '#/components/schemas/NamedRecord'
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/Deadline'
        updated_at:
          type: string
          format: date-time
    ReportingCycleInput:
      type: object
      properties:
        charity_id:
          type: integer
          description: The organisation, when creating
        name:
          type: string
        recipient:
          type: string
        reporting_guidance:
          type: string
        nuance:
          type: string
        editor_ids:
          type: array
          items:
            type: integer
        reporter_ids:
          type: array
          items:
            type: integer
        deadlines:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                description: An existing Deadline, to change or remove it
              _destroy:
                type: boolean
              name:
                type: string
              report_template_id:
                type: integer
              timeframe_from:
                type: string
                format: date
              timeframe_to:
                type: string
                format: date
              submission_deadline:
                type: string
                format: date
              project_ids:
                type: array
                items:
                  type: integer
              album_ids:
                type: array
                items:
                  type: integer
              exclusive_focus_filter_data:
                type: object
              reporting_guidance:
                type: string
              nuance:
                type: string
              editor_ids:
                type: array
                items:
                  type: integer
              reporter_ids:
                type: array
                items:
                  type: integer
    RequirementSet:
      type: object
      description: A funder's reporting requirements for a programme, and the metrics that answer each
      properties:
        id:
          type: integer
        charity_id:
          type: integer
        name:
          type: string
        recipient:
          type: string
          description: Who the requirements are for, e.g. Comic Relief
        source_name:
          type: string
          nullable: true
        source_url:
          type: string
          nullable: true
          description: Link to the original
        reporting_cycle_id:
          type: integer
          nullable: true
        project_ids:
          type: array
          items:
            type: integer
        album_ids:
          type: array
          items:
            type: integer
        requirements_count:
          type: integer
        covered_count:
          type: integer
          description: Requirements with at least one metric linked
        updated_at:
          type: string
          format: date-time
        requirements:
          type: array
          items:
            $ref: '#/components/schemas/Requirement'
    Requirement:
      type: object
      properties:
        id:
          type: integer
        position:
          type: integer
        reference:
          type: string
          nullable: true
          example: KPI 3
        wording:
          type: string
        answer_shape:
          type: string
          nullable: true
          enum: [count, sum, average, ratio, share_meeting_threshold, change_over_time, breakdown, quote, null]
        answer_format:
          type: string
          nullable: true
          enum: [narrative, number, table, makerble_data, null]
        answer_preset:
          type: string
          nullable: true
          description: The Makerble data preset, for makerble_data
        recommended_source:
          type: object
          description: |
            Where the answer comes from. `kind` is `preset` (a Makerble data block), `tracker` (an
            existing tracker shown in a data block), `new_tracker` (a tracker FrameworkMaker would
            make), `tool` (a read tool used when the report is written) or `stories` (worked out from
            Stories, the last resort). ReportMaker also stores a `key` and a `label`, e.g.
            {"kind":"tracker","key":"CohortTracker","label":"From the Cohort Tracker 'Attending 80% or more'"}
        word_limit:
          type: integer
          nullable: true
        covered:
          type: boolean
          description: false means Not covered
        metrics:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum: [Change, Indicator, CohortTracker, WorkflowTracker, FormulaTracker, FilteredMetric]
              id:
                type: integer
              name:
                type: string
    RequirementSetInput:
      type: object
      properties:
        charity_id:
          type: integer
          description: The organisation, when creating
        name:
          type: string
        recipient:
          type: string
        source_name:
          type: string
        source_url:
          type: string
        reporting_cycle_id:
          type: integer
        project_ids:
          type: array
          items:
            type: integer
        album_ids:
          type: array
          items:
            type: integer
        requirements:
          type: array
          items:
            type: object
            required: [wording]
            properties:
              id:
                type: integer
              reference:
                type: string
              wording:
                type: string
              answer_shape:
                type: string
              answer_format:
                type: string
              answer_preset:
                type: string
              recommended_source:
                type: object
              word_limit:
                type: integer
              metrics:
                type: array
                items:
                  type: object
                  required: [type, id]
                  properties:
                    type:
                      type: string
                    id:
                      type: integer
    PaginatedRequirementSets:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/RequirementSet'
    ReportContent:
      type: object
      description: A Report's answer to one question of its Report Template
      properties:
        report_id:
          type: integer
        question_id:
          type: integer
        question_title:
          type: string
        expected_output_types:
          type: array
          items:
            type: string
        output_settings:
          $ref: '#/components/schemas/ReportOutputSettings'
        narrative_content:
          type: string
          nullable: true
        number_content:
          type: number
          nullable: true
        word_count:
          type: integer
        words_over_limit:
          type: integer
          nullable: true
          description: How many words the Narrative is over its limit; null within it
        table_columns:
          type: array
          description: The columns the table was saved under
          items:
            type: object
            properties:
              heading:
                type: string
              type:
                type: string
        table_rows:
          type: array
          items:
            type: array
            items: {}
        table_changed_in_template:
          type: boolean
          description: True when the template's columns changed after the table was saved
        ai_status:
          type: string
          enum: [not_requested, queued, writing, written, failed]
        data_gaps:
          type: array
          items:
            type: string
        updated_at:
          type: string
          format: date-time
          nullable: true
        data_status:
          type: string
          enum: [empty, queued, filling, filled, failed]
          description: Only for a question with a Makerble data block
        data_block:
          type: object
          nullable: true
          description: |
            The block's figures, frozen as they were taken until it is refreshed: columns
            ({key, label, type: text|number|percent|status}), rows, notes, missing_metrics and, for a
            chart display, chart ({type, labels, series}); or error when it couldn't fill. A figure about
            fewer than 5 Contacts is "<5".
        data_taken_at:
          type: string
          format: date-time
          nullable: true
        data_scope:
          type: object
          nullable: true
          description: The project_ids, bundle_ids, from, to and exclusive_focus the figures were taken at
        data_scope_changed:
          type: boolean
          description: True when the Report's scope has changed since the figures were taken
        data_settings:
          type: object
          nullable: true
          description: This Report's own metrics, chosen when the template's aren't the organisation's
        written_against_data_at:
          type: string
          format: date-time
          nullable: true
          description: When the Report's data blocks were last filled before the Narrative was written
    PaginatedReportContents:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ReportContent'

    PaginatedExploreReportTemplates:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreReportTemplate'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExploreFormPreview:
      allOf:
        - $ref: '#/components/schemas/ExploreForm'
        - type: object
          properties:
            fields:
              type: array
              items:
                type: string

    ExploreForm:
      type: object
      properties:
        id:
          type: string
          description: The form's key, naming its type and number, e.g. case-5
        name:
          type: string
        type:
          type: string
          enum: [contact_form, case_form, custom_contact_form, event_form, project_form]
        field_count:
          type: integer
          description: How many fields it asks, leaving out built-in fields and section headings
        uses_standard_dropdowns:
          type: boolean
          description: Whether any field uses a Dropdown from the ImpactStore
        themes:
          type: array
          items:
            type: string
            enum: [referral_and_intake, equality_monitoring, safeguarding, events, project_information]
        shared_by:
          type: string
          nullable: true
        used_by_count:
          type: integer
          description: How many organisations use it
        yours:
          type: boolean
          description: Whether one of the caller's organisations owns it
        public_url:
          type: string
          nullable: true
          description: Its public page, for Contact Forms and Case Forms

    PaginatedExploreForms:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreForm'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExploreDropdownPreview:
      allOf:
        - $ref: '#/components/schemas/ExploreDropdown'
        - type: object
          properties:
            choices:
              type: array
              items:
                type: string

    ExploreDropdown:
      type: object
      properties:
        id:
          type: integer
        title:
          type: string
        choice_count:
          type: integer
        designed_for:
          type: array
          items:
            type: string
            enum: [surveys_and_trackers, forms]
        themes:
          type: array
          items:
            type: string
            enum: [scales, demographics]
        shared_by:
          type: string
          nullable: true
        used_in_count:
          type: integer
          description: How many surveys, trackers and forms use it
        yours:
          type: boolean
          description: Whether the caller or one of the caller's organisations owns it

    PaginatedExploreDropdowns:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreDropdown'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExploreImpactFrameworkPreview:
      allOf:
        - $ref: '#/components/schemas/ExploreImpactFramework'
        - type: object
          properties:
            stages:
              type: array
              items:
                type: object
                properties:
                  title:
                    type: string
                  items:
                    type: array
                    items:
                      type: string

    ExploreImpactFramework:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        description:
          type: string
          nullable: true
        themes:
          type: array
          items:
            type: string
        framework_sets:
          type: array
          description: The platform-wide Framework Sets it belongs to
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string
              short_code:
                type: string
                nullable: true
        outcome_count:
          type: integer
        progress_tracker_count:
          type: integer
        shared_by:
          type: string
          nullable: true
        libraries_count:
          type: integer
          description: How many organisations use it on a project
        yours:
          type: boolean
          description: Whether the caller or one of the caller's organisations owns it

    PaginatedExploreImpactFrameworks:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreImpactFramework'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExpertProfile:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
          description: The Expert's organisation
        level:
          type: string
          enum: [Certified Implementer, Makerble Expert]
        headline:
          type: string
          nullable: true
        bio:
          type: string
          nullable: true
          description: About the Expert, up to 600 characters
        logo_url:
          type: string
          nullable: true
        how_they_work:
          type: string
          nullable: true
          description: Remotely, in person in named places, or both
        taking_introductions:
          type: boolean
          description: False while the Expert is Paused
        reviewed_on:
          type: string
          format: date
          nullable: true
          description: When the Makerble team reviewed and listed the Expert
        website:
          type: string
          nullable: true
        typical_project_size:
          type: string
          nullable: true
        profile_url:
          type: string
          description: The Expert profile page
        services:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              name:
                type: string
              description:
                type: string
                nullable: true
                description: The service in the Expert's own words
        certified_people:
          type: array
          description: The organisation's people whose Certified Implementer certification is current
          items:
            type: object
            properties:
              name:
                type: string
              certified_until:
                type: string
                format: date
        ideas:
          type: array
          description: The organisation's newest Ideas listed on Explore Ideas (up to 6)
          items:
            type: object
            properties:
              id:
                type: integer
              title:
                type: string
              yours:
                type: boolean
        toolkits:
          type: array
          description: Toolkits listed in the ImpactStore that the Expert knows
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string

    ExploreIdeaPreview:
      allOf:
        - $ref: '#/components/schemas/ExploreIdea'
        - type: object
          properties:
            text:
              type: string

    ExploreIdea:
      type: object
      properties:
        id:
          type: integer
        title:
          type: string
        themes:
          type: array
          items:
            type: string
        reading_minutes:
          type: integer
        shared_by:
          type: string
          nullable: true
        saved_count:
          type: integer
          description: How many collections it has been saved to
        yours:
          type: boolean
          description: Whether the caller or one of the caller's organisations owns it

    PaginatedExploreIdeas:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreIdea'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExploreMetricPreview:
      allOf:
        - $ref: '#/components/schemas/ExploreMetric'
        - type: object
          properties:
            description:
              type: string
              nullable: true
            details:
              type: object
              description: The metric's key facts, by label
              additionalProperties:
                type: string
            choices:
              type: array
              items:
                type: string

    ExploreMetric:
      type: object
      properties:
        kind:
          type: string
          enum: [change, indicator, financial_value]
        id:
          type: integer
        name:
          type: string
        stage:
          type: string
          enum: [activities, engagement, ability, behaviour, effect, financial_values]
        whats_inside:
          type: string
          description: The tracker type or scale, e.g. "5-level scale" or "Activity tracker · count"
        shared_by:
          type: string
          nullable: true
        libraries_count:
          type: integer
          description: How many organisations use it on a project
        yours:
          type: boolean
          description: Whether the caller or one of the caller's organisations owns it

    PaginatedExploreMetrics:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/ExploreMetric'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/ExploreFacetGroup'

    ExploreSurveyPreview:
      allOf:
        - $ref: '#/components/schemas/ExploreSurvey'
        - type: object
          properties:
            sections:
              type: array
              items:
                type: object
                properties:
                  title:
                    type: string
                    nullable: true
                  questions:
                    type: array
                    items:
                      type: string

    PaginatedLibrarySearch:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/LibrarySearchResult'

    ForceCreate:
      type: boolean
      default: false
      description: Create it even though an item with a near-identical name exists (see the 409 response)

    SurveyDraftQuestion:
      type: object
      description: One question. Give exactly one of metric_id, field_id, activity_tracker_id, new_metric or new_field.
      properties:
        metric_id:
          type: integer
        field_id:
          type: integer
        activity_tracker_id:
          type: integer
        new_metric:
          type: object
          required: [name, metric_type, default_question, outcome_id]
          properties:
            name:
              type: string
            metric_type:
              type: string
              enum: [scale, value, binary]
            default_question:
              type: string
            list_id:
              type: integer
              description: Scale only
            list:
              type: object
              description: Scale only, instead of list_id
              required: [name, choices]
              properties:
                name:
                  type: string
                choices:
                  type: array
                  maxItems: 50
                  items: {type: string}
            outcome_id:
              type: integer
            unit_id:
              type: integer
              description: Value only
            success_direction:
              type: string
              enum: [top to bottom, bottom to top, none]
            description:
              type: string
            points:
              type: object
              description: Scale only, for a scored Survey. Whole-number points for every answer on its List.
              additionalProperties: {type: integer}
              example: {"Never": 0, "Sometimes": 1, "Often": 2}
        new_field:
          type: object
          required: [field_name, field_data_type]
          properties:
            field_name:
              type: string
            field_data_type:
              type: string
              enum: [text, number, date, time, file, section_title, email_address, telephone]
            section_text:
              type: string
            private:
              type: boolean
        is_mandatory:
          type: boolean
        choice:
          type: string
          enum: [single_choice, unlimited_choice, limited_choice]
          description: Scale Metrics only (default single_choice)
        choice_value:
          type: integer
          description: With limited_choice, how many answers may be picked
        external_description:
          type: string
        internal_description:
          type: string
        by_interval:
          type: array
          description: Needs the Survey's `intervals`. How the question is reworded or hidden in them.
          items:
            $ref: '#/components/schemas/SurveyIntervalWording'
        only_in_intervals:
          type: array
          description: Needs the Survey's `intervals`. Show the question only in these.
          items: {type: string}
        display_if:
          description: Display If. Show the question only when an earlier scale question is answered with one of the answers; a list is met when any one is.
          oneOf:
            - $ref: '#/components/schemas/SurveyCondition'
            - type: array
              items:
                $ref: '#/components/schemas/SurveyCondition'
        skip_to:
          type: array
          description: Skip To, on a scale question. For these answers, jump to a later question that isn't mandatory.
          items:
            type: object
            required: [answers, question]
            properties:
              answers:
                type: array
                items: {type: string}
                example: ["No"]
              question:
                type: integer
                example: 6

    SurveyCondition:
      type: object
      required: [question, answers]
      properties:
        question:
          type: integer
          description: The earlier question's number, counting section headings
          example: 2
        answers:
          type: array
          description: Answers from that question's List
          items: {type: string}
          example: ["No"]

    SurveyIntervalWording:
      type: object
      description: |
        How a question reads in an Interval, for a kind of respondent. Give `question` or `hide: true`.
        Leave out `interval` for every Interval and `respondent` for everyone. When reading a Survey,
        a respondent type set up for a relationship (e.g. "Parent") is given as stored.
      properties:
        interval:
          type: string
          example: Endpoint
        respondent:
          type: string
          description: participant (the Contact), colleague, observer (a 360° observer) or public (anyone with the universal link)
          example: participant
        question:
          type: string
          example: How confident do you feel about getting a job now, after the course?
        hide:
          type: boolean

    ContactFormDraftQuestion:
      type: object
      description: One field. Give exactly one of field_id, list_id, new_field or new_list.
      properties:
        field_id:
          type: integer
        list_id:
          type: integer
        new_field:
          type: object
          required: [field_name, field_data_type]
          properties:
            field_name:
              type: string
            field_data_type:
              type: string
              enum: [text, number, date, time, file, section_title, email_address, telephone, signature, weekly_availability]
              description: "`weekly_availability` asks for the days and times a Contact can usually attend. It can only be made on a Contact Form."
            section_text:
              type: string
            private:
              type: boolean
        new_list:
          type: object
          required: [name, choices]
          properties:
            name:
              type: string
            choices:
              type: array
              maxItems: 50
              items: {type: string}
        is_mandatory:
          type: boolean
        choice:
          type: string
          enum: [single_choice, unlimited_choice, limited_choice]
        choice_value:
          type: integer
        layout:
          type: string
          enum: [compact, expanded]
        external_description:
          type: string
        internal_description:
          type: string

    ImpactFrameworkDraftEntry:
      type: object
      description: One entry. Give a stage and exactly one of activity_tracker_id, new_activity_tracker, outcome_id or new_outcome.
      required: [stage]
      properties:
        stage:
          type: string
          enum: [Activity outputs, Participation outputs, Short-term outcomes, Medium-term outcomes, Long-term outcomes]
        activity_tracker_id:
          type: integer
        new_activity_tracker:
          type: object
          required: [name, category]
          properties:
            name:
              type: string
            category:
              type: string
              description: The cause area it belongs to (Make Change Category), e.g. Education
            description:
              type: string
            instruction:
              type: string
        outcome_id:
          type: integer
        new_outcome:
          type: object
          required: [title]
          properties:
            title:
              type: string
            description:
              type: string
            instruction:
              type: string
        indicator_ids:
          type: array
          minItems: 1
          items: {type: integer}
          description: Outcome entries only. Existing Metrics (Indicators). With outcome_id, only these of its Metrics (and any new_metrics) are taken instead of all of them; with new_outcome, they are linked to it without being copied.
        new_metrics:
          type: array
          description: Outcome entries only
          items:
            type: object
            required: [name, metric_type, default_question]
            properties:
              name:
                type: string
              metric_type:
                type: string
                enum: [scale, value, binary]
              default_question:
                type: string
              list_id:
                type: integer
              list:
                type: object
                required: [name, choices]
                properties:
                  name:
                    type: string
                  choices:
                    type: array
                    items: {type: string}
              unit_id:
                type: integer
              success_direction:
                type: string
                enum: [top to bottom, bottom to top, none]
              description:
                type: string

    LibraryItem:
      type: object
      description: A library item in full. The fields beyond these depend on `type`; see **Get a library item**.
      additionalProperties: true
      properties:
        id:
          type: integer
        type:
          type: string
        name:
          type: string
          nullable: true
        owner:
          type: string
          enum: [your organisation, public library, Makerble]

    LibraryUsage:
      type: object
      properties:
        id:
          type: integer
        type:
          type: string
        name:
          type: string
          nullable: true
        projects:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string
                nullable: true
        other_projects_count:
          type: integer
        records_count:
          type: integer
        last_used_at:
          type: string
          format: date-time
          nullable: true
        contained_in:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              id:
                type: integer
              name:
                type: string
                nullable: true
        contained_in_count:
          type: integer
        in_use:
          type: boolean

    ContactSummaryResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ready, stale, pending, failed, empty]
        new_story_count:
          type: integer
          description: Stories you can see that were added since this summary was made
        summary:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/ContactSummary'

    ContactSummary:
      type: object
      properties:
        id:
          type: integer
        generated_at:
          type: string
          format: date-time
        model:
          type: string
          example: claude-haiku-4-5-20251001
        source_story_ids:
          type: array
          items:
            type: integer
          description: The Stories the summary was made from
        sections:
          type: array
          items:
            type: object
            properties:
              heading:
                type: string
                enum: [Who, Progress, Watch for]
              text:
                type: string
              bio:
                type: boolean
                description: True if any sentence in the section came from the bio
              story_ids:
                type: array
                items:
                  type: integer
              sentences:
                type: array
                items:
                  type: object
                  properties:
                    text:
                      type: string
                    bio:
                      type: boolean
                    story_ids:
                      type: array
                      items:
                        type: integer

    CustomTableColumn:
      type: object
      description: One column, as listed by GET /custom_tables/available_columns.
      required: [class_name, field_name]
      properties:
        class_name:
          type: string
          description: "What the column shows: Beneficiary (a basic Contact field), CustomField or RatioSet (a question), Indicator (a progress tracker), Change, Story, Case, Project, Witness or RelationshipCategory"
        field_name:
          type: string
          description: Which value of it, e.g. name, most_recent_value or total_value
        field_id:
          type: string
          description: The ID of the question, tracker or relationship category; empty for fixed columns
        display_name:
          type: string
          description: The column heading
        relationship_category_id:
          type: string
        relationship_role:
          type: string
        category_name:
          type: string
        field_ids:
          type: array
          items: {}

    CustomTable:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        charity_id:
          type: integer
        owner:
          type: string
          enum: [User, Charity]
        created_by:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
              nullable: true
        visibility:
          type: string
          enum: [only_me, charity_colleagues, individual_list, specific_teams]
        individual_list:
          type: array
          description: User IDs who see the table when visibility is individual_list
          items:
            type: integer
        team_ids:
          type: array
          description: IDs of the Teams who see the table when visibility is specific_teams
          items:
            type: integer
        teams:
          type: array
          description: The Teams who see the table when visibility is specific_teams
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string
        can_edit:
          type: boolean
          description: Whether the user may change or delete the table
        columns:
          type: array
          items:
            $ref: '#/components/schemas/CustomTableColumn'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CustomTableList:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/CustomTable'

    CustomTableAttributes:
      type: object
      properties:
        name:
          type: string
        owner:
          type: string
          enum: [User, Charity]
        visibility:
          type: string
          enum: [charity_colleagues, individual_list, specific_teams]
          description: charity_colleagues is for Organisation editors only
        individual_list:
          type: array
          items:
            type: integer
        team_ids:
          type: array
          description: The Teams who see the table when visibility is specific_teams (at least one)
          items:
            type: integer
        columns:
          type: array
          items:
            $ref: '#/components/schemas/CustomTableColumn'

    CustomTableCreateRequest:
      type: object
      required: [custom_table]
      properties:
        custom_table:
          allOf:
            - $ref: '#/components/schemas/CustomTableAttributes'
            - type: object
              required: [charity_id, name]
              properties:
                charity_id:
                  type: integer

    CustomTableUpdateRequest:
      type: object
      required: [custom_table]
      properties:
        custom_table:
          $ref: '#/components/schemas/CustomTableAttributes'

    CustomTableAvailableColumns:
      type: object
      properties:
        charity_id:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              group:
                type: string
              columns:
                type: array
                items:
                  $ref: '#/components/schemas/CustomTableColumn'

    CustomTableRows:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        headers:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              class_name:
                type: string
              field_name:
                type: string
              field_id:
                type: string
        data:
          type: array
          items:
            type: object
            properties:
              contact_id:
                type: integer
              contact_name:
                type: string
              values:
                type: array
                description: One value per heading, in the same order; null when there is none
                items:
                  nullable: true

    Error:
      type: object
      properties:
        error:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string

    Timestamps:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
          example: "2024-01-15T09:30:00.000+00:00"
        updated_at:
          type: string
          format: date-time
          example: "2024-01-15T09:30:00.000+00:00"

    EventSummary:
      type: object
      description: An event, as listed on Manage Events.
      properties:
        id: { type: integer }
        name: { type: string }
        charity_id: { type: integer }
        start_datetime: { type: string, format: date-time }
        end_datetime: { type: string, format: date-time }
        timezone: { type: string, nullable: true, description: "IANA time zone the event is held in" }
        location: { type: string, nullable: true }
        event_type:
          type: string
          enum: [one-off, master, subsequent]
          description: "`master` is the first event of a recurring series; `subsequent` are the rest"
        listing_enabled: { type: boolean, description: "Whether the event appears in Events Catalogues" }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
        project:
          type: object
          properties:
            id: { type: integer }
            name: { type: string }
        event_category:
          type: object
          description: The Event Format
          properties:
            id: { type: integer }
            name: { type: string }
        master_event_id: { type: integer, nullable: true, description: "For a subsequent event, the master event of its series" }
        guests_count: { type: integer }
        managers_count: { type: integer }
        workers_count: { type: integer }

    Event:
      allOf:
        - $ref: '#/components/schemas/EventSummary'
        - type: object
          properties:
            can_edit: { type: boolean }
            can_delete: { type: boolean }
            recurring_schedule:
              type: object
              nullable: true
              description: For a master event, the rule its series repeats by
              properties:
                rule: { type: object, description: "The IceCube rule" }
                description: { type: string, example: "Weekly on Tuesdays" }
                frequency: { type: string, enum: [daily, weekly, monthly, yearly] }
                interval: { type: integer }
                days_of_week: { type: array, items: { type: string } }
                days_of_month: { type: array, items: { type: integer } }
            recurring_end_date: { type: string, format: date, nullable: true }
            series_events_count: { type: integer, nullable: true, description: "Events in this event's series, or null for a one-off event" }
            custom_fields:
              type: array
              items:
                type: object
                properties:
                  id: { type: integer, description: "Custom field id" }
                  name: { type: string }
                  value: { nullable: true, description: "The value; a file is an object with url and file_name" }
            dropdowns:
              type: array
              items:
                type: object
                properties:
                  id: { type: integer, description: "Dropdown (Ratio Set) id" }
                  name: { type: string }
                  answer_choices:
                    type: array
                    items:
                      type: object
                      properties:
                        id: { type: integer, description: "Answer choice (Sub Ratio) id" }
                        name: { type: string }
            signup_page:
              type: object
              nullable: true
              description: The Signup Page (Referral Link Detail) people register through
              properties:
                id: { type: integer }
                name: { type: string }
            self_check_in:
              type: object
              nullable: true
              description: The Survey (and Wave) guests answer when they check themselves in
              properties:
                survey:
                  type: object
                  properties:
                    id: { type: integer, description: "Survey (Story Category) id" }
                    name: { type: string }
                    project_survey_id: { type: integer, description: "The Survey's link to the project (Project Story Category)" }
                wave:
                  type: object
                  nullable: true
                  properties:
                    id: { type: integer }
                    name: { type: string }
            capacity:
              type: object
              properties:
                guests: { type: string, enum: [fixed, unlimited] }
                max_guests: { type: integer }
                allow_signup_after_full: { type: boolean }
                guest_status_for_signup_id: { type: integer, nullable: true, description: "Guest Status (Event State) for people who sign up while there is space" }
                guest_status_after_full_id: { type: integer, nullable: true, description: "Guest Status for people who sign up once the event is full" }
                confirmation_message_after_full: { type: string, nullable: true }
                thank_you_message: { type: string, nullable: true }
                workers: { type: string, enum: [fixed, unlimited] }
                max_workers: { type: integer }
                timesheets_for_workers: { type: boolean }
                timesheets_for_guests: { type: boolean }
            listing:
              type: object
              properties:
                listing_enabled: { type: boolean }
                location: { type: string, nullable: true }
                description: { type: string, nullable: true, description: "HTML" }
                image_url: { type: string, nullable: true }
            links:
              type: object
              description: Links to share with guests; null when the event has no such page
              properties:
                self_check_in: { type: string, nullable: true }
                signup: { type: string, nullable: true }
                signup_and_self_check_in: { type: string, nullable: true }

    PaginatedEvents:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/EventSummary'

    ProjectEventFormat:
      type: object
      required: [id, name, is_default]
      properties:
        id:
          type: integer
          example: 42
        name:
          type: string
          example: "Drop-in Session"
        is_default:
          type: boolean
          example: false

    PaginatedProjectEventFormats:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ProjectEventFormat'

    IdAndName:
      type: object
      required: [id, name]
      properties:
        id:
          type: integer
          example: 7
        name:
          type: string
          example: "Booked"

    EventFormField:
      type: object
      required: [name, kind, field_id, data_type, mandatory, priority, validation_hint, dropdown]
      properties:
        name:
          type: string
          description: The event attribute (name, start_datetime, end_datetime), or the custom field's or Dropdown's name.
          example: "Session type"
        kind:
          type: string
          enum: [event_attribute, custom_field, dropdown]
        field_id:
          type: integer
          nullable: true
          description: The custom field's id, or the Dropdown's (Ratio Set's) id. Null for an event attribute.
          example: 15
        data_type:
          type: string
          description: datetime or text for an event attribute; the custom field's type (date, number, text, tickbox, ward, ...); or dropdown.
          example: "dropdown"
        mandatory:
          type: boolean
        priority:
          type: integer
          nullable: true
          example: 4
        validation_hint:
          type: string
          nullable: true
          description: The rule a custom field's answer must follow, as the form shows it.
          example: "Must contain exactly 3 letters and numbers"
        dropdown:
          type: object
          nullable: true
          required: [choice, choice_limit, options]
          properties:
            choice:
              type: string
              enum: [single_choice, unlimited_choice, limited_choice]
            choice_limit:
              type: integer
              nullable: true
              description: How many options may be chosen, for limited_choice.
              example: 2
            options:
              type: array
              description: The answer choices (Sub Ratios).
              items:
                $ref: '#/components/schemas/IdAndName'

    EventForm:
      type: object
      required: [project, event_category, event_id, fields, self_check_in, signup_pages, guest_statuses, event_roles]
      properties:
        project:
          $ref: '#/components/schemas/IdAndName'
        event_category:
          $ref: '#/components/schemas/IdAndName'
        event_id:
          type: integer
          nullable: true
          example: null
        fields:
          type: array
          items:
            $ref: '#/components/schemas/EventFormField'
        self_check_in:
          type: object
          required: [enabled, surveys, waves]
          properties:
            enabled:
              type: boolean
              description: Whether the Event Format has Self Check-in (Survey Kiosk) turned on.
            surveys:
              type: array
              items:
                type: object
                required: [project_story_category_id, story_category_id, name]
                properties:
                  project_story_category_id:
                    type: integer
                    example: 2053
                  story_category_id:
                    type: integer
                    example: 2136
                  name:
                    type: string
                    example: "Attendance"
            waves:
              type: array
              items:
                type: object
                required: [id, name, story_category_id, project_story_category_id]
                properties:
                  id:
                    type: integer
                    example: 31
                  name:
                    type: string
                    example: "Week 1"
                  story_category_id:
                    type: integer
                    nullable: true
                    example: 2136
                  project_story_category_id:
                    type: integer
                    nullable: true
                    example: 2053
        signup_pages:
          type: array
          description: The Project's active Signup Pages (Referral Link Details).
          items:
            $ref: '#/components/schemas/IdAndName'
        guest_statuses:
          type: array
          description: The Event Format's Guest Statuses (Event States), in order. The first is the default for people who sign up.
          items:
            $ref: '#/components/schemas/IdAndName'
        event_roles:
          type: object
          required: [enabled, guests, event_managers_and_workers]
          properties:
            enabled:
              type: boolean
            guests:
              type: array
              items:
                $ref: '#/components/schemas/IdAndName'
            event_managers_and_workers:
              type: array
              items:
                $ref: '#/components/schemas/IdAndName'

    RecurringScheduleInput:
      type: object
      required: [frequency]
      description: How a recurring series repeats.
      properties:
        frequency: { type: string, enum: [daily, weekly, monthly, yearly] }
        interval: { type: integer, minimum: 1, default: 1, description: "Every this many days, weeks, months or years" }
        days_of_week:
          type: array
          description: Weekly series only
          items: { type: string, enum: [sunday, monday, tuesday, wednesday, thursday, friday, saturday] }
        days_of_month:
          type: array
          description: Monthly series only; -1 is the last day of the month
          items: { type: integer }

    EventUpdateRequest:
      type: object
      properties:
        event_category_id: { type: integer, description: "The Event Format (event category); one of the project's" }
        name: { type: string }
        start_datetime: { type: string, example: "2030-01-08T18:00", description: "ISO 8601; without an offset it is local to timezone" }
        end_datetime: { type: string, example: "2030-01-08T20:00" }
        timezone: { type: string, example: "Europe/London", description: "IANA time zone name" }
        location: { type: string }
        custom_fields:
          type: object
          description: "Custom field id => value. Dates are YYYY-MM-DD, times HH:MM, tickboxes true or false."
          additionalProperties: true
        dropdowns:
          type: object
          description: "Dropdown (ratio set) id => answer choice (sub ratio) ids, within the Dropdown's choice rule"
          additionalProperties: { type: array, items: { type: integer } }
        manager_ids: { type: array, items: { type: integer }, description: "Event Managers: colleagues in the project or organisation; at least one" }
        worker_ids: { type: array, items: { type: integer }, description: "Event Workers: colleagues in the project or organisation" }
        signup_page_id: { type: integer, nullable: true, description: "One of the project's active Signup Pages (referral link details)" }
        guest_status_for_signup_id: { type: integer, nullable: true, description: "Guest Status (event state) for people who sign up while there is space" }
        self_check_in:
          type: object
          nullable: true
          description: The Self Check-in (kiosk) Survey and Wave, when the Event Format has Self Check-in turned on
          properties:
            project_story_category_id: { type: integer }
            wave_id: { type: integer, nullable: true }
        capacity:
          type: object
          properties:
            guests: { type: string, enum: [fixed, unlimited] }
            max_guests: { type: integer, minimum: 0 }
            allow_signup_after_full: { type: boolean }
            guest_status_after_full_id: { type: integer, nullable: true }
            confirmation_message_after_full: { type: string }
            thank_you_message: { type: string }
            workers: { type: string, enum: [fixed, unlimited] }
            max_workers: { type: integer, minimum: 0 }
            timesheets_for_workers: { type: boolean }
            timesheets_for_guests: { type: boolean }
        listing:
          type: object
          properties:
            listing_enabled: { type: boolean, description: "Needs a Signup Page" }
            description: { type: string, description: "HTML" }
        apply_to: { type: string, enum: [this_event, all_events_in_series], default: this_event }
        recurring_schedule:
          allOf: [{ $ref: '#/components/schemas/RecurringScheduleInput' }]
          description: "Master event only: a new Recurring Schedule for the whole series"
        recurring_end_date: { type: string, format: date, description: "Master event only: a new Recurring End Date for the whole series" }
        keep_event_ids: { type: array, items: { type: integer }, description: "With a schedule change: events that no longer fit, to keep" }
        delete_event_ids: { type: array, items: { type: integer }, description: "With a schedule change: events that no longer fit, to delete" }

    SeriesScheduleChangeRequest:
      type: object
      properties:
        recurring_schedule: { $ref: '#/components/schemas/RecurringScheduleInput' }
        recurring_end_date: { type: string, format: date, example: "2030-02-05" }

    SeriesSchedulePreview:
      type: object
      required: [master_event_id, recurring_schedule, recurring_end_date, required_dates, no_longer_fitting_events]
      properties:
        master_event_id: { type: integer }
        recurring_schedule:
          type: object
          properties:
            frequency: { type: string, enum: [daily, weekly, monthly, yearly] }
            interval: { type: integer }
            days_of_week: { type: array, items: { type: string } }
            days_of_month: { type: array, items: { type: integer } }
            description: { type: string, example: "Every 2 weeks on Tuesdays" }
        recurring_end_date: { type: string, format: date }
        required_dates:
          type: array
          items:
            type: object
            required: [start_datetime, event_id, exists]
            properties:
              start_datetime: { type: string, format: date-time }
              event_id: { type: integer, nullable: true }
              exists: { type: boolean }
        no_longer_fitting_events:
          type: array
          items:
            type: object
            required: [id, name, start_datetime, has_stories, has_timesheets]
            properties:
              id: { type: integer }
              name: { type: string }
              start_datetime: { type: string, format: date-time }
              has_stories: { type: boolean }
              has_timesheets: { type: boolean }

    EventGuest:
      type: object
      required: [contact_id, name, guest_status, event_role, added_at, updated_at]
      properties:
        contact_id: { type: integer, description: "The Contact (beneficiary) id" }
        name: { type: string }
        guest_status:
          type: object
          nullable: true
          properties: { id: { type: integer }, name: { type: string } }
        event_role:
          type: object
          nullable: true
          properties: { id: { type: integer }, name: { type: string } }
        added_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    EventGuestCount:
      type: object
      required: [event_id, guests_count]
      properties:
        event_id: { type: integer }
        guests_count: { type: integer }

    BeneficiaryBulkAction:
      type: object
      description: A change to many Contacts at once, and how far it has got
      properties:
        id:
          type: integer
        status:
          type: string
          enum: [pending, running, completed, failed, undone]
        total_count:
          type: integer
          description: Contacts it will try to change (the selection, less Headline Only Contacts)
        processed_count:
          type: integer
          description: Contacts reached so far
        changed_count:
          type: integer
          description: Contacts it changed
        skip_counts:
          type: object
          additionalProperties: { type: integer }
          description: Skipped Contacts by reason, e.g. headline_only, not_in_project or error
        background:
          type: boolean
          description: True when it runs in the background (more than 50 Contacts)
        summary:
          type: string
          nullable: true
          description: The finished message, e.g. "6 contacts changed. 1 skipped …"; null until it has finished

    EventGuestsBulkAdd:
      allOf:
        - $ref: '#/components/schemas/BeneficiaryBulkAction'
        - type: object
          properties:
            event_id: { type: integer }
            guests_count:
              type: integer
              description: The event's guests now (while it runs in the background, so far)

    EventStaffMember:
      type: object
      required: [user_id, name, roles, event_role]
      properties:
        user_id: { type: integer }
        name: { type: string }
        roles: { type: array, items: { type: string, enum: [manager, worker] } }
        event_role:
          type: object
          nullable: true
          properties: { id: { type: integer }, name: { type: string } }

    EventCreateRequest:
      allOf:
        - $ref: '#/components/schemas/EventUpdateRequest'
        - type: object
          required: [project_id, event_category_id, name, start_datetime, end_datetime]
          properties:
            project_id: { type: integer }
            recurring_schedule:
              $ref: '#/components/schemas/RecurringScheduleInput'
            recurring_end_date: { type: string, format: date, description: "Last day of the series; required with recurring_schedule" }

    PaginationEnvelope:
      type: object
      properties:
        page:
          type: integer
          example: 1
        page_size:
          type: integer
          example: 10
        page_count:
          type: integer
          example: 42
        total_count:
          type: integer
          example: 418

    PaginatedGeneric:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                type: object

    PaginatedProjectResults:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            start_date:
              type: string
              format: date
              nullable: true
              example: "2026-04-01"
            end_date:
              type: string
              format: date
              nullable: true
              example: "2027-03-31"
            project_ids:
              type: array
              items:
                type: integer
              example: [619]
            data:
              type: array
              items:
                $ref: '#/components/schemas/ProjectResultsTracker'

    PaginatedDistanceTravelled:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            start_date:
              type: string
              format: date
              nullable: true
              example: "2026-04-01"
            end_date:
              type: string
              format: date
              nullable: true
              example: "2027-03-31"
            project_ids:
              type: array
              items:
                type: integer
              example: [619]
            data:
              type: array
              items:
                $ref: '#/components/schemas/DistanceTravelledTracker'
            skipped_trackers:
              type: array
              description: Only when tracker_ids is given. Chosen Choice trackers left out because they have no success direction.
              items:
                type: object
                properties:
                  tracker_id:
                    type: integer
                    example: 363
                  tracker_name:
                    type: string
                    example: Attended with a carer
                  reason:
                    type: string
                    example: No success direction is set, so there is no better or worse answer

    PaginatedSessionsAndAttendance:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            start_date:
              type: string
              format: date
              nullable: true
              example: "2026-04-01"
            end_date:
              type: string
              format: date
              nullable: true
              example: "2027-03-31"
            project_ids:
              type: array
              items:
                type: integer
              example: [619]
            group_by:
              type: string
              nullable: true
              enum: [project, event_format, month]
              example: month
            totals:
              $ref: '#/components/schemas/SessionsAndAttendanceFigures'
            data:
              type: array
              description: One row per group; empty without group_by.
              items:
                allOf:
                  - type: object
                    properties:
                      group:
                        description: The month (YYYY-MM), or the Project's or Event format's id and name.
                        oneOf:
                          - type: string
                            example: "2026-04"
                          - type: object
                            properties:
                              id:
                                type: integer
                                example: 619
                              name:
                                type: string
                                example: Youth club
                  - $ref: '#/components/schemas/SessionsAndAttendanceFigures'

    SessionsAndAttendanceFigures:
      type: object
      description: Events run and attendance for a set of Events.
      properties:
        events_scheduled:
          type: integer
          example: 24
        events_held:
          type: integer
          example: 20
        hours_delivered:
          type: number
          example: 40.5
        invited_contacts:
          type: integer
          example: 61
        attending_contacts:
          type: integer
          example: 48
        attendance_rates:
          type: array
          items:
            type: object
            properties:
              tracker_id:
                type: integer
                example: 1204
              tracker_name:
                type: string
                example: Session attendance
              invited_contacts:
                type: integer
                example: 61
              attendances:
                type: integer
                example: 9
              invitations:
                type: integer
                example: 21
              attendance_rate:
                type: number
                nullable: true
                example: 42.9

    DistanceTravelledTracker:
      type: object
      description: Distance travelled on one Choice tracker.
      properties:
        tracker_id:
          type: integer
          description: The Indicator ID
          example: 362
        tracker_name:
          type: string
          example: Confidence
        success_direction:
          type: string
          enum: [bottom to top, top to bottom]
          example: bottom to top
        success_direction_meaning:
          type: string
          nullable: true
          example: The last answer (Very confident) is the best
        contacts_answered:
          type: integer
          description: Contacts who answered at least once in the period
          example: 27
        judged_contacts:
          type: integer
          description: Contacts with two or more answers in the period
          example: 18
        not_judged:
          type: integer
          description: Contacts with only one answer in the period
          example: 9
        improved:
          $ref: '#/components/schemas/DistanceTravelledShare'
        no_change:
          $ref: '#/components/schemas/DistanceTravelledShare'
        worsened:
          $ref: '#/components/schemas/DistanceTravelledShare'
        answers:
          type: array
          description: For each answer (Sub Ratio), in the tracker's order, how many judged Contacts gave it first and last.
          items:
            type: object
            properties:
              answer:
                type: string
                example: Very confident
              first:
                type: integer
                example: 2
              latest:
                type: integer
                example: 6

    DistanceTravelledShare:
      type: object
      properties:
        count:
          type: integer
          example: 2
        percent:
          type: number
          nullable: true
          description: Percent of judged_contacts, to one decimal place. null when no Contact was judged.
          example: 11.1

    ProjectResultsTracker:
      type: object
      description: One tracker on the Results Canvas. Which figures appear depends on tracker_type.
      properties:
        tracker_type:
          type: string
          enum: [Activity tracker, Engagement tracker, Achievement tracker, Choice tracker, Numerical tracker]
          example: Activity tracker
        backend_type:
          type: string
          example: Change of Activity type
        tracker_id:
          type: integer
          description: The Change ID (Activity and Engagement trackers) or Indicator ID (the others)
          example: 1201
        tracker_name:
          type: string
          example: Sessions delivered
        outcome_name:
          type: string
          description: The Outcome an Indicator sits under
          example: Into employment
        times_recorded:
          type: integer
          example: 13
        contacts:
          type: integer
          example: 6
        contacts_achieved:
          type: integer
        answers:
          type: array
          items:
            type: object
            properties:
              sub_ratio_id:
                type: integer
              sub_ratio:
                type: string
                example: High
              count:
                type: integer
              contacts:
                type: integer
        total:
          type: number
        average_per_contact:
          type: number
          nullable: true
        anonymous_count:
          type: integer
          example: 7
        anonymous_total:
          type: number
        target:
          type: integer
          example: 20
        target_deadline:
          type: string
          format: date
          nullable: true
          example: "2026-03-31"
        percent_of_target:
          type: number
          example: 65.0
        groups:
          type: array
          description: Present with group_by. Each row has `month` ("YYYY-MM") or `project` ({id, name}) plus the same figures; Project rows also carry that Project's target.
          items:
            type: object

    AuthResponse:
      type: object
      properties:
        user_id:
          type: integer
          example: 42
        email:
          type: string
          format: email
          example: user@example.com
        authentication_token:
          type: string
          description: Long-lived token. Does not expire.
          example: "sJxyz_abc123longtoken"

    Charity:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 31
            name:
              type: string
              example: "Greenfield Community Trust"
            default_project_story_privacy:
              $ref: '#/components/schemas/DefaultProjectStoryPrivacy'
            participant_pass_sign_in_enabled:
              type: boolean
              description: >-
                "Enable contacts to sign in using a participant pass" (Charity Preferences, Contacts). Off
                by default.
              example: false
            region:
              $ref: '#/components/schemas/FactorChoice'
            industry:
              $ref: '#/components/schemas/FactorChoice'

    FactorChoice:
      type: object
      nullable: true
      description: >-
        A Region or Industry chosen for localised Financial Values: an id from `GET /factor_options`
        and its name. Null when none is chosen.
      properties:
        id: { type: integer, example: 7 }
        name: { type: string, example: North East }

    FactorChoiceInEffect:
      type: object
      nullable: true
      description: >-
        The Region or Industry a project's localised Financial Values use: its own, or else its
        organisation's (`source`). Null when neither is set, so national amounts apply.
      properties:
        id: { type: integer, example: 7 }
        name: { type: string, example: North East }
        source: { type: string, enum: [project, organisation] }

    FactorOption:
      type: object
      description: >-
        One option of a factor table Makerble publishes, e.g. the Region "North East" or the Industry
        "Construction", with the factors it holds. A localised Financial Value's formula names a factor
        as `dimension.key`, e.g. `region.median_wage`.
      properties:
        id: { type: integer, example: 7 }
        name: { type: string, example: North East }
        dimension: { type: string, example: region, description: The table's key, as a formula names it }
        dimension_name: { type: string, example: Region }
        edition: { type: string, nullable: true, example: TOM System 2024 Location }
        year: { type: integer, nullable: true, example: 2024 }
        position: { type: integer, description: Its place in the table's order }
        factors:
          type: array
          items:
            type: object
            properties:
              key: { type: string, example: regional_gva }
              name: { type: string, example: Regional GVA }
              value: { type: string, description: A decimal string, example: '1.5718765958' }
        updated_at: { type: string, format: date-time }

    DefaultProjectStoryPrivacy:
      type: string
      description: |
        The Story Privacy Level each new project in the Organisation starts with: Project colleagues
        only, Organisation colleagues only, Network & organisation colleagues only, or Everyone.
        Organisations created from November 2026 start with `only_project_colleagues`; older ones
        with `only_charity_colleagues`.
      enum: [only_project_colleagues, only_charity_colleagues, charity_plus_network, everyone]
      example: only_project_colleagues

    ProjectDetail:
      description: A Project as returned by `GET /projects/{id}`.
      allOf:
        - $ref: '#/components/schemas/Project'
        - type: object
          properties:
            beneficiary_states:
              type: array
              description: |
                The Contact statuses (Beneficiary States) switched on for the
                Project, e.g. Enrolled or Waiting List. Pass an `id` as `beneficiary_state_id` to
                `POST /project_beneficiaries`.
              items:
                type: object
                properties:
                  id:
                    type: integer
                    example: 3
                  name:
                    type: string
                    example: "Enrolled"

    Toolkit:
      type: object
      description: A Toolkit (Collection in the database) on Explore Toolkits.
      properties:
        id:
          type: integer
        name:
          type: string
        slug:
          type: string
          nullable: true
        toolkit_number:
          type: string
          nullable: true
          description: The Toolkit's number, e.g. "T14", shown on Site Overview › Manage Toolkits
        strapline:
          type: string
          nullable: true
        description:
          type: string
          nullable: true
        approved:
          type: boolean
          description: Whether Makerble has approved the Toolkit for Explore Toolkits
        thumbnail_image_url:
          type: string
          nullable: true
          description: The image on the Toolkit's Explore Toolkits card; when null, the card uses the cover image
        cover_image_url:
          type: string
          nullable: true
          description: The image at the top of the Toolkit's page
        cover_image_alt:
          type: string
          nullable: true
          description: The cover image's alt text, read out by screen readers; when null, the image is treated as decoration
        darken_thumbnail_image:
          type: boolean
          description: Whether a dark translucent layer covers the thumbnail on Explore Toolkits
        darken_cover_image:
          type: boolean
          description: Whether a dark translucent layer covers the cover image on the Toolkit's page
        url:
          type: string
          description: The Toolkit's page in Makerble
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ToolkitWithItems:
      description: One Toolkit, with its Checklist Templates and story Labels
      allOf:
        - $ref: '#/components/schemas/Toolkit'
        - type: object
          properties:
            checklist_templates:
              type: array
              description: The Toolkit's Checklist Templates, by name
              items:
                $ref: '#/components/schemas/ToolkitItemName'
            story_labels:
              type: array
              description: The Toolkit's story Labels (Labels in the database), by name
              items:
                $ref: '#/components/schemas/ToolkitItemName'

    ToolkitItemName:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string

    ToolkitItemRequest:
      type: object
      required: [item_type, item_id]
      properties:
        item_type:
          type: string
          enum: [checklist_template, story_label]
          description: A Checklist Template, or a story Label (Label in the database)
        item_id:
          type: integer

    ToolkitItem:
      type: object
      properties:
        item_type:
          type: string
          enum: [checklist_template, story_label]
        item_id:
          type: integer
        name:
          type: string

    ToolkitList:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/Toolkit'

    ToolkitUpdateRequest:
      type: object
      properties:
        toolkit_number:
          type: string
          nullable: true
        cover_image_alt:
          type: string
          nullable: true
          maxLength: 255
          description: The cover image's alt text, as on the Create/Edit Collection page; send null or "" for a decorative image
        darken_thumbnail_image:
          type: boolean
        darken_cover_image:
          type: boolean

    Album:
      type: object
      description: An Album (Bundle; Portfolio on screen) groups Projects so their results can be seen together.
      properties:
        id:
          type: integer
        name:
          type: string
        description:
          type: string
          nullable: true
        owner_type:
          type: string
          enum: [Charity, User]
          description: "`Charity` for an Organisation's Album, `User` for a personal one"
        owner_id:
          type: integer
        creator_id:
          type: integer
          description: The user who made the Album
        manager_ids:
          type: array
          items:
            type: integer
          description: The Album's managers, who may change it
        analyst_ids:
          type: array
          items:
            type: integer
          description: The Album's Album Analysts, who may see its results
        project_ids:
          type: array
          items:
            type: integer
        pending_project_ids:
          type: array
          items:
            type: integer
          description: Projects invited to join, until their managers accept. Not in list responses.
        target_type:
          type: string
          nullable: true
          enum: [manual_target, automatic_target, null]
        year_start_date:
          type: string
          format: date
          nullable: true
        automatically_create_survey_progress_board:
          type: boolean
          description: Whether each Survey on the Album's Projects gets a progress board
        default_results_template_id:
          type: integer
          nullable: true
          description: The Impact Framework the Album's Progress Panel opens on; null for All metrics
        cover_image_url:
          type: string
          nullable: true
        url:
          type: string
          description: The Album's page in Makerble
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    Team:
      type: object
      properties:
        id:
          type: integer
        charity_id:
          type: integer
          description: The Organisation the Team belongs to
        name:
          type: string
        colour:
          type: string
          description: The Team's chip colour, e.g. "#3595d5"
        manager_ids:
          type: array
          description: User IDs of the Team's managers (leaders)
          items:
            type: integer
        member_ids:
          type: array
          description: User IDs of the Team's other members
          items:
            type: integer
        auto_add_to_projects:
          type: boolean
          description: Whether people who join the Team are added to its Projects
        auto_add_project_ids:
          type: array
          items:
            type: integer
        auto_add_filter_ids:
          type: array
          description: Saved project filters (FilterHistory) whose matching open Projects people are added to
          items:
            type: integer
        auto_add_manager_role:
          type: string
          enum: [editor, reporter, observer]
          description: The project role a new manager gets
        auto_add_member_role:
          type: string
          enum: [editor, reporter, observer]
          description: The project role a new member gets
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    TeamAddMembersRequest:
      type: object
      required: [user_ids, role]
      properties:
        user_ids:
          type: array
          description: Colleagues (user IDs) in the Team's Organisation
          items:
            type: integer
        role:
          type: string
          enum: [member, manager]
          description: Add them as Members, or as Managers (leaders)

    TeamList:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/Team'

    TeamUpdateRequest:
      type: object
      properties:
        auto_add_to_projects:
          type: boolean
        auto_add_project_ids:
          type: array
          items:
            type: integer
        auto_add_filter_ids:
          type: array
          items:
            type: integer
        auto_add_manager_role:
          type: string
          enum: [editor, reporter, observer]
        auto_add_member_role:
          type: string
          enum: [editor, reporter, observer]

    AlbumList:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/Album'

    AlbumCreateRequest:
      type: object
      required: [name, owner_type]
      properties:
        name:
          type: string
        owner_type:
          type: string
          enum: [Charity, User]
        owner_id:
          type: integer
          description: The Organisation's ID when `owner_type` is `Charity`
        project_ids:
          type: array
          items:
            type: integer

    AlbumUpdateRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        owner_type:
          type: string
          enum: [Charity, User]
        owner_id:
          type: integer
        manager_ids:
          type: array
          items:
            type: integer
        analyst_ids:
          type: array
          items:
            type: integer
        automatically_create_survey_progress_board:
          type: boolean
        default_results_template_id:
          type: integer
          nullable: true
          description: One of the Organisation's Impact Frameworks; null for All metrics

    AlbumProjectsRequest:
      type: object
      required: [project_ids]
      properties:
        project_ids:
          type: array
          items:
            type: integer

    AlbumContributionTimeframe:
      type: object
      properties:
        start_date:
          type: string
          format: date
          nullable: true
          description: First day; null for the first period, which runs from the start
        end_date:
          type: string
          format: date
        label:
          type: string
          example: From 31 Mar 2026 to 30 Jun 2026
    AlbumProjectContributions:
      type: object
      properties:
        album_id:
          type: integer
        timeframe:
          type: string
          enum: [all_time, period, year_to_date]
        timeframes:
          type: array
          items:
            $ref: '#/components/schemas/AlbumContributionTimeframe'
        selected_timeframe:
          type: object
          nullable: true
          description: The period or year shown; null over all time, or when the Album has no periods
          properties:
            start_date:
              type: string
              format: date
              nullable: true
            end_date:
              type: string
              format: date
            label:
              type: string
        projects:
          type: array
          items:
            type: object
            properties:
              project_id:
                type: integer
              name:
                type: string
              colour:
                type: string
                example: "#225f85"
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              metric_type:
                type: string
                enum: [Change, Indicator]
              metric_id:
                type: integer
              name:
                type: string
              outcome_id:
                type: integer
                nullable: true
                description: The Outcome an Indicator sits under; null for a Change
              outcome_name:
                type: string
                nullable: true
              stage:
                type: string
                nullable: true
              total:
                type: integer
                description: Progress across the Album in the timeframe
              target:
                type: integer
                nullable: true
              percentage:
                type: number
                description: total as a percentage of target; 0 when there is no target
              projects:
                type: array
                items:
                  type: object
                  properties:
                    project_id:
                      type: integer
                    subtotal:
                      type: integer
                    contribution_percentage:
                      type: number
                      description: subtotal as a percentage of total; 0 when total is 0
                    target:
                      type: integer
                      nullable: true
                      description: The Project's own all-time target; only given for timeframe all_time
                    target_unavailable:
                      type: boolean
    AlbumTargets:
      type: object
      properties:
        album_id:
          type: integer
        target_type:
          type: string
          nullable: true
          enum: [manual_target, automatic_target, null]
        year_start_date:
          type: string
          format: date
          nullable: true
        metrics:
          type: array
          description: The Album's Activity and Outcome metrics and their one-off targets
          items:
            type: object
            properties:
              metric_type:
                type: string
                enum: [Change, Indicator]
              metric_id:
                type: integer
              name:
                type: string
              target:
                type: integer
        trackers:
          type: array
          description: The Album's Cohort, Workflow and Formula Trackers and filtered versions, and their one-off targets
          items:
            type: object
            properties:
              tracker_type:
                type: string
                enum: [CohortTracker, WorkflowTracker, FormulaTracker, FilteredMetric]
              tracker_id:
                type: integer
              name:
                type: string
              target:
                type: integer
        deadlines:
          type: array
          description: The deadline targets the Album uses now (its own with manual targets, its Projects' added up with automatic ones)
          items:
            type: object
            properties:
              metric_type:
                type: string
              metric_id:
                type: integer
              date:
                type: string
                format: date
              number:
                type: integer

    AlbumTargetsRequest:
      type: object
      properties:
        target_type:
          type: string
          enum: [manual_target, automatic_target]
        year_start_date:
          type: string
          format: date
        metrics:
          type: array
          items:
            type: object
            required: [metric_type, metric_id, target]
            properties:
              metric_type:
                type: string
                enum: [Change, Indicator]
              metric_id:
                type: integer
              target:
                type: integer
                minimum: 0
        trackers:
          type: array
          items:
            type: object
            required: [tracker_type, tracker_id, target]
            properties:
              tracker_type:
                type: string
                enum: [CohortTracker, WorkflowTracker, FormulaTracker, FilteredMetric]
              tracker_id:
                type: integer
              target:
                type: integer
                minimum: 0
        deadlines:
          type: array
          description: Replaces all of the Album's manual deadline targets
          items:
            type: object
            required: [metric_type, metric_id, date, number]
            properties:
              metric_type:
                type: string
              metric_id:
                type: integer
              date:
                type: string
                format: date
              number:
                type: integer
                minimum: 0

    ProjectPreferences:
      type: object
      description: A Project's Project Preferences. In a request, send only the settings to change.
      properties:
        project_id:
          type: integer
          readOnly: true
        region_factor_option_id:
          type: integer
          nullable: true
          description: >-
            The Project's own Region for localised Financial Values, from `GET /factor_options`. Null to
            use its organisation's.
        industry_factor_option_id:
          type: integer
          nullable: true
          description: >-
            The Project's own Industry for localised Financial Values, from `GET /factor_options`. Null
            to use its organisation's.
        region:
          allOf: [{ $ref: '#/components/schemas/FactorChoiceInEffect' }]
          readOnly: true
        industry:
          allOf: [{ $ref: '#/components/schemas/FactorChoiceInEffect' }]
          readOnly: true
        add_enrolled_contacts_to_upcoming_events:
          type: boolean
          nullable: true
          description: "Automatically add all enrolled Contacts to all upcoming Events in the Project"
        allow_stories_to_be_copied:
          type: boolean
          nullable: true
          description: "Allow Stories to be copied"
        alumni_state_contact_form_id:
          type: integer
          nullable: true
          description: The Contact Form for Contacts with the Alumni status
        automate_following_between_beneficiary:
          type: boolean
          nullable: true
          description: "Contacts in the Project who have Participation Access automatically follow each other"
        automatically_create_survey_progress_board:
          type: boolean
          nullable: true
          description: "Create a board for every Survey used on the Project"
        automatically_launch_create_case:
          type: boolean
          nullable: true
          description: "Automatically launch the Create Case page when a Contact is created"
        beneficiary_creation_ticked:
          type: boolean
          nullable: true
          description: "Allow users to create Contacts inside the Add Guests popup of an Event"
        declined_state_contact_form_id:
          type: integer
          nullable: true
          description: The Contact Form for Contacts with the Declined status
        display_register_for_event_series:
          type: boolean
          nullable: true
          description: "Display a register for each event series: every recurring Event gets a Register page with a row per guest and columns per Event. Switching it on also switches on edit_story_on_event_attendance; switching edit_story_on_event_attendance off switches it off. Switching Events on (is_creation_of_events_required) switches it on."
        edit_story_on_event_attendance:
          type: boolean
          nullable: true
          description: "When an Event's Story already exists, edit it rather than create a new one when adding attendance"
        enable_alumni_state_baseline_survey:
          type: boolean
          nullable: true
          description: Send a baseline Survey to Contacts who get the Alumni status
        enable_alumni_state_contact_form:
          type: boolean
          nullable: true
          description: Use a Contact Form for Contacts who get the Alumni status
        enable_declined_state_baseline_survey:
          type: boolean
          nullable: true
          description: Send a baseline Survey to Contacts who get the Declined status
        enable_declined_state_contact_form:
          type: boolean
          nullable: true
          description: Use a Contact Form for Contacts who get the Declined status
        enable_enrolled_state_baseline_survey:
          type: boolean
          nullable: true
          description: Send a baseline Survey to Contacts who get the Enrolled status
        enable_enrolled_state_contact_form:
          type: boolean
          nullable: true
          description: Use a Contact Form for Contacts who get the Enrolled status
        enable_financial_value:
          type: boolean
          nullable: true
          description: "Enable Financial Values"
        enable_waiting_list_state_baseline_survey:
          type: boolean
          nullable: true
          description: Send a baseline Survey to Contacts who get the Waiting List status
        enable_waiting_list_state_contact_form:
          type: boolean
          nullable: true
          description: Use a Contact Form for Contacts who get the Waiting List status
        enable_waiting_list_state_public_referral_link:
          type: boolean
          nullable: true
          description: Waiting List has a public Signup Page
        enrolled_state_contact_form_id:
          type: integer
          nullable: true
          description: The Contact Form for Contacts with the Enrolled status
        hide_anonymous_participants_section:
          type: boolean
          nullable: true
          description: "Hide the Manual Headcount section when there are Contacts in the Project"
        is_contact_outside_project_enabled:
          type: boolean
          nullable: true
          description: "Add Contacts from outside the Project to an Event"
        is_creation_of_events_required:
          type: boolean
          nullable: true
          description: "Enable Events"
        is_creation_of_new_cases_enabled:
          type: boolean
          nullable: true
          description: "Enable Cases"
        is_creation_of_timesheets_required:
          type: boolean
          nullable: true
          description: "Enable Timesheets"
        prevent_project_reporters_changing_story_privacy:
          type: boolean
          nullable: true
          description: "Prevent Project Changemakers from changing a Story's privacy level"
        share_story_with_other_active_beneficiary:
          type: boolean
          nullable: true
          description: "By default, share Stories with Contacts who have Participation Access"
        share_story_with_tagged_active_beneficiary:
          type: boolean
          nullable: true
          description: "Share Stories with Active Participants"
        story_beneficiary_checkbox_option:
          type: string
          description: "How the Tickbox tracker for a single Contact shows on the Quick Update popup: displayed_unticked or hidden_ticked"
        waiting_list_state_contact_form_id:
          type: integer
          nullable: true
          description: The Contact Form for Contacts with the Waiting List status
        alumni_state_baseline_survey_ids:
          type: array
          items:
            type: integer
          description: Baseline Surveys for Contacts who become Alumni
        beneficiary_state_ids:
          type: array
          items:
            type: integer
          description: The Contact statuses switched on (Waiting List, Enrolled, Alumni, Declined)
        case_creator_ids:
          type: array
          items:
            type: integer
          description: "Users (Project Changemakers and Analysts) who may create Cases; Project Managers already may"
        contact_form_ids:
          type: array
          items:
            type: integer
          description: "Bio forms (Contact Forms) to use when creating a Contact"
        custom_form_cases_ids:
          type: array
          items:
            type: integer
          description: "Case Forms to use when creating Cases"
        declined_state_baseline_survey_ids:
          type: array
          items:
            type: integer
          description: Baseline Surveys for Contacts who become Declined
        edit_contact_form_ids:
          type: array
          items:
            type: integer
          description: "Bio forms that can be added to or edited on a Contact's bio"
        enrolled_state_baseline_survey_ids:
          type: array
          items:
            type: integer
          description: Baseline Surveys for Contacts who become Enrolled
        event_creator_ids:
          type: array
          items:
            type: integer
          description: "Users who may create Events in addition to Project Managers"
        organisation_admin_form_ids:
          type: array
          items:
            type: integer
          description: "Editorial control: bio forms Organisation Admins may edit on Contacts they didn't create"
        project_manager_form_ids:
          type: array
          items:
            type: integer
          description: "Editorial control: bio forms Project Managers may edit on Contacts they didn't create"
        project_observers_form_ids:
          type: array
          items:
            type: integer
          description: "Editorial control: bio forms Project Analysts may edit on Contacts they didn't create"
        project_reporter_form_ids:
          type: array
          items:
            type: integer
          description: "Editorial control: bio forms Project Changemakers may edit on Contacts they didn't create"
        waiting_list_state_baseline_survey_ids:
          type: array
          items:
            type: integer
          description: Baseline Surveys for Contacts who join the Waiting List
        default_results_template_id:
          type: integer
          nullable: true
          description: The Impact Framework the Results Canvas shows by default; null for All metrics
        default_story_privacy:
          type: string
          nullable: true
          enum: [only_charity_colleagues, only_project_colleagues, only_certain_individual, charity_plus_network, everyone, null]
          description: Who sees a new Story by default
        individual_list:
          type: array
          items:
            type: integer
          description: The users who see new Stories, for only_certain_individual
        custom_field_category_id:
          type: integer
          nullable: true
          description: The Case Form used for the Project's Cases
        event_category_ids:
          type: array
          items:
            type: integer
          description: The Project's Event Formats
        required_case_story_category_ids:
          type: array
          items:
            type: integer
          description: Surveys a Case needs before it can be closed
        mailchimp_list_id:
          type: string
          nullable: true
          description: The Mailchimp list the Project's Contacts are added to

    ProjectTargets:
      type: object
      properties:
        project_id:
          type: integer
        year_start_date:
          type: string
          format: date
          nullable: true
        metrics:
          type: array
          description: The Project's Activity and Outcome metrics and their one-off targets
          items:
            type: object
            properties:
              metric_type:
                type: string
                enum: [Change, Indicator]
              metric_id:
                type: integer
              name:
                type: string
              target:
                type: integer
        trackers:
          type: array
          description: The Project's Cohort, Workflow and Formula Trackers and filtered versions, and their one-off targets
          items:
            type: object
            properties:
              tracker_type:
                type: string
                enum: [CohortTracker, WorkflowTracker, FormulaTracker, FilteredMetric]
              tracker_id:
                type: integer
              name:
                type: string
              target:
                type: integer
        deadlines:
          type: array
          items:
            type: object
            properties:
              metric_type:
                type: string
              metric_id:
                type: integer
              date:
                type: string
                format: date
              number:
                type: integer

    ProjectTargetsRequest:
      type: object
      properties:
        year_start_date:
          type: string
          format: date
        metrics:
          type: array
          items:
            type: object
            required: [metric_type, metric_id, target]
            properties:
              metric_type:
                type: string
                enum: [Change, Indicator]
              metric_id:
                type: integer
              target:
                type: integer
                minimum: 0
        trackers:
          type: array
          items:
            type: object
            required: [tracker_type, tracker_id, target]
            properties:
              tracker_type:
                type: string
                enum: [CohortTracker, WorkflowTracker, FormulaTracker, FilteredMetric]
              tracker_id:
                type: integer
              target:
                type: integer
                minimum: 0
        deadlines:
          type: array
          description: Replaces all the Project's deadline targets
          items:
            type: object
            required: [metric_type, metric_id, date, number]
            properties:
              metric_type:
                type: string
              metric_id:
                type: integer
              date:
                type: string
                format: date
              number:
                type: integer
                minimum: 0

    ProjectListItem:
      description: A Project as returned by `GET /projects`. `GET /projects/{id}`, `POST /projects` and `PATCH /projects/{id}` return the fuller Project.
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 572
            name:
              type: string
              example: "Youth Mentoring Programme 2024"
            charity_id:
              type: integer
              example: 31
            is_closed:
              type: boolean
              example: false
            beneficiary_category_ids:
              type: array
              items:
                type: integer
              description: The Contact Forms used to create Contacts in the Project.

    Project:
      allOf:
        - $ref: '#/components/schemas/ProjectListItem'
        - type: object
          properties:
            default_results_template_id:
              type: integer
              nullable: true
              example: 2413
              description: |
                The Impact Framework (Template) the Project's Results Canvas shows by default, chosen on Project
                Preferences. `null` means All metrics. Pass it as `template_id` to `GET /project_results` for the
                same figures.
            help_statement:
              type: string
              nullable: true
              description: Short Description.
              example: "Weekly mentoring for 14 to 18 year olds"
            help_description:
              type: string
              nullable: true
              description: Long Description.
            location:
              type: string
              nullable: true
              example: "Leeds"
            project_type_id:
              type: integer
              nullable: true
              example: 4
            solution_group_id:
              type: integer
              nullable: true
            project_category_id:
              type: integer
              example: 88

    ProjectSaveRequest:
      type: object
      properties:
        project:
          type: object
          properties:
            name:
              type: string
              example: "Youth Mentoring"
            project_type_id:
              type: integer
              description: One of the Project Types from `GET /projects/form`. Required when creating.
            solution_group_id:
              type: integer
              description: One of the chosen Project Type's solutions.
            project_category_id:
              type: integer
              description: One of the Organisation's Project Categories. Defaults to its default category.
            help_statement:
              type: string
              description: Short Description.
            help_description:
              type: string
              description: Long Description.
            location:
              type: string
            custom_colour:
              type: string
              description: Only saved for someone who may change the Project's privacy.
              example: "#f96d67"
            editor_ids:
              type: array
              items:
                type: integer
              description: Managers (Project Editors), by user id.
            reporter_ids:
              type: array
              items:
                type: integer
              description: Changemakers (Project Reporters), by user id.
            observer_ids:
              type: array
              items:
                type: integer
              description: Analysts (Project Observers), by user id.
        story_category_ids:
          type: array
          items:
            type: integer
          description: Surveys (Story Categories) to add to the Project.
        privacy:
          type: string
          enum: [only_charity_colleagues, only_project_colleagues, only_certain_individual, charity_plus_network, everyone]
          description: Who can see the Project.
        individual_list:
          type: array
          items:
            type: integer
          description: User ids the Project is shared with, for `only_certain_individual`.
        custom_fields:
          type: object
          additionalProperties: true
          description: Answers to the Project Category's custom questions, keyed by `field_id`.
          example: {"512": "14-18"}
        sub_ratios:
          type: object
          additionalProperties:
            type: array
            items:
              type: integer
          description: Choices in the Project Category's dropdowns, keyed by `field_id`.

    ProjectForm:
      type: object
      properties:
        charity_id:
          type: integer
          example: 31
        project_types:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 4
              name:
                type: string
                example: "Youth work"
              solutions:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    name:
                      type: string
        project_categories:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 88
              name:
                type: string
                example: "Youth clubs"
              is_default:
                type: boolean
              fields:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      example: "Short Description"
                    kind:
                      type: string
                      enum: [standard, custom_field, dropdown]
                    field_id:
                      type: integer
                      description: For `custom_field` and `dropdown` fields.
                    data_type:
                      type: string
                      nullable: true
                      description: For `custom_field` fields, e.g. `text`, `number`, `date`.
                    is_mandatory:
                      type: boolean
                    parameter:
                      type: string
                      example: "project[help_statement]"


    User:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 237
            name:
              type: string
              example: "Sarah Jones"
            email:
              type: string
              format: email
              example: "sarah@charity.org"

    Beneficiary:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 160498
            name:
              type: string
              example: "Jack Smith"
            dob:
              type: string
              format: date
              nullable: true
              example: "1990-05-13"
            charity_id:
              type: integer
              example: 31
            mobile:
              type: string
              nullable: true
              example: "+44 7700 900123"
            email:
              type: string
              nullable: true
              example: "jack@example.com"
            address:
              type: string
              nullable: true
              example: "123 Example Street, London"
            avatar:
              type: string
              nullable: true
            created_by:
              type: integer
              example: 237
            custom_fields:
              type: array
              items:
                $ref: '#/components/schemas/CustomFieldValue'
            restricted_fields:
              type: array
              items:
                type: string
              description: Built-in fields (`dob`, `mobile`, `email`, `address`) hidden from you by Field Visibility; each is returned as null
              example: ["mobile"]
            required_skills:
              type: array
              description: What the Contact needs a specialist in, each Essential or Desirable, added by hand or from a form answer
              items: { $ref: '#/components/schemas/RequiredSkill' }
            household:
              description: |
                The household (family) the Contact is in, from Relationships in Relationship Categories that
                count as a household, or null when they are in none
              nullable: true
              type: object
              properties:
                id: { type: integer }
                reference:
                  type: string
                  description: As shown on Manage Contacts, e.g. H123
                  example: H123
                role:
                  type: string
                  description: The titles the Contact holds in their family relationships, e.g. Parent, or Child / Parent
                  example: Parent
                members_count: { type: integer, example: 4 }

    BeneficiaryDetail:
      description: A Contact (Beneficiary) as returned by `GET /beneficiaries/{id}` and `POST /beneficiaries`. The list endpoint leaves out `weekly_availability`.
      allOf:
        - $ref: '#/components/schemas/Beneficiary'
        - type: object
          properties:
            weekly_availability:
              $ref: '#/components/schemas/ContactWeeklyAvailability'

    ContactWeeklyAvailability:
      type: object
      nullable: true
      description: >-
        The most recently saved answer to any Weekly availability field on the Contact's Contact Forms, or null if
        they haven't answered one. Use it to suggest appointment times the Contact can attend.
      properties:
        times:
          type: array
          nullable: true
          description: The days and times, in the organisation's timezone. Null when `restricted` is true.
          items:
            $ref: '#/components/schemas/WeeklyAvailabilityTime'
        source_form_id:
          type: integer
          nullable: true
          description: The Contact Form (Beneficiary Category) the answer came from
          example: 412
        source_field_id:
          type: integer
          description: The Weekly availability custom field the answer came from
          example: 9051
        answered_at:
          type: string
          format: date-time
          description: When the answer was saved
          example: "2026-11-10T09:30:00.000+00:00"
        restricted:
          type: boolean
          description: True when Field Visibility hides the source field from you; `times` is then null
          example: false

    WeeklyAvailabilityTime:
      type: object
      required: [day, from, to]
      description: >-
        One row of a Weekly availability answer. Times are HH:MM in 15-minute steps, in the organisation's timezone,
        and `to` must be after `from`. Overlapping rows on the same day are joined when saved.
      properties:
        day:
          type: string
          enum: [monday, tuesday, wednesday, thursday, friday, saturday, sunday]
          example: monday
        from:
          type: string
          example: "15:30"
        to:
          type: string
          example: "18:00"

    BeneficiaryCreateRequest:
      type: object
      required: [beneficiary]
      properties:
        beneficiary:
          type: object
          required: [name, owner_id]
          properties:
            name:
              type: string
            date_of_birth:
              type: string
              description: Format DD-MM-YYYY
            address:
              type: string
            latitude:
              type: string
            longitude:
              type: string
            beneficiary_type_id:
              type: integer
              description: "1=Person  2=Object  3=Organisation  4=Animal"
              default: 1
            owner_id:
              type: integer
        project_ids:
          type: array
          items:
            type: integer
        beneficiary_category_ids:
          type: array
          items:
            type: integer
        custom_fields:
          type: object
          additionalProperties: {}
          description: "Dictionary of custom_field_id → value. Most fields take a string. A Weekly availability field (`weekly_availability`) takes a list of days and times, for example `[{\"day\": \"monday\", \"from\": \"15:30\", \"to\": \"18:00\"}]` (see WeeklyAvailabilityTime); an answer that can't be read is refused with 422."
          example:
            "173": "Employed"
            "9051":
              - day: monday
                from: "15:30"
                to: "18:00"

    BeneficiaryType:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            name:
              type: string
              enum: [Person, Organisation, Animal, Object]

    FinancialValue:
      type: object
      description: A published money value per person for an outcome, in the currency of its country
      properties:
        id: { type: integer, example: 88 }
        name: { type: string, example: Moving into work }
        code: { type: string, nullable: true, example: MIW }
        amount: { type: string, description: The value per person, as a decimal string, example: '1234.5' }
        currency: { type: string, example: GBP }
        year: { type: integer, example: 2023 }
        country: { type: string, nullable: true, example: United Kingdom }
        category:
          type: object
          nullable: true
          description: Its Methodology (Financial Value Category)
          properties:
            id: { type: integer }
            name: { type: string }
        sources:
          type: array
          items:
            type: object
            properties:
              id: { type: integer }
              name: { type: string }
        publisher: { type: string, nullable: true, description: The web address of the source }
        short_description: { type: string, nullable: true }
        calculation_description: { type: string, nullable: true, description: Simple HTML }
        verified: { type: boolean, description: Whether Makerble has checked it }
        owner_type: { type: string, enum: [Organisation, User] }
        owner_id: { type: integer }
        privacy:
          type: string
          nullable: true
          enum: [only_project_colleagues, only_charity_colleagues, charity_plus_network, everyone]
          description: Who may use it
        project_ids: { type: array, items: { type: integer }, description: The projects it may be used in, for only_project_colleagues }
        formula:
          type: string
          nullable: true
          description: >-
            For a localised Financial Value, whose amount depends on where the work happens or the
            industry: arithmetic over factors from `GET /factor_options`, e.g.
            `(industry.gva_multiplier - 1) * region.regional_gva`. Each project values it with its own
            Region and Industry. Null for a fixed Financial Value.
        localised: { type: boolean, description: Whether it has a formula }
        national_amount:
          type: string
          nullable: true
          description: For a localised Financial Value, the amount used where no Region or Industry is set (the same as amount). Null for a fixed one.
          example: '0.8'
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
    FinancialValueInput:
      type: object
      required: [name, amount, year, country, privacy]
      properties:
        name: { type: string }
        amount: { type: number, description: The value per person, with no currency symbol }
        year: { type: integer }
        country: { type: string, description: The country's name. Sets its currency. }
        privacy:
          type: string
          enum: [Project colleagues only, Organisation colleagues only, Network & organisation colleagues only, Everyone]
        organisation_id: { type: integer, description: The organisation that will own it. Leave out to make it your own. }
        project_ids: { type: array, items: { type: integer }, description: For Project colleagues only }
        code: { type: string, description: Letters and numbers only }
        category: { type: string, description: The name of its Methodology }
        sources: { type: array, items: { type: string }, description: Names of its Sources }
        publisher: { type: string }
        short_description: { type: string }
        calculation_description: { type: string }
        formula:
          type: string
          description: >-
            Makes it localised: arithmetic (numbers, + - * / and brackets) over factors named
            `dimension.key`, e.g. `region.median_wage`. amount is then the national amount. A formula
            naming a factor that doesn't exist, or using anything but arithmetic, gets 422.
    ProjectFinancialValue:
      type: object
      description: One Financial Value put against one of a project's Metrics on its Financial Value calculator
      properties:
        id: { type: integer, description: The attachment id }
        metric_type: { type: string, enum: [Change, Indicator] }
        metric_id: { type: integer }
        metric_name: { type: string }
        color: { type: string, example: '#3595d5' }
        financial_value:
          type: object
          properties:
            id: { type: integer }
            name: { type: string }
            amount: { type: string }
            currency: { type: string }
        quantity: { type: integer, description: "The Metric's result in the project" }
        sub_total: { type: string, description: quantity times the amount }
        created_at: { type: string, format: date-time }
    Label:
      type: object
      description: A Label (Story Label), one of an organisation's themes for coding Stories and survey responses
      properties:
        id: { type: integer, example: 412 }
        name: { type: string, example: Housing }
        color: { type: string, description: Hex colour, example: '#36ac9a' }
        charity_id: { type: integer, description: The organisation that owns the Label, example: 913 }
        user_id: { type: integer, nullable: true, description: Who created it }
        privacy:
          type: string
          enum: [only_charity_colleagues, everyone]
          description: Who may open the Label's page
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
    LabelInput:
      type: object
      properties:
        charity_id: { type: integer, description: The organisation that owns the Label. Must be one you belong to. }
        name: { type: string, maxLength: 255 }
        color: { type: string, pattern: '^#[0-9a-fA-F]{6}$', description: 'Default #3595d5' }
        privacy: { type: string, enum: [only_charity_colleagues, everyone], description: Default only_charity_colleagues }
    LabelOutcomesPage:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            label_id: { type: integer }
            data:
              type: array
              items:
                type: object
                properties:
                  id: { type: integer }
                  title: { type: string }
                  project_count: { type: integer, description: How many projects use the Outcome }
                  editable: { type: boolean, description: Whether you may remove this link }
    OutcomeLabelsPage:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            outcome_id: { type: integer }
            editable: { type: boolean }
            other_label_count: { type: integer }
            data:
              type: array
              items: { $ref: '#/components/schemas/Label' }
    StoryLabelsResult:
      type: object
      properties:
        story_id: { type: integer }
        label: { $ref: '#/components/schemas/Label' }
        label_ids:
          type: array
          items: { type: integer }
          description: Your organisations' Labels now on the Story
    Flag:
      type: object
      description: A Flag (Contact Flag) of the organisation
      properties:
        id: { type: integer }
        name:
          type: string
          description: The Flag's name, e.g. Safeguarding concern
        color:
          type: string
          description: The colour the Flag is shown in
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    Group:
      type: object
      description: A Group (Contact Group) of the organisation
      properties:
        id: { type: integer }
        title:
          type: string
          description: The Group's name, e.g. Girls' football
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    Skill:
      type: object
      description: A Specialism (Skill) of the organisation
      properties:
        id: { type: integer }
        name:
          type: string
          description: The Specialism's name, e.g. Eating disorders
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
        linked_answers:
          type: array
          description: The Contact form answers that make a Contact need this Specialism
          items: { $ref: '#/components/schemas/SkillLinkedAnswer' }

    SkillLinkedAnswer:
      type: object
      description: |
        Answers (Sub Ratios) of one dropdown question (Ratio Set) on the organisation's Contact forms.
        A Contact whose form records any of them needs a specialist in the Specialism, with this importance.
      properties:
        ratio_set_id:
          type: integer
          description: The dropdown question
        sub_ratio_ids:
          type: array
          items: { type: integer }
          description: Its answers that are linked
        importance:
          type: string
          enum: [essential, desirable]

    SkillLinkedAnswers:
      type: object
      description: A Specialism (Skill) and the Contact form answers linked to it
      properties:
        id: { type: integer }
        name: { type: string }
        linked_answers:
          type: array
          items: { $ref: '#/components/schemas/SkillLinkedAnswer' }

    RequiredSkill:
      type: object
      description: Something a Contact needs a specialist in (a Skill Required)
      properties:
        id: { type: integer }
        skill_id:
          type: integer
          description: The Specialism (Skill)
        name:
          type: string
          description: The Specialism's name
        importance:
          type: string
          enum: [essential, desirable]
        source:
          type: string
          enum: [manual, form_answer]
          description: "`manual`: added by hand. `form_answer`: from an answer in the Contact's form; it goes when the answer changes. A Contact can have both for one Specialism."

    ColleagueSpecialisms:
      type: object
      description: A colleague's Specialisms (Skills) in one organisation
      properties:
        user_id: { type: integer }
        charity_id: { type: integer }
        can_change:
          type: boolean
          description: Whether you may add or remove them
        data:
          type: array
          items:
            type: object
            properties:
              id: { type: integer }
              name: { type: string }

    RelationshipCategory:
      type: object
      description: A kind of relationship between Contacts, with its two sides
      properties:
        id: { type: integer }
        parent_title:
          type: string
          description: The first side, e.g. School
        child_title:
          type: string
          description: The second side, e.g. Pupil
        counts_as_household:
          type: boolean
          description: |
            Whether Contacts linked by this category, directly or through other Contacts, are
            counted as one household (family), e.g. Parent & Child or Partner & Partner
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    Audience:
      type: object
      description: An audience (Contact Role; Beneficiary Role), e.g. Participant or Parent
      properties:
        id: { type: integer }
        name: { type: string }
        color:
          type: string
          description: Its colour on the Audiences page, e.g. '#f96d67'
        contact_types:
          type: array
          description: The Contact Types (Beneficiary Types) it is for
          items:
            type: object
            properties:
              id: { type: integer }
              name: { type: string }
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    PermittedRelationship:
      type: object
      description: Which audience may be on each side of a Relationship Category (a Role-holder Relationship)
      properties:
        id: { type: integer }
        relationship_category:
          type: object
          properties:
            id: { type: integer }
            parent_title: { type: string }
            child_title: { type: string }
        parent_audience:
          type: object
          properties:
            id: { type: integer }
            name: { type: string }
        child_audience:
          type: object
          properties:
            id: { type: integer }
            name: { type: string }
        parent_audience_titles:
          type: array
          items: { type: string }
          description: The category's titles the parent audience may hold
        child_audience_titles:
          type: array
          items: { type: string }
          description: The category's titles the child audience may hold
        created_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }

    BeneficiaryCategory:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 294
            name:
              type: string
              example: "Standard Contact Form"

    CustomFieldValue:
      type: object
      properties:
        id:
          type: integer
          example: 173
          description: The field's place on one of the Contact's forms. To change the answer, use `field_class` and `field_id` instead.
        field_class:
          type: string
          enum: [CustomField, RatioSet]
          example: "CustomField"
          description: With `field_id`, names the field itself, as PATCH /beneficiaries/{beneficiary_id}/bio_fields takes it. RatioSet is a Dropdown.
        field_id:
          type: integer
          example: 412
          description: The field's own id (a custom field or Dropdown id), to send to PATCH /beneficiaries/{beneficiary_id}/bio_fields.
        name:
          type: string
          example: "Employment Status"
        type:
          type: string
          example: "text"
          description: "Field type: text, date, time, file, weekly_availability, etc."
        value:
          description: Field value (string for most types; object for file attachments; a list of {day, from, to} for weekly_availability). Null when `restricted` is true.
          example: "Employed"
        restricted:
          type: boolean
          description: True when Field Visibility hides this field from you; `value` is then null, whether or not it has an answer
          example: true

    StoryCustomFieldValue:
      type: object
      description: An answer to one of the Story's own custom fields. Field Visibility applies to Contacts' fields, not these, so there is no `restricted` flag.
      properties:
        id:
          type: integer
          example: 88
        name:
          type: string
          example: "Session location"
        type:
          type: string
          example: "text"
          description: "Field type: text, date, time, file, etc."
        value:
          description: Field value (string for most types; object for file attachments)
          example: "Community centre"

    Story:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 369011
            label_ids:
              type: array
              items: { type: integer }
              description: The Labels (Story Labels) on the Story. Returned by GET /stories/{id}.
              example: [412, 418]
            text:
              type: string
              nullable: true
              example: "Session went well — good engagement from all attendees."
            number:
              type: string
              example: "0"
            approved:
              type: boolean
              example: true
            story_group:
              type: string
              example: "change_created"
            location:
              type: string
              nullable: true
            project_id:
              type: integer
              example: 572
            charity_id:
              type: integer
              nullable: true
              example: 31
            story_category_id:
              type: integer
              example: 327
            edited_by:
              type: integer
              example: 237
            user_id:
              type: integer
              example: 237
            actual_created_at:
              type: string
              format: date-time
              description: Date Posted — real database insertion time
              example: "2024-06-01T14:22:35.000+01:00"
            beneficiary_ids:
              type: array
              items:
                type: integer
              example: [160498]
            custom_fields:
              type: array
              items:
                $ref: '#/components/schemas/StoryCustomFieldValue'
            verdict_scores:
              type: array
              items:
                $ref: '#/components/schemas/VerdictScore'

    StoryDetail:
      allOf:
        - $ref: '#/components/schemas/Story'
        - type: object
          properties:
            case_ids:
              type: array
              items:
                type: integer
            story_indicator_beneficiaries:
              type: array
              items:
                $ref: '#/components/schemas/StoryIndicatorBeneficiary'
            story_change_beneficiaries:
              type: array
              items:
                type: object
            story_changes:
              type: array
              items:
                type: object

    DraftStoryCreateRequest:
      type: object
      required: [story]
      properties:
        story:
          type: object
          properties:
            project_id:
              type: integer
              description: Project the Answer In Progress belongs to. Required unless `charity_id` is given.
            charity_id:
              type: integer
              description: Organisation. Must be the Project's organisation when `project_id` is given.
            story_category_id:
              type: integer
              description: Survey (Story Category) being answered
            text:
              type: string
            event_id:
              type: integer
              description: Event this response is for. Must belong to `project_id`.
            source_of_story:
              type: string
              default: api
            story_group:
              type: string
              default: expanded
            story_format:
              type: string
            display_as:
              type: string
            latitude:
              type: number
            longitude:
              type: number
            location:
              type: string
            is_public:
              type: boolean
            witness_id:
              type: integer
        beneficiaries:
          type: array
          items:
            type: integer
          description: Contact (Beneficiary) IDs to tag
        story_privacy:
          type: string
        custom_fields:
          type: object
          description: "Survey field values: {custom_field_id: value}"
        send_survey_wave_id:
          type: integer

    DraftStoryCreated:
      type: object
      properties:
        success:
          type: boolean
        draft_story_id:
          type: integer
        text:
          type: string
        project_id:
          type: integer
        story_category_id:
          type: integer

    StoryCreateRequest:
      type: object
      required: [story]
      properties:
        story:
          type: object
          required: [story_group, story_format, project_id, story_category_id]
          properties:
            story_group:
              type: string
              enum: [change_created]
            story_format:
              type: string
              enum: [old]
            display_as:
              type: string
              example: "survey_questions_view"
            project_id:
              type: integer
            story_category_id:
              type: integer
            text:
              type: string
              description: "Main narrative text (supports Markdown)"
            created_at:
              type: string
              format: date
              description: "Date Happened — YYYY-MM-DD"
            source_of_story:
              type: string
              example: "api"
            is_public:
              type: boolean
              default: false
        story_privacy:
          type: string
          enum: [only_charity_colleagues, public, specific_individuals_only]
          default: only_charity_colleagues
        beneficiary_ids:
          type: array
          items:
            type: integer
        case_ids:
          type: array
          items:
            type: integer
        story_changes:
          type: array
          items:
            type: object
            properties:
              change_id:
                type: integer
              number:
                type: number
        story_change_beneficiaries:
          type: array
          items:
            type: object
            properties:
              change_id:
                type: integer
              beneficiary_id:
                type: integer
        story_indicator_beneficiaries:
          type: array
          items:
            $ref: '#/components/schemas/StoryIndicatorBeneficiaryInput'
        custom_fields:
          type: object
          additionalProperties: true
          description: "Dictionary of custom_field_id → value"

    StoryIndicatorBeneficiaryInput:
      type: object
      required: [indicator_id, indicator_type, outcome_id]
      properties:
        indicator_id:
          type: integer
        indicator_type:
          type: string
          enum: [scale, binary, value]
        outcome_id:
          type: integer
        beneficiary_id:
          type: integer
          nullable: true
        sub_ratio_id:
          type: integer
          nullable: true
          description: "Scale only — selected answer choice ID"
        binray_indicator_value:
          type: string
          enum: ["on"]
          nullable: true
          description: "Binary only — 'on' if ticked; omit record if not"
        number:
          type: number
          nullable: true
          description: "Value only — numerical response"

    StoryIndicatorBeneficiary:
      type: object
      properties:
        id:
          type: integer
        beneficiary_id:
          type: integer
        indicator_id:
          type: integer
        indicator_type:
          type: string
          enum: [scale, binary, value]
        sub_ratio_id:
          type: integer
          nullable: true
        outcome_id:
          type: integer
          nullable: true

    VerdictScore:
      type: object
      properties:
        id:
          type: integer
          example: 675900
        total_points:
          type: string
          example: "9.0"
        beneficiary_id:
          type: integer
          example: 147750
        story_id:
          type: integer
          example: 573975
        verdict_id:
          type: integer
          example: 8
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    VerdictScoreDetail:
      allOf:
        - $ref: '#/components/schemas/VerdictScore'
        - type: object
          properties:
            story_created_at:
              type: string
              format: date-time
            beneficiary_owner_id:
              type: integer
            story_category_id:
              type: integer

    VerdictScoresResponse:
      type: object
      properties:
        data:
          type: array
          items:
            type: array
            items:
              type: object
              properties:
                beneficiary_id:
                  type: integer
                story_points:
                  type: array
                  items:
                    $ref: '#/components/schemas/VerdictScoreDetail'

    StoryCategory:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 841
            name:
              type: string
              example: "Monthly Wellbeing Check-in"

    StoryCategoryDetail:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            name:
              type: string
            color:
              type: string
              example: "#4a8ac9"
            is_stopped:
              type: boolean
            is_default:
              type: boolean
            description:
              type: string
              nullable: true
            intro_message:
              type: string
              nullable: true
            contact_mode:
              type: string
              enum: [one_contact, several_contacts]
              description: How the survey is shown when someone tries it on a toolkit page, About one contact (`one_contact`) or for Several or no contacts (`several_contacts`)
            current_fields:
              type: array
              items:
                $ref: '#/components/schemas/StoryCategoryField'
            scale_indicator_choices:
              type: array
              items:
                $ref: '#/components/schemas/ScaleIndicatorChoice'
            verdict_data:
              $ref: '#/components/schemas/VerdictData'

    StoryCategoryField:
      type: object
      properties:
        id:
          type: integer
        field_id:
          type: integer
          description: ID of the underlying field (e.g. Indicator ID when field_class_name is Indicator)
        field_name:
          type: string
          example: "How are you feeling today?"
        field_class_name:
          type: string
          example: "Indicator"
          description: "e.g. CustomField, Indicator, Change"
        priority:
          type: integer
          description: "Display order — 1 is first"
          example: 3
        is_mandatory:
          type: boolean
        display_info:
          type: string
          nullable: true
        document_category_id:
          type: integer
          nullable: true
        outcome_id:
          type: integer
          nullable: true
          example: 145
        indicator_type:
          type: string
          nullable: true
          enum: [scale, binary, value]
        change_type:
          type: string
          nullable: true

    ScaleIndicatorChoice:
      type: object
      properties:
        id:
          type: integer
        indicator_id:
          type: integer
        choice:
          type: string
          enum: [single_choice, multiple_choice]
        choice_value:
          type: string

    VerdictData:
      type: object
      properties:
        verdict:
          type: array
          items:
            type: object
            properties:
              from:
                type: integer
                example: 0
              to:
                type: integer
                example: 4
              text:
                type: string
                example: "None-minimal Depression"
        indicators:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              levels:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      example: "Not at all"
                    points:
                      type: integer
                      example: 0

    ProjectStoryCategory:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            project_id:
              type: integer
            story_category_id:
              type: integer
            allow_sign_out_story:
              type: boolean
            allow_respondent_finish_later:
              type: boolean
              description: >-
                When true, a Contact who opens their personal survey link (Survey Invitation)
                without signing in can press Save & Finish Later and come back to the same link
                to finish. Unfinished responses are deleted 30 days after they were last saved.
            hide_unanswered_questions:
              type: boolean
              description: >-
                "Hide unanswered questions when viewing the story" on the Survey Campaign Settings page. When true,
                viewing one contact's response (for example on their profile timeline) leaves out the questions they
                did not answer. Read-only through the API.
            is_stopped:
              type: boolean
            display_intro_message:
              type: boolean
            display_respondent_name:
              type: boolean
            force_interval:
              type: boolean
              description: >-
                "Force colleagues to select an interval". When true and the Survey Campaign has
                intervals (Waves), colleagues must choose one when they add a story, send the survey,
                share its link or set up an automation that sends it, and POST
                /project_story_categories/{id}/survey_links requires send_survey_wave_id.
                On by default for new Survey Campaigns.

    StoryCategoryResponse:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            text:
              type: string
              nullable: true
            story_category_id:
              type: integer
            story_category:
              type: string
            project_id:
              type: integer
            project:
              type: string
            user_id:
              type: integer
            charity_id:
              type: integer
              nullable: true
            known_beneficiaries_count:
              type: integer
            unknown_beneficiaries_count:
              type: integer
            latitude:
              type: string
              nullable: true
            longitude:
              type: string
              nullable: true
            indicator:
              type: array
              items:
                type: object
            change:
              type: array
              items:
                type: object
            custom_field:
              type: array
              items:
                type: object

    Case:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 96
            beneficiary_id:
              type: integer
              example: 160498
            project_id:
              type: integer
              example: 572
            case_creator_id:
              type: integer
              description: User ID of the Case Owner
              example: 237

    CaseCreateRequest:
      type: object
      required: [project_id, beneficiary_id]
      properties:
        case:
          type: object
          properties:
            title:
              type: string
        custom_field_categories_definition:
          type: object
          additionalProperties: true
          description: "Case form field values: {field_definition_id: value}"
        case_owner_id:
          type: integer
        case_worker_ids:
          type: array
          items:
            type: integer
        project_id:
          type: integer
        beneficiary_id:
          type: integer

    ProjectBeneficiaryCase:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            project_id:
              type: integer
            beneficiary_id:
              type: integer
            case_id:
              type: integer

    CustomFieldCategory:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 47
            name:
              type: string
              example: "The Legal Aid Form"

    Change:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 276
            name:
              type: string
              example: "Sessions Attended"
            stage:
              type: string
              enum: [activity, participation]
              example: participation

    Indicator:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 577
            name:
              type: string
              example: "Confidence in finding work"
            indicator_type:
              type: string
              enum: [scale, binary, value]
              example: scale

    IndicatorDetail:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            name:
              type: string
            icon:
              type: string
              nullable: true
            ratio_set_id:
              type: integer
              nullable: true
            detail:
              type: string
              nullable: true
            approved:
              type: boolean
            description:
              type: string
              nullable: true
            instruction:
              type: string
              nullable: true
            private:
              type: boolean
            stage_id:
              type: integer
              nullable: true
            default_question:
              type: string
              nullable: true

    Outcome:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 145
            title:
              type: string
              example: "Improved employability skills"
            icon:
              type: string
              format: uri
              nullable: true
            stage:
              type: string
              enum: [short_term, medium_term, long_term]
              example: medium_term

    OutcomeIndicator:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            outcome_id:
              type: integer
              example: 145
            indicator_id:
              type: integer
              example: 577
            framework_indicator_id:
              type: integer
              nullable: true
              example: null
              description: For an Indicator linked to an Outcome in a Framework Set, which of the Outcome's own core Indicators it counts as (for example a TOMs Measure). Null when it counts as the Outcome itself, or isn't a linked Indicator.

    RatioSet:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 11
            name:
              type: string
              example: "Agreement Scale (1–5)"
            ratio_set_category_type:
              type: string
              enum: [identity, progress]
              example: progress

    SubRatio:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 54
            name:
              type: string
              example: "Strongly agree"
            ratio_set_id:
              type: integer
              example: 11
            priority:
              type: integer
              example: 5
            default_criteria:
              type: string
              nullable: true
              example: "Respondent shows strong agreement"
            default_points:
              type: number
              nullable: true
              example: 5

    RatioSetChoiceable:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            ratio_set_id:
              type: integer
            choice:
              type: string
              enum: [single, limited_multiple, unlimited_multiple]
              example: single
            limit:
              type: integer
              nullable: true
              description: "For limited_multiple — max selections allowed"

    # ── Paginated wrappers ──────────────────────────────────────────────────────

    PaginatedProjects:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ProjectListItem'

    PaginatedUsers:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/User'

    Version:
      type: object
      properties:
        id:
          type: integer
        record_type:
          type: string
          enum: [Contact, Story]
          example: Contact
        record_id:
          type: integer
          description: The Contact (Beneficiary) ID or the Story ID
        charity_id:
          type: integer
        event:
          type: string
          enum: [create, update, destroy]
        action:
          type: string
          enum: [Created, Edited, Destroyed]
          description: Type of access, as worded on the Manage Versions page
        user_id:
          type: integer
          nullable: true
          description: Who did it. Null when no signed-in user made the change.
        user_name:
          type: string
          description: Who did it — `System` when no signed-in user made the change, `Unknown user` if that user no longer exists
        created_at:
          type: string
          format: date-time

    VersionDetail:
      allOf:
        - $ref: '#/components/schemas/Version'
        - type: object
          properties:
            full_object:
              type: object
              additionalProperties: true
              description: Snapshot of every field of the record as saved in this Version
            restricted_fields:
              type: array
              items:
                type: string
              description: Fields of a Contact hidden from you by Field Visibility, nulled in `full_object` (column names, or custom field names)
              example: ["date_of_birth", "NHS number"]
            fields:
              type: array
              items:
                $ref: '#/components/schemas/VersionField'

    VersionField:
      type: object
      description: One field of a record in a Version, as the Version History page shows it
      properties:
        key:
          type: string
          description: Stable key for the field across Versions of the record (e.g. `name`, `custom_field:6807`, `answer:custom_field:501::`)
          example: name
        label:
          type: string
          example: Name
        value:
          type: string
          nullable: true
          description: The value as displayed (dates as "9 Mar 2026", Yes/No, lists joined with commas). Null unless state is `value`.
        state:
          type: string
          enum: [value, blank, absent, restricted]
          description: '`blank`: the field existed but was empty. `absent`: not a field of the record at that time. `restricted`: hidden from you by Field Visibility.'
        changed:
          type: boolean
          description: True when the value differs from the Version saved just before this one

    PaginatedVersions:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            record:
              type: object
              properties:
                record_type:
                  type: string
                record_id:
                  type: integer
                charity_id:
                  type: integer
                name:
                  type: string
                  description: The Contact's name (anonymised for Vault Contacts the caller can't see), or its last saved name once hard-deleted
                deleted:
                  type: boolean
                  description: True once the record has been permanently deleted; its Versions remain
            data:
              type: array
              items:
                $ref: '#/components/schemas/Version'

    AccessLog:
      type: object
      properties:
        id:
          type: integer
        record_type:
          type: string
          example: Contact
        record_id:
          type: integer
        charity_id:
          type: integer
        action:
          type: string
          description: '"Viewed ×N", as shown on the Access Logs tab'
        view_count:
          type: integer
          description: Views in this entry (views less than 30 minutes apart are counted together)
        source:
          type: string
          enum: [web, api, mcp]
          description: Opened in Makerble, fetched through the API, or fetched through the Makerble MCP server
        user_id:
          type: integer
        user_name:
          type: string
        first_viewed_at:
          type: string
          format: date-time
        last_viewed_at:
          type: string
          format: date-time
        monthly_summary:
          type: boolean
          description: True for a monthly summary entry, which totals one colleague's views of the record in that month once they passed the retention period

    PaginatedAuditTrail:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/AuditTrailEntry'
    AuditTrailEntry:
      type: object
      properties:
        entry_type:
          type: string
          enum: [version, access_log]
          description: '`version` for a change (its `id` works with `GET /versions/{id}`), `access_log` for a view'
        id:
          type: integer
        action:
          type: string
          enum: [Created, Edited, Destroyed, Viewed]
        record_type:
          type: string
          enum: [Contact, Story]
        record_id:
          type: integer
        record_name:
          type: string
          description: The Contact's name as shown in Makerble, or "<Survey> in <Project>, <date>" for a Story
        occurred_at:
          type: string
          format: date-time
          description: When the change was saved, or when the view session was last active
        user_id:
          type: integer
          nullable: true
          description: The colleague, or null for a change made by Makerble itself or an integration
        who:
          type: string
          description: The colleague's name, with "(via API)" or "(via MCP)" for views through those routes, or System / the integration's name
        view_count:
          type: integer
          nullable: true
          description: Views in the session (views only)
        source:
          type: string
          nullable: true
          enum: [web, api, mcp, null]
          description: How the record was viewed (views only)
    PaginatedAccessLogs:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            record:
              type: object
              properties:
                record_type:
                  type: string
                record_id:
                  type: integer
                charity_id:
                  type: integer
                name:
                  type: string
                deleted:
                  type: boolean
            data:
              type: array
              items:
                $ref: '#/components/schemas/AccessLog'

    PaginatedBeneficiaries:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Beneficiary'

    PaginatedBeneficiaryTypes:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/BeneficiaryType'

    PaginatedBeneficiaryCategories:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/BeneficiaryCategory'

    PaginatedStories:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Story'

    PaginatedStoryCategories:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/StoryCategory'

    PaginatedProjectStoryCategories:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ProjectStoryCategory'

    SurveyLink:
      type: object
      description: A personal survey link (Survey Invitation link) for one Contact
      properties:
        id:
          type: integer
        send_survey_id:
          type: integer
        beneficiary_id:
          type: integer
          description: The Contact
        email:
          type: string
          nullable: true
        survey_token:
          type: string
        survey_url:
          type: string
          format: uri
          example: https://app.makerble.com/stories/new/0f8c1d2e3b4a59687a6b5c4d3e2f1a0b
        link_expiry:
          type: string
          enum: [use_once, evergreen]
        is_anonymised:
          type: boolean
        send_survey_wave_id:
          type: integer
          nullable: true
        expired:
          type: boolean
          description: True once a use_once link has been answered
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        responses_in_progress:
          type: array
          description: |
            Survey responses the Contact has started on this link but not finished (saved with
            Finish Later), newest first; empty when there are none. Only those updated in the
            last 30 days. Not counted as completed responses.
          items:
            type: object
            properties:
              send_survey_wave_id:
                type: integer
                nullable: true
              last_updated_at:
                type: string
                format: date-time

    SurveyWave:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
          example: Baseline
        priority:
          type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    PaginatedSurveyLinks:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/SurveyLink'

    PaginatedSurveyWaves:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/SurveyWave'

    PaginatedStoryCategoryResponses:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            total_metrics_count_per_page:
              type: integer
            data:
              type: array
              items:
                $ref: '#/components/schemas/StoryCategoryResponse'

    PaginatedCases:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Case'

    CaseFilterField:
      type: object
      properties:
        id:
          type: integer
          description: The question (custom field definition) ID, used as the key in `custom_field_definition_hash`
        name:
          type: string
        field_type:
          type: string
          description: The question type, e.g. string, text, integer, float, date, time, datetime, ratio_set (select), boolean (checkbox), media (attachment), album, location, email_address
        filter_format:
          type: string
          nullable: true
          enum: [text, number_range, date_range, time_range, datetime_range, choice_ids, yes_no, has_files_no_files, album_ids, null]
        choices:
          type: array
          description: A select question's answer choices, alphabetically
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string

    PaginatedCaseFilterFields:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/CaseFilterField'

    PaginatedProjectsBeneficiariesCases:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ProjectBeneficiaryCase'

    PaginatedCustomFieldCategories:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/CustomFieldCategory'

    PaginatedChanges:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Change'

    PaginatedIndicators:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Indicator'

    PaginatedOutcomes:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Outcome'

    FrameworkSet:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
              example: 12
            name:
              type: string
              example: UN Sustainable Development Goals
            availability:
              type: string
              enum: [platform, network, charity]
              description: Who can use the set — every organisation, organisations in a Network, or one organisation
            network_id:
              type: integer
              nullable: true
            charity_id:
              type: integer
              nullable: true
              description: The owning organisation when availability is charity
            level1_singular:
              type: string
              example: Goal
            level1_plural:
              type: string
              example: goals
            level2_singular:
              type: string
              example: Target
            level2_plural:
              type: string
              example: targets
            level3_singular:
              type: string
              example: Indicator
              description: The name of each Outcome's own indicators in this set, e.g. Measure for the TOM System
            level3_plural:
              type: string
              example: indicators
            value_source:
              type: string
              enum: [organisation_values, set_values]
            version_label:
              type: string
              nullable: true
            supersedes_id:
              type: integer
              nullable: true
              description: The Framework Set this version replaces
            status:
              type: string
              enum: [draft, live]
            frameworks:
              type: array
              items:
                type: object
                properties:
                  template_id:
                    type: integer
                    description: The Impact Framework (template)
                  name:
                    type: string
                  position:
                    type: integer
                  short_code:
                    type: string
                    nullable: true
                  colour:
                    type: string
                    nullable: true
                  text_colour:
                    type: string
                    nullable: true
            financial_values:
              type: array
              items:
                type: object
                properties:
                  outcome_id:
                    type: integer
                  indicator_id:
                    type: integer
                    nullable: true
                    description: One of the Outcome's own Indicators whose value this is; empty for the Outcome's own value
                  financial_value_id:
                    type: integer
                  financial_value_name:
                    type: string
                    description: The Financial Value's name, as on the Framework Set page
                  amount:
                    type: number
                    description: The Financial Value's amount, in its currency
                  currency:
                    type: string
                    description: The currency's code, e.g. GBP

    PaginatedFrameworkSets:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FrameworkSet'

    FrameworkSetInput:
      type: object
      required: [charity_id]
      properties:
        charity_id:
          type: integer
          description: The organisation the user is acting for
        name:
          type: string
        availability:
          type: string
          enum: [platform, network, charity]
        network_id:
          type: integer
        level1_singular:
          type: string
        level1_plural:
          type: string
        level2_singular:
          type: string
        level2_plural:
          type: string
        level3_singular:
          type: string
        level3_plural:
          type: string
        value_source:
          type: string
          enum: [organisation_values, set_values]
        version_label:
          type: string
        supersedes_id:
          type: integer
        status:
          type: string
          enum: [draft, live]
        frameworks:
          type: array
          description: Impact Frameworks in order. Replaces the current list.
          items:
            type: object
            required: [template_id]
            properties:
              template_id:
                type: integer
              short_code:
                type: string
              colour:
                type: string
                example: "#C5192D"
              text_colour:
                type: string
                example: "#FFFFFF"
        new_frameworks:
          type: array
          description: Names of new Impact Frameworks to create and add at the end
          items:
            type: string
        financial_values:
          type: array
          description: |
            The Financial Value for each Outcome, and optionally for each of an Outcome's own Indicators
            (give indicator_id), used when value_source is set_values. An Indicator's value is used instead
            of its Outcome's. Replaces the current list.
          items:
            type: object
            properties:
              outcome_id:
                type: integer
              indicator_id:
                type: integer
                description: One of the Outcome's own Indicators, e.g. a TOMs Measure
              financial_value_id:
                type: integer

    FrameworkContribution:
      type: object
      properties:
        framework_set_id:
          type: integer
        charity_id:
          type: integer
        project_id:
          type: integer
          nullable: true
        bundle_id:
          type: integer
          nullable: true
        period:
          type: string
          example: all_time
        summary:
          type: object
          description: Each Story, Contact and entry counted once for the whole set
          properties:
            frameworks_contributed:
              type: integer
              description: How many of the set's Impact Frameworks (e.g. SDG Goals) at least one Story contributes to
            frameworks_total:
              type: integer
            stories:
              type: integer
            reached:
              type: integer
              description: Distinct Contacts (people and organisations) tagged on the counted entries
            entries:
              type: integer
            financial_value:
              type: number
        frameworks:
          type: array
          description: Every Impact Framework in the set, in order. Figures overlap, so never add them up.
          items:
            type: object
            properties:
              template_id:
                type: integer
              name:
                type: string
                example: Quality education
              short_code:
                type: string
                nullable: true
                example: "4"
              position:
                type: integer
              stories:
                type: integer
              outcomes:
                type: array
                description: The Outcomes (e.g. SDG Targets) with a contribution
                items:
                  type: object
                  properties:
                    outcome_id:
                      type: integer
                    title:
                      type: string
                    indicators:
                      type: array
                      items:
                        type: object
                        properties:
                          indicator_id:
                            type: integer
                          name:
                            type: string
                          membership:
                            type: string
                            enum: [core, linked]
                            description: "`core`: part of the framework itself; `linked`: one of the organisation's own Indicators"
                          stories:
                            type: integer
                          reached:
                            type: integer
                          financial_value:
                            type: number
                          framework_indicator_id:
                            type: integer
                            nullable: true
                            description: For a linked Indicator, which of the Outcome's own Indicators it counts as
                          counted_through_links:
                            type: boolean
                            description: For a core Indicator no Story records directly, whether linked Indicators count as it

    FrameworkLinkMigration:
      type: object
      properties:
        carried:
          type: array
          items:
            $ref: '#/components/schemas/FrameworkLinkReference'
        not_carried:
          type: array
          items:
            $ref: '#/components/schemas/FrameworkLinkReference'

    FrameworkLinkReference:
      type: object
      properties:
        id:
          type: integer
        indicator_id:
          type: integer
        outcome_id:
          type: integer

    FrameworkLink:
      allOf:
        - $ref: '#/components/schemas/Timestamps'
        - type: object
          properties:
            id:
              type: integer
            charity_id:
              type: integer
            indicator_id:
              type: integer
            indicator_name:
              type: string
              example: Bootcamp completions
            outcome_id:
              type: integer
            outcome_title:
              type: string
              example: "4.4 Increase the number of youth and adults who have relevant skills"
            framework_indicator_id:
              type: integer
              nullable: true
              description: Which of the Outcome's own Indicators this indicator counts as, if any (e.g. a TOMs Measure)
            framework_indicator_name:
              type: string
              nullable: true
            project_ids:
              type: array
              items:
                type: integer
              description: The projects the link counts in; empty when it counts in every project
            all_projects:
              type: boolean

    PaginatedFrameworkLinks:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FrameworkLink'

    PaginatedOutcomeIndicators:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/OutcomeIndicator'

    PaginatedRatioSets:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/RatioSet'

    PaginatedSubRatios:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/SubRatio'

    PaginatedRatioSetChoiceables:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/RatioSetChoiceable'

    PaginatedMediaItems:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            kind_counts:
              type: object
              description: Files of each kind for the same filters, ignoring `kind`
              properties:
                all: { type: integer }
                photo: { type: integer }
                video: { type: integer }
                audio: { type: integer }
                document: { type: integer }
            data:
              type: array
              items:
                $ref: '#/components/schemas/MediaItem'

    MediaItem:
      type: object
      description: One file in the Media Gallery. It points at the file on its Story or Contact; it is not a copy.
      properties:
        id: { type: integer }
        kind: { type: string, enum: [photo, video, audio, document] }
        file_name: { type: string }
        content_type: { type: string, nullable: true }
        file_size: { type: integer, nullable: true, description: Bytes }
        caption: { type: string, nullable: true }
        source_type: { type: string, enum: [story, contact], description: "`contact` means a file on a Contact's bio" }
        source_id: { type: integer, description: Story ID or Contact (Beneficiary) ID }
        source_title: { type: string, nullable: true, description: Story title or Contact name }
        project_id: { type: integer, nullable: true, description: The Story's Project; null for Contact bio files }
        project_name: { type: string, nullable: true }
        uploaded_by_id: { type: integer, nullable: true }
        uploaded_at: { type: string, format: date-time }
        updated_at: { type: string, format: date-time }
        thumbnail_url: { type: string, nullable: true, description: Photos only }

    MediaItemDetail:
      allOf:
        - $ref: '#/components/schemas/MediaItem'
        - type: object
          properties:
            field_name:
              type: string
              description: "Where the file sits: `Profile picture`, `<field> (file field)`, `Story attachment` or `Contact attachment`"
            download_url:
              type: string
              nullable: true
              description: Signed link that downloads the file. Null if the file has no stored address.
            download_url_expires_in:
              type: integer
              description: Seconds until `download_url` stops working

    FormDefinitionField:
      type: object
      description: One entry in `contact_form.fields` or a survey's `fields` — the same shape regardless of which form it came from.
      properties:
        id:
          type: integer
          description: The CurrentField id — key submitted answers back to the server using this, not the field name
          example: 500
        name:
          type: string
          example: "Full Name"
        field_type:
          type: string
          nullable: true
          enum: [string, text, boolean, integer, float, date, time, datetime, list, media, file, telephone, email_address, location, extended_table, section]
          description: "null for a genuinely unrecognised field"
        field_kind:
          type: string
          enum: [in_built_field, custom_field, ratio_set, indicator, change, outcome]
        order:
          type: integer
        mandatory:
          type: boolean
        options:
          type: array
          description: "{id, name} Sub Ratio options, for ratio_set/indicator fields — always submit the id, never the name"
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string
        choice:
          type: string
          nullable: true
          enum: [single_choice, limited_choice, unlimited_choice]
          description: Only present for ratio_set/indicator fields
        choice_max:
          type: integer
          nullable: true
          description: Only present when choice is limited_choice
        indicator_type:
          type: string
          nullable: true
          enum: [scale, binary, value]
          description: "Only present for field_kind: indicator"
        validation:
          type: object
          nullable: true
          description: Only present for CustomFields with validation configured
          properties:
            add_validation:
              type: boolean
            min_length:
              type: integer
            max_length:
              type: integer
            character_type:
              type: string
            earliest_date:
              type: string
            latest_date:
              type: string
            default_country:
              type: string
        columns:
          type: array
          items:
            type: string
          description: "Column names — only present for field_type: extended_table"
        description:
          type: string
          description: The field's Question Explanation — only present when set

    FormDefinitionSkipLogicRule:
      type: object
      properties:
        source_field_id:
          type: integer
          description: The field whose answer is the trigger
        destination_field_id:
          type: integer
          description: The field the rule affects
        kind:
          type: string
          enum: [hide_unless, jump_to]
          description: Contact forms only ever produce hide_unless; surveys can produce either
        sub_ratio_ids:
          type: array
          items:
            type: integer

    FormDefinitionFormSection:
      type: object
      description: Shared shape for contact_form and each entry in surveys
      properties:
        type:
          type: string
          example: "BeneficiaryCategory"
        id:
          type: integer
        name:
          type: string
        wave:
          nullable: true
        fields:
          type: array
          items:
            $ref: '#/components/schemas/FormDefinitionField'
        skip_logic:
          type: array
          items:
            $ref: '#/components/schemas/FormDefinitionSkipLogicRule'
        beneficiary_role:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
        beneficiary_type:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string

    SignupPageList:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/SignupPage'

    SignupPage:
      type: object
      properties:
        id:
          type: integer
          example: 123
        name:
          type: string
          example: "Family signup"
        organisation:
          $ref: '#/components/schemas/IdName'
        type:
          type: string
          enum: [fixed, flexible]
        status:
          type: string
          example: "activated"
        active:
          type: boolean
        public_link:
          type: string
          example: "https://app.makerble.com/charities/42/projects/7/beneficiaries/new?referral_link_detail_id=123"
        emails_enabled:
          type: boolean
          description: Whether any Send Emails email is switched on
        allow_finish_later:
          type: boolean
          description: Whether people filling in the Signup Page can save it part-way through and finish it later from a resume link (the "Allow people to save this form and finish it later" setting)
        created_by:
          type: object
          nullable: true
          properties:
            id:
              type: integer
            name:
              type: string
          description: "`null` when the Signup Page predates this being recorded; the screen shows the Organisation's name"
        created_at:
          type: string
          format: date-time
        last_updated_by:
          type: object
          nullable: true
          properties:
            id:
              type: integer
            name:
              type: string
        updated_at:
          type: string
          format: date-time
        individuals:
          type: array
          items:
            $ref: '#/components/schemas/SignupPageIndividual'

    SignupPageIndividual:
      type: object
      properties:
        label:
          type: string
          example: "Individual A"
        audience:
          type: object
          nullable: true
          properties:
            id:
              type: integer
            name:
              type: string
          description: The audience (Beneficiary Role), on a flexible Signup Page
        contact_form:
          $ref: '#/components/schemas/IdName'
        project:
          $ref: '#/components/schemas/IdName'
        beneficiary_state:
          $ref: '#/components/schemas/IdName'
        surveys:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string
              wave:
                type: object
                nullable: true
                properties:
                  id:
                    type: integer
                  name:
                    type: string
        send_emails:
          type: boolean

    IdName:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string

    StaffFormDefinition:
      allOf:
        - $ref: '#/components/schemas/FormDefinition'
        - type: object
          properties:
            send_emails:
              allOf: [{ $ref: '#/components/schemas/SignupPageSendEmails' }]
              description: Present only when a Send Emails email is switched on

    SignupPageSendEmails:
      type: object
      properties:
        individuals:
          type: array
          items:
            allOf:
              - type: object
                properties:
                  label:
                    type: string
                  audience:
                    type: object
                    nullable: true
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                  contact_form:
                    $ref: '#/components/schemas/IdName'
                  enabled:
                    type: boolean
                  recipient_fields:
                    type: array
                    description: The Contact Form's email fields the email is sent to. Only when enabled
                    items:
                      $ref: '#/components/schemas/IdName'
              - $ref: '#/components/schemas/SignupPageEmail'
        additional_recipients:
          allOf:
            - type: object
              properties:
                enabled:
                  type: boolean
                recipients:
                  type: array
                  items:
                    type: string
                    format: email
            - $ref: '#/components/schemas/SignupPageEmail'

    SignupPageCreateRequest:
      type: object
      required: [charity_id, name, type]
      properties:
        charity_id:
          type: integer
          description: The Organisation
        name:
          type: string
        type:
          type: string
          enum: [fixed, flexible]
        active:
          type: boolean
          default: true
        project_id:
          type: integer
          description: Individual A's Project (fixed), or the Signup Page's (flexible; defaults to the first audience's)
        beneficiary_state_id:
          type: integer
          description: The project status (Beneficiary State) people are added with
        contact_form_id:
          type: integer
          description: Individual A's Contact Form (Beneficiary Category)
        surveys:
          $ref: '#/components/schemas/SignupPageSurveyChoice'
        description:
          type: string
        thank_you_message:
          type: string
        allow_finish_later:
          type: boolean
          default: false
          description: Let people filling in the Signup Page save it part-way through and finish it later from a resume link. Unfinished forms are deleted 30 days after they were last saved.
        individuals:
          type: array
          description: Fixed only. Individual B, C, ... in order
          items:
            type: object
            properties:
              relationship_category_id:
                type: integer
              relationship:
                type: string
                description: The Relationship Category's parent or child title for this individual, e.g. "Child"
              project_id:
                type: integer
              beneficiary_state_id:
                type: integer
              contact_form_id:
                type: integer
              surveys:
                $ref: '#/components/schemas/SignupPageSurveyChoice'
        audiences:
          type: array
          description: Flexible only. One per audience (Beneficiary Role)
          items:
            type: object
            properties:
              beneficiary_role_id:
                type: integer
              project_id:
                type: integer
              beneficiary_state_id:
                type: integer
              contact_form_id:
                type: integer
              surveys:
                $ref: '#/components/schemas/SignupPageSurveyChoice'

    SignupPageSurveyChoice:
      type: array
      description: Surveys (Story Categories) the Project collects, each optionally with one of its waves
      items:
        type: object
        required: [id]
        properties:
          id:
            type: integer
          wave_id:
            type: integer

    SignupPageEmailSettingsRequest:
      type: object
      properties:
        individuals:
          type: array
          items:
            type: object
            required: [label]
            properties:
              label:
                type: string
                description: The individual's label from the definition, e.g. "Individual A"
              enabled:
                type: boolean
              subject_line:
                type: string
              message_body:
                type: string
                description: HTML. May contain {{Field name}} merge tags
              recipient_field_ids:
                type: array
                description: Email fields on the individual's Contact Form to send to
                items:
                  type: integer
              include_submission_details:
                type: boolean
              included_individuals:
                type: array
                description: Labels of the individuals whose submitted details are added
                items:
                  type: string
        additional_recipients:
          type: object
          properties:
            enabled:
              type: boolean
            recipients:
              type: array
              items:
                type: string
                format: email
            subject_line:
              type: string
            message_body:
              type: string
            include_submission_details:
              type: boolean
            included_individuals:
              type: array
              items:
                type: string

    SignupPageEmail:
      type: object
      description: Only when the email is enabled
      properties:
        subject_line:
          type: string
          example: "Welcome {{name}}"
        message_body:
          type: string
          description: HTML
        merge_tags:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                example: "name"
              id:
                type: integer
                nullable: true
                description: The Contact Form field, or null when no field has this name
              field_type:
                type: string
                nullable: true
        include_submission_details:
          type: boolean
        included_individuals:
          type: array
          description: The individuals whose submitted details are added to the email
          items:
            type: object
            properties:
              label:
                type: string
              contact_form:
                $ref: '#/components/schemas/IdName'

    FormDefinition:
      type: object
      properties:
        definition_version:
          type: string
          description: ISO 8601 timestamp identifying this snapshot of the Signup Page — echo back unchanged in the submission sync request
          example: "2026-08-28T12:00:00.000+01:00"
        signup_page:
          type: object
          properties:
            id:
              type: integer
              example: 123
            name:
              type: string
              example: "Bambanani Signup"
            description:
              type: string
              nullable: true
            link_type:
              type: string
              enum: [structured, personalised]
            status:
              type: string
              example: "activated"
            thank_you_message:
              type: string
            allow_referrer:
              type: boolean
            project:
              type: object
              properties:
                id:
                  type: integer
                name:
                  type: string
            beneficiary_state:
              type: object
              properties:
                id:
                  type: integer
                name:
                  type: string
            contact_form:
              $ref: '#/components/schemas/FormDefinitionFormSection'
            surveys:
              type: array
              items:
                $ref: '#/components/schemas/FormDefinitionFormSection'
            settings:
              type: object
              properties:
                redirect_after_signup:
                  type: object
                  properties:
                    enabled:
                      type: boolean
                    url:
                      type: string
                      nullable: true
                redirect_after_deactivate:
                  type: object
                  properties:
                    enabled:
                      type: boolean
                    url:
                      type: string
                      nullable: true
                delete_abandoned_beneficiary:
                  type: boolean
                hide_add_another_button_on_thank_you_page:
                  type: boolean
                display_project_image:
                  type: boolean
                see_summary:
                  type: boolean
                event_guest_person_names:
                  type: boolean
            charity:
              type: object
              properties:
                name:
                  type: string
                logo_url:
                  type: string
                  nullable: true
                hide_makerble_cobranding:
                  type: boolean
        branding:
          type: object
          nullable: true
          description: The charity's full ReferralLookAndFeel attributes, or null if none configured
          additionalProperties: true
        related_people:
          type: array
          description: Only present for a structured link — one entry per possible related person, each with a referral_link_relationship_detail_id
          items:
            type: object
            additionalProperties: true
        roles:
          type: array
          description: Only present for a personalised link — one entry per role, each with a referral_link_beneficiary_role_detail_id
          items:
            type: object
            additionalProperties: true

    SubmissionCredential:
      type: object
      description: Only present in the anonymous offline-device Form Definition response
      properties:
        signup_page_id:
          type: integer
          example: 123
        token:
          type: string
          description: Bearer token for POST /referral_submissions
        scope:
          type: string
          example: "referral_submission"
        submit_url:
          type: string
          example: "https://makerble.com/api/v2/referral_submissions"

    ReferralSubmissionRequest:
      type: object
      required: [idempotency_key, definition_version]
      properties:
        idempotency_key:
          type: string
          format: uuid
          description: A fresh UUID v4, generated once at the moment a submission is completed (not per sync attempt). Retrying the same key returns the original result rather than creating duplicates.
        definition_version:
          type: string
          description: The definition_version the offline device's cached Form Definition was fetched with
        primary:
          type: object
          description: Present for a structured link (one primary person plus zero or more related_people)
          properties:
            contact_form_answers:
              type: object
              additionalProperties: true
              description: Keyed by field id from the Form Definition
            survey_answers:
              type: array
              items:
                type: object
                properties:
                  story_category_id:
                    type: integer
                  answers:
                    type: object
                    additionalProperties: true
        related_people:
          type: array
          description: Present for a structured link
          items:
            type: object
            properties:
              referral_link_relationship_detail_id:
                type: integer
              contact_form_answers:
                type: object
                additionalProperties: true
              survey_answers:
                type: array
                items:
                  type: object
        roles:
          type: array
          description: Present for a personalised link instead of primary/related_people — one entry per person, no "primary" concept
          items:
            type: object
            properties:
              referral_link_beneficiary_role_detail_id:
                type: integer
              contact_form_answers:
                type: object
                additionalProperties: true
              survey_answers:
                type: array
                items:
                  type: object
      example:
        idempotency_key: "8f14e45f-ceea-467e-8a4c-b1a2c9c6f2a3"
        definition_version: "2026-08-28T12:00:00.000+01:00"
        primary:
          contact_form_answers: { "500": "Jane Doe", "501": "44 7911 123456" }
          survey_answers:
            - story_category_id: 200
              answers: { "600": "Great progress this month" }
        related_people:
          - referral_link_relationship_detail_id: 12
            contact_form_answers: { "502": "Baby Doe" }
            survey_answers: []

    ReferralSubmissionResponse:
      type: object
      properties:
        idempotent_replay:
          type: boolean
          description: true if this idempotency_key had already been processed — the response reflects the original processing result, not a new one
        definition_version_mismatch:
          type: boolean
          description: true if the submitted definition_version doesn't match the Signup Page's current one. Non-blocking — surfaced but doesn't prevent processing
        created_beneficiary_ids:
          type: array
          items:
            type: integer
        created_story_ids:
          type: array
          items:
            type: integer
      example:
        idempotent_replay: false
        definition_version_mismatch: false
        created_beneficiary_ids: [4501, 4502]
        created_story_ids: [8801]

    CohortTracker:
      type: object
      properties:
        id:
          type: integer
          example: 17
        name:
          type: string
          example: "Children attending 75%+"
        description:
          type: string
          nullable: true
        charity_id:
          type: integer
        user_id:
          type: integer
          nullable: true
        membership:
          type: string
          enum: [ever_enrolled, currently_enrolled]
          description: Membership of the Project or Album the tracker is placed on
        result_type:
          type: string
          enum: [number, percentage]
          description: Show the result as a number of Contacts, or a percentage of the denominator
        denominator:
          type: string
          enum: [members, enough_data, filtered]
          nullable: true
          description: |
            For a percentage, what it is out of: `members` (Contacts in this Project / Album),
            `enough_data` (Contacts with enough data to be judged on every data-based criterion: invited
            to an event in scope for Attendance Rate, two or more Choice Tracker responses for Distance
            Travelled Direction, a response to the question for an answer-based criterion), or `filtered`
            (members who also meet `denominator_criteria`). null for a number.
        denominator_criteria:
          type: object
          description: For a `filtered` denominator, the Contact Filter criteria the members must meet. `{}` otherwise
          example:
            group_ids: ["12"]
        criteria:
          type: object
          description: Contact Filter criteria, in the shape a Saved Filter uses
          example:
            attendance_rate: { change_id: "412", from: "75", to: "100" }
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CohortTrackerDetail:
      allOf:
        - $ref: '#/components/schemas/CohortTracker'
        - type: object
          properties:
            usage:
              type: object
              properties:
                projects:
                  type: integer
                albums:
                  type: integer
                templates:
                  type: integer
            names_projects_or_albums:
              type: boolean

    CohortTrackerRequest:
      type: object
      properties:
        cohort_tracker:
          type: object
          properties:
            charity_id:
              type: integer
              description: Required when creating
            name:
              type: string
            description:
              type: string
            membership:
              type: string
              enum: [ever_enrolled, currently_enrolled]
            criteria:
              type: object
            result_type:
              type: string
              enum: [number, percentage]
              description: Default number
            denominator:
              type: string
              enum: [members, enough_data, filtered]
              description: For a percentage. Defaults to members
            denominator_criteria:
              type: object
              description: |
                Required when denominator is `filtered`: Contact Filter criteria, the same keys as `criteria`,
                for the Contacts the percentage is out of. Cleared for any other denominator
        confirm_clear_targets:
          type: boolean
          description: |
            Update only. Switching result_type between number and percentage clears the tracker's
            targets everywhere, so it is refused (422) while it has targets unless this is true.

    CohortTrackerDeadline:
      type: object
      properties:
        date:
          type: string
          format: date
          example: "2026-12-31"
        number:
          type: integer
          example: 40

    CohortTrackerTargetsRequest:
      type: object
      description: |
        Send target, deadlines or both. deadlines replaces the tracker's deadline targets. For a
        percentage tracker, the target and each deadline number are a whole percentage from 0 to 100.
      properties:
        target:
          type: integer
          minimum: 0
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    CohortTrackerPlacement:
      type: object
      properties:
        cohort_tracker_id:
          type: integer
        project_id:
          type: integer
        column:
          type: string
          enum: [activities, engagement, potential, behaviour, growth]
        target:
          type: integer
          example: 40
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    CohortTrackerAlbumTargets:
      type: object
      properties:
        cohort_tracker_id:
          type: integer
        album_id:
          type: integer
        album_target_type:
          type: string
          enum: [manual_target, automatic_target]
        target:
          type: integer
          example: 120
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    CohortTrackerResult:
      type: object
      properties:
        cohort_tracker_id:
          type: integer
        name:
          type: string
        project_id:
          type: integer
          description: Present for a Project's result
        album_id:
          type: integer
          description: Present for an Album's result
        timeframe:
          type: string
          enum: [period, year_to_date, all_time]
        starts_on:
          type: string
          format: date
          nullable: true
          description: null when the window runs from the start
        ends_on:
          type: string
          format: date
        count:
          type: integer
          description: The result, a number of distinct Contacts
        eligible_count:
          type: integer
          description: Members the criteria could judge (who have the data the criteria need)
        result_type:
          type: string
          enum: [number, percentage]
        denominator:
          type: string
          enum: [members, enough_data, filtered]
          nullable: true
        denominator_count:
          type: integer
          nullable: true
          description: For a percentage, how many Contacts it is out of. null for a number
        percentage:
          type: integer
          nullable: true
          description: count as a whole percentage of denominator_count. null for a number, or when denominator_count is 0
        target:
          type: object
          nullable: true
          properties:
            number:
              type: integer
            date:
              type: string
              format: date
              nullable: true
              description: null for the one-off target
        qualifying_value_label:
          type: string
          nullable: true
          example: Attendance rate
        cohort:
          type: string
          enum: [in, not_in]
          description: Which Contacts data lists
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              restricted:
                type: boolean
                description: true for a Contact the user may not read; no other fields are given
              id:
                type: integer
              name:
                type: string
              qualifying_value:
                type: number
                nullable: true

    PaginatedCohortTrackers:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/CohortTracker'

    WorkflowTrackerAttributes:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        source:
          type: string
          enum: [signpostings, internal_referrals, cases_created, cases_closed, cases_open, time_spent]
          description: What it counts
        count_mode:
          type: string
          enum: [items, contacts]
          description: "items: each signposting, referral, Case or Case closing (adds up across periods, except cases_open); contacts: each Contact once (a snapshot)"
        settings:
          type: object
          description: "internal_referrals: which Projects count as a referral. The Cases sources: the Case Form to count (null for any). time_spent: which Timesheets, and whose time. signpostings has none."
          properties:
            destinations:
              type: string
              enum: [any, only, except]
            project_ids:
              type: array
              items:
                type: integer
            case_form_id:
              type: integer
              nullable: true
              description: "Cases sources only: count only the Cases created with this one of the Organisation's Case Forms"
            kinds:
              type: array
              description: "time_spent only: which Timesheets count (default updates_and_tasks and event_staff)"
              items:
                type: string
                enum: [updates_and_tasks, event_staff, event_guests]
            user_ids:
              type: array
              description: "time_spent only: count only these colleagues' time (with roles, either counts)"
              items:
                type: integer
            roles:
              type: array
              description: "time_spent only: count only the time of people with these roles in the Organisation or the Project"
              items:
                type: string
                enum: [editor, reporter, observer]
        contact_criteria:
          $ref: '#/components/schemas/WorkflowTrackerContactCriteria'

    WorkflowTrackerContactCriteria:
      type: object
      description: >-
        "Only count contacts who match": Contact Filters criteria, in the same shape as a Cohort Tracker's criteria
        and a Saved Filter's, that a Contact must meet for their items to count. Matched on each Contact's current
        details, so editing a Contact can change past results. {} counts every Contact. Keys a Contacts filter
        doesn't read, and blank values, are dropped.
      additionalProperties: true
      example:
        age_to:
          year: "17"
        beneficiary_types: ["3"]

    WorkflowTracker:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
          example: "Signpostings made"
        description:
          type: string
          nullable: true
        charity_id:
          type: integer
        user_id:
          type: integer
          nullable: true
        source:
          type: string
          enum: [signpostings, internal_referrals, cases_created, cases_closed, cases_open, time_spent]
        count_mode:
          type: string
          enum: [items, contacts]
        result_kind:
          type: string
          enum: [additive, snapshot]
          description: additive adds up across periods; snapshot (counting each Contact once, or cases_open) works each timeframe out on its own
        unit:
          type: string
          enum: [count, hours]
          description: What its numbers are in; hours (to 1 decimal place) for time_spent
        settings:
          type: object
          example:
            destinations: "except"
            project_ids: [4512]
        contact_criteria:
          $ref: '#/components/schemas/WorkflowTrackerContactCriteria'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    WorkflowTrackerDetail:
      allOf:
        - $ref: '#/components/schemas/WorkflowTracker'
        - type: object
          properties:
            usage:
              type: object
              properties:
                projects:
                  type: integer
                albums:
                  type: integer
                templates:
                  type: integer

    WorkflowTrackerRequest:
      type: object
      properties:
        workflow_tracker:
          allOf:
            - $ref: '#/components/schemas/WorkflowTrackerAttributes'
            - type: object
              properties:
                charity_id:
                  type: integer
                  description: Required when creating

    WorkflowTrackerPreview:
      type: object
      properties:
        project_id:
          type: integer
        period_end:
          type: string
          format: date
        result_kind:
          type: string
          enum: [additive, snapshot]
        results:
          type: object
          description: Whole numbers, or hours to 1 decimal place for time_spent
          properties:
            period:
              type: number
            year_to_date:
              type: number
            all_time:
              type: number
        hidden_count:
          type: integer
          description: Latest records counted but not listed, because the user may not see them (e.g. a confidential Case)
        records:
          type: array
          description: The latest records counted that the user may see
          items:
            type: object
            properties:
              contact_name:
                type: string
                nullable: true
              detail:
                type: string
                description: Who they were signposted to, the Project they were referred to, the Case's title, or the Update, Task or Event the time was logged on
              happened_at:
                type: string
                format: date-time
              user_name:
                type: string
                nullable: true
                description: "time_spent only: whose time it is (null for an Event guest's, named in contact_name)"
              hours:
                type: number
                nullable: true
                description: time_spent only, to 1 decimal place

    WorkflowTrackerPlacement:
      type: object
      properties:
        workflow_tracker_id:
          type: integer
        project_id:
          type: integer
        column:
          type: string
          enum: [activities, engagement, potential, behaviour, growth]
        target:
          type: integer
          example: 40
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    WorkflowTrackerAlbumTargets:
      type: object
      properties:
        workflow_tracker_id:
          type: integer
        album_id:
          type: integer
        album_target_type:
          type: string
          enum: [manual_target, automatic_target]
        target:
          type: integer
          example: 120
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    WorkflowTrackerResult:
      type: object
      properties:
        workflow_tracker_id:
          type: integer
        name:
          type: string
        project_id:
          type: integer
          description: Present for a Project's result
        album_id:
          type: integer
          description: Present for an Album's result
        timeframe:
          type: string
          enum: [period, year_to_date, all_time]
        starts_on:
          type: string
          format: date
          nullable: true
          description: Null when the window runs from the start
        ends_on:
          type: string
          format: date
        result_kind:
          type: string
          enum: [additive, snapshot]
        as_of:
          type: string
          format: date
          nullable: true
          description: For a snapshot, the date it is read at
        number:
          type: number
          description: A whole number, or hours to 1 decimal place for time_spent
        target:
          type: integer
          nullable: true
        page:
          type: integer
        page_size:
          type: integer
          description: Items listed on this page
        page_count:
          type: integer
        total_count:
          type: integer
          description: Every item counted, whatever the count mode
        hidden_count:
          type: integer
          description: Items on this page counted but not listed, because the user may not see them
        data:
          type: array
          items:
            type: object
            properties:
              contact_id:
                type: integer
                nullable: true
                description: Null for a time_spent entry of a colleague's time
              contact_name:
                type: string
                nullable: true
              detail:
                type: string
                nullable: true
                description: Who the Contact was signposted to, the Project they were referred to, the Case's title, or the Update, Task or Event the time was logged on
              project_id:
                type: integer
                nullable: true
                description: A referral's destination Project
              case_id:
                type: integer
                nullable: true
                description: The Case, for the Cases sources
              happened_at:
                type: string
                format: date-time
                description: For time_spent, the Update's date, when the Task was done, or when the Event started
              user_id:
                type: integer
                nullable: true
                description: "time_spent only: whose time it is (null for an Event guest's)"
              user_name:
                type: string
                nullable: true
              hours:
                type: number
                nullable: true
                description: time_spent only, to 1 decimal place
              story_id:
                type: integer
                nullable: true
                description: "time_spent only: the Update (Story) the time was logged on"
              task_id:
                type: integer
                nullable: true
                description: "time_spent only: the Task the time was logged on"
              event_id:
                type: integer
                nullable: true
                description: "time_spent only: the Event the time was logged on"

    FormulaToken:
      type: object
      required: [kind]
      description: "One part of a formula: a tracker, an operator, a number or a bracket"
      properties:
        kind:
          type: string
          enum: [tracker, operator, number, open, close]
        type:
          type: string
          enum: [Change, Indicator, CohortTracker, WorkflowTracker, FilteredMetric, FormulaTracker]
          description: "tracker only: the tracker's type"
        id:
          type: integer
          description: "tracker only: the tracker's id"
        value:
          description: "operator: +, -, * or /. number: the number."
          oneOf:
            - type: string
            - type: number

    FormulaTracker:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
          example: "Referrals completed"
        description:
          type: string
          nullable: true
        charity_id:
          type: integer
        user_id:
          type: integer
          nullable: true
        expression:
          type: array
          items:
            $ref: '#/components/schemas/FormulaToken'
        formula_text:
          type: string
          example: "External referrals + Internal referrals"
        display_format:
          type: string
          enum: [number, percentage]
        decimal_places:
          type: integer
          minimum: 0
          maximum: 3
        unit_label:
          type: string
          nullable: true
          example: "h per child"
        result_kind:
          type: string
          enum: [additive, snapshot]
          description: additive adds up across periods (only + and − of trackers that add up); snapshot works each timeframe out from its own totals
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    FormulaTrackerAlbumTargets:
      type: object
      properties:
        formula_tracker_id:
          type: integer
        album_id:
          type: integer
        album_target_type:
          type: string
          enum: [manual_target, automatic_target]
        target:
          type: integer
          example: 120
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    FormulaTrackerAttributes:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        expression:
          type: array
          description: The formula, in order
          items:
            $ref: '#/components/schemas/FormulaToken'
        display_format:
          type: string
          enum: [number, percentage]
          description: "Show result as: number (default) or percentage"
        decimal_places:
          type: integer
          minimum: 0
          maximum: 3
        unit_label:
          type: string
          maxLength: 50
          description: e.g. "h per child", shown after a number

    FormulaTrackerDetail:
      allOf:
        - $ref: '#/components/schemas/FormulaTracker'
        - type: object
          properties:
            usage:
              type: object
              properties:
                projects:
                  type: integer
                albums:
                  type: integer
                templates:
                  type: integer
            warnings:
              type: array
              description: Things worth checking that don't stop it being saved, e.g. a tracker used twice
              items:
                type: string

    FormulaTrackerOperand:
      type: object
      properties:
        type:
          type: string
          enum: [Change, Indicator, CohortTracker, WorkflowTracker, FilteredMetric, FormulaTracker]
        id:
          type: integer
        name:
          type: string
          example: "External referrals"
        type_name:
          type: string
          example: "Engagement tracker"
        unit:
          type: string
          example: "count"
        result_kind:
          type: string
          enum: [additive, snapshot]

    FormulaTrackerPlacement:
      type: object
      properties:
        formula_tracker_id:
          type: integer
        project_id:
          type: integer
        column:
          type: string
          enum: [activities, engagement, potential, behaviour, growth]
        target:
          type: integer
          example: 40
        deadlines:
          type: array
          items:
            $ref: '#/components/schemas/CohortTrackerDeadline'

    FormulaTrackerPreview:
      type: object
      properties:
        project_id:
          type: integer
        period_end:
          type: string
          format: date
        result_kind:
          type: string
          enum: [additive, snapshot]
        results:
          $ref: '#/components/schemas/FormulaTrackerTimeframeResults'
        warnings:
          type: array
          items:
            type: string
        trackers:
          type: array
          description: Each tracker the formula uses, with its own results
          items:
            type: object
            properties:
              type:
                type: string
              id:
                type: integer
              name:
                type: string
              type_name:
                type: string
              results:
                $ref: '#/components/schemas/FormulaTrackerTimeframeResults'

    FormulaTrackerRequest:
      type: object
      properties:
        formula_tracker:
          allOf:
            - $ref: '#/components/schemas/FormulaTrackerAttributes'
            - type: object
              properties:
                charity_id:
                  type: integer
                  description: Required when creating

    FormulaTrackerResult:
      type: object
      properties:
        formula_tracker_id:
          type: integer
        name:
          type: string
        project_id:
          type: integer
          description: Present for a Project's result
        album_id:
          type: integer
          description: Present for an Album's result
        timeframe:
          type: string
          enum: [period, year_to_date, all_time]
        starts_on:
          type: string
          format: date
          nullable: true
          description: Null when the window runs from the start
        ends_on:
          type: string
          format: date
        result_kind:
          type: string
          enum: [additive, snapshot]
        as_of:
          type: string
          format: date
          nullable: true
          description: For a snapshot, the date it is read at
        display_format:
          type: string
          enum: [number, percentage]
        decimal_places:
          type: integer
        unit:
          type: string
          description: '"percentage", the unit label (e.g. "h per child"), or "count"'
        number:
          type: number
          nullable: true
          description: Null when a tracker the formula uses has no result, or it divides by 0
        display_value:
          type: string
          description: The result as the Results Canvas shows it, e.g. "37.5%" or "2.4 h per child"; "–" when number is null
        target:
          type: number
          nullable: true
        formula:
          type: string
          description: e.g. "Referrals completed = External referrals + Internal referrals"
        formula_with_values:
          type: string
          description: The formula with each tracker's number in place, e.g. "2 + 3"; "–" for a tracker with no number
        trackers:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                description: Change, Indicator, CohortTracker, WorkflowTracker, FilteredMetric or FormulaTracker
              id:
                type: integer
              name:
                type: string
              type_name:
                type: string
                description: e.g. "Engagement tracker" or "Workflow Tracker"
              unit:
                type: string
              number:
                type: number
                nullable: true
        itemised:
          type: boolean
          description: Whether the formula only adds Workflow Trackers that count items, so data lists them
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
          description: Every item counted, when itemised; otherwise 0
        hidden_count:
          type: integer
          description: How many more on this page are counted but not listed, because the user can't see them
        data:
          type: array
          items:
            type: object
            properties:
              contact_id:
                type: integer
              contact_name:
                type: string
              detail:
                type: string
                nullable: true
              project_id:
                type: integer
                nullable: true
              case_id:
                type: integer
                nullable: true
              happened_at:
                type: string
                format: date-time

    FormulaTrackerTimeframeResults:
      type: object
      description: Each timeframe's result; null where it can't be worked out (e.g. dividing by 0)
      properties:
        period:
          type: number
          nullable: true
        year_to_date:
          type: number
          nullable: true
        all_time:
          type: number
          nullable: true

    PaginatedFormulaTrackerOperands:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FormulaTrackerOperand'

    PaginatedFormulaTrackers:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FormulaTracker'

    PaginatedWorkflowTrackers:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/WorkflowTracker'
    ContactAutomation:
      type: object
      description: A Contact Automation (AlertTrigger)
      properties:
        id: {type: integer}
        project_id: {type: integer}
        charity_id: {type: integer}
        user_id: {type: integer}
        active: {type: boolean, description: false when paused}
        action_types: {type: array, items: {type: string}, example: ["Survey", "In-App-alert with no escalation"]}
        criteria:
          type: object
          properties:
            field_type: {type: string, nullable: true, enum: [CurrentField, EventState, Relationships]}
            field_id: {type: integer, nullable: true}
            field: {type: string, nullable: true, example: minutes_since_contact_enrolled}
            condition: {type: string}
            value: {type: integer, description: Minutes for the "Amount of time" fields}
            state_ids: {type: array, items: {type: integer}}
            text: {type: string, nullable: true}
            survey_id: {type: integer, nullable: true}
            verdict_ids: {type: array, items: {type: integer}}
            contact_filter: {type: boolean}
            contact_criteria: {type: string, nullable: true}
        actions:
          type: object
          properties:
            in_app_alert: {type: object}
            send_survey: {type: object}
            change_status: {type: array, items: {type: object}}
            flags: {type: array, items: {type: object}}
            email_enabled: {type: boolean}
            sms_enabled: {type: boolean}
        created_at: {type: string, format: date-time}
        updated_at: {type: string, format: date-time}
    ContactAutomationRequest:
      type: object
      required: [project_id, criteria]
      properties:
        project_id: {type: integer}
        active: {type: boolean, default: true}
        criteria:
          type: object
          required: [condition]
          properties:
            field: {type: string}
            current_field_id: {type: integer}
            relationship_category_id: {type: integer}
            event_state_id: {type: integer}
            condition: {type: string}
            value: {type: integer}
            state_ids: {type: array, items: {type: integer}}
            text: {type: string}
            survey_id: {type: integer}
            verdict_ids: {type: array, items: {type: integer}}
        actions:
          type: object
          properties:
            send_survey:
              type: object
              properties:
                survey_id: {type: integer}
                via_email: {type: boolean}
                via_sms: {type: boolean}
                email_message: {type: string}
                sms_message: {type: string}
                expire: {type: boolean, default: true}
            in_app_alert:
              type: object
              properties:
                message: {type: string, maxLength: 40}
                recipients: {type: array, items: {type: string, enum: [beneficiary_workers, project_editors, charity_editors, charity_relationships]}}
                user_ids: {type: array, items: {type: integer}}
            change_status:
              type: array
              items:
                type: object
                properties:
                  status_id: {description: A status id from the options, or "removed"}
            flags:
              type: array
              items:
                type: object
                properties:
                  flag_id: {type: integer}
                  description: {type: string}
    PaginatedContactAutomations:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ContactAutomation'
    ProjectAutomation:
      type: object
      properties:
        id: {type: integer}
        name: {type: string}
        charity_id: {type: integer}
        user_id: {type: integer}
        active: {type: boolean, description: false when paused}
        priority: {type: integer, description: Lower runs first}
        saved_filter_id: {type: integer}
        settings: {type: object, description: The settings copied onto each matching Project}
        created_at: {type: string, format: date-time}
        updated_at: {type: string, format: date-time}
    ProjectAutomationRequest:
      type: object
      required: [charity_id, name, saved_filter_id]
      properties:
        charity_id: {type: integer}
        name: {type: string}
        saved_filter_id: {type: integer}
        active: {type: boolean, default: true}
        settings: {type: object}
    PaginatedProjectAutomations:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ProjectAutomation'
    AutomationTemplate:
      type: object
      properties:
        id: {type: integer}
        name: {type: string}
        charity_id: {type: integer}
        user_id: {type: integer}
        status: {type: string, enum: [available, hide]}
        project_ids: {type: array, items: {type: integer}, description: The Projects it has been applied to}
        contact_automation:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/ContactAutomation'
        created_at: {type: string, format: date-time}
        updated_at: {type: string, format: date-time}
    PaginatedAutomationTemplates:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/AutomationTemplate'
    FilteredMetric:
      type: object
      description: A filtered version of a Change or Indicator
      properties:
        id:
          type: integer
        display_name:
          type: string
          example: "Session attendances — Female, under 21"
        parent_type:
          type: string
          enum: [Change, Indicator]
          description: Change (Activity or Engagement tracker) or Indicator (Choice, Achievement or Numerical tracker)
        parent_id:
          type: integer
        parent_name:
          type: string
        outcome_id:
          type: integer
          nullable: true
          description: The Outcome an Indicator's filtered version sits under; null for a Change's
        response_criteria:
          type: object
          description: Response Filters (Progress Board "Filter responses/stories by" keys)
        contact_criteria:
          type: object
          description: Contact Filters, in the shape a Saved Filter uses
        charity_id:
          type: integer
        user_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    FilteredMetricRequest:
      type: object
      properties:
        filtered_metric:
          type: object
          properties:
            parent_type:
              type: string
              enum: [Change, Indicator]
              description: Creating only
            parent_id:
              type: integer
              description: Creating only
            display_name:
              type: string
            column:
              type: string
              enum: [activities, engagement, potential, behaviour, growth]
              description: Creating a Change's filtered version only; defaults to the parent's column
            response_criteria:
              type: object
            contact_criteria:
              type: object
    FilteredMetricResult:
      type: object
      properties:
        filtered_metric_id:
          type: integer
        timeframe:
          type: string
          enum: [period, year_to_date, all_time]
        start_date:
          type: string
          format: date
          nullable: true
        end_date:
          type: string
          format: date
        number:
          type: number
          description: Matching attendances (or answers); a Numerical tracker's total
        unit:
          type: string
          example: count
    PaginatedFilteredMetrics:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/FilteredMetric'

    WebhookEvent:
      type: string
      enum: [contact.created, contact.updated, contact.deleted, contact.merged, contact.restored, story.created, story.updated, story.deleted, project.created, project.updated, project.deleted, project.contact_added, project.contact_removed, import.completed]

    WebhookEndpointRequest:
      type: object
      required: [webhook_endpoint]
      properties:
        webhook_endpoint:
          type: object
          properties:
            charity_id:
              type: integer
              description: The Organisation (Charity) ID. Required when creating
            url:
              type: string
              format: uri
              description: HTTPS URL of the receiver. Required when creating
            description:
              type: string
            event_types:
              type: array
              items:
                $ref: '#/components/schemas/WebhookEvent'
              description: Defaults to every event
            active:
              type: boolean
              description: false pauses the endpoint; true resumes it

    EventbriteSettings:
      type: object
      properties:
        project_id:
          type: integer
          nullable: true
        event_category_id:
          type: integer
          nullable: true
        import_mode:
          type: string
          enum: [all_upcoming, selected]
        selected_event_ids:
          type: array
          readOnly: true
          items:
            type: string
        contact_project_id:
          type: integer
          nullable: true
        beneficiary_category_id:
          type: integer
          nullable: true
        change_id:
          type: integer
          nullable: true
        story_category_id:
          type: integer
          nullable: true
    EventbriteEventChoice:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        start:
          type: string
          description: Local start time on Eventbrite
        status:
          type: string
          enum: [live, started, ended, canceled, draft]
        url:
          type: string
        selected:
          type: boolean
        makerble_event_id:
          type: integer
          nullable: true
    EventbriteFieldPair:
      type: object
      required: [eventbrite_field, makerble_field]
      properties:
        eventbrite_field:
          type: string
        makerble_field:
          type: string
          description: A built-in field, `custom_field:<id>` or (Contacts) `dropdown:<ratio set id>`
        paused:
          type: boolean
    EventbriteFieldMapping:
      type: object
      properties:
        object_type:
          type: string
        mappings:
          type: array
          items:
            $ref: '#/components/schemas/EventbriteFieldPair'
        eventbrite_fields:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              label:
                type: string
              type:
                type: string
              compatible_makerble_fields:
                type: array
                items:
                  type: string
        makerble_fields:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              label:
                type: string
              type:
                type: string
    PaginatedEventbriteSyncLog:
      type: object
      properties:
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              outcome:
                type: string
                enum: [imported, updated, skipped, removed, needs_review, error]
              object_type:
                type: string
                enum: [connection, event, attendee, order, check_in]
              message:
                type: string
              eventbrite_id:
                type: string
                nullable: true
              eventbrite_url:
                type: string
                nullable: true
              record:
                type: object
                nullable: true
                properties:
                  type:
                    type: string
                    enum: [Contact, Event, Story]
                  id:
                    type: integer
              created_at:
                type: string
                format: date-time
              updated_at:
                type: string
                format: date-time
    EventbriteConnection:
      type: object
      properties:
        charity_id:
          type: integer
        status:
          type: string
          enum: [not_connected, choosing_organisation, active, reconnect_required]
        connected:
          type: boolean
          description: True when `status` is `active`
        available:
          type: boolean
          description: False when the Eventbrite integration isn't set up on this Makerble site
        page_url:
          type: string
          format: uri
          description: The Connect > Eventbrite page, where an admin signs in to Eventbrite
        test_succeeded:
          type: boolean
          description: Only on `POST /eventbrite_connection/test`
        eventbrite_organization:
          type: object
          nullable: true
          properties:
            id:
              type: string
            name:
              type: string
        available_organizations:
          type: array
          description: Only while `status` is `choosing_organisation`
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
        connected_by:
          type: object
          nullable: true
          properties:
            id:
              type: integer
            name:
              type: string
        last_checked_at:
          type: string
          format: date-time
          nullable: true
        last_synced_at:
          type: string
          format: date-time
          nullable: true
        syncing:
          type: boolean
          description: A sync is queued or running
        last_error:
          type: string
          nullable: true
        settings:
          $ref: '#/components/schemas/EventbriteSettings'
        check_in_problem:
          type: string
          nullable: true
          description: Why check-ins can't be recorded yet; they wait until it is put right
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      example:
        charity_id: 913
        status: active
        connected: true
        available: true
        page_url: "https://app.makerble.com/charities/hope-trust/eventbrite"
        eventbrite_organization:
          id: "555"
          name: "Hope Trust Events"
        connected_by:
          id: 42
          name: "Sam Patel"
        last_checked_at: "2026-11-04T09:15:00Z"
        last_error: null
        created_at: "2026-11-04T09:10:00Z"
        updated_at: "2026-11-04T09:15:00Z"
    WebhookEndpoint:
      type: object
      properties:
        id:
          type: integer
        charity_id:
          type: integer
        url:
          type: string
          example: "https://crm.example.org/makerble"
        description:
          type: string
          nullable: true
        event_types:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEvent'
        active:
          type: boolean
          description: false while paused
        source:
          type: string
          enum: [manual, power_automate, zapier, dynamics]
          readOnly: true
          description: |
            Who created the endpoint: `manual` for one added by hand on the Webhooks page or through
            this API, otherwise the automation platform's connector. Set by Makerble from the
            connected app (OAuth client) that made the request; it can't be sent or changed. A
            connected app may list, get, create and delete endpoints, in its connected Organisation only.
        disabled_at:
          type: string
          format: date-time
          nullable: true
          description: Set when Makerble switched the endpoint off after repeated failure
        failure_count:
          type: integer
          description: Deliveries in a row that failed every attempt
        last_success_at:
          type: string
          format: date-time
          nullable: true
        created_by_id:
          type: integer
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    WebhookEndpointWithSecret:
      allOf:
        - $ref: '#/components/schemas/WebhookEndpoint'
        - type: object
          properties:
            secret:
              type: string
              example: "whsec_3f1c..."
              description: The signing secret. Returned only when created or rotated

    WebhookDelivery:
      type: object
      properties:
        id:
          type: integer
        event_id:
          type: string
          example: "evt_6f0c2a4e-8d1b-4b7e-9a53-2f1d6c3e9b10"
          description: The `id` the receiver saw
        event:
          type: string
          example: contact.updated
        resource_type:
          type: string
          nullable: true
          description: Beneficiary (Contact), Story, Project, RecordImporter or ImportPlan
        resource_id:
          type: integer
          nullable: true
        occurred_at:
          type: string
          format: date-time
        status:
          type: string
          enum: [pending, succeeded, failed]
        attempts:
          type: integer
        response_code:
          type: integer
          nullable: true
          description: The receiver's HTTP status on the last attempt; null after a timeout or connection error
        next_attempt_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    EventFormat:
      type: object
      description: An Event Format (Event Category in the API), the template an organisation's events are created from.
      properties:
        id:
          type: integer
        name:
          type: string
        is_default:
          type: boolean
          description: One of the Event Formats every organisation starts with
        is_organisation_default:
          type: boolean
          description: |
            Whether this is the organisation's default Event Format, which is added to a Project
            whenever events are turned on there. An organisation has at most one.
        charity_id:
          type: integer
          description: The Organisation (Charity) that owns it
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        events_count:
          type: integer
          description: Events using this Event Format
        projects_count:
          type: integer
          description: Projects this Event Format is added to
        can_delete:
          type: boolean
          description: Whether **Delete an Event Format** would succeed now
        delete_blocked_reason:
          type: string
          nullable: true
          description: Why it can't be deleted yet, or null

    ColleagueCapacity:
      type: object
      description: A colleague's capacity caps in one Organisation, and how much they have taken on.
      properties:
        user_id:
          type: integer
        charity_id:
          type: integer
        max_sessions_per_day:
          type: integer
          nullable: true
          description: Maximum sessions (every event they are an Event Worker on) a day, or null for no limit
        max_sessions_per_week:
          type: integer
          nullable: true
          description: Maximum sessions a week, or null for no limit
        max_per_day:
          type: integer
          nullable: true
          description: Maximum appointments a day, or null for no limit
        max_per_week:
          type: integer
          nullable: true
          description: Maximum appointments a week, or null for no limit
        max_one_to_one_contacts:
          type: integer
          nullable: true
          description: Maximum Contacts with an upcoming appointment with them, or null for no limit
        can_edit:
          type: boolean
          description: Whether you may change the caps
        usage:
          type: object
          properties:
            sessions_today:
              type: integer
              description: Events today where they are an Event Worker
            sessions_this_week:
              type: integer
              description: Monday to Sunday, in the Organisation's timezone
            appointments_today:
              type: integer
            appointments_this_week:
              type: integer
              description: Monday to Sunday, in the Organisation's timezone
            ongoing_one_to_one_contacts:
              type: integer
              description: Distinct guests of their upcoming appointments

    FreeSlot:
      type: object
      description: A free start time, or the first session of a weekly series, in the Organisation's timezone
      properties:
        starts_at:
          type: string
          format: date-time
        ends_at:
          type: string
          format: date-time
          description: When the appointment ends, without its debrief time
        date:
          type: string
          format: date
        weekday:
          type: string
          example: monday
        start_time:
          type: string
          example: "10:00"
        end_time:
          type: string
          example: "11:00"
        sessions:
          type: integer
          description: For a weekly series, how many weekly sessions are free from this date
        summary:
          type: string
          description: In words, such as "Monday 23 Nov 10:00–11:00" or "Mondays 10:00–11:00 from 23 Nov"

    ColleagueFreeSlots:
      type: object
      description: A colleague's free slots for an Event Format, in the standard paged envelope
      properties:
        user_id:
          type: integer
        charity_id:
          type: integer
        event_category_id:
          type: integer
        project_id:
          type: integer
          nullable: true
        time_zone:
          type: string
          description: The Organisation's timezone, which every time is in
        from:
          type: string
          format: date
        to:
          type: string
          format: date
        weekly_sessions:
          type: integer
          nullable: true
        length_minutes:
          type: integer
          description: The Event Format's Default length
        preparation_minutes:
          type: integer
        debrief_minutes:
          type: integer
        capacity:
          type: object
          nullable: true
          description: Only if you see the colleague on Staff availability
          properties:
            max_per_day:
              type: integer
              nullable: true
            max_per_week:
              type: integer
              nullable: true
            max_one_to_one_contacts:
              type: integer
              nullable: true
            ongoing_one_to_one_contacts:
              type: integer
            at_one_to_one_limit:
              type: boolean
              description: True when a one-to-one Event Format has no free slots because the colleague is at their limit
        page:
          type: integer
        page_size:
          type: integer
        page_count:
          type: integer
        total_count:
          type: integer
        data:
          type: array
          items:
            $ref: '#/components/schemas/FreeSlot'

    SuggestedColleague:
      type: object
      properties:
        user:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
        has_all_essential:
          type: boolean
          description: Whether the colleague has every Essential need as a Specialism
        specialisms:
          type: array
          description: Each of the Contact's needs, Essential first, and whether the colleague has it as a Specialism
          items:
            type: object
            properties:
              skill_id:
                type: integer
              name:
                type: string
              importance:
                type: string
                enum: [essential, desirable]
              matched:
                type: boolean
        specialisms_summary:
          type: string
          example: "Eating disorders ✓ (essential) · Music ✗ (desirable)"
        load:
          type: object
          nullable: true
          description: Only for colleagues you see on Staff availability
          properties:
            ongoing_one_to_one_contacts:
              type: integer
            max_one_to_one_contacts:
              type: integer
              nullable: true
            summary:
              type: string
              example: "9 of 12 one-to-one Contacts"

    StaffSuggestions:
      type: object
      properties:
        beneficiary_id:
          type: integer
        project_id:
          type: integer
        event_category_id:
          type: integer
        sessions:
          type: integer
          description: How many weekly sessions a suggestion has free
        weeks:
          type: integer
          description: How many weeks ahead the first session may start
        contact_availability_note:
          type: string
          nullable: true
          description: Why the Contact's Weekly availability wasn't used, if it wasn't
          example: "Contact's availability not recorded"
        suggestions:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/SuggestedColleague'
              - type: object
                properties:
                  rank:
                    type: integer
                  first_slot:
                    $ref: '#/components/schemas/FreeSlot'
                  inside_contact_availability:
                    type: boolean
                    nullable: true
                    description: Whether the first slot is inside the Contact's Weekly availability; null if that wasn't used
        fully_booked:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/SuggestedColleague'
              - type: object
                properties:
                  free_from:
                    type: string
                    format: date
                    nullable: true
                    description: When a series could first start, if within 16 weeks
                  summary:
                    type: string
                    example: "Sarah Jones: fully booked until 8 Dec"
                  at_one_to_one_limit:
                    type: boolean
                    nullable: true
                    description: Only for colleagues you see on Staff availability

    EventFormatInput:
      type: object
      description: Settings for creating or editing an Event Format. Only the settings you send change.
      properties:
        name:
          type: string
        guest_status_ids:
          type: array
          items:
            type: integer
          description: The organisation's Guest Statuses its events use, in order
        attendance_form_id:
          type: integer
          nullable: true
          description: The Survey (Story Category) used to record attendance
        survey_kiosk_enabled:
          type: boolean
          description: Self Check-in
        survey_kiosk_registration_enabled:
          type: boolean
          description: Let new people register at Self Check-in
        enable_guest_fields:
          type: boolean
        enable_guest_booking_form:
          type: boolean
        assign_guests_to_workers_setting:
          type: string
          enum: [default, skill, limit]
        suggest_shortened_address:
          type: boolean
        apply_shortened_address:
          type: boolean
        enable_event_roles:
          type: boolean
        event_role_ids_for_event_managers_and_workers:
          type: array
          items:
            type: integer
          description: The organisation's Event Roles that Event Managers and Workers can have
        event_role_ids_for_guests:
          type: array
          items:
            type: integer
          description: The organisation's Event Roles that guests can have
        appointment_type:
          type: string
          nullable: true
          enum: [one_to_one, group, null]
          description: Appointment (`one_to_one`) or Group, or null for "Not an appointment". An appointment is with one Contact, and can have more than one staff member.
        default_length_minutes:
          type: integer
          nullable: true
          minimum: 5
          maximum: 1440
          description: How long an event of this format usually lasts, in 5-minute steps. The Create Event page sets the end time from it.
        preparation_minutes:
          type: integer
          minimum: 0
          maximum: 1440
          description: Preparation time a colleague needs before each appointment. Default 0.
        debrief_minutes:
          type: integer
          minimum: 0
          maximum: 1440
          description: Debrief time a colleague needs after each appointment. Default 0.
        send_add_to_calendar_email:
          type: boolean
          description: Send an 'Add to Calendar' email to each guest (Contact) added to an event of this format. Can only be turned on while the organisation has email messaging turned on. Default false.
        allow_guests_to_cancel:
          type: boolean
          description: Let guests cancel from the 'Add to Calendar' email. Only kept while send_add_to_calendar_email is true. Default false.
        cancellation_guest_status_id:
          type: integer
          nullable: true
          description: The Guest Status a guest who cancels is moved to. Required when allow_guests_to_cancel is true, and must be one of the Event Format's own Guest Statuses. null when guests can't cancel.

    EventGuestCalendarLinks:
      type: object
      description: A guest's Add to Calendar links (CP-7734).
      properties:
        event_id:
          type: integer
        contact_id:
          type: integer
        google_calendar_url:
          type: string
          description: Opens a new Google Calendar event with this event's name, times and location filled in
        outlook_url:
          type: string
          description: The same for Outlook.com
        office365_url:
          type: string
          description: The same for Microsoft 365 (Outlook on the web for work or school accounts)
        ics_url:
          type: string
          description: The event as an .ics file, for Apple Calendar and other calendar apps. Works without signing in, for this guest only.
        cancel_url:
          type: string
          nullable: true
          description: The page where the guest can cancel, or null when the Event Format doesn't let guests cancel. Works without signing in, for this guest only.

    UserNotificationSettings:
      type: object
      description: A user's own email notification settings (CP-7734).
      properties:
        data:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                description: The setting, e.g. event_guest_cancelled
              label:
                type: string
                description: The setting as the Notifications tab of User Settings shows it
              enabled:
                type: boolean

    EventFormatDetail:
      type: object
      description: One Event Format (Event Category in the API) with its settings.
      properties:
        id:
          type: integer
        name:
          type: string
        is_default:
          type: boolean
        is_organisation_default:
          type: boolean
          description: |
            Whether this is the organisation's default Event Format, which is added to a Project
            whenever events are turned on there. An organisation has at most one.
        charity_id:
          type: integer
        attendance_form_id:
          type: integer
          nullable: true
        survey_kiosk_enabled:
          type: boolean
        survey_kiosk_registration_enabled:
          type: boolean
        enable_guest_fields:
          type: boolean
        enable_guest_booking_form:
          type: boolean
        assign_guests_to_workers_setting:
          type: string
        suggest_shortened_address:
          type: boolean
        apply_shortened_address:
          type: boolean
        enable_event_roles:
          type: boolean
        event_role_ids_for_event_managers_and_workers:
          type: array
          items:
            type: integer
        event_role_ids_for_guests:
          type: array
          items:
            type: integer
        appointment_type:
          type: string
          nullable: true
          enum: [one_to_one, group, null]
          description: Appointment (`one_to_one`) or Group, or null for "Not an appointment". An appointment is with one Contact, and can have more than one staff member.
        default_length_minutes:
          type: integer
          nullable: true
          minimum: 5
          maximum: 1440
          description: How long an event of this format usually lasts, in 5-minute steps. The Create Event page sets the end time from it.
        preparation_minutes:
          type: integer
          minimum: 0
          maximum: 1440
          description: Preparation time a colleague needs before each appointment. Default 0.
        debrief_minutes:
          type: integer
          minimum: 0
          maximum: 1440
          description: Debrief time a colleague needs after each appointment. Default 0.
        send_add_to_calendar_email:
          type: boolean
          description: Sends an 'Add to Calendar' email to each guest added to an event of this format
        allow_guests_to_cancel:
          type: boolean
          description: Guests can cancel from the 'Add to Calendar' email
        cancellation_guest_status_id:
          type: integer
          nullable: true
          description: The Guest Status a guest who cancels is moved to
        guest_statuses:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
              name:
                type: string
        project_ids:
          type: array
          items:
            type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    EventFormatProject:
      type: object
      properties:
        event_category_id:
          type: integer
        project_id:
          type: integer
        status:
          type: string
          enum: [added, already_added, removed]

    EventCatalogueFilters:
      type: object
      description: Which upcoming events the catalogue shows. Every filter given must match.
      properties:
        project_ids:
          type: array
          items:
            type: integer
        event_category_ids:
          type: array
          items:
            type: integer
          description: Event Formats
        user_ids:
          type: array
          items:
            type: integer
          description: Events these users are Event Managers or Workers of
        beneficiary_ids:
          type: array
          items:
            type: integer
          description: Events these Contacts are guests of
        event_types:
          type: array
          items:
            type: string
            enum: [one-off, master, subsequent]
        date_from:
          type: string
          nullable: true
          description: A date range, "DD/MM/YYYY - DD/MM/YYYY"

    EventCatalogue:
      type: object
      description: An Event Catalogue, a public, bookable list of an organisation's upcoming events.
      properties:
        id:
          type: integer
        name:
          type: string
        charity_id:
          type: integer
        filters:
          $ref: '#/components/schemas/EventCatalogueFilters'
        public_url:
          type: string
          description: The public page people book from, which can also be embedded on a website
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    EventCatalogueDetail:
      allOf:
        - $ref: '#/components/schemas/EventCatalogue'
        - type: object
          properties:
            upcoming_events_count:
              type: integer
              description: How many events its public page shows now

    PaginatedEventCatalogues:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/EventCatalogue'

    EventCatalogueAccess:
      type: object
      properties:
        event_catalogue_id:
          type: integer
        project_id:
          type: integer
        mode:
          type: string
          enum: [every_enrolled, specific]
        contact_ids:
          type: array
          description: The Contacts ticked, under specific
          items:
            type: integer

    PortalLink:
      type: object
      properties:
        contact_id:
          type: integer
        name:
          type: string
        link_status:
          type: string
          enum: [active, deactivated, none]
          description: none means the Contact has never been sent a link
        last_sent_at:
          type: string
          format: date-time
          nullable: true
        last_sent_channel:
          type: string
          enum: [email, sms]
          nullable: true
        can_email:
          type: boolean
        can_sms:
          type: boolean

    PaginatedPortalLinks:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/PortalLink'

    PaginatedEventFormats:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/EventFormat'

    SeatBillingRole:
      type: object
      nullable: true
      description: A Billing Role (seat), e.g. Organiser, Practitioner or Helper. `null` on Flat Pricing.
      properties:
        id:
          type: integer
          example: 2
        name:
          type: string
          example: Helper

    SeatContract:
      type: object
      properties:
        id:
          type: integer
          example: 31
        component:
          type: string
          example: Makerble CRM
        price_plan:
          type: string
          nullable: true
          example: Standard
        pricing_model:
          type: string
          enum: [flat, role_based]
        status:
          type: string
          enum: [pending, trial, active, notice_given]
        default_for_new_colleagues:
          type: boolean
          description: New colleagues are given seats on this Contract automatically
        lines:
          type: array
          description: One line per Billing Role on Role-based Pricing, one line in all on Flat Pricing
          items:
            type: object
            properties:
              billing_role:
                $ref: '#/components/schemas/SeatBillingRole'
              bought:
                type: integer
                example: 3
              assigned:
                type: integer
                example: 4
              over:
                type: integer
                description: Seats in use beyond those bought
                example: 1

    SeatColleague:
      type: object
      properties:
        user_id:
          type: integer
          example: 7
        name:
          type: string
          example: Amira Khan
        roles:
          type: string
          description: The colleague's roles that need a seat, in words
          example: Event Worker on 6 events
        lowest_seat_allowed:
          $ref: '#/components/schemas/SeatBillingRole'
        status:
          type: string
          enum: [covered, no_seat, seat_too_low, no_seat_needed]
        seats:
          type: array
          items:
            type: object
            properties:
              contract_id:
                type: integer
                example: 31
              billing_role:
                $ref: '#/components/schemas/SeatBillingRole'
              seat_too_low:
                type: boolean
              assigned_at:
                type: string
                format: date-time
              assigned_by_system:
                type: boolean
                description: Makerble gave the seat automatically when the colleague was given a role

    AgeBands:
      type: object
      required: [source, starts, bands]
      properties:
        source:
          type: string
          enum: [organisation, album, project]
          description: Whose bands these are. `organisation` for an Album or Project with none of its own.
        starts:
          type: array
          items:
            type: integer
          description: The age each band starts at, in order
          example: [0, 13, 18, 25]
        bands:
          type: array
          items:
            type: string
          description: The bands as shown on screen
          example: ["0–12", "13–17", "18–24", "25 and over"]
    AgeBandsRequest:
      type: object
      properties:
        starts:
          type: array
          items:
            type: integer
          description: The age each band starts at (0 to 120), in any order
        use_organisation_bands:
          type: boolean
          description: Albums and Projects only. `true` removes their own bands so they use their Organisation's.
    SnapshotPanel:
      type: object
      required: [key, name, source]
      properties:
        key:
          type: string
          description: '`age_band`, `split_by_project` (Albums only) or `ratio_set:<id>`'
          example: "ratio_set:12"
        name:
          type: string
          example: Gender
        source:
          type: string
          enum: [Ratio Set, From Date of Birth, Albums only]
    SnapshotChoice:
      type: object
      required: [key, name, kind]
      properties:
        key:
          type: string
          description: '`<type>:<id>`, the type being Change, Indicator, FilteredMetric, WorkflowTracker, CohortTracker or FormulaTracker'
          example: "Change:31"
        name:
          type: string
          example: Sessions run
        kind:
          type: string
          enum: [Progress Tracker, Indicator, Filtered version, Workflow Tracker, Cohort Tracker, Formula Tracker]
    SnapshotChoiceOrNull:
      type: object
      nullable: true
      description: What a tile shows, or null when it is hidden
      required: [key, name, kind]
      properties:
        key:
          type: string
          example: "Change:31"
        name:
          type: string
          example: Sessions run
        kind:
          type: string
          enum: [Progress Tracker, Indicator, Filtered version, Workflow Tracker, Cohort Tracker, Formula Tracker]
    CelebrationSettings:
      type: object
      required: [resource_type, resource_id, enabled, metrics]
      properties:
        resource_type:
          type: string
          enum: [project, album]
          description: Workspace (project) or Portfolio (album)
        resource_id:
          type: integer
        enabled:
          type: boolean
          description: Whether Impact Celebrations are switched on. Off until someone switches them on.
        improvement_animation:
          type: string
          enum: [random, people, ring, shift]
          description: >-
            The animation a popup plays when 80% of Contacts improve on a Choice tracker: people (People
            rising), ring (Ring passes 80%), shift (Answers shift up), or random (a different one each time,
            the default). A target reached always fills a progress bar.
        changed_by_id:
          type: integer
          nullable: true
          description: The User who last saved the settings
        updated_at:
          type: string
          format: date-time
          nullable: true
        metrics:
          type: array
          description: Every metric that can celebrate here, in name order
          items:
            $ref: '#/components/schemas/CelebrationMetricChoice'
      example:
        resource_type: project
        resource_id: 619
        enabled: true
        improvement_animation: random
        changed_by_id: 42
        updated_at: "2026-11-30T09:15:00Z"
        metrics:
          - key: Change-12
            metric_type: Change
            metric_id: 12
            name: Attendance
            kind: target
            celebrates_when: 200 by 31 Dec 2026
            ticked: true
            can_tick: true
            reason: null
    CelebrationMetricChoice:
      type: object
      properties:
        key:
          type: string
          description: What to send in `metric_keys` to tick it
          example: Change-12
        metric_type:
          type: string
          enum: [Change, Indicator]
        metric_id:
          type: integer
        name:
          type: string
          example: Attendance
        kind:
          type: string
          enum: [target, improvement, milestone]
          description: >-
            target celebrates reaching a target (and, for an Engagement Tracker, its milestones too); milestone
            (an Engagement Tracker with no target) celebrates reaching 10, 100, 1,000 and so on; improvement
            (Choice trackers) celebrates 80% of Contacts improving
        celebrates_when:
          type: string
          example: 200 by 31 Dec 2026
        ticked:
          type: boolean
        can_tick:
          type: boolean
        reason:
          type: string
          nullable: true
          description: Why it can't be ticked, when can_tick is false
    CelebrationSettingsInput:
      type: object
      properties:
        enabled:
          type: boolean
        metric_keys:
          type: array
          items:
            type: string
          description: The `key`s of the metrics to tick; any not sent are unticked
        improvement_animation:
          type: string
          enum: [random, people, ring, shift]
          description: Which animation plays when Contacts improve; leave it out to keep it as it is
    Celebration:
      type: object
      properties:
        id:
          type: integer
        kind:
          type: string
          enum: [target, improvement, milestone]
        metric_type:
          type: string
          enum: [Change, Indicator]
        metric_id:
          type: integer
        metric_name:
          type: string
          nullable: true
        target_number:
          type: integer
          description: The target or milestone reached, or for an improvement the percentage of Contacts (80)
        target_date:
          type: string
          format: date
          nullable: true
          description: The dated target's date; null for an overall target, a milestone or an improvement
        reached_on:
          type: string
          format: date
        recorded_silently:
          type: boolean
          description: Already reached when first checked, so no popup was shown
        days_early:
          type: integer
          nullable: true
          description: How many days before its date a dated target was reached
        animation:
          type: string
          nullable: true
          enum: [bar, people, ring, shift, null]
          description: >-
            The animation its popup played: bar for a target or milestone reached, or the improvement animation
            picked when it was announced. Null when there was no popup (recorded silently), or for an improvement
            announced before animations.
        announcement:
          type: object
          nullable: true
          description: The popup Makerble showed; null when recorded silently
          properties:
            id:
              type: integer
            title:
              type: string
            body:
              type: string
            starts_on:
              type: string
              format: date
            ends_on:
              type: string
              format: date
            status:
              type: string
              enum: [scheduled, live, ended]
      example:
        id: 31
        kind: target
        metric_type: Change
        metric_id: 12
        metric_name: Attendance
        target_number: 200
        target_date: "2026-12-31"
        reached_on: "2026-12-19"
        recorded_silently: false
        days_early: 12
        announcement:
          id: 88
          title: "Target reached: Attendance"
          body: "Riverside Centre: Year 4 reached its target of 200 for Attendance, 12 days early."
          starts_on: "2026-12-19"
          ends_on: "2026-12-26"
          status: live
    CelebrationPage:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Celebration'
    SnapshotSettings:
      type: object
      required: [customised, panels, tiles, workload, choices]
      properties:
        customised:
          type: boolean
          description: false until the editors choose, when the defaults are shown (Age band and the first two Ratio Sets; the first metric in each column; no Workload tiles)
        panels:
          type: array
          description: The "Who we're working with" panels, in display order
          items:
            $ref: '#/components/schemas/SnapshotPanel'
        tiles:
          type: array
          description: One per Results Canvas column, in order
          items:
            type: object
            required: [column, column_label, choice]
            properties:
              column:
                type: string
                enum: [activities, engagement, potential, behaviour, growth]
              column_label:
                type: string
                description: The column's name on the Results Canvas
                example: Activity
              choice:
                $ref: '#/components/schemas/SnapshotChoiceOrNull'
        workload:
          type: array
          description: The three Workload tiles; null for a hidden one
          items:
            $ref: '#/components/schemas/SnapshotChoiceOrNull'
        choices:
          type: object
          required: [panels, columns, trackers]
          properties:
            panels:
              type: array
              items:
                $ref: '#/components/schemas/SnapshotPanel'
            columns:
              type: array
              description: The metrics in each Results Canvas column, filtered versions included
              items:
                type: object
                required: [key, label, options]
                properties:
                  key:
                    type: string
                  label:
                    type: string
                  options:
                    type: array
                    items:
                      $ref: '#/components/schemas/SnapshotChoice'
            trackers:
              type: array
              description: The Workflow, Cohort and Formula Trackers, which can go on any tile and on Workload
              items:
                $ref: '#/components/schemas/SnapshotChoice'
    SnapshotSettingsRequest:
      type: object
      properties:
        panels:
          type: array
          items:
            type: string
          description: Panel keys in display order. An empty list shows no panels.
        tiles:
          type: object
          description: Results Canvas column => metric or tracker key, or null to hide the tile. Columns left out keep their tile.
          properties:
            activities: {type: string, nullable: true}
            engagement: {type: string, nullable: true}
            potential: {type: string, nullable: true}
            behaviour: {type: string, nullable: true}
            growth: {type: string, nullable: true}
        workload:
          type: array
          maxItems: 3
          items:
            type: string
            nullable: true
          description: Up to three tracker keys; null hides a tile
    SnapshotOwner:
      type: object
      required: [type, id, name]
      properties:
        type:
          type: string
          enum: [album, project]
        id:
          type: integer
        name:
          type: string
          example: Youth Programme 2026
    SnapshotShareLink:
      type: object
      required: [url, created_at, showing]
      properties:
        url:
          type: string
          description: The read-only link to send. Opens without signing in.
          example: https://makerble.com/shared/snapshot/3vKq9wXbT2mYp8sLd4nR6cHf1jZa7eUo
        created_at:
          type: string
          format: date-time
        showing:
          $ref: '#/components/schemas/SnapshotOwner'
    SnapshotTile:
      type: object
      required: [column, key, name, kind, value, unit]
      properties:
        column:
          type: string
          nullable: true
          description: The Results Canvas column's name; null on a Workload tile
          example: Activity
        key:
          type: string
          example: "Change:31"
        name:
          type: string
          example: Sessions run
        kind:
          type: string
          enum: [Progress Tracker, Indicator, Filtered version, Workflow Tracker, Cohort Tracker, Formula Tracker]
        value:
          type: number
          nullable: true
          description: The result over `timeframe`, as on the Results Canvas's Period view; null when the tracker has no single number
          example: 148
        unit:
          type: string
          nullable: true
          example: count
    Snapshot:
      type: object
      required: [showing, contacts_count, timeframe, panels, tiles, workload]
      properties:
        showing:
          allOf:
            - $ref: '#/components/schemas/SnapshotOwner'
            - type: object
              required: [pinned]
              properties:
                pinned:
                  type: boolean
                  description: Whether this is your pinned Snapshot
        contacts_count:
          type: integer
          description: The Album's or Project's Contacts that you can view
        timeframe:
          type: object
          description: What the tiles count. The Results Canvas's current period (from the day after the last deadline to the next, or to today once they have all passed), or all time when there are no deadlines.
          required: [kind, start_date, end_date]
          properties:
            kind:
              type: string
              enum: [period, all_time]
            start_date:
              type: string
              format: date
              nullable: true
              description: null for all time
            end_date:
              type: string
              format: date
        panels:
          type: array
          items:
            type: object
            required: [key, name, source, rows]
            properties:
              key:
                type: string
              name:
                type: string
                example: Gender
              source:
                type: string
                example: Ratio Set, as on the Demographics tab
              rows:
                type: array
                items:
                  type: object
                  required: [label, contacts, percent]
                  properties:
                    label:
                      type: string
                      example: Female
                    contacts:
                      type: integer
                      nullable: true
                      description: null when below the Minimum Results Threshold
                    percent:
                      type: number
                      nullable: true
                      example: 51.1
        tiles:
          type: array
          items:
            $ref: '#/components/schemas/SnapshotTile'
        workload:
          type: array
          items:
            $ref: '#/components/schemas/SnapshotTile'
    AgeBandCounts:
      type: object
      required: [source, total_count, data]
      properties:
        source:
          type: string
          enum: [organisation, album, project]
          description: Whose age bands were used
        total_count:
          type: integer
          description: Every Contact counted, including any the threshold hides
        data:
          type: array
          items:
            type: object
            required: [band, contacts]
            properties:
              band:
                type: string
                example: "13–17"
              contacts:
                type: integer
                nullable: true
                description: Contacts in the band; null when below the Minimum Results Threshold
    SeatChangeRequest:
      type: object
      required: [contract_id]
      properties:
        contract_id:
          type: integer
          description: One of the Organisation's current Contracts
        billing_role_id:
          type: integer
          nullable: true
          description: Role-based Pricing only. The Billing Role to give, or `null` to take the seat away.
        has_seat:
          type: boolean
          description: Flat Pricing only. `true` gives a seat, `false` takes it away.

    PaginatedSeats:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            contracts:
              type: array
              items:
                $ref: '#/components/schemas/SeatContract'
            data:
              type: array
              items:
                $ref: '#/components/schemas/SeatColleague'

    OrganisationUsage:
      type: object
      properties:
        organisation_id:
          type: integer
        month:
          type: string
          description: The calendar month, YYYY-MM.
        currency:
          type: string
          description: The currency the Organisation is billed in (GBP when no exchange rate is stored).
        charge_so_far:
          type: number
        expected_charge:
          type: number
          description: The charge by the end of the month if usage carries on at the rate so far.
        unpriced:
          type: boolean
          description: True when some usage over an allowance has no price set, so the totals leave it out.
        data:
          type: array
          items:
            $ref: '#/components/schemas/OrganisationUsageType'

    OrganisationUsageType:
      type: object
      properties:
        usage_type:
          type: string
          enum: [sms_sent, sms_received, sms_line_rental, email_sent, email_received, file_upload_bytes, automation_run, story_created, api_integration_run, contacts_snapshot]
        name:
          type: string
          description: The name shown on the Usage page, e.g. "Stories (survey responses)".
        unit:
          type: string
          description: The unit of quantity, allowance and per_quantity, e.g. Stories, segments, GB.
        quantity:
          type: number
        allowance:
          type: number
          nullable: true
          description: How much can be used before being charged; 0 means charged from the first one, null means not set.
        percent_used:
          type: integer
          nullable: true
        status:
          type: string
          nullable: true
          enum: [within, near, over, waived, null]
        expected_quantity:
          type: number
        unit_price:
          type: number
          nullable: true
          description: The price of each per_quantity over the allowance, or of the bundle (tier_min to tier_max) the expected quantity falls in.
        per_quantity:
          type: number
          nullable: true
        tier_min:
          type: integer
          nullable: true
        tier_max:
          type: integer
          nullable: true
        charge_so_far:
          type: number
          nullable: true
        expected_charge:
          type: number
          nullable: true
        note:
          type: string
          nullable: true
          description: How the usage type is counted, for file storage and Contacts.

    OrganisationUsageHistory:
      type: object
      properties:
        organisation_id:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              month:
                type: string
              currency:
                type: string
              charge:
                type: number
              usage:
                type: array
                items:
                  type: object
                  properties:
                    usage_type:
                      type: string
                    name:
                      type: string
                    unit:
                      type: string
                    quantity:
                      type: number
                    allowance:
                      type: number
                      nullable: true
                    charge:
                      type: number
                      nullable: true
                    waived:
                      type: boolean

    ApiKey:
      type: object
      properties:
        id:
          type: integer
        charity_id:
          type: integer
          description: The Organisation (Charity) the key belongs to
        name:
          type: string
          example: "Finance dashboard"
        secret_hint:
          type: string
          description: The start of the key, to recognise it by. The rest is never shown again.
          example: "mk_live_Ab12"
        user_id:
          type: integer
          description: The colleague the key acts as
        created_by_id:
          type: integer
          nullable: true
        last_used_at:
          type: string
          format: date-time
          nullable: true
        revoked_at:
          type: string
          format: date-time
          nullable: true
        active:
          type: boolean
          description: false once revoked
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    AiAssistantLink:
      type: object
      required: [id, organisation_id, organisation_name, created_at, last_used_at]
      properties:
        id:
          type: integer
        organisation_id:
          type: integer
          description: The Organisation (Charity) the link's API usage is billed to
        organisation_name:
          type: string
        created_at:
          type: string
          format: date-time
        last_used_at:
          type: string
          format: date-time
          nullable: true
          description: When an assistant last used the link, to within a few minutes

    AiAssistantLinkStatus:
      type: object
      required: [link, organisations]
      properties:
        link:
          type: object
          nullable: true
          description: Your link, without the link itself, or null if you have none
          required: [id, organisation_id, organisation_name, created_at, last_used_at]
          properties:
            id:
              type: integer
            organisation_id:
              type: integer
            organisation_name:
              type: string
            created_at:
              type: string
              format: date-time
            last_used_at:
              type: string
              format: date-time
              nullable: true
        organisations:
          type: array
          description: The Organisations you can bill the link to
          items:
            type: object
            required: [id, name]
            properties:
              id:
                type: integer
              name:
                type: string

    AiAssistantLinkWithUrl:
      type: object
      required: [link, url]
      properties:
        link:
          $ref: '#/components/schemas/AiAssistantLink'
        url:
          type: string
          format: uri
          description: The link to paste into your AI assistant. Shown only in the response that made it.
          example: "https://mcp.makerble.com/mcp?key=mk_live_Ab12Cd34Ef56Gh78Ij90Kl12Mn34Op56&env=production"

    ApiKeyWithSecret:
      allOf:
        - $ref: '#/components/schemas/ApiKey'
        - type: object
          properties:
            secret:
              type: string
              description: The key itself. Shown only in the response that created it.
              example: "mk_live_Ab12Cd34Ef56Gh78Ij90Kl12Mn34Op56"

    ApiKeyRequest:
      type: object
      required: [charity_id, api_key]
      properties:
        charity_id:
          type: integer
          description: The Organisation (Charity) ID
        api_key:
          type: object
          required: [name, user_id]
          properties:
            name:
              type: string
              description: What the key is for
            user_id:
              type: integer
              description: The colleague the key acts as

    GuidancePanelPoint:
      type: object
      description: One point on a Guidance Panel, shown as its bold `lead` followed by its `text`
      properties:
        lead:
          type: string
          example: "Plan events"
        text:
          type: string
          example: "set rotas and track attendance for every session."

    GuidancePanelUser:
      type: object
      nullable: true
      description: The User who made the change, or null when it wasn't made by a User (e.g. the seed task)
      properties:
        id:
          type: integer
        name:
          type: string

    GuidancePanelStoryboardStep:
      type: object
      description: |
        One step of an Intro animation. Steps play in order, evenly spread across the loop, or each at its
        `at` (seconds from the start of the loop, to one decimal place, in order; on every step or on none).

        In an illustration storyboard, steps work on the illustration's parts:

        - `appear` shows a `part` with a `motion`: `fade`, `rise`, `lift` (the default) or `pop`. Parts that
          no `appear` names are there from the start.
        - `move_cursor` (with optional `seconds`, 0.2 to 3), `click`, `highlight` and `zoom` act on the part
          named in `target`. The cursor glides in from the bottom right corner on a gentle arc.
        - `type` and `swap` fill in a `field` part with `text`; `scroll` moves a `scroll` part `to` 0 (the
          top) or 1 (the bottom), or between, over `seconds` (0.2 to 10).
        - `scene` starts a new scene with another `illustration`, with a `transition` of `cut`, `fade` (the
          default) or `slide`. A slide moves the `moving` part, which both illustrations must have, out to
          the left and in from the right, while everything else (a header, say) stays put.

        In a building-block storyboard:

        - `appear` puts a building block on the stage: `block` (required), and optionally an `id` that later
          steps target, a `text` label, a `value` (required for a `chart_bar`, from 0 to 100, and for a
          `calendar_event`, the weekday from 1 for Monday to 5 for Friday) and a `face`, one of the five
          Makerble avatars (1 to 5), for an `avatar`, `table_row`, `card` or `timeline_item`.
          An `icon` block also needs an `icon`: pin, map, calendar, clock, document, chart, people, home,
          envelope, phone, star or heart. A chip, card or row shows a tick box only if a `check` step ticks it.
        - `move_cursor`, `click`, `highlight` and `check` act on the block whose `id` is `target`.
        - `type` types `text` into the `field` whose `id` is `target`.
        - `swap` replaces the label of the block whose `id` is `target` with `text`.
        - `cut` clears the stage and starts a new scene; blocks from before it can't be targeted after it.
        - `frame` makes the scene a simplified page, captioned with `text` (or the page's usual name):
          `register`, `profile`, `table`, `web_page`, `calendar` or `compare`. It must be the scene's first step.
        - `carry` lifts the block whose `id` is `target`; at the next `cut` it travels onto the block whose
          `id` is `to` in the next scene. It is the only way a block outlives a cut.
        - `zoom` scales the stage in on the block whose `id` is `target` for two beats, then back out.
      required: [type]
      additionalProperties: false
      properties:
        type:
          type: string
          enum: [appear, move_cursor, click, type, highlight, check, swap, cut, frame, carry, zoom, scroll, scene]
        at:
          type: number
          minimum: 0
          description: Seconds from the start of the loop that the step plays at
        part:
          type: string
          description: In an illustration storyboard, the part an `appear` step shows
        motion:
          type: string
          enum: [fade, rise, lift, pop]
        seconds:
          type: number
          description: How long a `move_cursor` (0.2 to 3) or `scroll` (0.2 to 10) takes
        illustration:
          type: string
          description: For `scene`, the next scene's illustration
        transition:
          type: string
          enum: [cut, fade, slide]
        moving:
          type: string
          description: For a `slide`, the part that slides, which both illustrations have
        block:
          type: string
          enum: [top_bar, sidebar_item, table_row, card, button, field, chip, avatar, chart_bar, cell, timeline_item, calendar_event, icon]
        id:
          type: string
          pattern: '^[a-z][a-z0-9_]{0,29}$'
        target:
          type: string
          description: The `id` of a block that has appeared since the last `cut`
        text:
          type: string
          maxLength: 40
        value:
          type: integer
          minimum: 0
          maximum: 100
        face:
          type: integer
          minimum: 1
          maximum: 5
          description: One of the five Makerble avatars, so people in the animation are faces, not initials
        icon:
          type: string
          enum: [pin, map, calendar, clock, document, chart, people, home, envelope, phone, star, heart]
          description: For an `icon` block (required there, and only there), the icon it shows beside its `text`
        frame:
          type: string
          enum: [register, profile, table, web_page, calendar, compare]
        to:
          oneOf:
            - type: string
              pattern: '^[a-z][a-z0-9_]{0,29}$'
            - type: number
              minimum: 0
              maximum: 1
          description: >-
            For `carry`, the `id` of the block the carried block lands on, which appears after the next `cut`.
            For `scroll`, how far down to scroll, from 0 (the top) to 1 (the bottom).


    GuidancePanelStoryboard:
      type: object
      nullable: true
      description: |
        An Intro's animation: a short loop of Makerble building blocks drawn in the panel's module colour,
        shown when there is no Vimeo link. Up to 8,000 characters of JSON.

        An illustration storyboard names an `illustration` instead, and animates its parts, following the
        visitor through the feature across scenes. It may run up to 40 seconds, 40 steps and 12,000
        characters, push the `camera` slowly in across each loop, and `crop` the first illustration for the
        small Intro panel (an announcement plays it uncropped). People who turn off motion, or pause it, see
        the finished picture of its last scene.
      required: [archetype, loop_seconds, alt, steps]
      additionalProperties: false
      properties:
        archetype:
          type: string
          enum: [assemble, flow, journey, concept]
          description: >-
            `assemble`: the parts of a page of the feature come together. `flow`: a short walkthrough of using
            the feature. `journey`: one piece of data travels from page to page by itself (with `frame`, `carry`
            and `zoom` steps). `concept`: an animated metaphor for the idea behind it.
        loop_seconds:
          type: integer
          minimum: 4
          maximum: 40
          description: Up to 20 for building blocks, 40 for an illustration storyboard
        alt:
          type: string
          minLength: 10
          maxLength: 250
          description: What the animation shows, read out by screen readers
        illustration:
          type: string
          description: The first scene's illustration, from `GET /guidance_panels/illustrations`
        hold_seconds:
          type: number
          minimum: 2
          maximum: 8
          description: How long the finished picture holds before the loop starts again; 2.5 if left out
        camera:
          type: string
          enum: [push]
          description: Illustration storyboards only. A slow 2.5% zoom in across each loop
        crop:
          type: array
          items:
            type: number
          minItems: 4
          maxItems: 4
          description: >-
            Illustration storyboards only. `[x, y, width, height]` of the first illustration, inside its
            `view_box`: the piece the small Intro panel shows
        steps:
          type: array
          minItems: 1
          maxItems: 40
          items:
            $ref: '#/components/schemas/GuidancePanelStoryboardStep'
      example:
        archetype: flow
        loop_seconds: 12
        alt: "A coworker clicks Create a contact, types the contact's name, clicks Save and the contact appears in the list."
        steps:
          - { type: appear, block: button, id: create, text: "Create a contact" }
          - { type: click, target: create }
          - { type: cut }
          - { type: appear, block: field, id: name, text: "Name" }
          - { type: type, target: name, text: "Amira Patel" }
          - { type: cut }
          - { type: appear, block: table_row, id: amira, text: "Amira Patel" }
          - { type: check, target: amira }


    GuidancePanel:
      type: object
      description: |
        The Show/Hide Guidance introduction at the top of a Manage page. Its main action, and who may use it,
        belong to the page, so they are not part of the panel.
      properties:
        key:
          type: string
          description: Identifies the panel, e.g. `events`
          example: events
        page_name:
          type: string
          description: The page's name on screen
          example: Events
        module:
          type: string
          enum: [spaces, crm, scheduling, surveys, impact, settings]
          description: The sidebar section the page is in, which sets the panel's colour
        eyebrow:
          type: string
          nullable: true
          example: "Makerble® Events"
        headline:
          type: string
          example: "For moments that have a lasting impact"
        points:
          type: array
          items:
            $ref: '#/components/schemas/GuidancePanelPoint'
        staff_text:
          type: string
          nullable: true
          description: Shown instead of the page's main action to people who can't use it
        user_guide_url:
          type: string
          description: The page's article in the Makerble User Guide, linked as "Learn more about <page> →"
        vimeo_url:
          type: string
          nullable: true
        storyboard:
          $ref: '#/components/schemas/GuidancePanelStoryboard'
        fallback_visual:
          type: string
          nullable: true
          description: The CSS animation, or the page's current image, shown when there is no Vimeo link
        visual:
          type: string
          enum: [vimeo, storyboard, animation, image, none]
          description: What the panel shows beside its text now. A Vimeo link wins over a storyboard, and a storyboard over the fallback visual
        updated_at:
          type: string
          format: date-time
        updated_by:
          $ref: '#/components/schemas/GuidancePanelUser'
        feature_tour_id:
          type: integer
          nullable: true
          description: |
            The feature tour this Intro offers with "Take the tour" (its live tour, otherwise the one most recently
            updated whose `page_key` is this Intro); null for none. Only a live tour is shown.
        feature_tour_name:
          type: string
          nullable: true
          description: That feature tour's name

    GuidancePanelVersion:
      type: object
      description: One change to a Guidance Panel
      properties:
        id:
          type: integer
        event:
          type: string
          enum: [create, update]
        created_at:
          type: string
          format: date-time
        user:
          $ref: '#/components/schemas/GuidancePanelUser'
        changed:
          type: array
          description: The parts that changed, in words, e.g. `["Headline", "Points"]`
          items:
            type: string
        changes:
          type: object
          additionalProperties: true
          description: 'Each changed field with its value before and after, e.g. `{"headline": ["Old", "New"]}`'

    GuidancePanelWithVersions:
      allOf:
        - $ref: '#/components/schemas/GuidancePanel'
        - type: object
          properties:
            versions:
              type: array
              description: The last 10 versions, newest first
              items:
                $ref: '#/components/schemas/GuidancePanelVersion'
            notices:
              type: array
              description: After a change, names any feature tour no longer offered on this Intro, e.g. "Checklists is no longer offered here."; otherwise empty
              items:
                type: string

    GuidancePanelRequest:
      type: object
      properties:
        guidance_panel:
          type: object
          properties:
            eyebrow:
              type: string
            headline:
              type: string
              maxLength: 80
            points:
              type: array
              minItems: 2
              maxItems: 5
              items:
                $ref: '#/components/schemas/GuidancePanelPoint'
            staff_text:
              type: string
              maxLength: 300
            user_guide_url:
              type: string
            vimeo_url:
              type: string
            storyboard:
              $ref: '#/components/schemas/GuidancePanelStoryboard'
            feature_tour_id:
              type: integer
              nullable: true
              description: |
                The feature tour this Intro offers with "Take the tour"; null for none. Any other tour whose
                `page_key` was this Intro is unlinked, and `notices` names it.

    PaginatedGuidancePanels:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/GuidancePanel'

    GuidancePanelIllustration:
      type: object
      properties:
        name:
          type: string
          example: event_booking
        view_box:
          type: array
          items:
            type: number
          example: [0, 0, 1600, 1000]
        parts:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                example: first_name
              kind:
                type: string
                enum: [part, field, scroll]

    PaginatedGuidancePanelIllustrations:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/GuidancePanelIllustration'

    PaginatedApiKeys:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/ApiKey'

    CaseNote:
      type: object
      properties:
        id:
          type: integer
        charity_id:
          type: integer
        project_id:
          type: integer
        user_id:
          type: integer
          description: The colleague who recorded it
        user_name:
          type: string
          nullable: true
        note_type:
          type: string
          enum: [case_note, session_note]
          description: "`case_note` is about one Contact (Beneficiary); `session_note` is about an Event"
        status:
          type: string
          enum: [queued, recording, transcribing, completed, failed, stitching, summarizing]
        beneficiary_id:
          type: integer
          nullable: true
        beneficiary_name:
          type: string
          nullable: true
        event_id:
          type: integer
          nullable: true
        draft_story_id:
          type: integer
          nullable: true
          description: The draft survey response written from the summary, once there is one
        story_id:
          type: integer
          nullable: true
          description: The survey response (Story) saved from that draft
        started_at:
          type: string
          format: date-time
        duration_seconds:
          type: integer
          nullable: true
        source:
          type: string
          enum: [product, manual]
          description: "`product` when recorded in Makerble, `manual` when an audio file was attached"
        platform:
          type: string
          enum: [desktop_web, mobile_web, api]
          nullable: true
          description: Where it was started; null for Audio Notes made before this was recorded
        has_recording:
          type: boolean
          description: false once the recording has been deleted, or before it is uploaded
        audio_deleted_at:
          type: string
          format: date-time
          nullable: true
          description: When the recording was deleted, if it has been
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    CaseNoteDetail:
      allOf:
        - $ref: '#/components/schemas/CaseNote'
        - type: object
          properties:
            transcript:
              type: string
              nullable: true
              description: "The transcript, one paragraph per speaker turn (Speaker A: ...)"
            summary:
              type: string
              nullable: true
              description: The AI summary

    PaginatedCaseNotes:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/CaseNote'

    PaginatedWebhookEndpoints:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/WebhookEndpoint'

    PaginatedWebhookDeliveries:
      allOf:
        - $ref: '#/components/schemas/PaginationEnvelope'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/WebhookDelivery'
    SupplementaryDetails:
      type: object
      properties:
        organisation_id:
          type: integer
        country:
          type: string
          nullable: true
          description: The Organisation's country. Set it with country_id when it has none
        country_iso_code:
          type: string
          nullable: true
        registration_identifier_automatic:
          type: boolean
          description: Whether the country decides the registration ID type
        verification_status:
          type: string
          enum: [not_started, pending_review, in_review, twilio_rejected, twilio_approved]
          description: Where Twilio's check of the details has got to
        editable:
          type: boolean
          description: False while Twilio is checking the details and once it has approved them
        missing_fields:
          type: array
          description: Fields Twilio needs that are still blank
          items:
            type: string
        website_url:
          type: string
          nullable: true
          description: "Website, e.g. www.example.org. https:// is added when it doesn't start with http:// or https://"
        business_type:
          type: string
          nullable: true
          description: "Organisation type: Sole Proprietorship, Partnership, Limited Liability Corporation, Co-operative, Non-profit Corporation or Corporation"
        business_industry:
          type: string
          nullable: true
          description: "Industry, as Twilio names it, e.g. NOT_FOR_PROFIT, EDUCATION, HEALTHCARE"
        business_registration_identifier:
          type: string
          nullable: true
          description: "Registration ID type: EIN, CBN, CN, ACN, CIN, VAT, VATRN, RN or Other. Set from the Organisation's country when registration_identifier_automatic is true, whatever is sent"
        other_registration_identifier:
          type: string
          nullable: true
          description: "Name of the other registration type, when the type is Other"
        business_registration_number:
          type: string
          nullable: true
          description: "Registration number"
        business_regions_of_operation:
          type: string
          nullable: true
          description: "Region of operation: AFRICA, ASIA, EUROPE, LATIN_AMERICA, USA_AND_CANADA or AUSTRALIA"
        address_friendly_name:
          type: string
          nullable: true
          description: "Address name, e.g. Headquarters"
        street:
          type: string
          nullable: true
          description: "Street address"
        street_secondary:
          type: string
          nullable: true
          description: "Street address line 2 (optional)"
        city:
          type: string
          nullable: true
          description: "City"
        region:
          type: string
          nullable: true
          description: "State, province or region"
        postal_code:
          type: string
          nullable: true
          description: "Postal code"
        representative_first_name:
          type: string
          nullable: true
          description: "The representative's first name"
        representative_last_name:
          type: string
          nullable: true
          description: "The representative's last name"
        representative_business_title:
          type: string
          nullable: true
          description: "The representative's job title"
        representative_job_position:
          type: string
          nullable: true
          description: "Job position: Director, GM, VP, CEO, CFO, General Counsel or Other"
        representative_other_job_position:
          type: string
          nullable: true
          description: "The job position, when Job position is Other"
        representative_email:
          type: string
          nullable: true
          description: "The representative's email address"
        representative_phone_number:
          type: string
          nullable: true
          description: "The representative's phone number in international format, e.g. +447700900123"
