EspoCRM MCP Server

Server URL:

Core Version: 1.1.5

MCP Status: Running ✅

Header Parameters

Tools

Accounts

Create a new Account in EspoCRM.

This tool creates an Account record using common EspoCRM Account fields.
Parameters map directly to EspoCRM Account attributes. Any parameter set
to `None` is omitted from the request to avoid sending unnecessary or
empty values.

Accounts can include contact details, billing and shipping addresses,
relationships to campaigns, teams, and target lists, as well as custom
EspoCRM fields.

Args:
- `name` (Optional[str]): Account name (<= 249 characters).
- `website` (Optional[str]): Website URL (<= 255 characters).
- `description` (Optional[str]): Description or internal notes.
- `email_address` (Optional[str]): Primary email address (<= 255 characters).
- `email_address_data` (Optional[List[Dict[str, Any]]]): Multiple email objects.
- `email_address_is_opted_out` (Optional[bool]): Email opted-out flag.
- `email_address_is_invalid` (Optional[bool]): Email invalid flag.
- `phone_number` (Optional[str]): Primary phone number (<= 36 characters).
- `phone_number_data` (Optional[List[Dict[str, Any]]]): Multiple phone objects.
- `phone_number_is_opted_out` (Optional[bool]): Phone opted-out flag.
- `phone_number_is_invalid` (Optional[bool]): Phone invalid flag.
- `type` (Optional[str]): Account category (Customer, Investor, Partner, Reseller).
- `industry` (Optional[str]): Industry (EspoCRM allowed values).
- `sic_code` (Optional[str]): SIC code (<= 40 characters).
- `billing_address_street` (Optional[str]): Billing street address.
- `billing_address_city` (Optional[str]): Billing city.
- `billing_address_state` (Optional[str]): Billing state.
- `billing_address_country` (Optional[str]): Billing country.
- `billing_address_postal_code` (Optional[str]): Billing postal code.
- `shipping_address_street` (Optional[str]): Shipping street address.
- `shipping_address_city` (Optional[str]): Shipping city.
- `shipping_address_state` (Optional[str]): Shipping state.
- `shipping_address_country` (Optional[str]): Shipping country.
- `shipping_address_postal_code` (Optional[str]): Shipping postal code.
- `campaign_id` (Optional[str]): Related Campaign record ID.
- `assigned_user_id` (Optional[str]): Assigned user ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `target_lists_ids` (Optional[List[str]]): Target List IDs.
- `target_list_id` (Optional[str]): Target List ID.
- `email_address_is_opted_out_flag` (Optional[bool]): Maps to `emailAddressIsOptedOut`.
- `email_address_is_invalid_flag` (Optional[bool]): Maps to `emailAddressIsInvalid`.
- `phone_number_is_opted_out_flag` (Optional[bool]): Maps to `phoneNumberIsOptedOut`.
- `phone_number_is_invalid_flag` (Optional[bool]): Maps to `phoneNumberIsInvalid`.
- `duplicate_source_id` (Optional[str]): Record ID being duplicated (sent as header `X-Duplicate-Source-Id`).
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check (sent as header `X-Skip-Duplicate-Check`).
- `custom_fields` (Optional[Dict[str, Any]]): Custom EspoCRM fields (must start with `c` prefix).

Example Requests:
- Create a basic account:
create_account_tool(name="Acme Corp", website="https://acme.com", email_address="info@acme.com")
- Create an account with multiple emails and phones:
create_account_tool(name="Acme Corp", email_address_data=[{"emailAddress": "info@acme.com", "primary": True}], phone_number_data=[{"phoneNumber": "+123456789", "type": "Office", "primary": True}])
- Create an account with addresses and relations:
create_account_tool(name="Acme Corp", billing_address_city="Bangkok", shipping_address_country="Thailand", assigned_user_id="USER_ID_123")
- Create an account with custom fields:
create_account_tool(name="Acme Corp", custom_fields={"c_customer_score": 95, "c_region": "APAC"})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Remove an existing Account record in EspoCRM.

Args:
- `account_id` (str): The ID of the Account to remove.

