# Contacts and companies API

Create, update, import, and erase customer contacts, companies, notes, custom attributes, tracked events, and audiences over the dimmi REST API.

## Attribute definitions

- `GET /attribute-definitions` - List custom attributes: Lists the custom attributes contacts and companies carry, each with its key, type and list values. Keys already in use without a definition are added as observed. Audience rules read them as contact.custom.<key> and company.custom.<key>. Returns the definitions, with status active or archived and whether browsers may write them.
- `POST /attribute-definitions` - Define a custom attribute: Defines a custom attribute so its values are typed and checked, and audience rules and filters can offer it. Its key and type never change afterwards. Values are set with PATCH /contacts/{contact} or PATCH /companies/{company}. Returns the definition.
- `PATCH /attribute-definitions/{attribute}` - Update a custom attribute: Changes a custom attribute's label, description or list values, archives it to stop new values while keeping old ones, or lets browsers write it. Archiving is refused while an audience or workflow reads it. Returns the definition as it now is.
- `DELETE /attribute-definitions/{attribute}` - Delete a custom attribute: Deletes an archived custom attribute and removes its value from every contact or company for good. Archive it with PATCH /attribute-definitions/{attribute} first.

## Attribute problems

- `GET /attribute-problems` - List dropped attribute values: Lists custom attribute values dimmi refused in the last 30 days: a wrong type, a value not in the list, a write to an archived attribute or past the key limit. Use it when values seem missing. Returns the problems by attribute and code, with counts, a sample value and when last seen.

## Audiences

- `GET /audiences` - List audiences: Lists the saved audiences: named rules selecting contacts, used by workflows, the messenger, help articles and the AI agent wherever dimmi asks who. Returns the audiences with their rules and last estimated size.
- `POST /audiences` - Create an audience: Saves a named rule selecting contacts by their details, custom attributes, events, tags and company. Membership is never stored: it always means who matches now. Check the rule with POST /audience-previews first. Returns the audience.
- `POST /audiences/{audience}/freezes` - Tag everyone in an audience: Puts a tag on everyone a saved audience matches right now, so the group stays fixed while the audience keeps changing. Later joiners are not tagged. Returns the tag and how many people matched and were tagged.
- `GET /audiences/{audience}` - Get an audience: Reads one saved audience with its rule and what uses it: workflows and other audiences. Returns the audience with used_by and lock_version.
- `PATCH /audiences/{audience}` - Update an audience: Changes a saved audience's name, description or rule. Everything using it follows the change at once, so check what uses it with GET /audiences/{audience} first. Returns the audience with its new lock_version.
- `DELETE /audiences/{audience}` - Delete an audience: Deletes a saved audience. Refused while a live workflow or another audience uses it.

## Companies

- `GET /companies` - List companies: Lists the companies your customers belong to. q searches by name or domain. Returns a page of companies, with next_cursor for more.
- `GET /companies/{company}/notes` - List a company's notes: Lists what the team wrote about a company, the pinned note first, then newest first. Returns the notes with their author and when they were written.
- `GET /companies/{company}/series` - List a company's series: Lists the account series a company is or was on, and where it stands on each. Returns the company's journeys with their series, step and status.
- `GET /companies/{company}/contacts` - List a company's people: Lists the contacts linked to one company, newest first. Returns a page of contacts, with next_cursor for more.
- `GET /companies/{company}/conversations` - List a company's conversations: Lists the conversations of all the company's people that you may see, newest first. Returns a page of conversations, with next_cursor for more.
- `POST /companies` - Add a company: Adds a company. With upsert=true it finds the company by external id, then domain, and updates it instead, so it is safe to repeat. Link people to it with PATCH /contacts/{contact}. Returns the company, and with upsert meta.upserted (created or updated).
- `POST /companies/{company}/notes` - Add a note about a company: Writes a note only the team sees about a company.
- `GET /companies/{company}` - Get a company: Reads one company: name, domain, external id, custom attributes, tags and notes. Returns the company.
- `PATCH /companies/{company}` - Update a company: Changes a company's details, custom attributes, notes or tags. Only sent fields change. Returns the company as it now is.
- `DELETE /companies/{company}` - Delete a company: Deletes a company. Its people stay as contacts without a company, and their conversations are untouched.

## Contact erasures

