Tickets from your app
The Tickets API lets your own app hand a customer to your team. The usual case is a chatbot: at some point the customer asks for a person. Your bot opens a ticket in MailInApp with what they asked and the chat so far, the customer gets an email saying a person will answer, and your team takes it from Tickets. Your app hears about every answer through webhooks, so the chat can say "We answered you by email".
It uses the same API key as the Send API:
Authorization: Bearer mia_live_...
Opening a ticket and adding a message allow 30 requests a minute per key; reading allows 60. Errors are RFC 9457 problem details, as on every /api/v1 route. The complete contract is in the OpenAPI spec.
Open a ticket
POST /api/v1/tickets:
{
"email": "[email protected]",
"name": "Ada",
"subject": "Refund for order 1042",
"message": "The boots arrived in the wrong size. Can someone help me return them?",
"externalId": "chat_8f2c",
"source": "In-app chat",
"metadata": { "user_id": "u_381", "order": "1042", "plan": "premium" },
"transcript": [
{ "role": "customer", "text": "My boots are the wrong size" },
{ "role": "bot", "text": "I can start an exchange. Which size do you need?" },
{ "role": "customer", "text": "I'd rather talk to a person" }
]
}
email,subjectandmessageare required.messageis the customer's request in their own words (up to 5,000 characters): it becomes the ticket's first message, from the customer, so the ticket starts Open.externalIdis the conversation's id in your system (up to 200 characters). There's only ever one open ticket perexternalId: a second call with it answers200with the existing ticket and"created": false, so a bot that retries or a customer who asks twice doesn't make two cases. AnIdempotency-Keyheader does the same for a single call.metadatais up to 20 values your team needs: an app user id, a plan, an order number. Keys area-z,0-9and_(up to 40), values up to 500 characters. They show as chips on the ticket and come back in every webhook, so you can match answers to your own records.transcriptis the chat before the handoff, up to 100 entries of{role, text, at?}withroleone ofcustomer,botoragent. Your team sees it folded above the conversation as Chat before handoff. It's never shown to the customer or put in an email, so your bot's own wording stays inside.sourceis a short label (up to 40 characters) shown on the ticket as From In-app chat.assigneeEmailassigns the ticket to the account owner or an editor, who's told by email and push. Without it, the ticket is unassigned and the owner hears about it.acknowledgeistrueunless you say otherwise: the customer gets an email right away saying a person from your brand will reply, with their message, a link to their ticket page and, when your account receives email, an address they can simply reply to. Set it tofalseif your app tells them itself.
The answer is 201:
{
"ticket": {
"id": "4b6c…",
"status": "open",
"subject": "Refund for order 1042",
"email": "[email protected]",
"name": "Ada",
"channel": "api",
"source": "In-app chat",
"externalId": "chat_8f2c",
"metadata": { "user_id": "u_381", "order": "1042", "plan": "premium" },
"assigneeEmail": null,
"messageCount": 1,
"url": "https://mailinapp.com/dashboard/tickets?id=4b6c…",
"createdAt": 1795000000000,
"updatedAt": 1795000000000
},
"created": true,
"email": { "sent": true }
}
email says whether the acknowledgement went out. An address that unsubscribed or bounced isn't emailed, and reason says why.
Keep the conversation going
POST /api/v1/tickets/{id}/messages adds a message:
{"from": "customer", "body": "…"}when the customer writes again in your app. The ticket reopens and your team is told. Nothing is emailed to the customer.{"from": "team", "body": "…"}when your team answers from your own tool. It's emailed to the customer (or not, with"notify": false) and the ticket moves to Pending.
PATCH /api/v1/tickets/{id} takes status (open, pending or resolved) and assigneeEmail (an address, or null to unassign). Resolve the ticket when the customer's chat session ends, for instance.
Read tickets
GET /api/v1/tickets lists tickets newest first. Filter with externalId, email or status, and limit (up to 100, default 50). To find the ticket of a chat session, use ?externalId=chat_8f2c.
GET /api/v1/tickets/{id} returns the ticket and its messages, each with from (customer or team), body, via (email, page, dashboard, api or app) and createdAt. Add ?include=notes for your team's internal notes and the transcript: the key is your account's own, so it can read what your team wrote.
Hear the answers
Subscribe a URL to these webhook events, each carrying the ticket in the shape above, externalId and metadata included:
| Event | When |
|---|---|
ticket.created | A ticket opens, from the API, the dashboard, a journey, an order or a privacy request. |
ticket.message_added | A message is added. message.from is customer or team, message.via says where it was written: email when the customer answered by email. |
ticket.status_changed | The status changes, with from and to. |
ticket.assigned | Someone takes it, with the new assigneeEmail (or null). |
Internal notes never go out in a webhook.
Example: a chatbot handing off
When the customer asks for a person:
const res = await fetch("https://mailinapp.com/api/v1/tickets", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MAILINAPP_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
email: user.email,
name: user.firstName,
subject: `Help with ${topic}`,
message: lastCustomerMessage,
externalId: session.id,
source: "In-app chat",
metadata: { user_id: user.id, plan: user.plan },
transcript: session.messages.map((m) => ({ role: m.role, text: m.text })),
}),
});
const { ticket } = await res.json();
await chat.say("A person from our team will reply by email shortly.");
Then, in the endpoint your ticket.message_added subscription calls (after checking the signature):
const { data } = event;
if (data.message.from === "team") {
await chat.post(data.ticket.externalId, "We answered you by email: " + data.message.body);
}
The same steps are in the Zapier app (Create Ticket, Add Ticket Message, Find Ticket, and a trigger per event), the n8n node's Ticket resource, and the MCP tool create_ticket for an AI assistant that hands off the same way.
Safety
- Everything is plain text, and every length is capped.
- The customer's address comes from your app and isn't verified by MailInApp, so treat it as you would a send: the acknowledgement counts toward your monthly sends, honours unsubscribes and bounces, and the 30-a-minute limit applies. An emailed answer is accepted into the ticket only from that same address.
externalId,metadataand the transcript are data about the customer. They're part of their data export and are erased with their tickets.