dhaga.docs
Using Dhaga

REST API and webhooks

Read and write contacts, notes and follow-ups over a JSON REST API with scoped keys, and get signed webhooks when something changes — for Zapier, Make or your own code.

MCP lets an AI assistant work in your network. The REST API and webhooks are for everything else: a Zapier or Make scenario, a spreadsheet sync, a script of your own.

  • The API lives at /api/v1 on your instance and speaks JSON.
  • Webhooks POST a signed event to a URL you choose when a contact, note or follow-up changes.

Both are set up under Settings → Connectors → API & webhooks.

What it costs

On a hosted instance, the API and webhooks are part of Pro and Power, and of every team seat — the same gate as MCP, with no extra charge for team plans. A key whose owner no longer has the plan gets 403 planRequired until the plan is active again.

Keys

Create a key in Settings. You choose:

  • a name — so you can tell your keys apart later;
  • scopes — what the key may do (below). Start with the least you need;
  • an expiry — 30, 90 or 365 days. Every key expires.

The key is shown once. Dhaga stores only a hash of it, so copy it before you leave the page. Revoke a key at any time from the same card; it stops working on the next request. You can hold up to 10 unexpired keys; revoke one to make room for another. Revoking a key does not remove webhook endpoints created with it — delete those separately.

Send it as a bearer token:

curl https://your-instance.example.com/api/v1/contacts \
  -H "Authorization: Bearer dhaga_EXAMPLEKEY"

Scopes

ScopeAllows
contacts:readList and read contacts and companies
contacts:writeCreate and update contacts
notes:readList a contact's notes
notes:writeAdd a note to a contact
followups:readList follow-ups
followups:writeCreate and close follow-ups
webhooks:manageList, add and remove webhook endpoints

A request without the scope it needs is refused with 403 insufficientScope.

Workspaces

A key acts in the workspace it was created in. Made in your personal workspace, it reads and writes your personal contacts. Made while an organization is active, it reads and writes that organization's — and only owners, admins, or a custom role with Manage API keys and webhooks can create one there. If you leave the organization or lose that permission, its keys stop working at once (403 workspaceRevoked).

An id from the other workspace answers 404, the same as an id that does not exist. In an organization you can read every contact and follow-up, but you can only change the ones you added: updating a colleague's contact or closing a colleague's follow-up also answers 404.

Personal access tokens (Settings → Account → API keys, used by the mobile app and local MCP clients) are a different thing: they have no scopes, so they are refused by /api/v1 (403 legacyKey), and API keys are refused by MCP and the older routes.

Requests and responses

Bodies are JSON. Unknown fields are an error, so a typo is caught instead of being silently dropped. Every success is JSON; every refusal is the same shape:

{ "error": { "code": "insufficientScope", "message": "This API key does not have the scope this request needs." } }
StatuscodeMeaning
400invalidRequestBad JSON, a bad field (named in details), a bad cursor or limit
401unauthorized, invalidKeyNo key, or one that is unknown, revoked or expired
403insufficientScope, legacyKey, workspaceRevoked, planRequired, pendingApprovalThe key is real but may not do this
404notFoundNo such row in the key's workspace
413tooLargeRequest body over 64 KB
429rateLimitedOver 60 requests a minute for this key, or 120 a minute across all your keys — wait Retry-After seconds
503busyDhaga is busy — retry in a few seconds

Pagination

Lists return one page and a cursor:

{ "data": [ { "id": "c_example" } ], "nextCursor": "WyIyMDI2LTAxLTAxIDAwOjAwOjAwKzAwIiwiY19leGFtcGxlIl0" }

Pass ?cursor= with that value for the next page; nextCursor is null on the last one. ?limit= is 1–100 (default 50). Treat the cursor as opaque.

Endpoints

Contacts

MethodPathScope
GET/api/v1/contactscontacts:read
POST/api/v1/contactscontacts:write
GET/api/v1/contacts/{id}contacts:read
PATCH/api/v1/contacts/{id}contacts:write

GET /api/v1/contacts lists oldest change first, and takes ?tag= and ?updated_since= (ISO 8601) — so "everything that changed since my last run" is one loop.

A contact:

{
  "id": "c_example",
  "name": "Example Person",
  "title": "Head of Partnerships",
  "companyId": "co_example",
  "location": "Pune",
  "tags": ["conference"],
  "emails": ["person@example.com"],
  "phones": ["+1 555 0100"],
  "links": ["https://example.com/profile"],
  "createdAt": "2026-11-14T09:00:00.000Z",
  "updatedAt": "2026-11-14T09:00:00.000Z"
}

Create with name (required) and any of title, company, location, emails, phones, links, tags:

curl -X POST https://your-instance.example.com/api/v1/contacts \
  -H "Authorization: Bearer dhaga_EXAMPLEKEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Example Person","company":"Example Co","emails":["person@example.com"],"tags":["conference"]}'