- `GET /contact-erasures` - List erasure requests: Lists the workspace's requests to erase customers and where each stands. Returns a page of erasure requests, newest first.
- `GET /contact-erasures/{contact_erasure}` - Get an erasure request: Reads one erasure request: its customer, status, when the wipe is due and what it removed. Returns the erasure request.
- `PATCH /contact-erasures/{contact_erasure}` - Cancel an erasure: Withdraws an erasure still in its grace period: the customer comes back as they were. A completed erasure cannot be undone. Returns the request, now canceled, with identities_conflicted listing addresses someone else took meanwhile, to merge by hand.

## Contact events

- `POST /contact-events` - Record a contact event: Records something a person did in your product, such as signed_up or upgraded, one event or up to 100 under events. Audience rules see it at once as event.<name>.count, first_at and last_at. A new name is defined on its first event. Returns accepted, and per event its status: accepted, duplicate, contact_not_found, archived or event_limit_reached.

## Contact lists

- `POST /contact-lists` - Tag customers from a CSV: Puts one tag on every existing customer an uploaded CSV names, by email or user id. It needs a multipart form with the CSV in the field named file (at most 5 MB and 50,000 rows) and the tag's name in the field named tag, and the contacts:write ability. Customers not in the workspace are counted, never created. Returns the tag with how many rows matched, were tagged and were not found.

## Contact notes

- `PATCH /contact-notes/{note}` - Change a note: Changes a customer or company note's text, or pins it so it shows first.
- `DELETE /contact-notes/{note}` - Delete a note: Deletes a customer or company note.

## Contacts

- `GET /contacts` - List contacts: Lists the workspace's customers (users, who have an external id) and leads, most recently seen first. Blocked contacts stay out unless filter[blocked]=true. To match a custom attribute, send filter[custom.<key>], such as filter[custom.plan]=pro, three at most. To find people by a saved rule, pass conditions with an audience, or use POST /audience-previews to only count them. Returns a page of contacts with their attributes, tags and company, and next_cursor for more.
- `GET /contacts/{contact}/notes` - List a customer's notes: Lists what the team wrote about a customer, the pinned note first, then newest first. Returns the notes with their author and when they were written.
- `GET /contacts/{contact}/series` - List a contact's series: Lists the series a contact is or was on, and where they stand on each. Returns the contact's journeys with their series, step and status.
- `GET /contacts/{contact}/duplicates` - Find duplicate contacts: Lists contacts that look like the same person as this one, such as a lead who typed the address of an existing user, with the reasons. Nothing is merged; a teammate decides. Returns up to 20 likely duplicates with their reasons, strongest first.
- `GET /contacts/{contact}/identities` - List a contact's identities: Lists how a customer appears on channels: email addresses, phone numbers, chat app users. Messages from any of them land in this contact's history. Returns the identities, with their ids.
- `GET /contacts/{contact}/conversations` - List a contact's conversations: Lists the conversations of one customer that you may see, newest first. Returns a page of conversations, with next_cursor for more.
- `GET /contacts/{contact}/event-summaries` - Summarize a contact's events: Says what one person did in your product: for each event name, how many times overall and in the last 7 and 30 days, and when first and last. Audience rules read the same counts. Returns one summary per event name, with the last event's metadata.
- `POST /contacts` - Add a contact: Adds a customer or lead. With upsert=true it finds the contact by external id, then by a proven email, and updates it instead, so it is safe to repeat. Typed-in lead emails are never merged; they come back as possible duplicates. Returns the contact, and with upsert meta.upserted (created or updated) and possible_duplicates.
- `POST /contacts/{contact}/notes` - Add a note about a customer: Writes a note only the team sees about a customer, such as context for the next teammate.
- `POST /contacts/{contact}/merges` - Merge a duplicate contact into this one: Folds source_id into this contact: conversations, identities, tags and event counts move over, this contact's details win and the source only fills blanks. The source keeps pointing here. Two users with different external ids cannot be merged. Returns this contact as it is now.
- `POST /contacts/{contact}/exports` - Export a customer's data: Starts building a zip of everything dimmi holds about one customer, to answer their request for a copy of their data. It is built in the background and kept for a day once ready. Returns the export with status pending.
- `POST /contacts/{contact}/companies` - Add a company to a contact: Links a contact to one more company. A contact can belong to several; one is the default, which conversations and tickets take when they start. The first company becomes the default. Returns the contact as it now is, with all its companies.
- `POST /contacts/{contact}/companies/{company}/default` - Make a company a contact's default: Makes one of the contact's companies its default: company_id and company on the contact then name it, and new conversations and tickets take it. Past ones keep theirs. Returns the contact as it now is, with all its companies.
- `GET /contacts/{contact}` - Get a contact: Reads one customer or lead: details, custom attributes, tags, company and notes. Returns the contact.
- `GET /contacts/{contact}/exports/{export}` - Get a customer's export: Reads where a customer's export stands: pending, running, ready, failed or expired. Returns the export, with when it expires once ready.
- `PATCH /contacts/{contact}` - Update a contact: Changes a contact's details, custom attributes, notes, tags, company or blocked state. Only sent fields change. Setting an external id turns a lead into a user; an existing one never changes. Returns the contact as it now is.
- `DELETE /contacts/{contact}` - Delete or erase a contact: Without erase, removes a contact added by mistake and only if it has no conversations. With erase=true, starts a privacy erasure: the person vanishes from lists now, and after a grace period every message, file and record of them is wiped for good. Use only when the person asked. Returns nothing for a plain delete, or the erasure request with its scheduled_for time.
- `DELETE /contacts/{contact}/widget-sessions` - Sign a contact out of the messenger: Ends every messenger session the contact has on your sites, such as after an account compromise. They must sign in again with a fresh identity token to keep chatting. Returns sessions_revoked, how many sessions ended.
- `DELETE /contacts/{contact}/companies/{company}` - Remove a company from a contact: Unlinks a contact from one company. When it was the default, the company linked longest becomes the default, or the contact has none left. Returns the contact as it now is, with all its companies.
- `DELETE /contacts/{contact}/identities/{identity}` - Detach a contact identity: Detaches an address or account attached to the wrong customer. The next message from it starts a new lead instead of joining this contact's history; past messages stay where they are.
- `GET /contacts/{contact}/exports/{export}/download` - Download a customer's export: Fetches the zip of a customer's data, to hand to that customer. It holds all their personal data, so fetch it only for the person answering the request. Returns the zip.

