KosmoKrator

crm

Affinity CLI for AI Agents

Use the Affinity CLI from KosmoKrator to call Affinity tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

8 functions 6 read 2 write API key auth

Affinity CLI Setup

Affinity can be configured headlessly with `kosmokrator integrations:configure affinity`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure affinity --set api_key="$AFFINITY_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor affinity --json
kosmokrator integrations:status --json

Credentials

Authentication type: API key api_key. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key AFFINITY_API_KEY Secret secret yes API Key

Call Affinity Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call affinity.affinity_list_contacts '{
  "limit": 1,
  "page": 1
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:affinity affinity_list_contacts '{
  "limit": 1,
  "page": 1
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs affinity --json
kosmo integrations:docs affinity.affinity_list_contacts --json
kosmo integrations:schema affinity.affinity_list_contacts --json
kosmo integrations:search "Affinity" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Affinity.

affinity.affinity_list_contacts

Read read

List contacts from Affinity CRM. Returns contact names, emails, phone numbers, and associated organizations. Use pagination to retrieve large result sets.

Parameters
limit, page

Generic CLI call

kosmo integrations:call affinity.affinity_list_contacts '{"limit":1,"page":1}' --json

Provider shortcut

kosmo integrations:affinity affinity_list_contacts '{"limit":1,"page":1}' --json

affinity.affinity_get_contact

Read read

Get details for a specific contact in Affinity by its ID. Returns the contact's full profile including name, emails, phone numbers, organization, and custom fields.

Parameters
id

Generic CLI call

kosmo integrations:call affinity.affinity_get_contact '{"id":1}' --json

Provider shortcut

kosmo integrations:affinity affinity_get_contact '{"id":1}' --json

affinity.affinity_create_contact

Write write

Create a new contact in Affinity CRM. Provide at least a first name or last name. Optionally include email addresses.

Parameters
first_name, last_name, emails, organization_ids

Generic CLI call

kosmo integrations:call affinity.affinity_create_contact '{"first_name":"example_first_name","last_name":"example_last_name","emails":"example_emails","organization_ids":"example_organization_ids"}' --json

Provider shortcut

kosmo integrations:affinity affinity_create_contact '{"first_name":"example_first_name","last_name":"example_last_name","emails":"example_emails","organization_ids":"example_organization_ids"}' --json

affinity.affinity_list_organizations

Read read

List organizations from Affinity CRM. Returns organization names, domains, and details. Use pagination to retrieve large result sets.

Parameters
limit, page

Generic CLI call

kosmo integrations:call affinity.affinity_list_organizations '{"limit":1,"page":1}' --json

Provider shortcut

kosmo integrations:affinity affinity_list_organizations '{"limit":1,"page":1}' --json

affinity.affinity_get_organization

Read read

Get details for a specific organization in Affinity by its ID. Returns the organization's full profile including name, domain, people, and custom fields.

Parameters
id

Generic CLI call

kosmo integrations:call affinity.affinity_get_organization '{"id":1}' --json

Provider shortcut

kosmo integrations:affinity affinity_get_organization '{"id":1}' --json

affinity.affinity_create_organization

Write write

Create a new organization in Affinity CRM. Provide a name (required) and optionally a domain.

Parameters
name, domain

Generic CLI call

kosmo integrations:call affinity.affinity_create_organization '{"name":"example_name","domain":"example_domain"}' --json

Provider shortcut

kosmo integrations:affinity affinity_create_organization '{"name":"example_name","domain":"example_domain"}' --json

affinity.affinity_list_lists

Read read

List all lists in Affinity CRM. Returns list names, types (contact or organization), and ownership details.

Parameters
none

Generic CLI call

kosmo integrations:call affinity.affinity_list_lists '{}' --json

Provider shortcut

kosmo integrations:affinity affinity_list_lists '{}' --json

affinity.affinity_get_current_user

Read read

Get the currently authenticated Affinity user's profile. Useful for verifying API credentials and identifying the active account.

Parameters
none

Generic CLI call

kosmo integrations:call affinity.affinity_get_current_user '{}' --json

Provider shortcut

kosmo integrations:affinity affinity_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

affinity.affinity_list_contacts

List contacts from Affinity CRM. Returns contact names, emails, phone numbers, and associated organizations. Use pagination to retrieve large result sets.

Operation
Read read
Schema command
kosmo integrations:schema affinity.affinity_list_contacts --json
ParameterTypeRequiredDescription
limit integer no Maximum number of contacts to return (default: 100, max: 500).
page integer no Page number for pagination (starts at 1).

affinity.affinity_get_contact

Get details for a specific contact in Affinity by its ID. Returns the contact's full profile including name, emails, phone numbers, organization, and custom fields.

Operation
Read read
Schema command
kosmo integrations:schema affinity.affinity_get_contact --json
ParameterTypeRequiredDescription
id integer yes The Affinity contact ID.

affinity.affinity_create_contact

Create a new contact in Affinity CRM. Provide at least a first name or last name. Optionally include email addresses.

Operation
Write write
Schema command
kosmo integrations:schema affinity.affinity_create_contact --json
ParameterTypeRequiredDescription
first_name string no The contact's first name.
last_name string no The contact's last name.
emails array no List of email addresses for the contact, e.g. ["[email protected]"].
organization_ids array no List of Affinity organization IDs to link this contact to.

affinity.affinity_list_organizations

List organizations from Affinity CRM. Returns organization names, domains, and details. Use pagination to retrieve large result sets.

Operation
Read read
Schema command
kosmo integrations:schema affinity.affinity_list_organizations --json
ParameterTypeRequiredDescription
limit integer no Maximum number of organizations to return (default: 100, max: 500).
page integer no Page number for pagination (starts at 1).

affinity.affinity_get_organization

Get details for a specific organization in Affinity by its ID. Returns the organization's full profile including name, domain, people, and custom fields.

Operation
Read read
Schema command
kosmo integrations:schema affinity.affinity_get_organization --json
ParameterTypeRequiredDescription
id integer yes The Affinity organization ID.

affinity.affinity_create_organization

Create a new organization in Affinity CRM. Provide a name (required) and optionally a domain.

Operation
Write write
Schema command
kosmo integrations:schema affinity.affinity_create_organization --json
ParameterTypeRequiredDescription
name string yes The organization's name.
domain string no The organization's website domain (e.g., "example.com").

affinity.affinity_list_lists

List all lists in Affinity CRM. Returns list names, types (contact or organization), and ownership details.

Operation
Read read
Schema command
kosmo integrations:schema affinity.affinity_list_lists --json
ParameterTypeRequiredDescription
No parameters.

affinity.affinity_get_current_user

Get the currently authenticated Affinity user's profile. Useful for verifying API credentials and identifying the active account.

Operation
Read read
Schema command
kosmo integrations:schema affinity.affinity_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.