Example Request:
- delete_account_tool(account_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

List Account records from EspoCRM with filtering, sorting, and pagination.

This tool retrieves Account records using EspoCRM list API features such as attribute
selection, boolean filters, pagination, ordering, text search, and advanced whereGroup
conditions.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to include in the response.
- `bool_filter_list` (Optional[List[str]]): Boolean filters (e.g. ['onlyMy']).
- `max_size` (Optional[int]): Maximum number of records to return (0–200).
- `offset` (Optional[int]): Pagination offset (0-based).
- `order` (Optional[str]): Sort direction ('asc' or 'desc').
- `order_by` (Optional[str]): Field to sort by.
- `primary_filter` (Optional[str]): Primary filter (customers, resellers, partners, recentlyCreated).
- `text_filter` (Optional[str]): Text search query (supports '*').
- `where_group` (Optional[List[Dict[str, Any]]]): Advanced deepObject filters.
- `no_total` (Optional[bool]): Disable total count calculation.

Example Requests:
- List first 50 accounts with selected fields:
list_accounts_tool(attribute_select=["name", "website", "emailAddress"], max_size=50)
- List only my accounts, newest first:
list_accounts_tool(bool_filter_list=["onlyMy"], order="desc", order_by="createdAt")
- Search accounts by name:
list_accounts_tool(text_filter="Acme*")
- Use advanced whereGroup filtering:
list_accounts_tool(where_group=[{"type": "equals", "attribute": "industry", "value": "Technology"}])

Returns:
- A structured dict containing:
`total`, `list`, `status_code`, `ok`, `error`, and `error_type`.

Read a single Account record by ID from EspoCRM.

This tool fetches the full Account entity, including core fields such as
name, contact details, addresses, ownership, campaign linkage, audit fields,
and related metadata.

Args:
- `account_id` (str): The ID of the Account record to fetch.

Example Request:
- Fetch an account by ID:
get_account_tool(account_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing Account in EspoCRM.

Updates an Account record by `account_id`. Only provided fields are sent to EspoCRM.
Fields left as None will not overwrite existing values.

Args:
- `account_id` (str): ID of the Account record to update.
- `name` (Optional[str]): Account name.
- `website` (Optional[str]): Website.
- `email_address` (Optional[str]): Primary email.
- `email_address_data` (Optional[List[Dict[str, Any]]]): Multiple email objects.
- `phone_number` (Optional[str]): Primary phone.
- `phone_number_data` (Optional[List[Dict[str, Any]]]): Multiple phone objects.
- `type` (Optional[str]): Account type.
- `industry` (Optional[str]): Industry.
- `sic_code` (Optional[str]): SIC code.
- Billing & Shipping address fields.
- `description` (Optional[str]): Description.
- `campaign_id` (Optional[str]): Campaign ID.
- `assigned_user_id` (Optional[str]): Assigned user ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `target_lists_ids` (Optional[List[str]]): Target list IDs.
- `target_list_id` (Optional[str]): Primary target list ID.
- Opt-out / invalid flags.
- `version_number` (Optional[str]): Optimistic locking version.
- `custom_fields` (Optional[Dict[str, Any]]): EspoCRM custom fields.

Example Requests:
- Update an account's name and website:
update_account_tool(account_id="abc123", name="Acme Inc", website="https://acme.com")
- Update phone number and industry:
update_account_tool(account_id="abc123", phone_number="+123456789", industry="Technology")
- Update custom fields:
update_account_tool(account_id="abc123", custom_fields={"c_score": 92})

Returns:
- A structured dict containing: status_code, ok, data, error, error_type.

Bulk

Create multiple EspoCRM records in a single request.

Each item must contain:
- entityType: one of ['Lead', 'Contact', 'Account', 'Campaign']
- payload: object containing the exact parameters accepted by the corresponding create_* tool

IMPORTANT:
- payload keys MUST match the single-create tool for that entity
- The assistant constructs payloads exactly as if calling the single tool

Example:
create_bulk_tool([{"entityType": "Lead", "payload": {"first_name": "Jane", "last_name": "Doe"}},{"entityType": "Account", "payload": {"name": "Acme Corp", "website": "https://acme.com"}},])

Returns a dict with `results` (list of per-item responses) and `ok` boolean.

Delete multiple EspoCRM records in a single request.

Each item must contain:
- entityType: one of ['Lead', 'Contact', 'Account', 'Campaign']
- id: the ID of the record to delete

Example:
delete_bulk_tool([{"entityType": "Contact", "id": "123"}])

Returns a dict with `results` (list of per-item responses) and `ok` boolean.

Update multiple EspoCRM records in a single request.

Each item must contain:
- entityType: one of ['Lead', 'Contact', 'Account', 'Campaign']
- id: the ID of the record to update
- payload: object containing the exact parameters accepted by the corresponding update_* tool

IMPORTANT:
- payload keys MUST match the single-update tool for that entity

Example:
update_bulk_tool([{"entityType": "Contact", "id": "123", "payload": {"first_name": "Jane"}}])

Returns a dict with `results` (list of per-item responses) and `ok` boolean.

Calls

Create a new Call in EspoCRM.

This tool creates a Call record using common Call fields. Parameters map directly
to EspoCRM Call attributes. Any parameter set to `None` is omitted from the request
to avoid overwriting default values.

Calls can be linked to other entities such as Accounts, Leads, Contacts, or Opportunities,
and can include multiple participants via users, contacts, or leads relationships.

Args:
- `name` (Optional[str]): Call subject or title (<= 255 chars).
- `status` (Optional[str]): Call status. Allowed values: Planned, Held, Not Held.
- `date_start` (Optional[str]): Call start time in UTC (YYYY-MM-DD HH:MM:SS).
- `date_end` (Optional[str]): Call end time in UTC (YYYY-MM-DD HH:MM:SS).
- `direction` (Optional[str]): Call direction. Allowed values: Outbound, Inbound.
- `description` (Optional[str]): Multi-line description or notes.
- `parent_id` (Optional[str]): ID of the related parent record.
- `parent_type` (Optional[str]): Parent entity type (Account, Lead, Contact, Opportunity, Case, CCompany).
- `parent_name` (Optional[str]): Name of the related parent record.
- `account_id` (Optional[str]): Related Account record ID.
- `account_name` (Optional[str]): Related Account name.
- `uid` (Optional[str]): External unique identifier (<= 255 chars).
- `acceptance_status` (Optional[str]): Acceptance status (None, Accepted, Tentative, Declined).
- `users_ids` (Optional[List[str]]): IDs of User participants.
- `users_columns` (Optional[Dict[str, Any]]): Relationship column values for users.
- `users_names` (Optional[Dict[str, str]]): User ID to name mapping.
- `contacts_ids` (Optional[List[str]]): IDs of Contact participants.
- `contacts_columns` (Optional[Dict[str, Any]]): Relationship column values for contacts.
- `contacts_names` (Optional[Dict[str, str]]): Contact ID to name mapping.
- `leads_ids` (Optional[List[str]]): IDs of Lead participants.
- `leads_columns` (Optional[Dict[str, Any]]): Relationship column values for leads.
- `leads_names` (Optional[Dict[str, str]]): Lead ID to name mapping.
- `assigned_user_id` (Optional[str]): Assigned user ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `duplicate_source_id` (Optional[str]): Record ID being duplicated (sent as header `X-Duplicate-Source-Id`).
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check (sent as header `X-Skip-Duplicate-Check`).
- `custom_fields` (Optional[Dict[str, Any]]): Custom EspoCRM fields (must start with `c` prefix).

Example Requests:
- Create a basic planned outbound call:
create_call_tool(name="Intro Call", status="Planned", direction="Outbound", date_start="2026-01-01 10:00:00")
- Create a held call linked to a Lead:
create_call_tool(name="Follow-up Call", status="Held", parent_type="Lead", parent_id="LEAD_ID_123")
- Create a call with multiple participants:
create_call_tool(name="Sales Call", users_ids=["USER_ID_1"], contacts_ids=["CONTACT_ID_1"])
- Create a call with custom fields:
create_call_tool(name="Demo Call", custom_fields={"c_call_score": 95, "c_recording_url": "https://example.com/recording"})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Remove an existing Call record in EspoCRM.

Args:
- `call_id` (str): The ID of the Call to remove.

Example Request:
- delete_call_tool(call_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

List Calls from EspoCRM with optional filtering, sorting, and pagination.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to include in the response to improve performance.
- `bool_filter_list` (Optional[List[str]]): Boolean filters such as `['onlyMy']`.
- `max_size` (Optional[int]): Maximum number of records to return (0–200).
- `offset` (Optional[int]): Pagination offset (0-based).
- `order` (Optional[str]): Sort direction, either `'asc'` or `'desc'`.
- `order_by` (Optional[str]): Attribute to sort results by.
- `primary_filter` (Optional[str]): Primary filter to use. Allowed: `'planned'`, `'held'`, `'todays'`.
- `text_filter` (Optional[str]): Text search query. Supports wildcard `*`.
- `where_group` (Optional[List[Dict[str, Any]]]): Advanced deepObject filters for complex queries.

Example Requests:
- Fetch first 50 calls with only selected attributes:
list_calls_tool(attribute_select=["name", "dateStart"], max_size=50)
- Fetch calls assigned to current user only (bool filter):
list_calls_tool(bool_filter_list=["onlyMy"], max_size=100)
- Fetch today's planned calls:
list_calls_tool(primary_filter="todays", primary_filter="planned")
- Fetch outbound calls using a where_group filter:
list_calls_tool(where_group=[{"type": "equals", "attribute": "direction", "value": "Outbound"}])
- Fetch calls filtered by parent (Account) and paginated:
list_calls_tool(where_group=[{"type":"equals","attribute":"parentType","value":"Account"},{"type":"equals","attribute":"parentId","value":""}], max_size=25, offset=50)

Returns:
- A dictionary containing calls data and metadata.

Get a single Call record by ID from EspoCRM.

This tool retrieves an existing Call record, including metadata, participants,
related entities, and timestamps.

Args:
- `call_id` (str): The ID of the Call record to fetch.

Example Request:
- get_call_tool(call_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing Call in EspoCRM.

This tool updates a Call record by `call_id`. Provide any Call fields to update.
Parameters left as `None` will not be sent to avoid overwriting unchanged values.

Args:
- `call_id` (str): ID of the Call record to update.
- `name` (Optional[str]): Call subject or title (<= 255 chars).
- `status` (Optional[str]): Call status. Allowed values: Planned, Held, Not Held.
- `date_start` (Optional[str]): Call start time in UTC (YYYY-MM-DD HH:MM:SS).
- `date_end` (Optional[str]): Call end time in UTC (YYYY-MM-DD HH:MM:SS).
- `direction` (Optional[str]): Call direction. Allowed values: Outbound, Inbound.
- `description` (Optional[str]): Multi-line description or notes.
- `parent_id` (Optional[str]): ID of the related parent record.
- `parent_type` (Optional[str]): Parent entity type (Account, Lead, Contact, Opportunity, Case, CCompany).
- `acceptance_status` (Optional[str]): Acceptance status (None, Accepted, Tentative, Declined).
- `users_ids` / `users_columns` / `users_names`: Participants (users) relationship maps.
- `contacts_ids` / `contacts_columns` / `contacts_names`: Participants (contacts) relationship maps.
- `leads_ids` / `leads_columns` / `leads_names`: Participants (leads) relationship maps.
- `assigned_user_id` (Optional[str]): Assigned user ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `duplicate_source_id` (Optional[str]): Record ID being duplicated (sent as header `X-Duplicate-Source-Id`).
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check (sent as header `X-Skip-Duplicate-Check`).
- `custom_fields` (Optional[Dict[str, Any]]): Custom EspoCRM fields to update on the Call record. Custom fields must start with `c` prefix.

Example Requests:
- Update call name and start time:
update_call_tool(call_id="abc123", name="Rescheduled Call", date_start="2026-02-01 09:00:00")
- Update participants and direction:
update_call_tool(call_id="abc123", users_ids=["USER1","USER2"], contacts_ids=["CONTACT1"], direction="Inbound")
- Update custom fields:
update_call_tool(call_id="abc123", custom_fields={"c_priority": "high", "c_score": 75})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Campaigns

Create a new Campaign in EspoCRM.

This tool creates a Campaign record using common Campaign fields. Any parameter set to `None` is omitted
from the request to avoid overwriting defaults. Supports optional headers for duplicate handling.

Args:
- `name` (str): Campaign name (<= 255 chars).
- `status` (Optional[str]): Campaign status (Planning, Active, Inactive, Complete).
- `type` (Optional[str]): Campaign type (Email, Newsletter, Informational Email, Web, Television, Radio, Mail).
- `start_date` (Optional[str]): Start date (YYYY-MM-DD).
- `end_date` (Optional[str]): End date (YYYY-MM-DD).
- `description` (Optional[str]): Multi-line description.
- `assigned_user_id` (Optional[str]): Assigned user ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `target_lists_ids` (Optional[List[str]]): Target List IDs.
- `excluding_target_lists_ids` (Optional[List[str]]): Excluded Target List IDs.
- `budget` (Optional[float]): Budget amount.
- `budget_currency` (Optional[str]): Currency code (USD, EUR).
- `contacts_template_id` (Optional[str]): Template ID for contacts.
- `leads_template_id` (Optional[str]): Template ID for leads.
- `accounts_template_id` (Optional[str]): Template ID for accounts.
- `users_template_id` (Optional[str]): Template ID for users.
- `mail_merge_only_with_address` (Optional[bool]): Mail merge only with address flag.
- `duplicate_source_id` (Optional[str]): Record ID of entity being duplicated, sent as header `X-Duplicate-Source-Id`.
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check flag. Sent as header `X-Skip-Duplicate-Check` with value `'true'` or `'false'`.
- `custom_fields` (Optional[Dict[str, Any]]): Custom EspoCRM fields prefixed with `c`.

Example Requests:
- Create a basic campaign:
create_campaign_tool(name="Summer Sale 2026", status="Planning", type="Email")
- Create a campaign with assigned user, teams, and budget:
create_campaign_tool(name="Product Launch", status="Active", type="Web", assigned_user_id="abc123", teams_ids=["team1", "team2"], budget=5000, budget_currency="USD")
- Create a campaign with custom fields:
create_campaign_tool(name="Demo Campaign", type="Email", custom_fields={"c_customCode": "XYZ", "c_priority": 1})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Remove an existing Campaign record in EspoCRM.

Args:
- `campaign_id` (str): The ID of the Campaign to remove.

Example Request:
- delete_campaign_tool(campaign_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

List campaigns from EspoCRM with optional filtering, sorting, and pagination.

This tool fetches campaigns with advanced query options such as attribute selection, boolean filters,
pagination, sorting, and deep where group conditions.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to include in the response to improve performance.
- `bool_filter_list` (Optional[List[str]]): Boolean filters such as `['onlyMy']`.
- `max_size` (Optional[int]): Maximum number of records to return (0–200). Overrides page_size if provided.
- `offset` (Optional[int]): Pagination offset (0-based). If not set, computed from page and page_size.
- `order` (Optional[str]): Sort direction, either `'asc'` or `'desc'`.
- `order_by` (Optional[str]): Attribute to sort results by.
- `primary_filter` (Optional[str]): Primary filter to use. Allowed values depend on your EspoCRM setup (e.g., `'active'`, `'completed'`).
- `text_filter` (Optional[str]): Text search query. Supports wildcard `*`.
- `where_group` (Optional[List[Dict[str, Any]]]): Advanced deepObject filters for complex queries.

Example Requests:
- Fetch first 50 campaigns with only selected attributes:
list_campaigns_tool(attribute_select=["name", "status"], max_size=50)
- Fetch campaigns assigned only to the current user, sorted by creation date descending:
list_campaigns_tool(bool_filter_list=["onlyMy"], order="desc", order_by="createdAt")
- Fetch campaigns using advanced whereGroup filter:
list_campaigns_tool(where_group=[{"type": "equals", "attribute": "status", "value": "Active"}, {"type": "contains", "attribute": "name", "value": "Launch"}])
- Fetch campaigns with a primary filter:
list_campaigns_tool(primary_filter="completed", max_size=20)
- Fetch campaigns using a text search query:
list_campaigns_tool(text_filter="Summer*2026", max_size=10)

Returns:
- A dictionary containing campaigns data and metadata.

Get a single Campaign record by ID from EspoCRM.

Args:
- `campaign_id` (str): The ID of the Campaign to fetch.

Example Request:
- get_campaign_tool(campaign_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing Campaign in EspoCRM.

This tool updates a Campaign record by `campaign_id`. Provide any Campaign fields to update.
Parameters left as `None` will not be sent to avoid overwriting unchanged values.

Args:
- `campaign_id` (str): ID of the Campaign record to update.
- `name` (Optional[str]): Campaign name (<=255 chars).
- `status` (Optional[str]): Campaign status (Planning, Active, Inactive, Complete).
- `type` (Optional[str]): Campaign type (Email, Newsletter, Informational Email, Web, Television, Radio, Mail).
- `start_date` (Optional[str]): Start date (YYYY-MM-DD).
- `end_date` (Optional[str]): End date (YYYY-MM-DD).
- `description` (Optional[str]): Multi-line description.
- `assigned_user_id` (Optional[str]): Assigned user ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `target_lists_ids` (Optional[List[str]]): Target List IDs.
- `excluding_target_lists_ids` (Optional[List[str]]): Excluded Target List IDs.
- `budget` (Optional[float]): Budget amount.
- `budget_currency` (Optional[str]): Budget currency code (USD, EUR).
- `contacts_template_id` (Optional[str]): Template ID for contacts.
- `leads_template_id` (Optional[str]): Template ID for leads.
- `accounts_template_id` (Optional[str]): Template ID for accounts.
- `users_template_id` (Optional[str]): Template ID for users.
- `mail_merge_only_with_address` (Optional[bool]): Mail merge only with address flag.
- `custom_fields` (Optional[Dict[str, Any]]): A dictionary of EspoCRM custom fields to update on the Campaign record. All EspoCRM custom fields are prefixed with `c`.

Example Requests:
- Update campaign name and status:
update_campaign_tool(campaign_id="abc123", name="Spring Promo", status="Active")
- Update campaign teams and budget:
update_campaign_tool(campaign_id="abc123", teams_ids=["team1","team2"], budget=10000, budget_currency="USD")
- Update custom fields on a campaign:
update_campaign_tool(campaign_id="abc123", custom_fields={"c_campaign_code":"X123","c_priority":2})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Contacts

Create a new Contact in EspoCRM.

This tool creates a Contact record using common Contact fields. Any parameter set to `None` is omitted from the request to avoid overwriting defaults. Supports optional headers for duplicate handling.

Args:
- `salutation_name` (Optional[str]): Salutation (Mr., Ms., Mrs., Dr., etc.).
- `first_name` (Optional[str]): First name (<=100 chars).
- `middle_name` (Optional[str]): Middle name (<=100 chars).
- `last_name` (Optional[str]): Last name (<=100 chars).
- `title` (Optional[str]): Job title (<=100 chars).
- `description` (Optional[str]): Multi-line description or notes.
- `email_address` (Optional[str]): Primary email (<=255 chars).
- `email_address_data` (Optional[List[Dict[str, Any]]]): Multiple email objects. Each object: `emailAddress` (str, required), `primary` (bool, required), `optOut` (bool, optional), `invalid` (bool, optional)
- `phone_number` (Optional[str]): Primary phone number (<=36 chars).
- `phone_number_data` (Optional[List[Dict[str, Any]]]): Multiple phone objects. Each object: `phoneNumber` (str, required), `primary` (bool, required), `optOut` (bool, optional), `invalid` (bool, optional)
- `do_not_call` (Optional[bool]): Do not call flag.
- `address_street` (Optional[str]): Street address (<=255 chars).
- `address_city` (Optional[str]): City (<=100 chars).
- `address_state` (Optional[str]): State (<=100 chars).
- `address_country` (Optional[str]): Country (<=100 chars).
- `address_postal_code` (Optional[str]): Postal code (<=40 chars).
- `account_id` (Optional[str]): Related Account ID.
- `accounts_ids` (Optional[List[str]]): Multiple related Account IDs.
- `accounts_columns` (Optional[Dict[str, Dict[str, Any]]]): {AccountID => column values} for relationships.
- `account_role` (Optional[str]): Account role.
- `account_is_inactive` (Optional[bool]): Account inactive flag.
- `opportunity_role` (Optional[str]): Opportunity role (Decision Maker, Evaluator, Influencer).
- `campaign_id` (Optional[str]): Related Campaign ID.
- `assigned_user_id` (Optional[str]): Assigned User ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `target_list_id` (Optional[str]): Target List ID.
- `original_lead_id` (Optional[str]): Original Lead ID if created from a Lead.
- `original_email_id` (Optional[str]): Original Email ID.
- `email_address_is_opted_out` (Optional[bool]): Email opted out flag.
- `email_address_is_invalid` (Optional[bool]): Email invalid flag.
- `phone_number_is_opted_out` (Optional[bool]): Phone opted out flag.
- `phone_number_is_invalid` (Optional[bool]): Phone invalid flag.
- `duplicate_source_id` (Optional[str]): Record ID of entity being duplicated, sent as header `X-Duplicate-Source-Id`.
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check, sent as header `X-Skip-Duplicate-Check` with value 'true' or 'false'.
- `custom_fields` (Optional[Dict[str, Any]]): Custom EspoCRM fields prefixed with c.

Example Requests:
- Create a basic contact: create_contact_tool(first_name="Jane", last_name="Doe", email_address="jane@example.com")
- Create a contact with multiple emails and phones: create_contact_tool(first_name="Acme", last_name="Inc", email_address_data=[{"emailAddress": "a@acme.com", "primary": True}], phone_number_data=[{"phoneNumber": "+123456789", "primary": True}])
- Create a contact with custom fields: create_contact_tool(first_name="Demo", last_name="User", custom_fields={"c_demo_field": "value"})

Returns:
- A structured dict containing the API response with keys: `status_code`, `ok`, `data`, `error`, and `error_type`.

Delete an existing Contact in EspoCRM.

This tool removes a Contact record permanently from EspoCRM.

Args:
- `contact_id` (str): The ID of the Contact record to delete.

Example Requests:
- Delete a contact: delete_contact_tool(contact_id="abc123")

Returns:
- A structured dict containing the API response with keys: `status_code`, `ok`, `data`, `error`, `error_type`.
The `data` field is always True if deletion succeeded.

List Contact records in EspoCRM.

This tool retrieves Contact records with optional filtering, ordering, and pagination. Supports deep filtering and selective attributes to improve performance.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to return. Allowed values: salutationName, firstName, lastName, middleName, name, accountAnyId, title, description, emailAddressIsOptedOut, emailAddressIsInvalid, emailAddress, emailAddressData, phoneNumberIsOptedOut, phoneNumberIsInvalid, phoneNumber, phoneNumberData, doNotCall, addressStreet, addressCity, addressState, addressCountry, addressPostalCode, accountId, accountName, accountsIds, accountsColumns, accountsNames, accountRole, accountIsInactive, accountType, opportunityRole, acceptanceStatus, acceptanceStatusMeetings, acceptanceStatusCalls, campaignId, campaignName, createdAt, modifiedAt, createdById, createdByName, modifiedById, modifiedByName, assignedUserId, assignedUserName, teamsIds, teamsNames, targetListsIds, targetListsNames, targetListId, targetListName, portalUserId, portalUserName, hasPortalUser, originalLeadId, originalLeadName, targetListIsOptedOut, originalEmailId, originalEmailName, addressMap, streamUpdatedAt
- `bool_filter_list` (Optional[List[str]]): Boolean filters. Allowed: onlyMy
- `max_size` (Optional[int]): Max records to return (0-200)
- `offset` (Optional[int]): Pagination offset
- `order` (Optional[str]): Order direction, asc or desc
- `order_by` (Optional[str]): Attribute to order by
- `primary_filter` (Optional[str]): Primary filter, allowed: portalUsers, notPortalUsers, accountActive
- `text_filter` (Optional[str]): Text filter query, wildcard (*) supported
- `where_group` (Optional[List[Dict[str, Any]]]): Where conditions [{type, attribute, operator, value}]
- `type_filter` (Optional[str]): Record type
- `date_time` (Optional[bool]): Set true for date-time fields
- `time_zone` (Optional[str]): Time zone for date-time fields
- `x_no_total` (Optional[bool]): Disable total count calculation

Example Requests:
- List first 50 contacts: list_contacts_tool(max_size=50)
- List contacts with only my records and select names: list_contacts_tool(attribute_select=["firstName","lastName"], bool_filter_list=["onlyMy"])
- List contacts with text filter and order by last name: list_contacts_tool(text_filter="Acme*", order_by="lastName", order="asc")

Returns:
- A structured dict containing the API response with keys: `status_code`, `ok`, `data`, `error`, `error_type`, `total`.

Read an existing Contact record in EspoCRM.

This tool retrieves a single Contact record by ID, returning all standard and custom fields.

Args:
- `contact_id` (str): The ID of the Contact record.

Example Requests:
- Read a contact by ID: read_contact_tool(contact_id="abc123")
- Read another contact: read_contact_tool(contact_id="xyz789")
Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing Contact in EspoCRM.

This tool updates a Contact record using standard Contact fields. Any parameter set to `None` is omitted
from the request to avoid overwriting existing data.

Args:
- `contact_id` (str): The ID of the Contact record.
- `salutation_name` (Optional[str]): Salutation (Mr., Ms., Mrs., Dr., etc.).
- `first_name` (Optional[str]): First name (<=100 chars).
- `middle_name` (Optional[str]): Middle name (<=100 chars).
- `last_name` (Optional[str]): Last name (<=100 chars).
- `title` (Optional[str]): Job title (<=100 chars).
- `description` (Optional[str]): Multi-line description.
- `email_address` (Optional[str]): Primary email (<=255 chars).
- `email_address_data` (Optional[List[Dict[str, Any]]]): Multiple email objects.
- `phone_number` (Optional[str]): Primary phone (<=36 chars).
- `phone_number_data` (Optional[List[Dict[str, Any]]]): Multiple phone objects.
- `do_not_call` (Optional[bool]): Do not call flag.
- `address_street` (Optional[str]): Street address (<=255 chars).
- `address_city` (Optional[str]): City (<=100 chars).
- `address_state` (Optional[str]): State (<=100 chars).
- `address_country` (Optional[str]): Country (<=100 chars).
- `address_postal_code` (Optional[str]): Postal code (<=40 chars).
- `account_id` (Optional[str]): Related Account ID.
- `accounts_ids` (Optional[List[str]]): Multiple related Account IDs.
- `accounts_columns` (Optional[Dict[str, Any]]): {AccountID => column values} for relationships.
- `account_role` (Optional[str]): Account role.
- `account_is_inactive` (Optional[bool]): Account inactive flag.
- `opportunity_role` (Optional[str]): Opportunity role (Decision Maker, Evaluator, Influencer).
- `campaign_id` (Optional[str]): Related Campaign ID.
- `assigned_user_id` (Optional[str]): Assigned User ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `target_lists_ids` (Optional[List[str]]): Target List IDs.
- `target_list_id` (Optional[str]): Target List ID.
- `original_email_id` (Optional[str]): Original Email ID.
- `email_address_is_opted_out` (Optional[bool]): Email opted out flag.
- `email_address_is_invalid` (Optional[bool]): Email invalid flag.
- `phone_number_is_opted_out` (Optional[bool]): Phone opted out flag.
- `phone_number_is_invalid` (Optional[bool]): Phone invalid flag.
- `custom_fields` (Optional[Dict[str, Any]]): A dictionary of EspoCRM custom fields to update on the Lead record. All EspoCRM custom fields are prefixed with `c`.

Example Requests:
- Update a contact's name: update_contact_tool(contact_id="abc123", first_name="John", last_name="Doe")
- Update emails and phones: update_contact_tool(contact_id="abc123", email_address_data=[{"emailAddress":"a@acme.com","primary":True}], phone_number_data=[{"phoneNumber":"+123456789","primary":True}])
- Update address: update_contact_tool(contact_id="abc123", address_street="123 Main St", address_city="Bangkok", address_country="Thailand")

Returns:
- A structured dict containing the API response with keys: `status_code`, `ok`, `data`, `error`, `error_type`.
The `data` object contains updated Contact fields similar to Read Contact.

Emails

Create a new Email in EspoCRM.

This tool creates an Email record using standard Email fields. Any parameter set to `None` is omitted from the request to avoid overwriting defaults.

Args:
- `name` (Optional[str]): Email name (<=255 chars).
- `subject` (Optional[str]): Email subject line (<=255 chars).
- `from_` (Optional[str]): From display string (<=255 chars).
- `reply_to_string` (Optional[str]): Reply-To display string (<=255 chars).
- `from` (Optional[str]): From email address (<=255 chars).
- `to` (Optional[str]): To email addresses (<=255 chars).
- `cc` (Optional[str]): CC email addresses (<=255 chars).
- `bcc` (Optional[str]): BCC email addresses (<=255 chars).
- `reply_to` (Optional[str]): Reply-To email addresses (<=255 chars).
- `person_string_data` (Optional[str]): Person string data (<=255 chars).
- `email_address` (Optional[str]): Primary email address (<=255 chars).
- `body` (Optional[str]): Email body content (plain text or HTML).
- `is_html` (Optional[bool]): True if `body` is HTML.
- `status` (Optional[str]): Email status (Draft, Sending, Sent, Archived, Failed).
- `parent_id` (Optional[str]): ID of the parent record.
- `parent_type` (Optional[str]): Type of parent record (Account, Lead, Contact, Opportunity, Case, CCompany).
- `date_sent` (Optional[str]): Date/time the email was sent (UTC, format: YYYY-MM-DD HH:MM:SS).
- `send_at` (Optional[str]): Scheduled send date/time (UTC, format: YYYY-MM-DD HH:MM:SS).
- `assigned_user_id` (Optional[str]): User ID of the assigned owner.
- `replied_id` (Optional[str]): ID of the email being replied to.
- `teams_ids` (Optional[List[str]]): List of Team IDs.
- `duplicate_source_id` (Optional[str]): Record ID of an email being duplicated. Sent as header `X-Duplicate-Source-Id`.
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check, sent as header `X-Skip-Duplicate-Check`.
- `custom_fields` (Optional[Dict[str, Any]]): Custom fields to update on the Email record (must start with `c`).

Example Requests:
- Create a basic email: create_email_tool(subject="Hello", to="recipient@example.com", body="This is a test email.")
- Create an email with HTML body and parent Contact: create_email_tool(subject="Welcome", to="user@example.com", body="

Hello!

", is_html=True, parent_type="Contact", parent_id="abc123")
- Create an email with a custom field: create_email_tool(subject="Custom", to="user@example.com", custom_fields={"c_custom_flag": True})

Returns:
- `Dict`: Structured dict containing the API response with keys `status_code`, `ok`, `data`, `error`, and `error_type`.

Remove an existing Email record in EspoCRM.

Args:
- `email_id` (str): The ID of the Email to remove.

Example Request:
- delete_email_tool(email_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

List Email records from EspoCRM with optional filtering, sorting, and pagination.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to include in the response.
- `max_size` (Optional[int]): Maximum number of records to return (0–200).
- `offset` (Optional[int]): Pagination offset (0-based).
- `order` (Optional[str]): Sort direction, 'asc' or 'desc'.
- `order_by` (Optional[str]): Attribute to sort results by.
- `text_filter` (Optional[str]): Text search query, supports wildcard '*'.
- `where_group` (Optional[List[Dict[str, Any]]]): Advanced deepObject filters.
- `primary_filter` (Optional[str]): Primary filter to apply.

Example Requests:
- List first 50 emails with selected attributes:
list_emails_tool(attribute_select=["subject", "fromName", "dateSent"], max_size=50)
- List emails containing a specific string in subject:
list_emails_tool(text_filter="*Invoice*")
- List emails sorted by date sent descending:
list_emails_tool(order="desc", order_by="dateSent")

Returns:
- A dictionary containing emails data and metadata.

Get a single Email record by ID from EspoCRM.

Args:
- `email_id` (str): The ID of the Email to fetch.

Example Request:
- get_email_tool(email_id="email123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing Email in EspoCRM.

This tool updates an Email record by `email_id`. Provide any Email fields to update.
parameters left as `None` will not be sent to avoid overwriting unchanged values.

Args:
- `email_id` (str): ID of the Email record to update.
- `name` (Optional[str]): Email name (<=255 chars).
- `subject` (Optional[str]): Email subject (<=255 chars).
- `from_string` (Optional[str]): From display string (<=255 chars).
- `reply_to_string` (Optional[str]): Reply-To display string (<=255 chars).
- `from_field` (Optional[str]): From email address (<=255 chars).
- `to` (Optional[str]): To email addresses (<=255 chars).
- `cc` (Optional[str]): CC email addresses (<=255 chars).
- `bcc` (Optional[str]): BCC email addresses (<=255 chars).
- `reply_to` (Optional[str]): Reply-To email addresses (<=255 chars).
- `person_string_data` (Optional[str]): Person string data (<=255 chars).
- `email_address` (Optional[str]): Primary email address (<=255 chars).
- `body` (Optional[str]): Email body content (plain text or HTML).
- `is_html` (Optional[bool]): True if `body` is HTML.
- `status` (Optional[str]): Email status (Draft, Sending, Sent, Archived, Failed).
- `parent_id` (Optional[str]): ID of the parent record.
- `parent_type` (Optional[str]): Type of parent record (Account, Lead, Contact, Opportunity, Case, CCompany).
- `date_sent` (Optional[str]): Date/time the email was sent (UTC, format: YYYY-MM-DD HH:MM:SS).
- `send_at` (Optional[str]): Scheduled send date/time (UTC, format: YYYY-MM-DD HH:MM:SS).
- `assigned_user_id` (Optional[str]): User ID of the assigned owner.
- `replied_id` (Optional[str]): ID of the email being replied to.
- `teams_ids` (Optional[List[str]]): List of Team IDs.
- `custom_fields` (Optional[Dict[str, Any]]): A dictionary of EspoCRM custom fields to update on the Email record. All EspoCRM custom fields are prefixed with `c`.

Example Requests:
- Update subject and body: update_email_tool(email_id="abc123", subject="Updated", body="New body")
- Update parent and status: update_email_tool(email_id="abc123", parent_type="Contact", parent_id="contact456", status="Sent")
- Update custom fields: update_email_tool(email_id="abc123", custom_fields={"c_processed": True})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Leads

Create a new Lead in EspoCRM.

This tool creates a Lead record using common Lead fields, parameters map to EspoCRM Lead attributes.
Any parameter set to `None` is omitted from the request to avoid overwriting defaults.

Args:
- `salutation_name` (Optional[str]): Salutation (e.g. 'Mr.', 'Ms.', 'Dr.').
- `first_name` (Optional[str]): First name (<= 100 chars).
- `middle_name` (Optional[str]): Middle name (<= 100 chars).
- `last_name` (Optional[str]): Last name (<= 100 chars).
- `title` (Optional[str]): Job title (<= 100 chars).
- `status` (Optional[str]): Lead status (New, Assigned, In Process, Converted, Recycled, Dead).
- `source` (Optional[str]): Lead source (Call, Email, Campaign, etc.).
- `industry` (Optional[str]): Industry (see API allowed values).
- `opportunity_amount` (Optional[float]): Opportunity amount (>= 0).
- `opportunity_amount_currency` (Optional[str]): Currency code (USD, EUR).
- `website` (Optional[str]): Website (<= 255 chars).
- `address_street` (Optional[str]): Street (<= 255 chars).
- `address_city` (Optional[str]): City (<= 100 chars).
- `address_state` (Optional[str]): State (<= 100 chars).
- `address_country` (Optional[str]): Country (<= 100 chars).
- `address_postal_code` (Optional[str]): Postal code (<= 40 chars).
- `email_address` (Optional[str]): Primary email (<= 255 chars).
- `email_address_data` (Optional[List[Dict[str, Any]]]): Multiple email objects.
- `phone_number` (Optional[str]): Primary phone (<= 36 chars).
- `phone_number_data` (Optional[List[Dict[str, Any]]]): Multiple phone objects.
- `do_not_call` (Optional[bool]): Do not call flag.
- `description` (Optional[str]): Description / notes.
- `account_name` (Optional[str]): Account name (<= 255 chars).
- `assigned_user_id` (Optional[str]): ID of the assigned User record.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `campaign_id` (Optional[str]): Campaign ID.
- `target_list_id` (Optional[str]): Target list ID.
- `duplicate_source_id` (Optional[str]): Record ID of an entity being duplicated. Sent as header `X-Duplicate-Source-Id`.
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check flag. When provided, sent as header `X-Skip-Duplicate-Check` with value `'true'` or `'false'`.
- `custom_fields` (Optional[Dict[str, Any]]): A dictionary of EspoCRM custom fields to update on the Lead record. All EspoCRM custom fields are prefixed with `c`.

Example Requests:
- Create a basic lead with name and email:
create_lead_tool(first_name="Jane", last_name="Doe", email_address="jane@example.com")
- Create a lead with multiple emails and phone numbers:
create_lead_tool(first_name="Acme", last_name="Inc", email_address_data=[{"emailAddress": "a@acme.com", "primary": True}], phone_number_data=[{"phoneNumber": "+123456789", "primary": True}])
- Create a lead with a custom field (e.g., c_demo_url):
create_lead_tool(first_name="Demo", last_name="User", custom_fields={"c_demo_url": "https://example.com/demo", "c_score": 90})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Remove an existing Lead record in EspoCRM.

Args:
- `lead_id` (str): The ID of the Lead to remove.

Example Request:
- delete_lead_tool(lead_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

List leads from EspoCRM with optional filtering, sorting, and pagination.

This tool fetches leads with advanced query options such as attribute selection, boolean filters,
pagination, sorting, and deep where group conditions.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to include in the response to improve performance.
- `bool_filter_list` (Optional[List[str]]): Boolean filters such as `['onlyMy']`.
- `max_size` (Optional[int]): Maximum number of records to return (0–200). Overrides page_size if provided.
- `offset` (Optional[int]): Pagination offset (0-based). If not set, computed from page and page_size.
- `order` (Optional[str]): Sort direction, either `'asc'` or `'desc'`.
- `order_by` (Optional[str]): Attribute to sort results by.
- `primary_filter` (Optional[str]): Primary filter to use. Allowed: `'actual'`, `'active'`, `'converted'`.
- `text_filter` (Optional[str]): Text search query. Supports wildcard `*`.
- `where_group` (Optional[List[Dict[str, Any]]]): Advanced deepObject filters for complex queries.

Example Requests:
- Fetch first 50 leads with only selected attributes:
list_leads_tool(attribute_select=["firstName", "lastName", "emailAddress"], max_size=50)
- Fetch leads assigned only to the current user, sorted by creation date descending:
list_leads_tool(bool_filter_list=["onlyMy"], order="desc", order_by="createdAt")
- Fetch leads using advanced whereGroup filter:
list_leads_tool(where_group=[{"type": "equals", "attribute": "status", "value": "New"}, {"type": "contains", "attribute": "emailAddress", "value": "@example.com"}])

Returns:
- A dictionary containing leads data and metadata.

Get a single Lead record by ID from EspoCRM.

Args:
- `lead_id` (str): The ID of the Lead to fetch.

Example Request:
- get_lead_tool(lead_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing Lead in EspoCRM.

This tool updates a Lead record by `lead_id`. Provide any Lead fields to update.
parameters left as `None` will not be sent to avoid overwriting unchanged values.

Args:
- `lead_id` (str): ID of the Lead record to update.
- `salutation_name` (Optional[str]): Salutation (e.g. 'Mr.', 'Ms.', 'Dr.').
- `first_name` (Optional[str]): First name (<= 100 chars).
- `middle_name` (Optional[str]): Middle name (<= 100 chars).
- `last_name` (Optional[str]): Last name (<= 100 chars).
- `title` (Optional[str]): Job title (<= 100 chars).
- `status` (Optional[str]): Lead status (New, Assigned, In Process, Converted, Recycled, Dead).
- `source` (Optional[str]): Lead source (Call, Email, Campaign, etc.).
- `industry` (Optional[str]): Industry (see API allowed values).
- `opportunity_amount` (Optional[float]): Opportunity amount (>= 0).
- `opportunity_amount_currency` (Optional[str]): Currency code (USD, EUR).
- `website` (Optional[str]): Website (<= 255 chars).
- `address_street` (Optional[str]): Street (<= 255 chars).
- `address_city` (Optional[str]): City (<= 100 chars).
- `address_state` (Optional[str]): State (<= 100 chars).
- `address_country` (Optional[str]): Country (<= 100 chars).
- `address_postal_code` (Optional[str]): Postal code (<= 40 chars).
- `email_address` (Optional[str]): Primary email (<= 255 chars).
- `email_address_data` (Optional[List[Dict[str, Any]]]): Multiple email objects.
- `phone_number` (Optional[str]): Primary phone (<= 36 chars).
- `phone_number_data` (Optional[List[Dict[str, Any]]]): Multiple phone objects.
- `do_not_call` (Optional[bool]): Do not call flag.
- `description` (Optional[str]): Description / notes.
- `account_name` (Optional[str]): Account name (<= 255 chars).
- `assigned_user_id` (Optional[str]): ID of the assigned User record.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `campaign_id` (Optional[str]): Campaign ID.
- `target_list_id` (Optional[str]): Target list ID.
- `custom_fields` (Optional[Dict[str, Any]]): A dictionary of EspoCRM custom fields to update on the Lead record. All EspoCRM custom fields are prefixed with `c`.

Example Requests:
- Update a lead's name and email:
update_lead_tool(lead_id="abc123", first_name="Jane", last_name="Doe", email_address="jane@example.com")
- Update multiple fields including phone numbers:
update_lead_tool(lead_id="abc123", phone_number_data=[{"phoneNumber": "+123456789", "primary": True}], do_not_call=True)
- Update custom fields:
update_lead_tool(lead_id="6954254b5723b823f", custom_fields={"c_demo_url": "https://someurl", "c_score": 85})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

TargetLists

Create a new TargetList in EspoCRM.

Args:
- `name` (str): TargetList name.
- `category_id` (Optional[str]): TargetListCategory ID.
- `description` (Optional[str]): Description text.
- `source_campaign_id` (Optional[str]): Source Campaign ID.
- `assigned_user_id` (Optional[str]): Assigned User ID.
- `teams_ids` (Optional[List[str]]): Team IDs.
- `duplicate_source_id` (Optional[str]): Record ID of an entity being duplicated.
- `skip_duplicate_check` (Optional[bool]): Skip duplicate check.
- `custom_fields` (Optional[Dict[str, Any]]): EspoCRM custom fields prefixed with 'c'.

Example Requests:
- Create a simple TargetList:
`create_target_list_tool(name="Prospects 2026")`
- Create a TargetList with a category and assigned user:
`create_target_list_tool(name="Campaign Leads", category_id="cat123", assigned_user_id="user456")`
- Create a TargetList with custom fields:
`create_target_list_tool(name="Demo List", custom_fields={"c_priority": "High"})`

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Remove an existing TargetList record in EspoCRM.

Args:
- `target_list_id` (str): The ID of the TargetList to remove.

Example Request:
- delete_target_list_tool(target_list_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.
The `data` will always be True if deletion succeeded.

List TargetList records from EspoCRM with optional filtering, sorting, and pagination.

Args:
- `attribute_select` (Optional[List[str]]): Attributes to include in the response to improve performance.
- `bool_filter_list` (Optional[List[str]]): Boolean filters like `['onlyMy']`.
- `max_size` (Optional[int]): Maximum number of records to return (0–200).
- `offset` (Optional[int]): Pagination offset (0-based).
- `order` (Optional[str]): Sort direction, 'asc' or 'desc'.
- `order_by` (Optional[str]): Attribute to sort results by.
- `text_filter` (Optional[str]): Text search query. Supports wildcard `*`.
- `where_group` (Optional[List[Dict[str, Any]]]): Advanced deepObject filters.

Example Requests:
- Fetch first 50 TargetLists with selected attributes:
`list_target_lists_tool(attribute_select=["name", "assignedUserName"], max_size=50)`
- Fetch only TargetLists assigned to current user:
`list_target_lists_tool(bool_filter_list=["onlyMy"])`
- Fetch TargetLists using advanced whereGroup filter:
`list_target_lists_tool(where_group=[{"type": "equals", "attribute": "targetStatus", "value": "Listed"}])`

Returns:
- A dictionary containing TargetLists data and metadata.

Get a single TargetList record by ID from EspoCRM.

Args:
- `target_list_id` (str): The ID of the TargetList to fetch.

Example Request:
- get_target_list_tool(target_list_id="abc123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Update an existing TargetList record in EspoCRM.

Args:
- `target_list_id` (str): ID of the TargetList record to update.
- `name` (Optional[str]): Name of the TargetList.
- `category_id` (Optional[str]): ID of the TargetListCategory.
- `description` (Optional[str]): Description / notes.
- `source_campaign_id` (Optional[str]): Source campaign ID.
- `assigned_user_id` (Optional[str]): ID of the assigned User.
- `teams_ids` (Optional[List[str]]): List of Team IDs.
- `custom_fields` (Optional[Dict[str, Any]]): Dictionary of custom fields (must start with `c`).

Example Requests:
- Update name and assigned user:
update_target_list_tool(target_list_id="abc123", name="New List", assigned_user_id="user123")
- Update category and description:
update_target_list_tool(target_list_id="abc123", category_id="cat456", description="Updated description")
- Update custom fields:
update_target_list_tool(target_list_id="abc123", custom_fields={"c_priority": "High", "c_score": 90})

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Users

List User records in EspoCRM.

Args:
- `attribute_select` (Optional[List[str]]): List of User fields to include in the response.
- `bool_filter_list` (Optional[List[str]]): Boolean filters such as `['onlyMyTeam']`.
- `max_size` (Optional[int]): Maximum number of records to return (0-200).
- `offset` (Optional[int]): Pagination offset (0-based).
- `order` (Optional[str]): Sort direction: 'asc' or 'desc'.
- `order_by` (Optional[str]): Attribute to sort by.
- `primary_filter` (Optional[str]): Primary filter value.
- `text_filter` (Optional[str]): Text search query. Supports wildcard '*'.
- `where_group` (Optional[List[Dict[str, Any]]]): Deep object filters for complex queries.
- `x_no_total` (Optional[bool]): Disable total count calculation if True.

Example Requests:
- List all users:
list_users_tool()
- List users with only first and last names:
list_users_tool(attribute_select=["firstName", "lastName"])
- List active users only:
list_users_tool(primary_filter="active")

Returns:
- A dictionary with the API response containing keys: `status_code`, `ok`, `data`, `error`, `error_type`.

Get a single User record by ID from EspoCRM.

Args:
- `user_id` (str): The ID of the User to fetch.

Example Request:
- get_user_tool(user_id="user123")

Returns:
- A structured dict containing the API response with keys:
`status_code`, `ok`, `data`, `error`, and `error_type`.

Privacy Policy Terms and Conditions