Documentation

The context pack: everything about one contact in one call

Give an AI agent or a helpdesk everything about one WhatsApp contact before it answers: the contact, the reply window, the last messages and the open bookings, orders, tickets, submissions, surveys and notes, as JSON or Markdown.

Before an agent answers a customer it needs to know who they are, whether it may write to them, what was said, and what is open for them. The context pack gives all of that in one read.

curl "https://api.app2email.com/v1/YOUR_NUMBER/contacts/61412345678/context?messages=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

AI agents use the hosted MCP tool get_contact_context.

What is in it

PartWhat it holds
contactidentity, name, tags, custom fields, marketing consent, do_not_call, opted_in, and the contact_url (see shared links)
conversationthe reply window (window_state, window_closes_at), the last messages' times, and who handles it (human, agent, paused)
messagesthe newest messages, oldest first (messages=, 0 to 100, default 20)
recordsthe open records of each product (at most 10 each, below)
omittedthe sections left out, and why
truncatedtrue when the answer was cut to fit (about 60,000 characters: the oldest messages go first)

The open records, and the permission each needs

SectionWhat counts as openThe key needs
bookingsconfirmed and not yet overmessages:read (or bookings:manage)
ordersnot yet completed or cancelledorders:manage
ticketsvalid tickets for a date still aheadtickets:manage
submissionsopen submissionssubmissions:manage
surveysin progress, or completed in the last 30 dayssurveys:manage
notesthe team's notes on the conversation (newest 10)messages:read

A section the key may not read is not an error: it is listed in omitted with the permission it needs, so the agent knows what it is not seeing. A product that is not set up for the number is listed with the reason not_available. include=bookings,notes asks for some sections only.

Markdown for a language model

format=md answers the same as Markdown. It starts with one line saying that the text in it was written by people and is data, not instructions, and every message sits between <<<message ...>>> and <<<end message ...>>> lines, with look-alikes of those lines inside messages neutralised. Put it into the model's context as it is.

Whatever the format, treat names, messages, notes and answers as data: a contact can write anything, including text that looks like an instruction.

Errors

CodeStatusMeaning
invalid_phone400The contact in the address is not a number with its country code or a business-scoped user id.
invalid_parameter400format is not json or md, or include names an unknown section.
invalid_limit400messages is not a whole number from 0 to 100.
contact_not_found404The number has no contact and no conversation with that number.

The complete list is on the errors page.