PATCH changes only what you send: name, title, company, location, customFields; and adds or removes list items with addTags / removeTags, addEmails / removeEmails, addPhones / removePhones, addLinks / removeLinks. Nothing you leave out is touched.

Companies

MethodPathScope
GET/api/v1/companiescontacts:read
GET/api/v1/companies/{id}contacts:read

Notes

MethodPathScope
GET/api/v1/contacts/{id}/notesnotes:read
POST/api/v1/contacts/{id}/notesnotes:write

Post { "body": "Met at the meetup; wants the pricing deck." }. The note is stored as written. No AI runs on it — open it in Dhaga to pull out facts and follow-ups when you want them. In an organization, a note added through the API is private to you until you publish it, like any note.

Follow-ups

MethodPathScope
GET/api/v1/follow-upsfollowups:read
POST/api/v1/follow-upsfollowups:write
POST/api/v1/follow-ups/{id}/closefollowups:write

GET takes ?status=open (default) or all, and ?contact_id=. Create with { "action": "Send the deck", "contactId": "c_example", "dueDate": "2026-12-01" } (contactId and dueDate optional). Close with { "status": "done" } or { "status": "dismissed" }; for a repeating follow-up, also send its current expectedDueDate so a retried request cannot complete the next occurrence.

Webhook endpoints

MethodPathScope
GET/api/v1/webhookswebhooks:manage
POST/api/v1/webhookswebhooks:manage
DELETE/api/v1/webhooks/{id}webhooks:manage

POST takes { "url": "https://hooks.example.com/dhaga", "events": ["contact.created"] } and answers the endpoint plus its secret — the only time the secret is shown.

Webhooks

Add an endpoint in Settings (or with the API above): an https URL and the events you want. Dhaga shows its signing secret once.

EventWhen
contact.createdA contact is created
contact.updatedA contact is edited
contact.deletedA contact is deleted
note.createdA note is added
followup.createdA follow-up is created
followup.completedA follow-up is marked done

Each delivery is a POST with this body:

{
  "id": "evt_example",
  "event": "contact.updated",
  "createdAt": "2026-11-14T09:00:00.000Z",
  "workspace": { "kind": "personal" },
  "data": { "id": "c_example", "changed": ["name", "location"] }
}

Payloads carry ids, never data. data holds the id of what changed (and the contact a note or follow-up belongs to, and the names of changed fields when known) — never a name, an email or a note. Fetch the record with an API key. That way a webhook can never show a receiver more than a key's scopes would.

An organization's endpoints get that organization's events. If the person who added an endpoint leaves the organization or loses Manage API keys and webhooks, the endpoint is switched off (shown as Off in Settings) and gets no more events, including retries already queued. A note there is private until its author publishes it, so a new note emits no event to the organization's endpoints.

"Send test event" in Settings delivers a webhook.test event to one endpoint.

An automation with a Send a webhook step delivers a crm_rule.fired event to the one endpoint you picked in it, whatever events that endpoint is subscribed to. Its data holds the record's id, the automation's ruleId, the trigger, a record with its type and id, the contactId (the person, a deal's first person, or null for a company), and the pipelineId, stageId or tag involved. It's signed and retried like any other event.

Delivery and retries

Answer with any 2xx within 5 seconds. Redirects are not followed. Anything else is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 18 hours — seven attempts over about a day — then marked failed. Recent deliveries and their outcomes are listed in Settings and kept for 30 days.

The same event can arrive twice (a retry after a timeout you did answer). Use the body's id to ignore duplicates.

Endpoints must be public: Dhaga refuses http, credentials in the URL, ports other than 443 and 8443, and any name that resolves to a private, loopback, link-local or cloud-metadata address — checked when you add the endpoint and again on every delivery.

Verifying the signature

Every delivery carries:

  • dhaga-signature: t=1763110800,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
  • dhaga-event — the event name
  • dhaga-delivery — this delivery's id

v1 is the hex HMAC-SHA256 of t, a dot, and the raw request body, keyed by your endpoint's secret. Verify it against the raw bytes before parsing JSON, compare in constant time, and reject a t more than 5 minutes old.

Node.js:

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyDhaga(rawBody, header, secret, toleranceSec = 300) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
  const given = Buffer.from(parts.v1 ?? "", "hex");
  return given.length === expected.length && timingSafeEqual(given, expected);
}

Python:

import hashlib, hmac, time

def verify_dhaga(raw_body: bytes, header: str, secret: str, tolerance_sec: int = 300) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    t = int(parts.get("t", "0"))
    if abs(time.time() - t) > tolerance_sec:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))

The secret looks like whsec_ followed by 64 hex characters. Keep it on your server; anyone holding it can forge deliveries to your endpoint. To rotate it, add a new endpoint and delete the old one.