Contacts, Notes and Leads
Your agent already collects the people it talks to. With the Public API your CRM or automation can read them, keep their details current, write notes your team sees in the dashboard, create leads and move them through the statuses you set up, one at a time or many at once, and change when the AI saves a lead. Every endpoint lives under one agent: /v1/agents/{agentId}/….
How do contacts, notes and leads fit together?
- A contact is a person. Mojeeb creates one the first time someone messages the agent or a lead is saved, and recognises them again by their WhatsApp number, Facebook or Instagram id, or phone. That is why the API can update a contact but not create one.
- Notes live on the contact. One timeline follows the person across every conversation and lead. It holds notes written by your team or your integration, and the status changes Mojeeb records when a lead moves.
- A lead is a sales opportunity in the dashboard's Clients table. It belongs to a contact, carries your custom fields, and moves through the statuses you defined for the agent.
See Contacts and Lead management for how your team uses them in the dashboard. To assign, filter and pin leads, or to change the agent's lead fields, see Lead Assignment, Filters and Fields.
How do I find a contact?
List the agent's contacts, newest first. Filter by channel, by search (name, mobile or email), or by creation date with date_from and date_to (dates in UTC, both days included).
curl "https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/contacts?search=sara&limit=20" \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE"
The response is a page: items, plus next_cursor and has_more. Pass next_cursor back as cursor to read the next page. Every field is in the List contacts reference.
How do I update a contact?
PATCH the contact with only the fields you want to change. custom_fields merges key by key, so you can set one field without resending the rest, and a null value clears that field. A mobile number must be E.164, such as +201001234567, and an empty string clears it; another format returns 422 invalid_request_body with param mobile.
curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/contacts/CONTACT_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "name": "Sara Example", "custom_fields": { "city": "Cairo" } }'
Email and the Facebook and Instagram ids stay read-only. The mobile can be changed, but it is how Mojeeb matches WhatsApp messages and new leads to this person, so change it only to correct a wrong number: afterwards, a WhatsApp message from the old number no longer matches this contact. See the Update contact reference.
How do I add a note my team will see?
POST the text to the contact's notes. It appears on the contact's timeline in the dashboard straight away.
curl -X POST https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/contacts/CONTACT_ID/notes \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "text": "Asked for a call back on Sunday." }'
A note written with a key is signed by the person who created the key. Only a note's author can edit or delete it, so a key can change that person's notes and no one else's. Status-change notes are records Mojeeb keeps, so nobody can edit or delete them. See the Notes reference.
How do I create a lead?
POST to the agent's leads. Every field is optional. The lead starts in the agent's starting status (new unless your team chose another), unassigned. A phone, when you send one, must be a valid number in E.164, as in the example; Mojeeb links the lead to the contact with that number, or creates a new contact. Another format returns 422 invalid_request_body with param phone. An empty string is the same as leaving the phone out when you create a lead, and clears the phone when you update one.
curl -X POST https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/leads \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "name": "Sara Example", "phone": "+201001234567", "summary": "Wants a quote for 20 units." }'
The response is 201 Created with the lead. See the Create lead reference.
How do I link a lead to the conversation it came from?
Send conversation_id when you create the lead. The lead then takes the chat's contact, assignee and ad, exactly as a lead the AI saves does, and your team sees a button that opens the chat from the lead. This matters most on Instagram and Facebook, where a chat's contact has no phone: without conversation_id, the phone you send would create a second, empty contact. A phone or name you send with it fills the chat's contact where it has none.
A conversation can hold several leads, as it can hold several tickets: one per request the person made. Creating with conversation_id always makes a new lead and never changes one the conversation already has; to change a lead, PATCH it. To see what a conversation already has, GET /v1/agents/{agentId}/conversations/{conversationId}/leads returns its leads, newest first (an empty list when it has none). See the List a conversation's leads reference. A retried POST creates a second lead, so after a lost response read that list before you send it again.
To link a lead you already created, PATCH it with conversation_id. It moves to the chat's contact, and a name or phone sent in the same request lands on that contact. Where the chat's contact has no name or phone, it takes those of the contact the lead left, so the phone stays on the lead. The contact the lead left stays as it is, with its notes: notes belong to a contact, so notes written before the link stay on the old contact's timeline.
Instead of a conversation you can send contact_id, to make the lead about that contact with no phone match. Send at most one of the two. Each returns 422 invalid_request when the conversation or contact belongs to another agent. A PATCH also returns it when the lead is already on a different conversation; the conversation may already have other leads.
How do I move a lead to another status?
PATCH the lead with its new status. The status must be the value of one of the options of the field keyed status in List lead fields, and a move your team's status flow doesn't allow may be refused. If the list has no status field, or that field has no options, the agent uses the statuses new, processing and completed, and a new lead starts in new.
curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/leads/LEAD_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "status": "processing" }'
Mojeeb records the change on the contact's timeline when the lead has a contact. A move to a status the agent doesn't have, or a refused move, returns 422 invalid_request and changes nothing. Each status option also carries final: true on a status your team counts as finished, which the dashboard hides by default and leaves off its activity cards.
In List lead fields, fields with built_in: false are the ones your team added; use their keys in custom_fields. Mojeeb keeps each value as you send it and doesn't check it against the field's type, options or required, so validate against that list before you write. To add, change or remove those fields, see Lead Assignment, Filters and Fields.
How do I delete a lead?
DELETE the lead. It is permanent: there is no undo, and a second delete of the same lead returns 404 not_found. The contact, its notes and the conversation stay, so the person and their history remain in the dashboard.
curl -X DELETE https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/leads/LEAD_ID \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE"
The response is 204 with no body. Status-change notes that name the lead stay on the contact's timeline. If the AI later saves a lead from the same conversation, it is a new lead with a new id. To take a lead out of your team's open work without losing it, move it to a finished status (one whose option has final: true) instead, or many leads at once. See the Delete a lead reference.
How do I change when the AI saves a lead?
Replace the lead capture prompt. Every agent has the built-in Capture Lead tool, and its prompt tells the AI when a conversation holds a lead and what to write in the lead's summary. It is the same text your team edits under Clients → ⋮ → AI Instructions in the dashboard. Read it with GET and replace it with PATCH.
curl -X PATCH https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/lead-capture \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "prompt": "Capture a lead when the customer shares a phone number and asks about prices. In the summary, say what they want and by when." }'
The AI follows the new prompt on its next replies, usually within a minute, and sending the prompt the agent already has changes nothing. Mojeeb stores it without leading or trailing spaces and line breaks. Only the prompt can change: the tool's other settings, its on/off switch included, stay in the dashboard. For the length limits, see the Update the lead capture prompt reference; the Get the lead capture prompt reference covers reading it.
How do I know which ad brought a contact or a lead?
Contacts and leads carry attribution, the same block a conversation has: origin is the touch that first brought the person in and latest the most recent one. For a lead it describes the conversation the lead came from, so the source ad of every lead is one field away: attribution.origin.ad.title and meta_ad_id, the id Ads Manager shows. A touch that was not an ad, such as a link, your website chat or a private reply to a comment, has kind set and ad null. Both touches are null when nothing is known, and the block is null on the response to a write. See Conversations for the kinds, and the Get a contact and Get a lead references.
How do I find leads with no recent activity?
Every lead carries last_activity_at: the last time a person worked it, by changing its status or adding a note on its contact. A new lead's is its creation. List leads with last_activity_before set to a past instant, and only those nobody has touched since then come back. Add status to keep to the stages your team still works.
curl "https://api.mojeeb.app/v1/agents/$AGENT_ID/leads?status=processing,no_answer&last_activity_before=2026-10-29T00:00:00Z" \
-H "Authorization: Bearer $MOJEEB_API_KEY"
last_activity_since does the opposite: leads worked after an instant, such as the ones touched today. Both take ISO 8601 with an offset (Z for UTC). AI replies, AI lead capture, pins and assignment don't move last_activity_at; updated_at moves on any change at all. See the List leads reference.
How do I change the status of many leads at once?
POST to leads/change-status with the statuses to take leads from in status and the new one in new_status. It takes the same filters as listing leads, so listing leads with the same query shows the leads it changes. There is no undo, so send a dry run first: dry_run: true counts the leads that would change and changes nothing.
curl -X POST "https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/leads/change-status?status=processing,no_answer&last_activity_before=2026-10-07T00:00:00Z" \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "new_status": "completed", "dry_run": true }'
The response's changed says how many leads would change. Then send the same query with dry_run: false and that number as max_changes:
curl -X POST "https://api.mojeeb.app/v1/agents/YOUR_AGENT_ID/leads/change-status?status=processing,no_answer&last_activity_before=2026-10-07T00:00:00Z" \
-H "Authorization: Bearer mk_live_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "new_status": "completed", "dry_run": false, "max_changes": 42 }'
If the dry run says 0, there is nothing to change: don't send the real call (max_changes must be at least 1). If more leads would change than max_changes, because new leads arrived or leads crossed into the time window since the dry run, the call returns 409 too_many_leads and changes nothing: send a dry run again, confirm the new number, then call with it. Never raise max_changes without confirming.
statusis required, so a call always names the statuses it takes leads from; without it the call returns422 invalid_request_bodywithparamstatus.limitandcursoraren't taken (422 invalid_request_body). An unknownnew_statusreturns422 invalid_request, and its message lists the agent's statuses.- Leads already in
new_statusare left alone and not counted. - Each lead that changes gets a status-change note on its contact's timeline, as a single status change does, and a new
last_activity_at. Nobody is assigned, and your team's status flow (the moves it allows) isn't applied. - It takes the
leads:writescope and Admin rank on the agent, as in the dashboard; a key acts as an admin on its agents. - Leads change in batches of 1,000. If a call fails part way, the leads already changed stay changed: send a dry run again to see how many are left, then the call with that count.
See the Change the status of many leads reference.
Common questions
Does updating a lead through the API assign it to someone?
No. When a teammate edits an unassigned lead in the dashboard, the lead becomes theirs. An edit through the API never assigns the lead, so your integration doesn't silently hand leads to the person who created the key. To assign a lead on purpose, use its assign endpoint; see Lead Assignment, Filters and Fields.
Why can't I create a contact?
Mojeeb creates contacts itself so one person stays one contact across channels. To add someone by hand, create a lead with their phone number, including the country code: Mojeeb links it to the contact with that number, or creates one.
What does null in custom_fields do?
It sets that one field to null; the key stays. Fields you leave out keep their values. This works the same way for contacts and leads.
Why do some leads always come first?
Pinned leads come first, on the first page only, then the rest newest first; each lead's pinned field says which, and PATCH with pinned pins or unpins a lead. Later pages never contain pinned leads, so if your team pins more leads than your limit, the extra ones aren't returned: use a limit above that number, up to the maximum in the List leads reference.
Can I delete a lead or a contact?
A lead, yes: DELETE removes it permanently, with no undo. A contact, no: deleting a person's record stays in the dashboard, where someone confirms it. You can also delete notes your key's creator wrote.
Why does lead capture return 404 lead_capture_not_found?
The agent has no Capture Lead tool, so it has no lead capture prompt, and its AI doesn't save leads from conversations either. Every agent gets the tool when it is created; if one is missing, contact Mojeeb support to add it.
What if Capture Lead is switched off?
The API still reads and replaces its prompt, but the AI saves no leads until someone switches the tool back on from its card on the Tools page. A key can't switch it, and GET on the lead capture prompt doesn't say whether the tool is on: check its card.
Can I change what Capture Lead saves or where it sends leads?
Where it sends them, no: every capture lands in the agent's Clients table. What it saves follows your lead fields: add, change or remove them through the API (see Lead Assignment, Filters and Fields) or under Edit Columns in the dashboard. The prompt decides when to save and what goes in the summary.
Why does a contact from another agent return 404?
Every contact, note and lead belongs to one agent. Asking for one under a different agent returns 404 not_found, even inside your own company, so ids never reveal data across agents.