Raw OpenAPI Spec

The complete OpenAPI 3.1 specification for the Booked55 API. Copy this YAML to use with AI assistants, code generators, or your own tooling.

openapi.yaml
openapi: 3.1.0
info:
  title: Booked55 API
  description: |-
    Public API reference for Booked55 — a CRM and sales management platform.

    ## Authentication
    Most endpoints require a Bearer token in the `Authorization` header:
    ```
    Authorization: Bearer <your_api_key>
    ```
    Create an API key in your workspace settings. Keys are prefixed with `vg_` and shown only once at creation.

    ## Rate Limiting
    API requests are rate limited. Check response headers for limit details.
  version: 1.0.0
  contact:
    name: Booked55 Support
  license:
    name: Proprietary
servers:
  - url: https://api.booked55.com
    description: Production
tags:
  - name: Contacts
    description: Contact management and bulk operations
  - name: Companies
    description: Company records
  - name: Events
    description: Events and attendance tracking
  - name: Tasks
    description: Tasks and follow-ups
  - name: Pipelines
    description: Sales pipelines, stages, and items
  - name: Campaigns
    description: Marketing and activity campaigns
  - name: Email Templates
    description: Reusable email templates
  - name: Client Types
    description: "Product and service types: what a client buys, its usual price and how it is paid"
  - name: Deals
    description: Closed sales and how they are paid
  - name: Invoices
    description: One invoice for each payment expected on a deal
  - name: Lead Sources
    description: The organization's list of where leads come from
  - name: Notes
    description: Notes written on a contact, a company, a task, a deal, a pipeline card or an event
  - name: Webhooks
    description: Subscribe a URL to events, and read the event types and a sample of each. Owner and manager keys only.
  - name: Organization
    description: The organization an API key belongs to