## Event definitions

- `GET /event-definitions` - List event names: Lists the names of the events your product reports, with how many arrived and when last. Returns the event definitions, with status active or archived.
- `PATCH /event-definitions/{event}` - Update an event name: Changes an event name's label or description, or archives it to stop recording new events of it. Counts already kept still answer audience rules. Returns the event definition.

## Event settings

- `GET /event-settings` - Get the messenger event settings: Reads whether the messenger may record event names nobody defined yet. Returns the event settings.
- `PATCH /event-settings` - Change the messenger event settings: Turns on or off accepting any event name sent from the messenger; when off, only names marked writable from the messenger are recorded. Returns the event settings.

## Imports

- `GET /imports` - List imports: Lists the latest imports of customers or companies with where each stands. Imports need imports:manage. Returns up to 20 imports, newest first.
- `POST /imports` - Upload an import file: Uploads a CSV of contacts or companies and keeps it as a draft import to map and run next. It needs a multipart form with the CSV in the field named file (at most 10 MB and 50,000 rows) and a field named kind set to contacts or companies, and the contacts:write ability. Returns the draft import.
- `POST /imports/{import}/runs` - Start an import: Starts a draft import in the background with the mapping and mode given. An import runs once. Returns the import with status queued; poll it for progress.
- `POST /imports/{import}/previews` - Dry run an import: Runs a mapping over every row without writing anything and counts what would be created, updated, skipped or refused. Returns the counts and the first refused rows with why.
- `POST /imports/{import}/rollbacks` - Undo an import: Undoes a finished import within 7 days, in the background: removes the records it created unless changed or talked to since, puts back the values it changed unless changed again, and takes off the tags it added. Needs imports:rollback. Returns the import with rollback.status queued; poll it for the counts removed, reverted and kept.
- `GET /imports/{import}` - Get an import: Reads one import: its columns, mapping, progress, counts and first failed rows. Returns the import with status draft, queued, running, completed or failed.
- `GET /imports/{import}/errors` - Download an import's failed rows: Fetches a CSV of the rows that failed, each with its line in the file and why. Returns the CSV.

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
