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

# Create a deal from intake data

> Creates or reuses a company and contact, then creates a new deal in the requested stage.
Company deduplication checks existing records by LinkedIn URL, domain, then name.
Contact deduplication checks existing records by LinkedIn profile, email, then name + company.




## OpenAPI

````yaml /openapi.yaml post /deals/intake
openapi: 3.0.3
info:
  title: Leonar API
  description: >
    REST API for accessing and managing workspace data in Leonar CRM.


    ## Authentication


    All API requests require a Bearer token in the Authorization header:


    ```

    Authorization: Bearer leo_xxxxx

    ```


    API keys can be created and managed in Settings > API.


    ## Rate limiting


    - **2000 requests per hour by default**, configurable per workspace and
    shared by all API keys owned by the same user

    - Rate limit headers are included in all responses


    ## Pagination


    List endpoints support pagination via `limit` and `offset` query parameters.
  version: 1.0.0
  contact:
    name: Leonar Support
    url: https://leonar.ai
    email: support@leonar.ai
servers:
  - url: https://app.leonar.app/api/v1
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Contacts
    description: Manage contacts in your workspace
  - name: Companies
    description: Manage companies and their relationships
  - name: Deals
    description: Track and manage sales deals
  - name: Deal Pipelines
    description: View deal pipeline configurations
  - name: Projects
    description: Organize recruiting projects
  - name: Pipeline Entries
    description: Manage candidates in project pipelines
  - name: Tasks
    description: Track to-dos and follow-ups
  - name: Tags
    description: Organize resources with tags
  - name: Notes
    description: Manage notes on contacts, companies, deals, and projects
  - name: Sequences
    description: Automate outreach campaigns
  - name: Conversations
    description: View conversations across channels
  - name: Messages
    description: Send messages via email, LinkedIn, or WhatsApp
  - name: Enrichment
    description: Find emails and phone numbers for contacts
  - name: Sourcing
    description: Search and import candidates
  - name: Connected Accounts
    description: View linked LinkedIn accounts
