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

# CRM Search

> Look up a contact in your connected CRM(s) and surface the record owner. Provide `email` and/or `linkedin_url`. Only connected CRMs are queried. Pipedrive and Sellsy search is email-only, so a linkedin-only lookup returns HubSpot/Salesforce matches only.



## OpenAPI

````yaml POST /crm/search
openapi: 3.1.0
info:
  title: OpenAPI Lonescale
  description: A sample API for Lonescale
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://public-api.lonescale.com
security:
  - ApiKeyAuth: []
paths:
  /crm/search:
    post:
      description: >-
        Look up a contact in your connected CRM(s) and surface the record owner.
        Provide `email` and/or `linkedin_url`. Only connected CRMs are queried.
        Pipedrive and Sellsy search is email-only, so a linkedin-only lookup
        returns HubSpot/Salesforce matches only.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CrmSearchRequest'
        required: true
      responses:
        '200':
          description: CRM matches with owner
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmSearchResult'
        '401':
          description: Invalid or missing authentication credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
              example:
                message: Invalid API Key
                error: Unauthorized
                statusCode: 401
        '422':
          description: Neither email nor linkedin_url provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: email or linkedin_url is required
                error: Unprocessable Entity
                statusCode: 422
components:
  schemas:
    CrmSearchRequest:
      type: object
      description: >-
        Provide `email`, `linkedin_url`, or a name (`first_name`/`last_name`)
        together with `company_domain` or `company_name`. A name is never
        searched unconstrained.
      properties:
        email:
          type: string
          description: Email to look up in the connected CRM(s).
        linkedin_url:
          type: string
          description: LinkedIn profile URL to look up. HubSpot/Salesforce only.
        first_name:
          type: string
          description: >-
            Used with `last_name` + a company when no email/LinkedIn is
            available. Matches are fuzzier and reported with a lower
            `confidence`.
        last_name:
          type: string
        company_domain:
          type: string
          description: >-
            Constrains a name search to that company. Preferred over
            `company_name` (more precise).
        company_name:
          type: string
          description: >-
            Fallback company constraint when no domain is known. Yields
            `confidence: low`.
        crm:
          type: string
          enum:
            - hubspot
            - salesforce
            - pipedrive
            - sellsy
          description: Restrict the search to a single CRM instead of all connected ones.
    CrmSearchResult:
      type: object
      properties:
        matches:
          type: array
          items:
            $ref: '#/components/schemas/CrmContactMatch'
        searched_crms:
          type: array
          items:
            type: string
          description: The connected CRMs actually queried.
        default_crm:
          type: string
          nullable: true
          description: >-
            The CRM a `crm`-less sync would resolve to (same rules as POST
            /trigger/crm-sync). Null when ambiguous: ask the user which CRM to
            act on.
        errors:
          type: array
          description: >-
            Per-CRM lookup failures. Present only when a provider errored.
            IMPORTANT: an empty `matches` alongside `errors` is NOT a confirmed
            "no match" — do not treat it as "contact is new".
          items:
            type: object
            properties:
              crm:
                type: string
              error:
                type: string
    AuthError:
      required:
        - message
        - error
        - statusCode
      type: object
      properties:
        message:
          type: string
          example: Invalid API Key
        error:
          type: string
          example: Unauthorized
        statusCode:
          type: integer
          example: 401
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    CrmContactMatch:
      type: object
      properties:
        crm:
          type: string
          enum:
            - hubspot
            - salesforce
            - pipedrive
            - sellsy
        id:
          type: string
          description: CRM record id
        name:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        profileUrl:
          type: string
          nullable: true
          description: LinkedIn URL stored on the record
        url:
          type: string
          nullable: true
          description: Link to the CRM record
        company:
          type: string
          nullable: true
        companyDomain:
          type: string
          nullable: true
        ownerId:
          type: string
          nullable: true
          description: CRM owner id
        ownerName:
          type: string
          nullable: true
          description: CRM owner name (null for Sellsy)
        matchedEmail:
          type: string
          nullable: true
          description: >-
            The address that actually matched. HubSpot's contact search also
            matches secondary addresses, so the record's primary `email` can
            differ from the one you searched.
        matchedOn:
          type: string
          nullable: true
          enum:
            - primary_email
            - secondary_email
            - linkedin
            - unicity_criteria
            - name_company_id
            - name_company_name
          description: >-
            Which identifier produced the match. `unicity_criteria` means the
            team's own CRM unicity rules matched (the same rule crm-sync
            applies).
        confidence:
          type: string
          enum:
            - high
            - medium
            - low
          description: >-
            How much to trust the match. Email / LinkedIn / unicity-criteria
            hits are `high`; a name constrained by a resolved company is
            `medium`; a name matched against a free-text company name is `low`
            (homonym risk) and should be verified before acting.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Provide your API key in the x-api-key header.

````