openapi: 3.1.0
info:
  title: Add to CRM Public API
  version: "1.1.0"
  summary: Enrich contacts, push to your connected CRM, manage lists — programmatically.
  description: |
    The Add to CRM Public API is a Pro-tier feature that exposes the same enrichment
    and CRM-write capabilities as the Chrome extension and dashboard. Use it to
    build automations in Zapier, Make, n8n, or your own systems.

    **Auth:** every request needs `Authorization: Bearer addtocrm_live_…` — create
    keys at <https://addtocrm.com/dashboard/developer>.

    **Pricing:** API calls draw from the same monthly credit pool as the dashboard.
    See `/v1/pricing` in the docs for per-endpoint costs.

    **Rate limits:** 60 req/min and 1,000 req/hr per API key. All responses include
    `X-RateLimit-*` headers; rate-limited responses include `Retry-After`.

  contact:
    name: Add to CRM Support
    url: https://addtocrm.com/contact

servers:
  - url: https://api.addtocrm.com
    description: Production

security:
  - bearerAuth: []

tags:
  - name: Enrichment
    description: Look up verified contact and company data.
  - name: CRM
    description: Read and write the user's connected CRM.
  - name: Lists
    description: Manage user-owned contact lists.
  - name: Meta
    description: Account and event-stream introspection.