paths:
  /deals/intake:
    post:
      tags:
        - Deals
      summary: Create a deal from intake data
      description: >
        Creates or reuses a company and contact, then creates a new deal in the
        requested stage.

        Company deduplication checks existing records by LinkedIn URL, domain,
        then name.

        Contact deduplication checks existing records by LinkedIn profile,
        email, then name + company.
      operationId: create-deal-intake
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealIntakeCreate'
      responses:
        '201':
          description: Deal intake processed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/DealIntakeResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    DealIntakeCreate:
      type: object
      required:
        - deal
        - company
        - contact
      properties:
        deal:
          $ref: '#/components/schemas/DealIntakeDealInput'
        company:
          $ref: '#/components/schemas/DealIntakeCompanyInput'
        contact:
          $ref: '#/components/schemas/DealIntakeContactInput'
      example:
        deal:
          title: Inbound demo request
          stage_id: e5f6a7b8-9012-34cd-efab-567890123def
          primary_source_id: a7b8c9d0-1234-56ef-abcd-789012345ef1
          expected_amount: 12000
          currency: EUR
        company:
          name: Acme
          domain: acme.com
          industry: SaaS
        contact:
          first_name: Jane
          last_name: Doe
          email: jane@acme.com
          title: VP Sales
    DealIntakeResponse:
      type: object
      required:
        - deal
        - company
        - contact
      properties:
        deal:
          $ref: '#/components/schemas/Deal'
        company:
          allOf:
            - $ref: '#/components/schemas/DealIntakeResolution'
            - type: object
              properties:
                name:
                  type: string
        contact:
          $ref: '#/components/schemas/DealIntakeResolution'
    DealIntakeDealInput:
      type: object
      required:
        - title
        - stage_id
      properties:
        title:
          type: string
          maxLength: 255
        stage_id:
          type: string
          format: uuid
        owner_id:
          type: string
          format: uuid
          description: Defaults to the API key creator when omitted.
        primary_source_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            Optional source definition ID, for example the workspace's Inbound
            source.
        amount:
          type: number
        currency:
          type: string
          maxLength: 3
          default: EUR
        expected_amount:
          type: number
        expected_close_date:
          type: string
          format: date
        location:
          type: string
          maxLength: 500
        probability:
          type: number
          minimum: 0
          maximum: 100
        custom_data:
          type: object
          additionalProperties: true
    DealIntakeCompanyInput:
      type: object
      properties:
        name:
          type: string
          maxLength: 255
        domain:
          type: string
          maxLength: 255
        industry:
          type: string
          maxLength: 100
        phone:
          type: string
          maxLength: 50
        linkedin_url:
          type: string
          format: uri
        location:
          type: string
          maxLength: 500
        description:
          type: string
          maxLength: 5000
      description: Company name or domain is required.
    DealIntakeContactInput:
      type: object
      properties:
        first_name:
          type: string
          maxLength: 100
        last_name:
          type: string
          maxLength: 100
        email:
          type: string
          format: email
        phone:
          type: string
          maxLength: 50
        title:
          type: string
          maxLength: 255
        linkedin_profile:
          type: string
          format: uri
        location:
          type: string
          maxLength: 500
      description: Contact email or at least one name field is required.
    Deal:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        status:
          type: string
          enum:
            - open
            - won
            - lost
            - unqualified
        amount:
          type: number
          nullable: true
        signed_amount:
          type: number
          nullable: true
        currency:
          type: string
          default: EUR
        expected_amount:
          type: number
          nullable: true
        expected_close_date:
          type: string
          format: date
          nullable: true
        probability:
          type: number
          nullable: true
        pipeline_id:
          type: string
          format: uuid
        stage_id:
          type: string
          format: uuid
        company_id:
          type: string
          format: uuid
        owner_id:
          type: string
          format: uuid
          nullable: true
        primary_source_id:
          type: string
          format: uuid
          nullable: true
          description: Primary deal source definition ID.
        closed_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        archived_at:
          type: string
          format: date-time
          nullable: true
      example:
        id: c3d4e5f6-7890-12ab-cdef-345678901bcd
        title: Recruitment - 3 Senior Engineers
        status: open
        amount: 45000
        signed_amount: null
        currency: EUR
        expected_amount: 45000
        expected_close_date: '2025-03-15'
        probability: 60
        pipeline_id: d4e5f6a7-8901-23bc-defa-456789012cde
        stage_id: e5f6a7b8-9012-34cd-efab-567890123def
        company_id: b2c3d4e5-6789-01ab-cdef-234567890abc
        owner_id: f6a7b8c9-0123-45de-fabc-678901234ef0
        primary_source_id: a7b8c9d0-1234-56ef-abcd-789012345ef1
        closed_at: null
        created_at: '2025-02-01T10:00:00Z'
        updated_at: '2025-02-10T15:30:00Z'
        archived_at: null
    DealIntakeResolution:
      type: object
      required:
        - id
        - created
      properties:
        id:
          type: string
          format: uuid
        created:
          type: boolean
        name:
          type: string
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - invalid_api_key
                - insufficient_scope
                - rate_limit_exceeded
                - validation_error
                - not_found
                - internal_error
                - billing_required
                - plan_upgrade_required
              description: >
                Error codes:

                - `invalid_api_key` — API key is missing, malformed, or revoked

                - `insufficient_scope` — API key lacks the required scope for
                this endpoint

                - `rate_limit_exceeded` — Too many requests (2000/hour)

                - `validation_error` — Request body or parameters failed
                validation

                - `not_found` — The requested resource does not exist

                - `internal_error` — Unexpected server error

                - `billing_required` — Workspace has no active subscription

                - `plan_upgrade_required` — Current plan does not include this
                feature
            message:
              type: string
              description: Human-readable error description
  responses:
    ValidationError:
      description: Invalid request data
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: validation_error
              message: Invalid input
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_api_key
              message: Invalid API key
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
              message: Resource not found
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key starting with `leo_`

````