# CRM — Companies & Contacts

> **TL;DR for agents:** `POST /api/companies`, `POST /api/contacts`. Same response shape as the LDM web UI — list endpoint returns `{ data, meta: { total, page, pageSize, totalPages } }`.

## List companies (paginated)

Scope: `crm:read`. Use `pageSize`, `page`, `search` query params.

```bash
curl -s "https://api.live-direct-marketing.online/api/companies?pageSize=10&search=acme" \
  -H "Authorization: Bearer $LDM_KEY"
```

## Create company

Scope: `crm:write`. Required: `name`. Optional: `domain`, `industry`, `phone`, `website`, `taxId`, custom fields.

```bash
curl -s -X POST "https://api.live-direct-marketing.online/api/companies" \
  -H "Authorization: Bearer $LDM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Acme Inc","domain":"acme.com","industry":"SaaS"}'
```

## Create contact attached to a company

Scope: `crm:write`. Channels (email/phone) are an array under `channels`.

```bash
curl -s -X POST "https://api.live-direct-marketing.online/api/contacts" \
  -H "Authorization: Bearer $LDM_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "firstName":"John","lastName":"Doe","companyId":"<uuid>",
    "channels":[{"type":"EMAIL","value":"john@acme.com","isPrimary":true}]
  }'
```