paths:
  /v1/people/enrich:
    post:
      tags: [Enrichment]
      summary: Enrich a person
      description: |
        Looks up verified email, phone, and profile data for a person. Provide one
        of: `linkedin_url`, `email`, or `name + company_name`. Repeated requests
        within 30 days return cached data with `credits_deducted = 0`; the
        answer's `data.last_enriched_at` says how old that data is.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnrichPersonRequest'
      responses:
        '200':
          description: Person found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichPersonResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '402': { $ref: '#/components/responses/InsufficientCredits' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimit' }

  /v1/companies/enrich:
    post:
      tags: [Enrichment]
      summary: Enrich a company
      description: Lookup company details by `linkedin_url` or `domain`. Cached for 30 days.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnrichCompanyRequest'
      responses:
        '200':
          description: Company found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnrichCompanyResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '402': { $ref: '#/components/responses/InsufficientCredits' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '404': { $ref: '#/components/responses/NotFound' }
        '429': { $ref: '#/components/responses/RateLimit' }

  /v1/emails/verify:
    post:
      tags: [Enrichment]
      summary: Verify an email address
      description: Validates deliverability against two providers in parallel. Cached results are free.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email]
              properties:
                email: { type: string, format: email }
      responses:
        '200':
          description: Verification result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerifyEmailResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '402': { $ref: '#/components/responses/InsufficientCredits' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '429': { $ref: '#/components/responses/RateLimit' }
        '503': { $ref: '#/components/responses/UpstreamUnavailable' }

  /v1/people/search:
    post:
      tags: [Enrichment]
      summary: Search the people database
      description: |
        People search. Filter by title, company, location, seniority,
        technology stack, and more. Costs 1 credit per *new* page; a page you have
        already run is free, and so is a page with no results.

        A page holds at most 25 people: a `per_page` above 25 is served as 25, and the
        response's `per_page` says so. A search reaches its first 1,000 pages (25,000
        people); `total_entries` is the full count.

        `organization_domains` takes each company's own website (`acme.com`,
        `imperial.nhs.uk`). A value that cannot identify one company — a company
        name, a domain ending shared by many organisations such as `co.uk` or
        `nhs.uk`, or a subdomain such as `careers.acme.com` (send `acme.com`; `www.`
        is dropped) — is ignored, and if **none** of the values can match, the request is
        refused with a 400 `validation_error` rather than searching everyone.
        Nothing is searched and no credit is used.

        A request with no filter left to search on is refused the same way: one that
        sends only `page` and `per_page`, or whose only filter is a department the
        people database does not recognise. The 400
        `validation_error` asks for at least one filter. Nothing is searched and no
        credit is used.

        A filter the people database cannot apply (a location, industry or technology
        it has no matching value for) refuses the request the same way: the 400
        `validation_error` names the filters. The search is never run without them,
        because it would return other people.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchPeopleRequest'
      responses:
        '200':
          description: Search results page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchPeopleResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '402': { $ref: '#/components/responses/InsufficientCredits' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '429': { $ref: '#/components/responses/RateLimit' }

  /v1/crm/info:
    get:
      tags: [CRM]
      summary: Active CRM info
      description: Returns the user's connected CRM and the entity types they can write to.
      responses:
        '200':
          description: CRM info
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CRMInfoResponse'
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '409': { $ref: '#/components/responses/CRMNotConnected' }

  /v1/crm/contacts:
    post:
      tags: [CRM]
      summary: Add a contact to the user's CRM
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddContactRequest'
      responses:
        '200':
          description: Contact added
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddContactResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '409': { $ref: '#/components/responses/CRMNotConnected' }
        '502':
          description: CRM rejected the request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'

  /v1/crm/contacts/{id}:
    patch:
      tags: [CRM]
      summary: Update a contact in the user's CRM
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
          description: CRM contact ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateContactRequest'
      responses:
        '200':
          description: Contact updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddContactResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '409': { $ref: '#/components/responses/CRMNotConnected' }

  /v1/crm/contacts/find:
    get:
      tags: [CRM]
      summary: Find a contact in the user's CRM
      description: >-
        Answers only a record the CRM holds for THIS person: one carrying the LinkedIn URL or one of the
        email addresses, or one the user's team confirmed. A record that shares only the person's name
        is answered with a 404, because acting on it (writing to it, linking it) would risk acting on
        somebody else. Send `first_name` and `last_name` when you have them: most CRMs find people by
        surname first, so a lookup by email alone can miss someone who is there.
      parameters:
        - in: query
          name: email
          schema: { type: string }
        - in: query
          name: linkedin_url
          schema: { type: string }
        - in: query
          name: first_name
          schema: { type: string }
        - in: query
          name: last_name
          schema: { type: string }
        - in: query
          name: company_name
          schema: { type: string }
      responses:
        '200':
          description: Contact match
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FindContactResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '404': { $ref: '#/components/responses/NotFound' }
        '409': { $ref: '#/components/responses/CRMNotConnected' }

  /v1/crm/companies:
    post:
      tags: [CRM]
      summary: Add a company to the user's CRM
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddCompanyRequest'
      responses:
        '200':
          description: Company added
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddCompanyResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '409': { $ref: '#/components/responses/CRMNotConnected' }

  /v1/crm/companies/{id}:
    patch:
      tags: [CRM]
      summary: Update a company in the user's CRM
      description: >-
        Multi-value channels (phones, socials) REPLACE what the client says it
        displayed, rather than appending. Send `channels` to state both halves
        explicitly, or `clear_fields` to empty an allowlisted scalar. See
        docs/api/CHANGELOG.md.
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCompanyRequest'
      responses:
        '200':
          description: Company updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddCompanyResponse'
        '400': { $ref: '#/components/responses/ValidationError' }
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
        '409': { $ref: '#/components/responses/CRMNotConnected' }

  /v1/lists:
    get:
      tags: [Lists]
      summary: List the user's lists
      responses:
        '200':
          description: Lists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListsResponse'
        '401': { $ref: '#/components/responses/InvalidAuth' }
        '403': { $ref: '#/components/responses/ScopeRequired' }
    post:
      tags: [Lists]
      summary: Create a list
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                name: { type: string }
                description: { type: string }
                tags: { type: array, items: { type: string } }
      responses:
        '200':
          description: List created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListResponse'

  /v1/lists/{id}:
    patch:
      tags: [Lists]
      summary: Rename / update a list
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name: { type: string }
                description: { type: string }
      responses:
        '200':
          description: List updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListResponse'
    delete:
      tags: [Lists]
      summary: Delete a list and all its items
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: { type: object }

  /v1/lists/{id}/items:
    post:
      tags: [Lists]
      summary: Add a contact to a list
      description: |
        Provide one of `profile_id`, `linkedin_url`, or `email`. The same contact
        can be added twice without error — the underlying composite primary key
        rejects duplicates silently (200 with the existing row).
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                profile_id: { type: string }
                linkedin_url: { type: string }
                email: { type: string }
      responses:
        '200':
          description: Item added (idempotent on duplicates)

  /v1/lists/{id}/items/{profile_id}:
    delete:
      tags: [Lists]
      summary: Remove a contact from a list
      parameters:
        - in: path
          name: id
          required: true
          schema: { type: string }
        - in: path
          name: profile_id
          required: true
          schema: { type: string }
      responses:
        '200': { description: Removed }

  /v1/usage:
    get:
      tags: [Meta]
      summary: Account usage
      description: Credits remaining, rate-limit ceilings, and 30-day call summary.
      responses:
        '200':
          description: Usage data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'

  /v1/events:
    get:
      tags: [Meta]
      summary: Event stream
      description: |
        Cursor-paginated stream of user-visible events. Used by Zapier/Make/n8n
        polling triggers. Pass `since=<ISO-8601>` for the first call, then
        `cursor=<next_cursor>` from each response to resume.

        Event types: `person.enriched`, `company.enriched`, `person.added_to_crm`,
        `company.added_to_crm`. Filter via `?types=person.added_to_crm,company.added_to_crm`.
      parameters:
        - in: query
          name: since
          schema: { type: string, format: date-time }
        - in: query
          name: cursor
          schema: { type: string }
        - in: query
          name: types
          schema: { type: string }
          description: Comma-separated event types
        - in: query
          name: limit
          schema: { type: integer, default: 100, maximum: 200 }
      responses:
        '200':
          description: Events page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventsResponse'

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: addtocrm_live_xxx

  schemas:
    EnrichPersonRequest:
      type: object
      description: |
        Provide at least one identifier combination:
          - `linkedin_url`
          - `email`
          - `name` + `company_name`
          - `first_name` + `last_name`
        Empty bodies return a 400 `validation_error`.
      properties:
        linkedin_url: { type: string }
        email: { type: string, format: email }
        name: { type: string }
        first_name: { type: string }
        last_name: { type: string }
        company_name: { type: string }
        include_phones:
          type: boolean
          description: |
            Whether to look up a direct phone/mobile number. Omitted = included,
            preserving the long-standing default. The phone lookup uses no extra
            credits; set `false` to skip it.
      example:
        linkedin_url: https://www.linkedin.com/in/jane-smith
    EnrichPersonResponse:
      type: object
      properties:
        data: { $ref: '#/components/schemas/Person' }
        cached:
          type: boolean
          description: True when the result came from the 30-day cache.
        credits_deducted:
          type: number
          description: Credits charged for this call. 0 on a cache hit.
      example:
        data:
          first_name: Jane
          last_name: Smith
          email: jane.smith@acme.com
          job_title: VP of Sales
          company_name: Acme Inc
          linkedin_url: https://www.linkedin.com/in/jane-smith
        cached: false
        credits_deducted: 1

    EnrichCompanyRequest:
      type: object
      description: Provide one of `domain` or `linkedin_url`.
      properties:
        linkedin_url: { type: string }
        domain: { type: string }
      example:
        domain: stripe.com
    EnrichCompanyResponse:
      type: object
      properties:
        data: { $ref: '#/components/schemas/Company' }
        cached: { type: boolean }
        credits_deducted: { type: number }
      example:
        data:
          name: Stripe
          domain: stripe.com
          industry: Financial Services
          num_employees: 8000
          linkedin_url: https://www.linkedin.com/company/stripe
        cached: false
        credits_deducted: 1

    VerifyEmailResponse:
      type: object
      properties:
        data:
          type: object
          description: The verification result — deliverability status and quality signals.
          additionalProperties: true
          properties:
            email: { type: string, format: email }
            status:
              type: string
              description: The verifier's own result word, lower case — `deliverable`, `risky`, `undeliverable` or `unknown`.
            score: { type: integer, description: The verifier's own 0-100 quality score. }
            is_deliverable:
              type: boolean
              description: The result is `deliverable`, or the score is high. It ignores `accept_all`.
            accept_all:
              type: boolean
              description: The domain accepts all mail, so no check can confirm the mailbox exists. Absent when it does not.
            accept_all_judged:
              type: boolean
              description: |
                A verifier that tests mailboxes at accept-all domains judged this one `deliverable`.
                Only ever present beside `accept_all`, and only on a `deliverable` result. It does not
                change `verdict`, `status` or `is_deliverable`; it says the `accept_all` answer was
                tested rather than guessed. Absent when it does not apply.
            verdict:
              type: string
              enum: [deliverable, accept_all, undeliverable, unknown]
              description: |
                Our reading of `status` and `accept_all` together. `undeliverable` always wins;
                otherwise an accept-all domain gives `accept_all`, `deliverable` gives
                `deliverable`, and anything else (`risky` included) gives `unknown`. Absent on
                a result stored before this field existed.
        cached: { type: boolean }
        credits_deducted: { type: number }
      example:
        data:
          email: jane.smith@acme.com
          status: deliverable
          score: 96
          is_deliverable: true
          verdict: deliverable
        cached: false
        credits_deducted: 1

    SearchPeopleRequest:
      type: object
      properties:
        page: { type: integer, default: 1 }
        per_page:
          type: integer
          default: 25
          maximum: 25
          description: >-
            People per page, at most 25. A larger value is served as 25 and the response
            says `per_page: 25`.
        titles: { type: array, items: { type: string } }
        departments: { type: array, items: { type: string } }
        keywords: { type: string }
        locations: { type: array, items: { type: string } }
        seniorities: { type: array, items: { type: string } }
        organization_locations: { type: array, items: { type: string } }
        organization_domains:
          type: array
          items: { type: string }
          description: >-
            Each company's own website, such as `acme.com` or `imperial.nhs.uk`. Values
            that cannot match one company (a name, an ending shared by many
            organisations like `co.uk`, or a subdomain like `careers.acme.com`) are
            ignored; if none can match, the request is a 400 `validation_error`.
        organization_num_employees: { type: array, items: { type: string } }
        contact_email_status: { type: array, items: { type: string } }
        technologies_any: { type: array, items: { type: string } }
        technologies_not: { type: array, items: { type: string } }
        revenue_range_min: { type: integer }
        revenue_range_max: { type: integer }
        include_similar_titles: { type: boolean }
    SearchPeopleResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/SearchPersonResult'
        total_entries: { type: integer }
        page: { type: integer }
        per_page: { type: integer }
        cached: { type: boolean }
        credits_deducted: { type: number }
    SearchPersonResult:
      type: object
      properties:
        id: { type: string }
        first_name: { type: string }
        last_name: { type: string }
        title: { type: string }
        headline: { type: string }
        linkedin_url: { type: string }
        photo_url: { type: string }
        city: { type: string }
        state: { type: string }
        country: { type: string }
        email_status: { type: string }
        seniority: { type: string }
        departments: { type: array, items: { type: string } }
        organization:
          $ref: '#/components/schemas/SearchOrgResult'
    SearchOrgResult:
      type: object
      properties:
        id: { type: string }
        name: { type: string }
        logo_url: { type: string }
        primary_domain: { type: string }
        industry: { type: string }

    CRMInfoResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            software: { type: string }
            slug: { type: string }
            writable_entities:
              type: array
              items: { type: string, enum: [contact, company, lead] }
            connected_at: { type: string, format: date-time }

    AddContactRequest:
      type: object
      required: [person]
      properties:
        person: { $ref: '#/components/schemas/Person' }
        tags: { type: array, items: { type: string } }
        apply_default_tags:
          type: boolean
          description: >-
            Send false to suppress the account's "Default Tags" setting, so `tags`
            is exactly what the record gets. Omitted or true applies the defaults
            on top of `tags` (duplicates are dropped), matching the extension and
            dashboard.
        entity_type: { type: string, enum: [contact, lead] }
        company_id: { type: string }
        misc:
          type: object
          additionalProperties: { type: string }
      example:
        person:
          first_name: Jane
          last_name: Smith
          email: jane.smith@acme.com
          job_title: VP of Sales
        tags: [inbound, q3-campaign]
    AddContactResponse:
      type: object
      properties:
        data:
          type: object
          additionalProperties: true
    UpdateContactRequest:
      type: object
      required: [person]
      properties:
        person: { $ref: '#/components/schemas/Person' }
        channels:
          $ref: '#/components/schemas/PersonChannels'
        clear_fields:
          type: array
          description: >-
            Fields to remove the value from. A field is cleared ONLY when named
            here — sending an empty string in `person` does not clear it on this
            API, because an integration serialising a zero value is almost never
            asking us to delete data. Identity fields (`first_name`,
            `last_name`, `linkedin_url`) can never be cleared.
          items: { type: string }
          example: ["job_title", "city"]

    ChannelEntry:
      type: object
      description: >-
        One entry of a multi-value channel. `value` carries the address, number
        or profile URL; locations leave it empty and use the part fields.
      properties:
        value: { type: string }
        type:
          type: string
          description: >-
            The CRM-facing qualifier — work/personal/mobile/home for emails and
            phones, the service (linkedin, twitter, facebook) for socials, the
            address type for locations.
        primary:
          type: boolean
          description: Marks the entry the CRM should show first.
        street: { type: string }
        city: { type: string }
        state: { type: string }
        country: { type: string }
        zip: { type: string }
    ChannelSet:
      type: object
      description: >-
        One channel's three-way merge input. `desired` is what the record should
        hold; `baseline` is what YOU were looking at when you decided. The
        server reconciles both against a fresh read of the CRM:
        add = desired - existing, remove = (baseline AND existing) - desired,
        keep = everything else.


        The removal rule is the one to understand: you can only remove what you
        say you were shown. An entry added in the CRM since you read it, or one
        you never listed, is outside `baseline` and is always preserved. Send
        `baseline: []` (or omit the channel) and nothing is ever deleted.


        Omitting a channel means "leave it alone". A channel present with an
        empty `desired` means "remove everything I listed in baseline".
      required: [desired, baseline]
      properties:
        desired:
          type: array
          items: { $ref: '#/components/schemas/ChannelEntry' }
        baseline:
          type: array
          items: { $ref: '#/components/schemas/ChannelEntry' }
    PersonChannels:
      type: object
      description: >-
        Multi-value channels. When a channel is present here, the matching
        scalar fields in `person` are IGNORED for that channel — send one or the
        other, not both. Channels you omit still honour `person`.
      properties:
        emails: { $ref: '#/components/schemas/ChannelSet' }
        phones: { $ref: '#/components/schemas/ChannelSet' }
        socials: { $ref: '#/components/schemas/ChannelSet' }
        locations: { $ref: '#/components/schemas/ChannelSet' }
    CompanyChannels:
      type: object
      description: >-
        As PersonChannels. A company has no email channel, and its single
        address is written through the ordinary scalar fields.
      properties:
        phones: { $ref: '#/components/schemas/ChannelSet' }
        socials: { $ref: '#/components/schemas/ChannelSet' }
    SkippedValue:
      type: object
      properties:
        value: { type: string }
        reason:
          type: string
          description: >-
            capacity (the CRM's slots for this channel are full), conflict
            (another record already owns the value), delete_unsupported (the
            CRM's API cannot remove an entry), unsupported (the CRM has no such
            channel), switched_off (the account set this data point to "Don't
            sync" in its Fields settings, so the value was withheld and nothing
            was sent to the CRM). Treat a reason you do not know as "not sent".
          enum: [capacity, conflict, delete_unsupported, unsupported, switched_off]
    ChannelReport:
      type: object
      description: >-
        What actually happened to one channel. A report is returned for EVERY
        channel the request submitted, even when nothing changed — so if you
        sent `channels` and get none back, you are talking to a server that does
        not understand them and must NOT treat the response as a success.
      properties:
        channel:
          type: string
          enum: [emails, phones, socials, locations]
        added:
          type: array
          items: { type: string }
        removed:
          type: array
          items: { type: string }
        skipped:
          type: array
          items: { $ref: '#/components/schemas/SkippedValue' }
    FindContactResponse:
      type: object
      properties:
        data:
          type: object
          additionalProperties: true
        match_type:
          type: string
          enum: [linkedin, email, confirmed]
          description: >-
            What the record was found on: the LinkedIn URL, an email address, or `confirmed` (a member
            of the user's team confirmed the record is this person).

    UpdateCompanyRequest:
      type: object
      required: [company]
      properties:
        company: { $ref: '#/components/schemas/Company' }
        channels:
          $ref: '#/components/schemas/CompanyChannels'
        clear_fields:
          type: array
          items: { type: string }

    AddCompanyRequest:
      type: object
      required: [company]
      properties:
        company: { $ref: '#/components/schemas/Company' }
        tags: { type: array, items: { type: string } }
        apply_default_tags:
          type: boolean
          description: >-
            See AddContactRequest.apply_default_tags.
    AddCompanyResponse:
      type: object
      properties:
        data:
          type: object
          additionalProperties: true

    ListsResponse:
      type: object
      properties:
        data:
          type: array
          items: { $ref: '#/components/schemas/List' }
    ListResponse:
      type: object
      properties:
        data: { $ref: '#/components/schemas/List' }

    UsageResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            plan: { type: string }
            credits_remaining: { type: integer }
            monthly_credits: { type: integer }
            non_expiring_credits: { type: integer }
            credits_scope:
              type: string
              enum: [account, team]
              description: Whose balance the three credit figures are. "team" means the one balance every seat on the team shares and this key's owner spends from.
            team:
              type: object
              description: Present when credits_scope is "team".
              properties:
                members: { type: integer, description: People who spend from the shared balance. }
                used_by_me_this_cycle: { type: integer, description: Credits this key's owner has spent in the current cycle. }
                resets_at: { type: integer, description: Unix time the team's monthly credits renew. }
            credit_limit:
              type: object
              description: >-
                Present when the team's billing admin has set this key's owner a monthly credit limit. The three credit
                figures above are then capped at what it leaves: credits_remaining never exceeds credit_limit.remaining.
                The month is the calendar month in UTC.
              properties:
                limit: { type: integer, description: Credits this key's owner may use this calendar month. }
                used: { type: integer, description: Credits they have used this month, less any given back. }
                remaining: { type: integer, description: What is left under the limit. }
                resets_at: { type: integer, description: 'Unix time the count starts again (00:00 UTC on the first of next month). A limit of 0 stays 0 after it: only a raise lifts that limit.' }
            rate_limit:
              type: object
              properties:
                limit_minute: { type: integer }
                limit_hour: { type: integer }
            api_usage_30d:
              type: object
              properties:
                total_calls: { type: integer }
                total_credits_used: { type: number }
                error_count: { type: integer }

    EventsResponse:
      type: object
      properties:
        data:
          type: array
          items: { $ref: '#/components/schemas/Event' }
        next_cursor: { type: string }
    Event:
      type: object
      properties:
        id: { type: string }
        type: { type: string, enum: [person.enriched, company.enriched, person.added_to_crm, company.added_to_crm] }
        name: { type: string }
        linkedin_url: { type: string }
        job_title: { type: string }
        company_name: { type: string }
        image_url: { type: string }
        crm: { type: string }
        credits: { type: integer }
        occurred_at: { type: string, format: date-time }

    Person:
      type: object
      description: |
        An enriched person. All fields are best-effort — any field may be absent
        if the providers had no data for it. `additionalProperties` is true
        because provider coverage evolves; treat unknown fields as optional.
      additionalProperties: true
      properties:
        first_name: { type: string }
        last_name: { type: string }
        email: { type: string, format: email, description: Primary work email. }
        personal_email: { type: string, format: email }
        phone_number:
          type: string
          description: |
            Phone number in E.164 format, e.g. `+14155550142` — a leading `+`
            followed by country code and subscriber number, no spaces or
            punctuation. Changed 2026-08-06: responses previously omitted the
            leading `+` (`14155550142`). The digits are unchanged, so any
            digit-based parsing is unaffected.
        job_title: { type: string }
        seniority:
          type: string
          description: |
            The level as a word, e.g. `VP`, `C-Suite`, `Director`. Changed 2026-11-04: responses used to read
            `Vp` and `C Suite`.
        department:
          type: string
          description: |
            The department as a word, e.g. `Marketing`, `Engineering & Technical`, `C-Suite`. Changed 2026-11-04:
            responses used to carry a code such as `master_marketing`. A department we have no word for is sent as
            we hold it.
        headline: { type: string }
        linkedin_url: { type: string }
        twitter_url: { type: string }
        company_name: { type: string }
        city: { type: string }
        state: { type: string }
        country: { type: string }
        last_enriched_at:
          type: string
          format: date-time
          description: |
            When the stored record this answer was built from was built, in UTC. Records
            are rebuilt after 30 days, so this is the age of the data and not of your
            request: a cached answer built nine days ago says nine days ago. Absent when
            the record's age is not known.
        employer_status:
          type: string
          enum: [current, past, unknown]
          description: |
            Whether `company_name` is where the person works now, as far as we can tell.
            `current`: something backs it (see `employer_evidence`; a data provider's own
            claim is the weakest backing). `past`: the person's work histories say they
            have left it. `unknown`: nothing backs it, or another source names a different
            employer we could not settle, which is then in `other_current_employers`.
            Absent on records built before this field existed: read absent as "not
            confirmed".
        employer_evidence:
          type: array
          items:
            type: string
            enum: [address, headline, public_profile, timeline, provider]
          description: |
            What backs `company_name`, strongest first. `address`: the address looked up is
            at the employer's domain. `headline`: the person's profile headline names it.
            `public_profile`: their public profile names it. `timeline`: a current role on
            a work history. `provider`: a data provider's own claim.
        other_current_employers:
          type: array
          description: |
            Employers other than `company_name` where the person also works. When
            `employer_status` is `unknown` it holds the employer another source names
            (such as the profile headline) that we could not confirm, as "likely now at".
          items:
            type: object
            properties:
              name: { type: string }
              domain: { type: string }
              title: { type: string }
              start_date: { type: string }
              evidence:
                type: array
                items: { type: string }
                description: Kinds of evidence, as `employer_evidence`.
        employer_left:
          type: object
          description: |
            Present when the person's work histories say they have left the employer
            `company_name` names. It does not wait for `employer_status`, which says `past`
            beside it only while the employer decision is on. `company_name` keeps naming
            that employer, so this says which one was left, when, and as what; `job_title`
            is the last title they held. Absent when we do not know that they left, and
            dropped when a different employer is served in its place.

            It changes what is written for the person. An add or an update that carries this
            object and still names the employer left (the same domain, else the same name)
            writes the title and leaves out the company, the company record and the
            company's phone lines, in the CRM and in an enriched CSV export alike. Nothing
            already in the CRM is cleared. A different company in `company_name` is written
            as usual, and a person sent without this object is written exactly as sent.
          properties:
            company: { type: string, description: "The employer left, as `company_name` names it." }
            domain: { type: string, description: "The employer's website domain, when we know it." }
            end_date:
              type: string
              description: |
                When the role there ended, as the data provider wrote it: a day
                (`2023-02-01`), a month (`2023-02`) or a year (`2023`).
            title: { type: string, description: "The title they held there: the last title we know." }
        emails:
          type: array
          description: |
            The addresses we offer for the person, best first; `email` is the first work
            address. An address we hold but do not offer is in `former_employer_emails`
            and is never here.
          items:
            type: object
            properties:
              email: { type: string, format: email }
              type: { type: string, enum: [work, personal, unknown] }
              status:
                type: string
                description: |
                  One of `verified` (our own check found the mailbox exists; `checked_at`
                  says when), `accept_all` (the domain accepts all mail, so no check can
                  confirm the mailbox), `unverified` (no check of ours stands behind it)
                  or `guessed` (a provider built it from the person's name and the
                  company's address format). A record built before these words were
                  introduced may still carry the word the data provider used.
              checked_at:
                type: string
                format: date-time
                description: When our own check last answered for this address. Always present with `verified`.
        former_employer_emails:
          type: array
          description: |
            Addresses we hold for the person but do not offer: never in `emails`, never
            the primary `email`. The name is older than its contents.
          items:
            type: object
            properties:
              email: { type: string, format: email }
              type: { type: string, enum: [work, personal, unknown] }
              company: { type: string }
              domain: { type: string }
              end_date: { type: string }
              reason:
                type: string
                enum: [left_employer, other_employer, undeliverable]
                description: |
                  `left_employer`: two work histories say the person left that employer.
                  `other_employer`: they now work somewhere else and this address is at the
                  employer they were shown before. `undeliverable`: our own check says the
                  mailbox does not exist. A missing `reason` reads as `left_employer`.
              checked_at:
                type: string
                format: date-time
                description: When our check called the address undeliverable. Present only for `undeliverable`.
        employment_history:
          type: array
          description: The person's work history as the data provider holds it.
          items:
            type: object
            properties:
              title: { type: string }
              organization_name: { type: string }
              domain: { type: string, description: The employer's website domain, when the provider resolved the role to a company. }
              start_date: { type: string }
              end_date: { type: string }
              current: { type: boolean }
        phones:
          type: array
          items:
            type: object
            properties:
              phone: { type: string, description: E.164, as `phone_number`. }
              type: { type: string, description: "`work` or `personal`; absent when the type is not known." }
              status: { type: string, description: The data provider's own word about the number. }
        custom_option_sets:
          type: object
          description: |
            Present only on a person read from a CRM record, which no `/v1` route returns today, so an
            enrichment answer never carries it. It holds what the record keeps in each of its multi-option
            fields, keyed by the CRM's field id, as the option values the CRM lists for the field. A field the
            record holds nothing in is absent.
          additionalProperties:
            type: array
            items: { type: string }
      example:
        first_name: Jane
        last_name: Smith
        email: jane.smith@acme.com
        phone_number: "+14155550142"
        job_title: VP of Sales
        seniority: VP
        linkedin_url: https://www.linkedin.com/in/jane-smith
        company_name: Acme Inc
        city: San Francisco
        state: California
        country: United States
        last_enriched_at: "2026-09-24T08:30:00Z"
        employer_status: current
        employer_evidence: [headline, provider]
        emails:
          - { email: jane.smith@acme.com, type: work, status: verified, checked_at: "2026-10-01T10:15:00Z" }
    Company:
      type: object
      description: An enriched company. All fields are best-effort — any field may be absent.
      additionalProperties: true
      properties:
        name: { type: string }
        domain: { type: string }
        linkedin_url: { type: string }
        twitter_url: { type: string }
        industry: { type: string }
        description: { type: string }
        num_employees: { type: integer }
        year_founded: { type: integer }
        city: { type: string }
        state: { type: string }
        country: { type: string }
        postal_code: { type: string }
        phone:
          type: string
          description: Company phone number, E.164 where the provider supplies one.

      example:
        name: Stripe
        domain: stripe.com
        linkedin_url: https://www.linkedin.com/company/stripe
        industry: Financial Services
        num_employees: 8000
        year_founded: 2010
        city: San Francisco
        country: United States
    List:
      type: object
      properties:
        id: { type: string }
        name: { type: string }
        description: { type: string }
        total_items: { type: integer }
        status: { type: string }
        tags: { type: array, items: { type: string } }
        inserted: { type: string, format: date-time }
        updated: { type: string, format: date-time }

    ErrorEnvelope:
      type: object
      properties:
        error:
          type: object
          required: [type, message, request_id]
          properties:
            type:
              type: string
              enum: [
                invalid_auth, key_revoked, key_suspended_plan, scope_required,
                insufficient_credits, rate_limit_minute, rate_limit_hour,
                crm_not_connected, crm_token_expired, crm_rate_limit, crm_unavailable,
                validation_error, not_found, internal_error, method_not_allowed
              ]
            message: { type: string }
            request_id: { type: string, format: uuid }
            crm: { type: string }
            retry_after_seconds: { type: integer }

  responses:
    InvalidAuth:
      description: Missing, malformed, or revoked API key (401)
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: invalid_auth
              message: The Authorization header is missing or not a recognised API key.
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
    InsufficientCredits:
      description: >-
        The account's monthly credit balance is exhausted, or the monthly credit limit the team's billing admin set for this
        key's owner is reached (402). The type is the same for both; the message says which.
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: insufficient_credits
              message: Your monthly credit balance is exhausted — add credits in the dashboard.
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
    ScopeRequired:
      description: The API key lacks the scope this endpoint requires (403)
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: scope_required
              message: This endpoint requires the 'write' scope.
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
    ValidationError:
      description: The request body or query parameters failed validation (400)
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: validation_error
              message: 'must provide one of: linkedin_url, email, (first_name + last_name), or (name + company_name)'
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
    NotFound:
      description: No matching resource (404)
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: not_found
              message: No data found for this person.
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
    RateLimit:
      description: Per-minute or per-hour rate limit exceeded (429)
      headers:
        Retry-After:
          schema: { type: integer }
          description: Seconds to wait before retrying
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: rate_limit_minute
              message: 'Rate limit exceeded: 60 requests per minute. Slow down or retry in a moment.'
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
              retry_after_seconds: 12
    CRMNotConnected:
      description: The key's owner has no CRM connected (409)
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: crm_not_connected
              message: Connect a CRM from your dashboard before calling /v1/crm/*.
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
    UpstreamUnavailable:
      description: A downstream provider was unavailable (503)
      content:
        application/json:
          schema: { $ref: '#/components/schemas/ErrorEnvelope' }
          example:
            error:
              type: crm_unavailable
              message: Email verification providers are unavailable, try again shortly.
              request_id: 7b3e1f4a-1c2d-4e5f-9a0b-c1d2e3f4a5b6
