# LDM Developer API — UI = MCP

LDM is a multi-tenant CRM and outbound mailing platform that exposes on the order of a thousand capabilities to autonomous agents through plain HTTPS. There is no separate "agent API" mirror to keep in sync — the human web UI and Claude / Cursor / your custom MCP client hit the same `/api/*` routes, with HybridAuthGuard resolving either a session cookie or a Bearer key to the same handler. Issue a key, grant scopes, and the agent can do everything the UI can: search and create companies, contacts, leads; manage pipelines; run mailing campaigns and self-approve them; tune anti-spam guardrails; pull exports; subscribe to webhooks.

> **TL;DR for agents:** Base URL: `https://api.live-direct-marketing.online`. Register with `POST /api/auth/register` → you get a Bearer `ldm_…` key alongside a PENDING account. Reads work immediately; sending and unavailable writes wait for activation. Then either call `/api/*` directly, or run `npx -y --package=@live-direct-marketing/sdk@latest ldm-mcp` in Claude Desktop / Cursor and let your agent use the tools.

## 60-second hello

```bash
# 1. Register — get a PENDING account + read-capable key
curl -X POST https://api.live-direct-marketing.online/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","termsAccepted":true,"channel":"mcp","use_case":"Automated CRM ops via MCP"}'
# => { "pending": true, "api_key": "ldm_...", "scope": [...], ... }

# 2. Hit any /api/* endpoint with that key
curl https://api.live-direct-marketing.online/api/companies?pageSize=5 \
  -H "Authorization: Bearer ldm_..."

# 3. Discover the live capability list (~1000 entries)
curl https://api.live-direct-marketing.online/.well-known/agent-card.json | jq .
```

## Plug into Claude Desktop / Cursor (MCP)

The whole API is also published as an MCP server — run it with `npx`, no install step, and your agent gets a tool per API operation, generated from the live agent card at connect time. No key yet? Skip `LDM_API_KEY` — the anonymous `ldm_terms` / `ldm_register` tools issue one without a human.

```json
// claude_desktop_config.json
{
  "mcpServers": {
    "ldm": {
      "command": "npx",
      "args": ["-y", "--package=@live-direct-marketing/sdk@latest", "ldm-mcp"],
      "env": { "LDM_API_KEY": "ldm_..." }
    }
  }
}
```

## Endpoint map

- `POST /api/auth/register` — self-serve account + key (agent channels get the key immediately). Public.
- `GET  /api/auth/me` — bearer-authenticated profile.
- `GET  /api/v1/health` — service liveness.
- `GET  /.well-known/agent-card.json` — LDM discovery (custom format), lists every `/api/*` capability with its scope. `GET /.well-known/agent.json` for the A2A-compliant variant.
- `/api/*` — the unified surface (companies / contacts / leads / pipelines / dialogs / mailing / exports / webhooks / ai / suppression / files / …). Same routes the UI calls.

## Where to read next

- **Get started** → [Quickstart](/quickstart), [Authentication](/authentication), [Agent Card](/agent-card)
- **CRM** → [Companies & Contacts](/crm-companies), [Leads & Pipelines](/leads-pipeline), [Pipelines & Stages](/pipelines-stages), [Activities](/activities), [Tags & Saved Views](/tags-views), [Custom Fields](/custom-fields)
- **Dialogs / Mail** → [Dialogs](/dialogs), [Mailing Campaign](/mailing-flow), [Tasks (lifecycle)](/tasks-campaigns)
- **Content** → [Briefs & Creatives](/briefs-creatives), [Files](/files)
- **Compliance & integrations** → [Anti-spam](/anti-spam), [Webhooks](/webhooks), [AI keys](/ai-keys), [Connectors](/connectors), [Best send time](/best-send-time)
- **Reference** → [Limits](/limits), [Errors](/errors)
