Skip to content

Contacts API

Manage contacts and identity resolution.

Endpoints

MethodEndpointDescription
GET/api/agents/{id}/contactsList contacts
POST/api/agents/{id}/contactsCreate contact
GET/api/agents/{id}/contacts/{contactId}Get contact
PUT/api/agents/{id}/contacts/{contactId}Update contact
DELETE/api/agents/{id}/contacts/{contactId}Delete contact

List Contacts

bash
GET /api/agents/{id}/contacts?search=john&limit=50

Query Parameters

ParameterTypeDescription
searchstringSearch name, email, phone
tagstringFilter by tag
limitnumberMax results (default: 50)
offsetnumberSkip results

Response

json
{
  "contacts": [
    {
      "id": "contact-123",
      "name": "John Doe",
      "email": "john@example.com",
      "phone": "+1234567890",
      "telegram": "@johndoe",
      "tags": ["customer", "vip"],
      "created_at": "2024-12-01T00:00:00Z"
    }
  ],
  "meta": {
    "total": 500,
    "limit": 50,
    "offset": 0
  }
}

Create Contact

bash
POST /api/agents/{id}/contacts
Content-Type: application/json

Request Body

json
{
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "+1234567890",
  "telegram": "@johndoe",
  "whatsapp": "+1234567890",
  "twitter": "@johndoe",
  "external_id": "crm-123",
  "notes": "VIP customer",
  "tags": ["customer", "vip"],
  "metadata": {
    "company": "Acme Corp",
    "plan": "enterprise"
  }
}

Response

json
{
  "id": "contact-123",
  "name": "John Doe",
  "email": "john@example.com",
  "created_at": "2024-12-15T10:00:00Z"
}

Get Contact

bash
GET /api/agents/{id}/contacts/{contactId}

Response

json
{
  "id": "contact-123",
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "+1234567890",
  "telegram": "@johndoe",
  "whatsapp": "+1234567890",
  "twitter": "@johndoe",
  "external_id": "crm-123",
  "notes": "VIP customer",
  "tags": ["customer", "vip"],
  "metadata": {
    "company": "Acme Corp",
    "plan": "enterprise"
  },
  "created_at": "2024-12-01T00:00:00Z",
  "updated_at": "2024-12-15T10:00:00Z"
}

Update Contact

bash
PUT /api/agents/{id}/contacts/{contactId}
Content-Type: application/json

Request Body

json
{
  "name": "John D. Doe",
  "tags": ["customer", "vip", "enterprise"],
  "metadata": {
    "company": "Acme Corp",
    "plan": "enterprise",
    "mrr": 5000
  }
}

Delete Contact

bash
DELETE /api/agents/{id}/contacts/{contactId}

Contact Fields

FieldTypeDescription
namestringContact name (required)
emailstringEmail address
phonestringPhone number
telegramstringTelegram username
whatsappstringWhatsApp number
twitterstringTwitter handle
external_idstringExternal system ID
notesstringFree-form notes
tagsstring[]Array of tags
metadataobjectCustom metadata

Identity Resolution

Resolve contact by any identifier:

bash
GET /api/agents/{id}/contacts/resolve?email=john@example.com
GET /api/agents/{id}/contacts/resolve?phone=+1234567890
GET /api/agents/{id}/contacts/resolve?telegram=@johndoe

Response

json
{
  "contact": {
    "id": "contact-123",
    "name": "John Doe",
    "email": "john@example.com"
  },
  "matched_by": "email"
}

Import Contacts

bash
POST /api/agents/{id}/contacts/import
Content-Type: multipart/form-data

CSV Format

csv
name,email,phone,telegram,tags
John Doe,john@example.com,+1234567890,@johndoe,"customer,vip"
Jane Smith,jane@example.com,+0987654321,@janesmith,prospect

Export Contacts

bash
GET /api/agents/{id}/contacts/export?format=csv

Errors

CodeDescription
400Invalid contact data
404Contact not found
409Duplicate contact

Examples

Create with Metadata

bash
curl -X POST .../contacts \
  -d '{
    "name": "Jane Smith",
    "email": "jane@example.com",
    "metadata": {
      "source": "website",
      "campaign": "summer-2024"
    }
  }'

Search by Tag

bash
curl ".../contacts?tag=vip&limit=100"

Released under the MIT License.