paths:
  /contact:
    post:
      tags:
        - Contacts
      summary: Create contact
      description: Create a new contact in your organization.
      security: &ref_1
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContactCreateRequest"
            examples:
              basic:
                summary: Basic contact
                value:
                  name: Jane Smith
                  email: [email protected]
                  phone_numbers:
                    - label: primary
                      phone_number: "+15551234567"
                  tags:
                    - prospect
                  company_id: 674a1b2c3d4e5f6789012345
      responses:
        "200":
          description: Created contact
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contact"
        "400": &ref_0
          $ref: "#/components/responses/Error"
        "401": *ref_0
  /contact/{contactId}:
    get:
      tags:
        - Contacts
      summary: Get contact
      security: *ref_1
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: string
          description: Contact ID
      responses:
        "200":
          description: Contact details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contact"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Contacts
      summary: Update contact
      security: *ref_1
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: string
          description: Contact ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContactUpdateRequest"
      responses:
        "200":
          description: Updated contact
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Contact"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Contacts
      summary: Delete contact
      security: *ref_1
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: string
          description: Contact ID
      responses:
        "200":
          description: Contact deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /contacts:
    get:
      tags:
        - Contacts
      summary: List contacts
      description: Paginated list of contacts with optional filters.
      security: *ref_1
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
        - name: offset
          in: query
          required: false
          schema:
            type: integer
        - name: source_id
          in: query
          required: false
          schema:
            type: string
        - name: lead_source_id
          in: query
          required: false
          schema:
            type: string
            description: Only contacts with this lead source
          description: Only contacts with this lead source
        - name: company_id
          in: query
          required: false
          schema:
            type: string
        - name: event_id
          in: query
          required: false
          schema:
            type: string
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: is_client
          in: query
          required: false
          schema:
            type: string
            enum:
              - "true"
              - "false"
        - name: pipeline_id
          in: query
          required: false
          schema:
            type: string
        - name: stage_id
          in: query
          required: false
          schema:
            type: string
        - name: tags
          in: query
          required: false
          schema:
            type: string
            description: Comma-separated tags
          description: Comma-separated tags
        - name: sort_by
          in: query
          required: false
          schema:
            type: string
        - name: sort_order
          in: query
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
      responses:
        "200":
          description: Paginated contacts
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedContacts"
        "401": *ref_0
  /contacts/search:
    get:
      tags:
        - Contacts
      summary: Search contacts
      description: >-
        Search across name, email and phone. search_tag and search_company also find contacts by tag and by company
        name, after those matches. The filters List contacts takes (pipeline, stage, tags, company, event and the rest)
        narrow the matches. Minimum query length is 2 characters.
      security: *ref_1
      parameters:
        - name: query
          in: query
          required: true
          schema:
            type: string
            minLength: 2
          description: Search query
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 50
            default: 20
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: lead_source_id
          in: query
          required: false
          schema:
            type: string
            description: Only contacts with this lead source
          description: Only contacts with this lead source
        - name: company_id
          in: query
          required: false
          schema:
            type: string
        - name: event_id
          in: query
          required: false
          schema:
            type: string
        - name: is_client
          in: query
          required: false
          schema:
            type: string
            enum:
              - "true"
              - "false"
        - name: pipeline_id
          in: query
          required: false
          schema:
            type: string
        - name: stage_id
          in: query
          required: false
          schema:
            type: string
        - name: tags
          in: query
          required: false
          schema:
            type: string
            description: Comma-separated tags
          description: Comma-separated tags
        - name: search_tag
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: Also find contacts carrying a tag that starts a word with the query
        - name: search_company
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: Also find contacts at a company whose name matches the query
      responses:
        "200":
          description: Matching contacts ranked by relevance
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Contact"
              examples:
                results:
                  summary: Search results
                  value:
                    - id: 674a1b2c3d4e5f6789012345
                      name: Jane Smith
                      email: [email protected]
                      tags:
                        - prospect
        "400": *ref_0
        "401": *ref_0
  /contact/{contactId}/referrals:
    get:
      tags:
        - Contacts
      summary: Get referrals
      description: Contacts referred by the given contact.
      security: *ref_1
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: string
          description: Contact ID
      responses:
        "200":
          description: Referral list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ReferralsResponse"
        "401": *ref_0
        "404": *ref_0
  /contacts/check-duplicates:
    get:
      tags:
        - Contacts
      summary: Check duplicates
      description: Check for existing contacts by email or phone.
      security: *ref_1
      parameters:
        - name: email
          in: query
          required: false
          schema:
            type: string
            format: email
        - name: phone
          in: query
          required: false
          schema:
            type: string
      responses:
        "200":
          description: Duplicate check result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DuplicateCheckResponse"
        "400": *ref_0
        "401": *ref_0
  /contacts/bulk-update-tags:
    post:
      tags:
        - Contacts
      summary: Bulk update tags
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkUpdateTagsRequest"
      responses:
        "200":
          description: Tags updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  updated:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /contacts/bulk-add-event:
    post:
      tags:
        - Contacts
      summary: Bulk add to event
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkAddEventRequest"
      responses:
        "200":
          description: Contacts added to event
          content:
            application/json:
              schema:
                type: object
                properties:
                  updated:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /contacts/bulk-update-pipeline:
    post:
      tags:
        - Contacts
      summary: Bulk update pipeline
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkUpdatePipelineRequest"
      responses:
        "200":
          description: Pipeline updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  updated:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /contacts/bulk-delete:
    post:
      tags:
        - Contacts
      summary: Bulk delete contacts
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkDeleteContactsRequest"
      responses:
        "200":
          description: Contacts deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  deleted:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /contacts/export:
    post:
      tags:
        - Contacts
      summary: Export contacts
      description: Initiate an async contact export. Returns a request ID to poll for completion.
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContactExportRequest"
      responses:
        "202":
          description: Export job accepted
          content:
            application/json:
              schema:
                type: object
                properties:
                  request_id:
                    type: string
        "400": *ref_0
        "401": *ref_0
  /note:
    post:
      tags:
        - Notes
      summary: Add a note
      description: >-
        Write a note on a contact, a company, a task, a deal, a pipeline card, an event or an attendance. The key must
        be able to open that record. A note is never deleted.
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                entity_type:
                  type: string
                  description: contact, company, task, deal, pipelineItem, event or eventAttendance
                entity_id:
                  type: string
                  description: The id of the parent record
                body:
                  type: string
                  description: The note text (max 20000 characters)
                note_at:
                  type: string
                  format: date-time
                  description: The note's own date; defaults to now. An imported note keeps the date it was written.
              required:
                - entity_type
                - entity_id
                - body
            examples:
              onContact:
                summary: A note on a contact
                value:
                  entity_type: contact
                  entity_id: 674a1b2c3d4e5f6789012345
                  body: Met at the trade show. Wants a quote by Friday.
      responses:
        "201":
          description: The note
          content:
            application/json:
              schema:
                type: object
                properties:
                  note:
                    $ref: "#/components/schemas/Note"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /contact/{contactId}/notes:
    get:
      tags:
        - Notes
      summary: List a contact's notes
      description: The notes written on the contact and on its tasks, deals and pipeline card, newest first.
      security: *ref_1
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: string
          description: The contact ID
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Notes per page (max 100)
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Notes to skip
        - name: sources
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: array
                items:
                  type: string
          description: >-
            Only notes from these sources: user, meeting_bot, email_sync, inbound, import, system. Comma-separated or
            repeated; omitted means every source.
        - name: q
          in: query
          required: false
          schema:
            type: string
            maxLength: 200
          description: Free text, matched case-insensitively anywhere in the note body. Under 2 characters is ignored.
      responses:
        "200":
          description: Paginated notes
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedNotes"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /webhook/event-types:
    get:
      tags:
        - Webhooks
      summary: List webhook event types
      description: >-
        Every event a URL can subscribe to, with when it fires. Needs an API key made by an owner or a manager: a sales
        person's or an operator's key is refused with 403.


        - `deal.created`: Fires when a deal is created — manually, from a pipeline stage that marks a contact as a
        client, from an import, or via the API.

        - `deal.cancelled`: Fires when a deal is cancelled, which stops its schedule of payments.

        - `pipeline_item.created`: Fires when a card is added to a pipeline. Its first stage is in new_stage_name.

        - `pipeline_item.stage_changed`: Fires when a card moves to another stage in the same pipeline.

        - `pipeline_item.pipeline_changed`: Fires when a card moves to another pipeline, which also moves it to a stage
        there.

        - `invoice.created`: Fires when an invoice is made for a payment on a deal.

        - `invoice.sent`: Fires when an invoice is marked Sent. Marking a Draft Paid fires this and then invoice.paid.

        - `invoice.paid`: Fires when an invoice is marked Paid.

        - `invoice.cancelled`: Fires when an invoice is cancelled.

        - `invoice.voided`: Fires when an invoice is voided. A corrected copy of it arrives as invoice.created.

        - `invoice.refunded`: Fires when money from a paid invoice is given back.

        - `invoice.refund_demanded`: Fires when a refund is asked for on a paid invoice.

        - `invoice.refund_demand_dropped`: Fires when a refund demand is dropped, so the invoice is Paid again.

        - `invoice.payment_undone`: Fires when a payment is undone, so a Paid invoice is Sent again.

        - `invoice.edited`: Fires when a correction to a migrated invoice changes its status.

        - `contact.created`: Fires when one contact is added: by a person, through the API, or from a Booked55 profile
        or QR code. An import or a connected system sends none.

        - `contact.updated`: Fires when a person edits a contact. changed_fields lists the fields whose value changed.

        - `contact.deleted`: Fires when a contact is deleted, one event for each contact.

        - `company.created`: Fires when a company is added by a person or through the API.

        - `note.created`: Fires when a person writes a note on a contact, company, deal, task, card or attendance.

        - `task.completed`: Fires when a person marks a task done, or logs one that is already done.

        - `contact.event_added`: Fires when a contact is linked to an event, one event for each contact and event.

        - `contact.do_not_contact_changed`: Fires when a do not call, text, email or record mark changes on a contact,
        whoever or whatever changed it.

        - `contact.marketing_email_changed`: Fires when a contact unsubscribes from or is resubscribed to marketing
        email.
      security: *ref_1
      responses:
        "200":
          description: The event types
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/WebhookEventType"
        "401": *ref_0
        "403": *ref_0
  /webhook/sample-event:
    get:
      tags:
        - Webhooks
      summary: Get a sample event
      description: >-
        One event of the type, in the shape it is delivered: the organization's most recent real one when it has one,
        else a made-up one with every field filled (`is_test: true`). Needs an API key made by an owner or a manager: a
        sales person's or an operator's key is refused with 403.
      security: *ref_1
      parameters:
        - name: event_type
          in: query
          required: false
          schema:
            type: string
            default: deal.created
            enum: &ref_2
              - deal.created
              - deal.cancelled
              - pipeline_item.created
              - pipeline_item.stage_changed
              - pipeline_item.pipeline_changed
              - invoice.created
              - invoice.sent
              - invoice.paid
              - invoice.cancelled
              - invoice.voided
              - invoice.refunded
              - invoice.refund_demanded
              - invoice.refund_demand_dropped
              - invoice.payment_undone
              - invoice.edited
              - contact.created
              - contact.updated
              - contact.deleted
              - company.created
              - note.created
              - task.completed
              - contact.event_added
              - contact.do_not_contact_changed
              - contact.marketing_email_changed
          description: The event type to get a sample of
      responses:
        "200":
          description: The sample
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookSampleEvent"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
  /webhook/subscription:
    post:
      tags:
        - Webhooks
      summary: Subscribe a URL to an event
      description: >-
        Booked55 sends every event of that type to the URL from then on, signed, as an HTTPS POST. The URL must be HTTPS
        and public. Keep the `id` that comes back: it is what unsubscribes. Needs an API key made by an owner or a
        manager: a sales person's or an operator's key is refused with 403.
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                target_url:
                  type: string
                  maxLength: 2048
                  description: URL to deliver to
                event:
                  type: string
                  description: Single event type to subscribe to
                  enum: *ref_2
                label:
                  type: string
                  maxLength: 200
                  description: Optional description of the subscriber
              required:
                - target_url
                - event
              additionalProperties: false
            examples:
              newContact:
                summary: Every new contact
                value:
                  target_url: https://hooks.example.com/booked55/contacts
                  event: contact.created
      responses:
        "201":
          description: The subscription
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookSubscription"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
  /webhook/subscription/{subscriptionId}:
    delete:
      tags:
        - Webhooks
      summary: Unsubscribe
      description: >-
        Stops the events to that subscription's URL. Needs an API key made by an owner or a manager: a sales person's or
        an operator's key is refused with 403.
      security: *ref_1
      parameters:
        - name: subscriptionId
          in: path
          required: true
          schema:
            type: string
          description: The subscription (endpoint) ID returned at subscribe time
      responses:
        "200":
          description: Unsubscribed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /org:
    get:
      tags:
        - Organization
      summary: Get the organization
      description: >-
        The organization the API key belongs to. A key works in one organization, so this is also the way to check a key
        and to show whose account it is. The answer carries the organization's settings as well; the fields listed here
        are the ones to rely on.
      security: *ref_1
      responses:
        "200":
          description: The organization
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Organization"
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /company:
    post:
      tags:
        - Companies
      summary: Create company
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompanyCreateRequest"
      responses:
        "200":
          description: Created company
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Company"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /company/{companyId}:
    get:
      tags:
        - Companies
      summary: Get company
      security: *ref_1
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
          description: Company ID
      responses:
        "200":
          description: Company details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Company"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Companies
      summary: Update company
      security: *ref_1
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
          description: Company ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompanyUpdateRequest"
      responses:
        "200":
          description: Updated company
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Company"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Companies
      summary: Delete company
      security: *ref_1
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
          description: Company ID
      responses:
        "200":
          description: Company deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /companies:
    get:
      tags:
        - Companies
      summary: List companies
      security: *ref_1
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
        - name: sort_by
          in: query
          required: false
          schema:
            type: string
            enum:
              - created_at
              - updated_at
              - name
        - name: sort_order
          in: query
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
      responses:
        "200":
          description: Paginated companies
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedCompanies"
        "401": *ref_0
  /companies/search:
    get:
      tags:
        - Companies
      summary: Search companies
      security: *ref_1
      parameters:
        - name: search
          in: query
          required: true
          schema:
            type: string
          description: Search query
      responses:
        "200":
          description: Matching companies
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Company"
        "400": *ref_0
        "401": *ref_0
  /event:
    post:
      tags:
        - Events
      summary: Create event
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EventCreateRequest"
      responses:
        "200":
          description: Created event
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Event"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /event/{eventId}:
    get:
      tags:
        - Events
      summary: Get event
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
      responses:
        "200":
          description: Event details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Event"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Events
      summary: Update event
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EventUpdateRequest"
      responses:
        "200":
          description: Updated event
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Event"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Events
      summary: Delete event
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
      responses:
        "200":
          description: Event deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /events:
    get:
      tags:
        - Events
      summary: List events
      security: *ref_1
      responses:
        "200":
          description: Event list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Event"
        "401": *ref_0
  /events/search:
    get:
      tags:
        - Events
      summary: Search events
      security: *ref_1
      parameters:
        - name: search
          in: query
          required: true
          schema:
            type: string
          description: Search query
      responses:
        "200":
          description: Matching events
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Event"
        "400": *ref_0
        "401": *ref_0
  /event/{eventId}/attendance:
    get:
      tags:
        - Events
      summary: Get attendance
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
        - name: attended_date
          in: query
          required: false
          schema:
            type: string
            format: date
      responses:
        "200":
          description: Attendance records
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/EventAttendance"
        "401": *ref_0
        "404": *ref_0
    post:
      tags:
        - Events
      summary: Mark attendance
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MarkAttendanceRequest"
      responses:
        "201":
          description: Attendance marked
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EventAttendance"
        "400": *ref_0
        "401": *ref_0
  /event/{eventId}/attendance/{attendanceId}:
    put:
      tags:
        - Events
      summary: Update attendance
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
        - name: attendanceId
          in: path
          required: true
          schema:
            type: string
          description: Attendance ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateAttendanceRequest"
      responses:
        "200":
          description: Updated attendance
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EventAttendance"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Events
      summary: Remove attendance
      security: *ref_1
      parameters:
        - name: eventId
          in: path
          required: true
          schema:
            type: string
          description: Event ID
        - name: attendanceId
          in: path
          required: true
          schema:
            type: string
          description: Attendance ID
      responses:
        "200":
          description: Attendance removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /task:
    post:
      tags:
        - Tasks
      summary: Create task
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskCreateRequest"
      responses:
        "200":
          description: Created task
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Task"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /task/{taskId}:
    get:
      tags:
        - Tasks
      summary: Get task
      security: *ref_1
      parameters:
        - name: taskId
          in: path
          required: true
          schema:
            type: string
          description: Task ID
      responses:
        "200":
          description: Task details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Task"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Tasks
      summary: Update task
      security: *ref_1
      parameters:
        - name: taskId
          in: path
          required: true
          schema:
            type: string
          description: Task ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaskUpdateRequest"
      responses:
        "200":
          description: Updated task
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Task"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Tasks
      summary: Delete task
      security: *ref_1
      parameters:
        - name: taskId
          in: path
          required: true
          schema:
            type: string
          description: Task ID
        - name: delete_reason
          in: query
          required: true
          schema:
            type: string
            enum: &ref_6
              - not_relevant
              - contacted_too_many_times
              - removing_contact
              - moving_contact
              - did_not_join
              - meeting_cancelled
              - not_needed
              - other
        - name: delete_other_reason
          in: query
          required: false
          schema:
            type: string
      responses:
        "200":
          description: Task deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /tasks:
    get:
      tags:
        - Tasks
      summary: List tasks
      security: *ref_1
      parameters:
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: contact_id
          in: query
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: &ref_4
              - active
              - completed
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 500
            default: 500
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
        - name: sort_by
          in: query
          required: false
          schema:
            type: string
            enum:
              - date
              - created_at
              - status
              - activity_type
              - description
        - name: sort_order
          in: query
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
      responses:
        "200":
          description: Paginated tasks
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedTasks"
        "401": *ref_0
  /tasks/search:
    get:
      tags:
        - Tasks
      summary: Search tasks
      security: *ref_1
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
            minLength: 1
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 100
            default: 50
      responses:
        "200":
          description: Matching tasks
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Task"
        "400": *ref_0
        "401": *ref_0
  /tasks/bulk-delete:
    post:
      tags:
        - Tasks
      summary: Bulk delete tasks
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkDeleteTasksRequest"
      responses:
        "200":
          description: Tasks deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  deleted:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /tasks/bulk-complete:
    post:
      tags:
        - Tasks
      summary: Bulk complete tasks
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkCompleteTasksRequest"
      responses:
        "200":
          description: Tasks completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  completed:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /pipeline:
    post:
      tags:
        - Pipelines
      summary: Create pipeline
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PipelineCreateRequest"
      responses:
        "200":
          description: Created pipeline
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pipeline"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
        "409": *ref_0
  /pipeline/{pipelineId}:
    get:
      tags:
        - Pipelines
      summary: Get pipeline
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      responses:
        "200":
          description: Pipeline details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pipeline"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Pipelines
      summary: Update pipeline
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PipelineUpdateRequest"
      responses:
        "200":
          description: Updated pipeline
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pipeline"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
        "409": *ref_0
    delete:
      tags:
        - Pipelines
      summary: Delete pipeline
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      responses:
        "200":
          description: Pipeline deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /pipelines:
    get:
      tags:
        - Pipelines
      summary: List pipelines
      security: *ref_1
      responses:
        "200":
          description: Pipeline list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Pipeline"
        "401": *ref_0
  /pipeline/{pipelineId}/stage:
    post:
      tags:
        - Pipelines
      summary: Create stage
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PipelineStageCreateRequest"
      responses:
        "200":
          description: Created stage
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PipelineStage"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /pipeline/{pipelineId}/stages:
    get:
      tags:
        - Pipelines
      summary: List stages
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      responses:
        "200":
          description: Stage list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/PipelineStage"
        "401": *ref_0
  /pipeline/{pipelineId}/stage/{stageId}:
    get:
      tags:
        - Pipelines
      summary: Get stage
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
        - name: stageId
          in: path
          required: true
          schema:
            type: string
          description: Stage ID
      responses:
        "200":
          description: Stage details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PipelineStage"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Pipelines
      summary: Update stage
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
        - name: stageId
          in: path
          required: true
          schema:
            type: string
          description: Stage ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PipelineStageUpdateRequest"
      responses:
        "200":
          description: Updated stage
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PipelineStage"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Pipelines
      summary: Delete stage
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
        - name: stageId
          in: path
          required: true
          schema:
            type: string
          description: Stage ID
      responses:
        "200":
          description: Stage deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /pipeline/{pipelineId}/item:
    post:
      tags:
        - Pipelines
      summary: Create pipeline item
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PipelineItemCreateRequest"
      responses:
        "200":
          description: Created pipeline item
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PipelineItem"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /pipeline/{pipelineId}/items:
    get:
      tags:
        - Pipelines
      summary: List pipeline items
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
      responses:
        "200":
          description: Pipeline items
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/PipelineItem"
        "401": *ref_0
  /pipeline/{pipelineId}/item/{pipelineItemId}:
    put:
      tags:
        - Pipelines
      summary: Update pipeline item
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
        - name: pipelineItemId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline item ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PipelineItemUpdateRequest"
      responses:
        "200":
          description: Updated pipeline item
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PipelineItem"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Pipelines
      summary: Delete pipeline item
      security: *ref_1
      parameters:
        - name: pipelineId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline ID
        - name: pipelineItemId
          in: path
          required: true
          schema:
            type: string
          description: Pipeline item ID
      responses:
        "200":
          description: Pipeline item deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /pipeline-items/search:
    get:
      tags:
        - Pipelines
      summary: Search pipeline items
      security: *ref_1
      parameters:
        - name: contact_id
          in: query
          required: false
          schema:
            type: string
        - name: pipeline_id
          in: query
          required: false
          schema:
            type: string
        - name: stage_id
          in: query
          required: false
          schema:
            type: string
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            type: string
      responses:
        "200":
          description: Matching pipeline items
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/PipelineItem"
        "401": *ref_0
  /campaign:
    post:
      tags:
        - Campaigns
      summary: Create campaign
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CampaignCreateRequest"
      responses:
        "200":
          description: Created campaign
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Campaign"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /campaign/{campaignId}:
    get:
      tags:
        - Campaigns
      summary: Get campaign
      security: *ref_1
      parameters:
        - name: campaignId
          in: path
          required: true
          schema:
            type: string
          description: Campaign ID
      responses:
        "200":
          description: Campaign details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Campaign"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Campaigns
      summary: Update campaign
      security: *ref_1
      parameters:
        - name: campaignId
          in: path
          required: true
          schema:
            type: string
          description: Campaign ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CampaignUpdateRequest"
      responses:
        "200":
          description: Updated campaign
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Campaign"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Campaigns
      summary: Delete campaign
      security: *ref_1
      parameters:
        - name: campaignId
          in: path
          required: true
          schema:
            type: string
          description: Campaign ID
      responses:
        "200":
          description: Campaign deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /campaigns:
    get:
      tags:
        - Campaigns
      summary: List campaigns
      security: *ref_1
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 100
            default: 50
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - pending
              - contact_filtering
              - contact_filtered
              - running
              - completed
              - error
      responses:
        "200":
          description: Paginated campaigns
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedCampaigns"
        "401": *ref_0
  /campaign/{campaignId}/launch:
    post:
      tags:
        - Campaigns
      summary: Launch campaign
      security: *ref_1
      parameters:
        - name: campaignId
          in: path
          required: true
          schema:
            type: string
          description: Campaign ID
      responses:
        "200":
          description: Campaign launched
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Campaign"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /campaign/{campaignId}/contacts:
    get:
      tags:
        - Campaigns
      summary: Get campaign contacts
      security: *ref_1
      parameters:
        - name: campaignId
          in: path
          required: true
          schema:
            type: string
          description: Campaign ID
      responses:
        "200":
          description: Campaign contacts
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Contact"
        "401": *ref_0
        "404": *ref_0
  /email-template:
    post:
      tags:
        - Email Templates
      summary: Create template
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EmailTemplateCreateRequest"
      responses:
        "200":
          description: Created template
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmailTemplate"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /email-template/{templateId}:
    get:
      tags:
        - Email Templates
      summary: Get template
      security: *ref_1
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
          description: Template ID
      responses:
        "200":
          description: Template details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmailTemplate"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Email Templates
      summary: Update template
      security: *ref_1
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
          description: Template ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EmailTemplateUpdateRequest"
      responses:
        "200":
          description: Updated template, with how many contacts live sequences will send the new version to
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmailTemplateUpdated"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Email Templates
      summary: Delete template
      security: *ref_1
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
          description: Template ID
      responses:
        "200":
          description: Template deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /template-library:
    get:
      tags:
        - Email Templates
      summary: List Booked55's template library
      description: >-
        Public: no sign-in needed. The counts are totals across every customer, shown once 3 organizations have sent a
        template; replies are never counted.
      responses:
        "200":
          description: The library
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TemplateLibrary"
  /template-library/{key}/copy:
    post:
      tags:
        - Email Templates
      summary: Copy a library template into the organization's templates
      security: *ref_1
      parameters:
        - name: key
          in: path
          required: true
          schema:
            type: string
          description: Library key, e.g. nice_to_meet_you
      responses:
        "200":
          description: The new template, with library_key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmailTemplate"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /email-templates:
    get:
      tags:
        - Email Templates
      summary: List templates
      security: *ref_1
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 100
            default: 50
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
      responses:
        "200":
          description: Paginated templates
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedEmailTemplates"
        "401": *ref_0
  /email-templates/search:
    get:
      tags:
        - Email Templates
      summary: Search templates
      security: *ref_1
      parameters:
        - name: query
          in: query
          required: true
          schema:
            type: string
            minLength: 2
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 50
            default: 20
      responses:
        "200":
          description: Matching templates
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/EmailTemplate"
        "401": *ref_0
  /email-template/{templateId}/usage:
    get:
      tags:
        - Email Templates
      summary: Where a template is used
      description: >-
        The sequences whose steps send the template (drafts too, with which steps), the active newsletters whose new
        issues start from it, and the campaigns made from it (each keeps its own copy). Totals count the whole
        organization; at most 50 of each are listed, newest first, and only those the caller may open. live_use says how
        many live sequences send it and how many contacts are still to get it.
      security: *ref_1
      parameters:
        - name: templateId
          in: path
          required: true
          schema:
            type: string
          description: Template ID
      responses:
        "200":
          description: Where the template is used
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EmailTemplateUsage"
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
        "422": *ref_0
  /client-type:
    post:
      tags:
        - Client Types
      summary: Create client type
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClientTypeCreateRequest"
      responses:
        "200":
          description: Created client type
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientType"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /client-type/{clientTypeId}:
    get:
      tags:
        - Client Types
      summary: Get client type
      security: *ref_1
      parameters:
        - name: clientTypeId
          in: path
          required: true
          schema:
            type: string
          description: Client type ID
      responses:
        "200":
          description: Client type details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientType"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Client Types
      summary: Update client type
      security: *ref_1
      parameters:
        - name: clientTypeId
          in: path
          required: true
          schema:
            type: string
          description: Client type ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClientTypeUpdateRequest"
      responses:
        "200":
          description: Updated client type
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientType"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Client Types
      summary: Delete client type
      security: *ref_1
      parameters:
        - name: clientTypeId
          in: path
          required: true
          schema:
            type: string
          description: Client type ID
      responses:
        "200":
          description: Client type deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /client-types:
    get:
      tags:
        - Client Types
      summary: List client types
      security: *ref_1
      responses:
        "200":
          description: Client type list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ClientType"
        "401": *ref_0
  /deals:
    get:
      tags:
        - Deals
      summary: List deals
      description: Paginated list of closed sales, newest first.
      security: *ref_1
      parameters:
        - name: contact_id
          in: query
          required: false
          schema:
            type: string
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: client_type_id
          in: query
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - active
              - ended
              - cancelled
        - name: managed_by
          in: query
          required: false
          schema:
            type: string
            description: Only deals this operator looks after
          description: Only deals this operator looks after
        - name: pricing_model
          in: query
          required: false
          schema:
            type: string
            enum:
              - one_time
              - recurring
        - name: start_date
          in: query
          required: false
          schema:
            type: string
            format: date
            description: Deal date from. Send end_date too.
          description: Deal date from. Send end_date too.
        - name: end_date
          in: query
          required: false
          schema:
            type: string
            format: date
            description: Deal date to. Send start_date too.
          description: Deal date to. Send start_date too.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: sort_by
          in: query
          required: false
          schema:
            type: string
            enum:
              - dealDate
              - createdAt
              - value
            default: dealDate
        - name: sort_order
          in: query
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
      responses:
        "200":
          description: Deal list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Deal"
                  pagination:
                    type: object
                    properties:
                      limit:
                        type: integer
                      offset:
                        type: integer
                      total:
                        type: integer
                      total_value:
                        type: number
                      page:
                        type: integer
                      totalPages:
                        type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /deal:
    post:
      tags:
        - Deals
      summary: Create deal
      description: >-
        Records a closed sale and marks the contact as a client. A recurring deal makes one invoice for each payment as
        its due date comes up.
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DealCreateRequest"
      responses:
        "200":
          description: Created deal
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Deal"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /deal/{dealId}:
    get:
      tags:
        - Deals
      summary: Get deal
      security: *ref_1
      parameters:
        - name: dealId
          in: path
          required: true
          schema:
            type: string
          description: Deal ID
      responses:
        "200":
          description: Deal details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Deal"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Deals
      summary: Update deal
      description: >-
        A change to the amount, the tax or the schedule reaches invoices in Draft and those not made yet. Sent and Paid
        invoices stay as they are.
      security: *ref_1
      parameters:
        - name: dealId
          in: path
          required: true
          schema:
            type: string
          description: Deal ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DealUpdateRequest"
      responses:
        "200":
          description: Updated deal
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Deal"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    delete:
      tags:
        - Deals
      summary: Delete deal
      description: "Refused for a deal with money on it: cancel that deal instead."
      security: *ref_1
      parameters:
        - name: dealId
          in: path
          required: true
          schema:
            type: string
          description: Deal ID
      responses:
        "200":
          description: Deal deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /deal/{dealId}/cancel:
    post:
      tags:
        - Deals
      summary: Cancel deal
      description: "Stops a deal: no more invoices are made, and its Draft invoices are cancelled. Invoices already Sent stay owed."
      security: *ref_1
      parameters:
        - name: dealId
          in: path
          required: true
          schema:
            type: string
          description: Deal ID
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  maxLength: 1000
      responses:
        "200":
          description: Cancelled deal
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Deal"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /deals/reassign-operator:
    post:
      tags:
        - Deals
      summary: Move deals to another operator
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - deal_ids
                - managed_by
              properties:
                deal_ids:
                  type: array
                  minItems: 1
                  maxItems: 500
                  items:
                    type: string
                managed_by:
                  type: string
                  description: The new operator's user ID
      responses:
        "200":
          description: How many deals moved
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  updated_count:
                    type: integer
                  matched_count:
                    type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoices:
    get:
      tags:
        - Invoices
      summary: List invoices
      security: *ref_1
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - draft
              - sent
              - paid
              - cancelled
              - refund_demanded
              - refunded
              - void
              - overdue
              - upcoming
            description: A stored status, overdue (sent, past its due date) or upcoming (draft, due date ahead)
          description: A stored status, overdue (sent, past its due date) or upcoming (draft, due date ahead)
        - name: due_from
          in: query
          required: false
          schema:
            type: string
            format: date
        - name: due_to
          in: query
          required: false
          schema:
            type: string
            format: date
        - name: managed_by
          in: query
          required: false
          schema:
            type: string
            description: Only invoices this operator looks after
          description: Only invoices this operator looks after
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: contact_id
          in: query
          required: false
          schema:
            type: string
        - name: deal_id
          in: query
          required: false
          schema:
            type: string
        - name: mine
          in: query
          required: false
          schema:
            type: boolean
            description: Only invoices where the caller is the sales person or the operator
          description: Only invoices where the caller is the sales person or the operator
        - name: migrated
          in: query
          required: false
          schema:
            type: boolean
            description: Only the invoices made from deals that existed before invoices
          description: Only the invoices made from deals that existed before invoices
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
      responses:
        "200":
          description: Invoice list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Invoice"
                  pagination:
                    type: object
                    properties:
                      limit:
                        type: integer
                      offset:
                        type: integer
                      total:
                        type: integer
                      page:
                        type: integer
                      totalPages:
                        type: integer
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoices/export:
    get:
      tags:
        - Invoices
      summary: Export invoices as CSV
      description: The same filters as the list. Needs the Data Export permission.
      security: *ref_1
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - draft
              - sent
              - paid
              - cancelled
              - refund_demanded
              - refunded
              - void
              - overdue
              - upcoming
            description: A stored status, overdue (sent, past its due date) or upcoming (draft, due date ahead)
          description: A stored status, overdue (sent, past its due date) or upcoming (draft, due date ahead)
        - name: due_from
          in: query
          required: false
          schema:
            type: string
            format: date
        - name: due_to
          in: query
          required: false
          schema:
            type: string
            format: date
        - name: managed_by
          in: query
          required: false
          schema:
            type: string
            description: Only invoices this operator looks after
          description: Only invoices this operator looks after
        - name: assigned_to
          in: query
          required: false
          schema:
            type: string
        - name: contact_id
          in: query
          required: false
          schema:
            type: string
        - name: deal_id
          in: query
          required: false
          schema:
            type: string
        - name: mine
          in: query
          required: false
          schema:
            type: boolean
            description: Only invoices where the caller is the sales person or the operator
          description: Only invoices where the caller is the sales person or the operator
        - name: migrated
          in: query
          required: false
          schema:
            type: boolean
            description: Only the invoices made from deals that existed before invoices
          description: Only the invoices made from deals that existed before invoices
      responses:
        "200":
          description: CSV file
          content:
            text/csv:
              schema:
                type: string
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoice/{invoiceId}:
    get:
      tags:
        - Invoices
      summary: Get invoice
      security: *ref_1
      parameters:
        - name: invoiceId
          in: path
          required: true
          schema:
            type: string
          description: Invoice ID
      responses:
        "200":
          description: Invoice details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
    put:
      tags:
        - Invoices
      summary: Correct a migrated invoice
      description: For an invoice made from a deal that existed before invoices, during the time such invoices can be edited.
      security: *ref_1
      parameters:
        - name: invoiceId
          in: path
          required: true
          schema:
            type: string
          description: Invoice ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                due_date:
                  type: string
                  format: date
                amount:
                  type: number
                  minimum: 0
                tax_rate:
                  type: number
                  minimum: 0
                status:
                  type: string
                  enum:
                    - draft
                    - sent
                    - paid
                    - cancelled
                    - refund_demanded
                    - refunded
                    - void
                paid_at:
                  type: string
                payment_note:
                  type: string
                  maxLength: 1000
      responses:
        "200":
          description: Corrected invoice
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoice/{invoiceId}/pdf:
    get:
      tags:
        - Invoices
      summary: Get a link to the PDF
      description: A link that works for one hour. Only where the organization has Booked55 make its invoices.
      security: *ref_1
      parameters:
        - name: invoiceId
          in: path
          required: true
          schema:
            type: string
          description: Invoice ID
      responses:
        "200":
          description: The link
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                  expires_at:
                    type: string
                    format: date-time
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoice/{invoiceId}/send:
    post:
      tags:
        - Invoices
      summary: Mark invoice as sent
      description: Records that the invoice went out. Booked55 does not email it.
      security: *ref_1
      parameters:
        - name: invoiceId
          in: path
          required: true
          schema:
            type: string
          description: Invoice ID
      responses:
        "200":
          description: Sent invoice
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoice/{invoiceId}/move:
    post:
      tags:
        - Invoices
      summary: Move an invoice
      description: >-
        Marks it paid, cancels or voids it, or records a refund. Records what happened: no money moves. The `moves`
        field on an invoice lists what it can do next.
      security: *ref_1
      parameters:
        - name: invoiceId
          in: path
          required: true
          schema:
            type: string
          description: Invoice ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - action
              properties:
                action:
                  type: string
                  enum:
                    - pay
                    - cancel
                    - void
                    - demand_refund
                    - refund
                    - drop_refund_demand
                    - undo_paid
                paid_at:
                  type: string
                  description: The day the money came in. Today when left out
                payment_note:
                  type: string
                  maxLength: 1000
                  description: How it was paid, never card or account numbers
                reason:
                  type: string
                  maxLength: 1000
                  description: Why it was cancelled or voided
                amount_refunded:
                  type: number
                  description: "How much was given back: above 0, at most the total"
                refunded_at:
                  type: string
                  description: The day the money went back. Today when left out
                refund_note:
                  type: string
                  maxLength: 1000
      responses:
        "200":
          description: Moved invoice
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /invoice/{invoiceId}/correct:
    post:
      tags:
        - Invoices
      summary: Make a corrected copy
      description: "For a voided invoice: makes a new Draft for the same payment, with the next revision number."
      security: *ref_1
      parameters:
        - name: invoiceId
          in: path
          required: true
          schema:
            type: string
          description: Invoice ID
      responses:
        "200":
          description: The corrected copy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
  /lead-sources:
    get:
      tags:
        - Lead Sources
      summary: List lead sources
      description: An organization's first read fills in the starter list.
      security: *ref_1
      responses:
        "200":
          description: Lead source list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/LeadSource"
        "401": *ref_0
  /lead-source:
    post:
      tags:
        - Lead Sources
      summary: Create lead source
      security: *ref_1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LeadSourceRequest"
      responses:
        "200":
          description: Created lead source
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LeadSource"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
        "409": *ref_0
  /lead-source/{leadSourceId}:
    put:
      tags:
        - Lead Sources
      summary: Rename lead source
      security: *ref_1
      parameters:
        - name: leadSourceId
          in: path
          required: true
          schema:
            type: string
          description: Lead source ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LeadSourceRequest"
      responses:
        "200":
          description: Renamed lead source
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LeadSource"
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
        "409": *ref_0
    delete:
      tags:
        - Lead Sources
      summary: Delete lead source
      description: Refused while a contact or a campaign uses it.
      security: *ref_1
      parameters:
        - name: leadSourceId
          in: path
          required: true
          schema:
            type: string
          description: Lead source ID
      responses:
        "200":
          description: Lead source deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        "400": *ref_0
        "401": *ref_0
        "403": *ref_0
        "404": *ref_0
        "409": *ref_0
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: vg_ API key
      description: Bearer token in Authorization header
  responses:
    Error:
      description: Error response
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
    Pagination:
      type: object
      properties:
        limit:
          type: integer
        offset:
          type: integer
        total:
          type: integer
        has_more:
          type: boolean
    PaginatedContacts:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Contact"
        pagination:
          $ref: "#/components/schemas/Pagination"
    PaginatedCompanies:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Company"
        pagination:
          $ref: "#/components/schemas/Pagination"
    PaginatedTasks:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Task"
        pagination:
          $ref: "#/components/schemas/Pagination"
    PaginatedCampaigns:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Campaign"
        pagination:
          $ref: "#/components/schemas/Pagination"
    PaginatedEmailTemplates:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/EmailTemplate"
        pagination:
          $ref: "#/components/schemas/Pagination"
    ContactBio:
      type: object
      description: Professional and business-relevant bio fields only
      properties:
        personal_info:
          type: object
          properties:
            nick_name:
              type: string
            first_name:
              type: string
            last_name:
              type: string
            middle_name:
              type: string
            suffix:
              type: string
            birth_date:
              oneOf:
                - type: string
                  maxLength: 0
                - type: string
                  format: date
            birth_place:
              type: string
            nationality:
              type: string
        social_media:
          type: object
          properties:
            facebook:
              type: string
              format: uri
            twitter:
              type: string
              format: uri
            instagram:
              type: string
              format: uri
            linkedin:
              type: string
              format: uri
            youtube:
              type: string
              format: uri
            website:
              type: string
              format: uri
            tiktok:
              type: string
              format: uri
            others:
              type: array
              items:
                type: string
        hobbies:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              description:
                type: string
              interest_score:
                type: number
                minimum: 0
                maximum: 100
        education:
          type: array
          items:
            type: object
            properties:
              school:
                type: string
              degree:
                type: string
              duration:
                type: string
              start_date:
                type: string
                format: date
              end_date:
                type: string
                format: date
        work_history:
          type: array
          items:
            type: object
            properties:
              company:
                type: string
              title:
                type: string
              duration:
                type: string
              start_date:
                type: string
                format: date
              end_date:
                type: string
                format: date
        location:
          type: object
          properties:
            city:
              type: string
            state:
              type: string
            country:
              type: string
            zip_code:
              type: string
        languages:
          type: array
          items:
            type: object
            properties:
              categories:
                type: array
                items:
                  type: string
              primary:
                type: boolean
              proficiency:
                type: number
                minimum: 0
                maximum: 100
        interests:
          type: object
          properties:
            sports:
              type: object
            music:
              type: object
            movies:
              type: object
            books:
              type: object
            others:
              type: array
              items:
                type: object
    ContactMeetingDetails:
      type: object
      properties:
        conversation_summary:
          type: array
          items: &ref_3
            type: object
            properties:
              summary:
                type: string
              timestamp:
                oneOf:
                  - type: string
                    maxLength: 0
                  - type: string
                    format: date-time
        occupation_learnings:
          type: array
          items: *ref_3
        outside_work_interests:
          type: array
          items: *ref_3
        dream:
          type: array
          items: *ref_3
    ContactFields:
      type: object
      properties:
        email:
          oneOf:
            - type: string
              maxLength: 0
            - type: string
              format: email
        name:
          type: string
        phone_numbers:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
                enum:
                  - primary
                  - mobile
                  - work
                  - home
                  - fax
                  - other
              phone_number:
                type: string
            required:
              - phone_number
        external_id:
          type: string
          nullable: true
        source_id:
          type: string
        lead_source_id:
          type: string
          nullable: true
          description: "Why this contact came to you: an id from GET /lead-sources"
        lead_source_detail:
          type: string
          nullable: true
          maxLength: 200
          description: The event, the referrer or the campaign behind the lead source
        company_id:
          type: string
          nullable: true
        client_type_id:
          type: string
        is_client:
          type: boolean
          readOnly: true
          description: "True while the contact has a deal. Only a deal makes a client: a value sent here is ignored"
        mark_as_client_on:
          type: string
          format: date-time
          nullable: true
          readOnly: true
          description: Noon UTC of the close day of the contact's first deal. Ignored when sent
        owned_by_id:
          type: string
        assigned_to_id:
          type: string
        referred_by:
          type: string
          nullable: true
        referred_by_on:
          type: string
          format: date-time
          nullable: true
        event_id:
          type: string
        event_ids:
          type: array
          items:
            type: string
        attached_files:
          type: array
          items:
            type: string
        tags:
          type: array
          items:
            type: string
        gender:
          type: string
        describe_intension_reasoning:
          type: string
        met_at:
          type: string
        met_at_description:
          type: string
        meeting_details:
          $ref: "#/components/schemas/ContactMeetingDetails"
        bio:
          $ref: "#/components/schemas/ContactBio"
    ContactDoNotContactRequest:
      type: object
      properties:
        call:
          type: boolean
          description: Do not call this contact
        text:
          type: boolean
          description: Do not text (SMS) this contact
        email:
          type: boolean
          description: Do not email this contact; also puts the address on the do-not-email list
        record:
          type: boolean
          description: Do not record calls with this contact
      additionalProperties: false
      description: >-
        Do not call, text, email or record. A mark left out is unchanged. Anyone who may edit the contact can turn a
        mark on; only an owner or a manager can turn one off (403 do_not_contact_clear_forbidden, and nothing else in
        that request is saved). On a new contact a false does nothing.
    ContactCreateRequest:
      allOf:
        - $ref: "#/components/schemas/ContactFields"
        - type: object
          required:
            - name
          properties:
            do_not_contact:
              $ref: "#/components/schemas/ContactDoNotContactRequest"
    ContactUpdateRequest:
      allOf:
        - $ref: "#/components/schemas/ContactFields"
        - type: object
          properties:
            do_not_contact:
              $ref: "#/components/schemas/ContactDoNotContactRequest"
    Note:
      type: object
      properties:
        id:
          type: string
        entity_type:
          type: string
          description: contact, company, task, deal, pipelineItem, event or eventAttendance
        entity_id:
          type: string
          description: The record the note is written on
        contact_id:
          type: string
          nullable: true
          description: The contact whose notes list it shows in
        company_id:
          type: string
          nullable: true
        body:
          type: string
        note_at:
          type: string
          format: date-time
          description: The note's own date
        source:
          type: string
          description: "Who wrote it: user, meeting_bot, email_sync, inbound, import or system"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
          nullable: true
        edited_at:
          type: string
          format: date-time
          nullable: true
        created_by:
          type: string
          nullable: true
        created_by_name:
          type: string
          nullable: true
        can_edit:
          type: boolean
          description: Whether the caller may still change it
        editable_until:
          type: string
          format: date-time
          nullable: true
        entity_label:
          type: string
          nullable: true
          description: What the note is on, in a list that mixes records
    PaginatedNotes:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Note"
        pagination:
          type: object
          properties:
            limit:
              type: integer
            offset:
              type: integer
            total:
              type: integer
            page:
              type: integer
            totalPages:
              type: integer
            sources:
              type: array
              items:
                type: string
              description: The sources filter that ran
            q:
              type: string
              nullable: true
              description: The text filter that ran
    WebhookEventType:
      type: object
      properties:
        type:
          type: string
          enum: *ref_2
        description:
          type: string
          description: When it fires
    WebhookSubscription:
      type: object
      properties:
        id:
          type: string
          description: Send this to DELETE /webhook/subscription/{subscriptionId} to unsubscribe
        target_url:
          type: string
        event:
          type: string
          enum: *ref_2
    WebhookEvent:
      type: object
      description: "An event as it is delivered. Fields are only ever added: none is renamed, removed or changed in meaning."
      properties:
        id:
          type: string
          description: Unique to the event. Use it to ignore one delivered twice.
        type:
          type: string
          enum: *ref_2
        created_at:
          type: string
          format: date-time
        account_id:
          type: string
          description: The organization
        actor:
          type: object
          description: Who or what caused it
          properties:
            type:
              type: string
              enum:
                - user
                - api_key
                - system
                - import
            id:
              type: string
              nullable: true
            name:
              type: string
              nullable: true
        test:
          type: boolean
          description: True for a sample or a test event
        data:
          type: object
          description: >-
            What happened. Every event carries `contact` and `company` (null when there is none), and the record the
            event is about: `deal`, `pipeline_item`, `invoice`, `note`, `task` or `event`. A field with no value is sent
            as null, never left out.
    WebhookSampleEvent:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum: *ref_2
        created_at:
          type: string
          format: date-time
        is_test:
          type: boolean
          description: True for a made-up sample, false for a real recent event
        payload:
          $ref: "#/components/schemas/WebhookEvent"
    Organization:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        kind:
          type: string
          nullable: true
          description: Null for an ordinary organization
        account_id:
          type: string
          nullable: true
          description: The parent account, for a team of one
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Contact:
      allOf:
        - $ref: "#/components/schemas/ContactFields"
        - type: object
          properties:
            id:
              type: string
            org_id:
              type: string
            email_verified:
              type: boolean
            company:
              type: object
              nullable: true
              properties:
                id:
                  type: string
                name:
                  type: string
                email:
                  type: string
                phone:
                  type: string
                website:
                  type: string
            assigned_to:
              type: string
              nullable: true
            owned_by:
              type: string
              nullable: true
            referred_by_contact:
              type: object
              nullable: true
              properties:
                id:
                  type: string
                name:
                  type: string
                email:
                  type: string
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
    ReferralsResponse:
      type: object
      properties:
        total:
          type: integer
        referrals:
          type: array
          items:
            $ref: "#/components/schemas/Contact"
    DuplicateCheckResponse:
      type: object
      properties:
        has_duplicates:
          type: boolean
        duplicates:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              email:
                type: string
    BulkUpdateTagsRequest:
      type: object
      required:
        - contact_ids
        - tags
      properties:
        contact_ids:
          type: array
          items:
            type: string
          minItems: 1
        tags:
          type: array
          items:
            type: string
          minItems: 1
        action:
          type: string
          enum:
            - add
            - remove
          default: add
    BulkAddEventRequest:
      type: object
      required:
        - contact_ids
        - event_id
      properties:
        contact_ids:
          type: array
          items:
            type: string
          minItems: 1
        event_id:
          type: string
    BulkUpdatePipelineRequest:
      type: object
      required:
        - contact_ids
        - pipeline_id
        - stage_id
      properties:
        contact_ids:
          type: array
          items:
            type: string
          minItems: 1
        pipeline_id:
          type: string
        stage_id:
          type: string
    BulkDeleteContactsRequest:
      type: object
      required:
        - contact_ids
      properties:
        contact_ids:
          type: array
          items:
            type: string
          minItems: 1
    ContactFilters:
      type: object
      properties:
        source_id:
          type: string
        lead_source_id:
          type: string
        company_id:
          type: string
        created_by:
          type: string
        assigned_to:
          type: string
        is_client:
          type: boolean
        event_id:
          type: string
        pipeline_id:
          type: string
        stage_id:
          type: string
        no_pipeline:
          type: boolean
        no_event:
          type: boolean
        missing_email:
          type: boolean
        missing_phone:
          type: boolean
        tags:
          type: array
          items:
            type: string
    ContactExportRequest:
      type: object
      properties:
        selection_type:
          type: string
          enum:
            - contact_list
            - filter
        contact_ids:
          type: array
          items:
            type: string
        contact_filters:
          $ref: "#/components/schemas/ContactFilters"
        excluded_contact_ids:
          type: array
          items:
            type: string
    CompanyFields:
      type: object
      properties:
        name:
          type: string
        email:
          oneOf:
            - type: string
              maxLength: 0
            - type: string
              format: email
        phone:
          type: string
        fax:
          type: string
        website:
          type: string
        linkedin:
          type: string
        location:
          type: object
          properties:
            address:
              type: string
            city:
              type: string
            state:
              type: string
            country:
              type: string
            zip:
              type: string
        industries:
          type: array
          items:
            type: string
        company_type:
          type: string
          enum:
            - public
            - private
            - government
            - ""
        employee_range:
          type: object
          properties:
            min:
              type: number
            max:
              type: number
        revenue:
          type: number
          minimum: 0
        external_id:
          type: string
          nullable: true
        description:
          type: string
        notes:
          type: string
        assigned_to:
          type: string
    CompanyCreateRequest:
      allOf:
        - $ref: "#/components/schemas/CompanyFields"
        - type: object
          required:
            - name
    CompanyUpdateRequest:
      $ref: "#/components/schemas/CompanyFields"
    Company:
      allOf:
        - $ref: "#/components/schemas/CompanyFields"
        - type: object
          properties:
            id:
              type: string
            org_id:
              type: string
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
    EventFields:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        event_frequency:
          type: string
          enum:
            - single-day
            - multi-day
            - recurring
            - ""
        date:
          type: object
          required:
            - start
          properties:
            start:
              type: string
              format: date
            end:
              type: string
              format: date
        recurrence:
          type: object
          properties:
            frequency:
              type: string
              enum:
                - daily
                - weekly
                - monthly
                - yearly
                - ""
            interval:
              type: integer
              minimum: 1
            days_of_week:
              type: array
              items:
                type: integer
                minimum: 0
                maximum: 6
            day_of_month:
              type: integer
              nullable: true
            ends_on:
              type: string
              nullable: true
            occurrences:
              type: integer
              nullable: true
        location:
          type: string
        cost:
          type: number
          minimum: 0
        assigned_to:
          type: string
    EventCreateRequest:
      allOf:
        - $ref: "#/components/schemas/EventFields"
        - type: object
          required:
            - name
            - date
    EventUpdateRequest:
      $ref: "#/components/schemas/EventFields"
    Event:
      allOf:
        - $ref: "#/components/schemas/EventFields"
        - type: object
          properties:
            id:
              type: string
            org_id:
              type: string
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
    EventAttendance:
      type: object
      properties:
        id:
          type: string
        event_id:
          type: string
        user_id:
          type: string
        attended_date:
          type: string
          format: date
        notes:
          type: string
        marked_by:
          type: string
        created_at:
          type: string
          format: date-time
    MarkAttendanceRequest:
      type: object
      required:
        - attended_date
      properties:
        attended_date:
          type: string
          format: date
          description: Date in YYYY-MM-DD format
        notes:
          type: string
    UpdateAttendanceRequest:
      type: object
      properties:
        notes:
          type: string
    TaskCreateRequest:
      type: object
      required:
        - description
        - date
        - activity_type
      properties:
        company_id:
          type: string
        contact_id:
          type: string
        pipeline_item_id:
          type: string
        description:
          type: string
        activity_type:
          type: string
          enum: &ref_5
            - call
            - sms
            - email
            - marketing_email
            - social_engagement
            - meeting
            - visit
            - lunch
            - dinner
            - recreation
            - follow_up
            - to_do
            - market_research
            - event_and_networking
            - brand_visibility
            - referral_expansion
            - partnership_ecosystem
            - webinar
            - group_video_calls
            - one_to_many_outreach
        date:
          type: string
          format: date-time
        assigned_to:
          type: string
        status:
          type: string
          enum: *ref_4
          default: active
    TaskUpdateRequest:
      type: object
      properties:
        company_id:
          type: string
        contact_id:
          type: string
        pipeline_item_id:
          type: string
        description:
          type: string
        activity_type:
          type: string
          enum: *ref_5
        date:
          oneOf:
            - type: string
              maxLength: 0
            - type: string
              format: date-time
        assigned_to:
          type: string
        status:
          type: string
          enum: *ref_4
        task_result_description:
          type: string
    Task:
      type: object
      properties:
        id:
          type: string
        org_id:
          type: string
        description:
          type: string
        activity_type:
          type: string
          enum: *ref_5
        date:
          type: string
          format: date-time
        status:
          type: string
          enum: *ref_4
        contact_id:
          type: string
        company_id:
          type: string
        pipeline_item_id:
          type: string
        assigned_to:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    BulkDeleteTasksRequest:
      type: object
      required:
        - task_ids
        - delete_reason
      properties:
        task_ids:
          type: array
          items:
            type: string
          minItems: 1
        delete_reason:
          type: string
          enum: *ref_6
        delete_other_reason:
          type: string
    BulkCompleteTasksRequest:
      type: object
      required:
        - task_ids
      properties:
        task_ids:
          type: array
          items:
            type: string
          minItems: 1
    PipelineCreateRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        description:
          type: string
        color: &ref_7
          type: string
          enum: &ref_8
            - coral
            - orange
            - amber
            - olive
            - green
            - teal
            - sky
            - blue
            - lavender
            - fuchsia
            - rose
            - slate
          description: >-
            One of the twelve pipeline colours, never one another pipeline of the organization has. Left out, a new
            pipeline gets a free one.
        settings:
          type: object
    PipelineUpdateRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        color: *ref_7
        settings:
          type: object
    Pipeline:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        color:
          type: string
          enum: *ref_8
          description: >-
            One of the twelve pipeline colours, never one another pipeline of the organization has. Left out, a new
            pipeline gets a free one.
          nullable: true
        order:
          type: integer
        settings:
          type: object
        org_id:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    PipelineStageCreateRequest:
      type: object
      required:
        - name
        - order
      properties:
        name:
          type: string
        order:
          type: number
        markAsClient:
          type: boolean
        is_assessment:
          type: boolean
          description: This stage is where a contact is assessed. It counts in the assessment numbers.
        is_lost:
          type: boolean
          description: A card here is lost. It asks for a lost reason and counts as lost in the numbers.
        generateActivityOnEntry:
          type: boolean
        activityFrequency:
          type: object
        automation:
          type: object
    PipelineStageUpdateRequest:
      $ref: "#/components/schemas/PipelineStageCreateRequest"
    PipelineStage:
      type: object
      properties:
        id:
          type: string
        pipeline_id:
          type: string
        name:
          type: string
        order:
          type: number
        markAsClient:
          type: boolean
        is_assessment:
          type: boolean
        is_lost:
          type: boolean
        generateActivityOnEntry:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    PipelineItemCreateRequest:
      type: object
      required:
        - contact_id
        - pipeline_id
        - stage_id
      properties:
        contact_id:
          type: string
        pipeline_id:
          type: string
        stage_id:
          type: string
        status:
          type: string
        notes:
          type: string
        assigned_to:
          type: string
        value:
          type: number
          minimum: 0
        client_type_id:
          type: string
        lost_reason:
          type: string
          nullable: true
          enum:
            - price
            - timing
            - no_response
            - went_elsewhere
            - not_qualified
            - other
            - null
          description: Why the card was lost. Read when it enters a lost stage.
        deal_note:
          type: string
          description: >-
            What was sold. Read, with the deal fields below, when the card enters a stage that marks the contact as a
            client.
        deal_client_type_id:
          type: string
          description: The product or service sold
        deal_date:
          type: string
          format: date
          description: "The close date. Default: today on the person's clock"
        deal_pricing:
          $ref: "#/components/schemas/DealPricing"
        deal_managed_by:
          type: string
          description: "The operator: the member who looks after the deal's invoices"
        deal_tax_rate:
          type: number
          minimum: 0
          description: Tax on each payment, in percent
        deal_credit:
          $ref: "#/components/schemas/DealCredit"
    PipelineItemUpdateRequest:
      $ref: "#/components/schemas/PipelineItemCreateRequest"
    PipelineItem:
      type: object
      properties:
        id:
          type: string
        contact_id:
          type: string
        pipeline_id:
          type: string
        stage_id:
          type: string
        status:
          type: string
        notes:
          type: string
        value:
          type: number
        assigned_to:
          type: string
        org_id:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    CampaignFields:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        campaign_type:
          type: string
          enum:
            - daily_activity
            - marketing_email
        date:
          type: string
          format: date-time
        email_template_id:
          type: string
        email_subject:
          type: string
        email_body:
          type: string
        library_key:
          type: string
          nullable: true
          pattern: ^[a-z0-9_]{1,64}$
          description: >-
            The Booked55 library template the email came from (GET /template-library). Left out with email_template_id,
            it is taken from that template.
        event_id:
          type: string
          nullable: true
          description: The event {{event.name}} names in this email. Left out, a filter on one event sets it.
        selection_type:
          type: string
          enum:
            - contact_list
            - filter
            - ""
        contact_list:
          type: array
          items:
            oneOf:
              - type: string
              - type: object
                required:
                  - contact_id
                properties:
                  contact_id:
                    type: string
                  task_id:
                    type: string
        contact_filters:
          $ref: "#/components/schemas/ContactFilters"
        excluded_contact_ids:
          type: array
          items:
            type: string
    CampaignCreateRequest:
      allOf:
        - $ref: "#/components/schemas/CampaignFields"
        - type: object
          required:
            - name
    CampaignUpdateRequest:
      allOf:
        - $ref: "#/components/schemas/CampaignFields"
        - type: object
          properties:
            status:
              type: string
              enum:
                - pending
                - contact_filtering
                - contact_filtered
                - completed
                - error
              description: Setting running is refused. Use the Launch campaign endpoint to send a campaign.
            error:
              type: string
              nullable: true
    Campaign:
      allOf:
        - $ref: "#/components/schemas/CampaignFields"
        - type: object
          properties:
            status:
              type: string
              enum:
                - pending
                - contact_filtering
                - contact_filtered
                - running
                - completed
                - error
            error:
              type: string
              nullable: true
            id:
              type: string
            org_id:
              type: string
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
    EmailTemplateFields:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        subject:
          type: string
        body:
          type: string
        content_type:
          type: string
          enum:
            - visual
            - html
            - unlayer
        design_json:
          type: object
        attachments:
          type: array
          items:
            type: object
            properties:
              file_id:
                type: string
              filename:
                type: string
              cid:
                type: string
              is_inline:
                type: boolean
        assigned_to:
          type: string
    EmailTemplateCreateRequest:
      allOf:
        - $ref: "#/components/schemas/EmailTemplateFields"
        - type: object
          required:
            - name
            - subject
    EmailTemplateUpdateRequest:
      $ref: "#/components/schemas/EmailTemplateFields"
    EmailTemplate:
      allOf:
        - $ref: "#/components/schemas/EmailTemplateFields"
        - type: object
          properties:
            id:
              type: string
            org_id:
              type: string
            library_key:
              type: string
              nullable: true
              description: The Booked55 library template this one was copied from, or null.
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
    TemplateLibrary:
      type: object
      properties:
        categories:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              name:
                type: string
        templates:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
              category:
                type: string
              channel:
                type: string
                enum:
                  - email
                  - text
              name:
                type: string
              description:
                type: string
              subject:
                type: string
                nullable: true
              body:
                type: string
                description: HTML
              text:
                type: string
              times_used:
                type: integer
                nullable: true
                description: Sent by every Booked55 customer together. Null until 3 organizations have sent it, and for a text.
              open_rate:
                type: number
                nullable: true
                description: 0 to 1, of the sends that carried the open pixel. Null as times_used is.
    EmailTemplateLiveUse:
      type: object
      description: >-
        Live (active or paused) sequences that send the template, and the distinct contacts still to get it. A sequence
        prepares each step from the template's current text, so these contacts get any change that is saved.
      properties:
        sequence_count:
          type: integer
        contact_count:
          type: integer
    EmailTemplateUpdated:
      allOf:
        - $ref: "#/components/schemas/EmailTemplate"
        - type: object
          properties:
            live_use:
              allOf:
                - $ref: "#/components/schemas/EmailTemplateLiveUse"
              nullable: true
              description: Null when it could not be worked out; the save still happened.
    EmailTemplateUsage:
      type: object
      properties:
        template_id:
          type: string
        live_use:
          $ref: "#/components/schemas/EmailTemplateLiveUse"
        sequences:
          type: object
          properties:
            total:
              type: integer
            data:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  category:
                    type: string
                    enum:
                      - drip
                      - cold_outreach
                      - custom
                  status:
                    type: string
                    enum:
                      - draft
                      - active
                      - paused
                  steps:
                    type: array
                    items:
                      type: integer
                    description: Positions (1-based, in send order) of the steps that send this template
                  contact_count:
                    type: integer
                    description: Contacts still to get this template from this sequence; 0 for a draft
        newsletters:
          type: object
          properties:
            total:
              type: integer
            data:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  status:
                    type: string
                    enum:
                      - active
        campaigns:
          type: object
          properties:
            total:
              type: integer
            data:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  campaign_type:
                    type: string
                    enum:
                      - daily_activity
                      - marketing_email
                      - newsletter
                  status:
                    type: string
                  created_at:
                    type: string
                    format: date-time
    ClientTypeCreateRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          minLength: 1
        description:
          type: string
        value:
          type: number
          minimum: 0
          nullable: true
          description: The amount of each payment. A new deal with this product starts with it.
        pricing:
          $ref: "#/components/schemas/ProductPricing"
    ClientTypeUpdateRequest:
      $ref: "#/components/schemas/ClientTypeCreateRequest"
    ClientType:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        value:
          type: number
          nullable: true
        pricing:
          $ref: "#/components/schemas/ProductPricing"
        billing:
          type: string
          description: "How it is paid, in a word: One-time, Monthly and so on"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ProductPricing:
      type: object
      properties:
        model:
          type: string
          enum:
            - one_time
            - recurring
          description: "one_time is paid once, recurring again and again. Default: one_time"
        frequency:
          type: string
          nullable: true
          enum:
            - weekly
            - biweekly
            - monthly
            - quarterly
            - semiannual
            - yearly
            - null
          description: How often a recurring product is paid
    DealPricing:
      type: object
      description: >-
        How the deal is paid. For recurring, give exactly one of payments, end_date and until_cancelled. Copied from the
        product when left out.
      properties:
        model:
          type: string
          enum:
            - one_time
            - recurring
        frequency:
          type: string
          nullable: true
          enum:
            - weekly
            - biweekly
            - monthly
            - quarterly
            - semiannual
            - yearly
            - null
        start_date:
          type: string
          format: date
          nullable: true
          description: "The day the first invoice is due. Default: the deal date"
        payments:
          type: integer
          nullable: true
          description: How many payments
        end_date:
          type: string
          format: date
          nullable: true
          description: The day of the last payment. It must fall on a payment day
        until_cancelled:
          type: boolean
          description: True when the payments have no end
    DealCredit:
      type: array
      description: "Who gets the credit for this sale. Shares above 0 adding up to 100. Default: the sales person with 100"
      items:
        type: object
        required:
          - user_id
          - percent
        properties:
          user_id:
            type: string
          percent:
            type: number
    DealCreateRequest:
      type: object
      required:
        - contact_id
        - deal_date
        - value
        - note
        - client_type_id
      properties:
        contact_id:
          type: string
        deal_date:
          type: string
          format: date-time
        value:
          type: number
          minimum: 0
          description: The amount of each payment
        note:
          type: string
          description: What was sold
        client_type_id:
          type: string
          description: The product or service sold
        pipeline_item_id:
          type: string
        assigned_to:
          type: string
        pricing:
          $ref: "#/components/schemas/DealPricing"
        managed_by:
          type: string
          description: "The operator: the member who looks after this deal's invoices"
        tax_rate:
          type: number
          minimum: 0
          description: "Tax on each payment, in percent. Default: the organization's"
        credit:
          $ref: "#/components/schemas/DealCredit"
    DealUpdateRequest:
      type: object
      properties:
        deal_date:
          type: string
          format: date-time
        value:
          type: number
          minimum: 0
        note:
          type: string
          description: New words for this deal, added as a new note
        client_type_id:
          type: string
        pipeline_item_id:
          type: string
        assigned_to:
          type: string
        pricing:
          $ref: "#/components/schemas/DealPricing"
        managed_by:
          type: string
        tax_rate:
          type: number
          minimum: 0
        credit:
          $ref: "#/components/schemas/DealCredit"
    Deal:
      type: object
      properties:
        id:
          type: string
        deal_date:
          type: string
        value:
          type: number
          description: The amount of each payment
        booked_value:
          type: number
          description: >-
            What the deal is worth: the amount for one-time, every payment for a fixed schedule, a year of payments for
            one with no end
        note:
          type: string
        contact_id:
          type: string
        client_type_id:
          type: string
        client_type:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
        pipeline_item_id:
          type: string
          nullable: true
        assigned_to:
          type: string
        managed_by:
          type: string
          nullable: true
          description: "The operator: the member who looks after this deal's invoices"
        pricing:
          $ref: "#/components/schemas/DealPricing"
        billing:
          type: string
        schedule_text:
          type: string
          description: The schedule in words
        next_due_date:
          type: string
          nullable: true
        invoices_made:
          type: integer
        status:
          type: string
          enum:
            - active
            - ended
            - cancelled
        ended_at:
          type: string
          nullable: true
        cancelled_at:
          type: string
          nullable: true
        cancel_reason:
          type: string
        currency:
          type: string
          nullable: true
        tax_rate:
          type: number
        credit:
          $ref: "#/components/schemas/DealCredit"
        check_schedule:
          type: boolean
          description: True when someone should check the schedule this deal was given
        check_reason:
          type: string
          nullable: true
        created_at:
          type: string
        updated_at:
          type: string
    Invoice:
      type: object
      properties:
        id:
          type: string
        deal_id:
          type: string
          nullable: true
        contact_id:
          type: string
          nullable: true
        assigned_to:
          type: string
          nullable: true
        managed_by:
          type: string
          nullable: true
        iteration:
          type: integer
          description: The payment's number in the schedule
        revision:
          type: integer
          description: Goes up when a voided invoice gets a corrected copy
        payment_label:
          type: string
          description: Payment 3 of 12
        due_date:
          type: string
          nullable: true
        amount:
          type: number
        tax_rate:
          type: number
        tax_amount:
          type: number
        total:
          type: number
        currency:
          type: string
          nullable: true
        number:
          type: string
          nullable: true
          description: Given when the invoice leaves Draft, where the organization has Booked55 make its invoices
        status:
          type: string
          enum:
            - draft
            - sent
            - paid
            - cancelled
            - refund_demanded
            - refunded
            - void
        display_status:
          type: string
          description: "The status to show: overdue and upcoming as well as the stored ones"
        sent_at:
          type: string
          nullable: true
        paid_at:
          type: string
          nullable: true
        payment_note:
          type: string
        amount_refunded:
          type: number
        refund_demanded_at:
          type: string
          nullable: true
        refunded_at:
          type: string
          nullable: true
        refund_note:
          type: string
        cancelled_at:
          type: string
          nullable: true
        voided_at:
          type: string
          nullable: true
        reason:
          type: string
        has_pdf:
          type: boolean
        source:
          type: string
        migrated:
          type: boolean
        editable:
          type: boolean
          description: True while PUT /invoice/{invoiceId} can correct it, for someone allowed to
        moves:
          type: array
          items:
            type: string
          description: What the caller can do with it next
        status_history:
          type: array
          items:
            type: object
            properties:
              from:
                type: string
                nullable: true
              to:
                type: string
              at:
                type: string
              by:
                type: string
                nullable: true
              note:
                type: string
        created_at:
          type: string
          nullable: true
        updated_at:
          type: string
          nullable: true
    LeadSourceRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          maxLength: 100
    LeadSource:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        created_at:
          type: string
          format: date-time