Skip to content
Documentation
Hevia for developers

Sync contacts

Keep your CRM and Hevia in step: an initial import, then only what changed.

Scopes: contacts:read to read, contacts:write to write.

1. Pull everything once

import { HeviaClient } from "@hevia/sdk";

const hevia = new HeviaClient({ apiKey: process.env.HEVIA_KEY!, version: "2026-11-09" });
const startedAt = new Date().toISOString();
for await (const contact of hevia.contacts.listAll({ limit: 100 })) {
  await myCrm.upsert({ heviaId: contact.id, email: contact.email, name: contact.name });
}
await saveCursor(startedAt);

Remember the time before you started, not after: changes during the import are picked up by the next run.

2. Then only the changes

Shell
curl "https://hevia.app/api/v1/contacts?updated_since=2026-11-10T08:00:00Z&limit=100" \
  -H "Authorization: Bearer $HEVIA_KEY"

3. Write back

POST /contacts matches by e-mail address or phone number: an existing contact is updated, otherwise one is created (created in the answer says which).

Shell
curl -X POST "https://hevia.app/api/v1/contacts" \
  -H "Authorization: Bearer $HEVIA_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: crm-4711" \
  -d '{"name":"Anna Example","email":"anna@example.com","tags":["newsletter"]}'
Tip

Subscribe to the contact.created webhook to hear about new contacts at once instead of polling. Keep the updated_since run for changes: contact.updated is planned, not live.

Generated from the product's own registries, so the reference matches the API.