Build AI agents that autonomously operate on Leonar CRM data using the API.
This guide explains how to connect an AI agent (Claude, GPT, LangChain, CrewAI, etc.) to the Leonar API so it can search candidates, manage contacts, enroll in sequences, and track deals on behalf of your users.
import anthropicimport yaml# Load spec and convert operations to toolswith open("openapi.yaml") as f: spec = yaml.safe_load(f)# Claude's tool_use format accepts OpenAPI-style schemas directlytools = []for path, methods in spec["paths"].items(): for method, operation in methods.items(): if isinstance(operation, dict) and "operationId" in operation: tools.append({ "name": operation["operationId"], "description": operation.get("description", operation.get("summary", "")), "input_schema": extract_schema(operation), # your conversion logic })
Workflow 1: Source and add candidates to a project
Copy
1. GET /projects → Pick target project2. GET /connected-accounts → Get LinkedIn account ID3. GET /sourcing/linkedin/locations → Resolve location names to IDs4. POST /sourcing/linkedin/search → Search with filters5. POST /sourcing/add-to-project → Add selected profiles
location_ids requires LinkedIn geo IDs, not plain-text names. You must call GET /sourcing/linkedin/locations?q=Paris&account_id=ACCOUNT_ID first to resolve a location name to its LinkedIn numeric ID. Passing plain text like {"Paris": "Paris"} will silently return zero results.
Copy
curl -X GET "https://app.leonar.app/api/v1/projects?status=active&limit=10" \ -H "Authorization: Bearer leo_your_api_key"
LinkedIn Classic search may return null first_name and last_name. Set resolve_names: true and provide account_id in the add-to-project request to automatically resolve missing names via LinkedIn profile lookup. Without this, contacts are created with “Unknown” as their first name.
1. GET /deal-pipelines → Get pipeline stages2. POST /deals → Create deal3. POST /deals/{id}/contacts → Link contacts to deal4. PUT /deals/{id}/stage → Move through stages5. POST /deals/{id}/close → Close as won/lost