Quickstart
From an API key to a reply, with curl. Every request goes to https://api.mailcraft.ntconnect.com (also reachable as https://api.mailcraft.cc).
1. Get an API key
Sign in to the console and create your organization. New people may first land on a waitlist until they are let in; someone who accepts an invitation joins the inviting organization instead.
Create a key on the API keys page (owners and admins). It starts with mc_live_ and is shown once, so copy it then. Revoke a key there at any time. A new key cannot delete inboxes unless you tick Can delete inboxes when you create it (an owner or admin can change that later). Keep it in an environment variable, never in code:
export MAILCRAFT_API_KEY=mc_live_…
Send it as Authorization: Bearer <key> on every request.
2. Create an inbox
curl https://api.mailcraft.ntconnect.com/v0/inboxes \
-H "Authorization: Bearer $MAILCRAFT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"username": "support", "displayName": "Support"}'
Both fields are optional: leave out username and MailCraft picks one. The answer is 201 with the inbox's id (ibx_…), address, aliases, displayName, createdAt and requireApproval. For most organizations the address is <username>.<handle>@agents.mxcraft.cc, where the handle is your organization's; the Inboxes page shows yours. A username that is taken or reserved is a 409, and an organization at its plan's inbox limit gets a 403.
export INBOX_ID=ibx_…
Delete an inbox
curl -X DELETE https://api.mailcraft.ntconnect.com/v0/inboxes/$INBOX_ID \
-H "Authorization: Bearer $MAILCRAFT_API_KEY"
The answer is 204. Only a key that an owner or admin allowed with Can delete inboxes may do this; any other key gets a 403. Owners and admins can also delete an inbox from its page in the console. It cannot be undone:
- The address is retired for good. It is never issued again, to you or anyone else.
- Mail sent to it is refused.
- All of the inbox's mail and drafts are deleted.
- An
inbox.deletedevent is sent, and the inbox's slot on your plan comes back.
3. Receive mail on a webhook
Add an endpoint on the console's Webhooks page: an https:// (or http://) URL and the event types you want, or none for all of them. Copy the signing secret it shows once. When mail arrives at the inbox, MailCraft POSTs a message.received event to your URL:
{
"id": "evt_…",
"type": "message.received",
"created_at": "2026-11-10T09:30:00.000Z",
"createdAt": "2026-11-10T09:30:00.000Z",
"data": {
"message_id": "msg_…",
"thread_id": "thr_…",
"inbox_id": "ibx_…",
"channel": "email",
"from": "…",
"subject": "…",
"spf": "pass",
"dkim": "pass",
"dmarc": "pass"
}
}
Check the Mailcraft-Signature header before you trust it, and answer with a 2xx within 10 seconds. Webhooks covers the signature, retries and every event type. Note the casing: webhook payloads are snake_case, while REST bodies are camelCase.
No public URL? Poll the event feed instead. It returns the same envelopes, oldest first; pass the nextCursor of one page as since on the next:
curl https://api.mailcraft.ntconnect.com/v0/events \
-H "Authorization: Bearer $MAILCRAFT_API_KEY"
4. Read the thread
GET /v0/threads/{threadId} returns the thread with a summary of each message (sender, recipients, subject, a snippet of the text, and its attachment count):
curl https://api.mailcraft.ntconnect.com/v0/threads/$THREAD_ID \
-H "Authorization: Bearer $MAILCRAFT_API_KEY"
Read a message by its id for the full text, its attachments and its SPF, DKIM and DMARC results:
curl https://api.mailcraft.ntconnect.com/v0/messages/$MESSAGE_ID \
-H "Authorization: Bearer $MAILCRAFT_API_KEY"
GET /v0/messages/{messageId}/raw gives the message exactly as it was received, and GET /v0/attachments/{attachmentId} streams one attachment.
5. Send a message
curl https://api.mailcraft.ntconnect.com/v0/inboxes/$INBOX_ID/messages \
-H "Authorization: Bearer $MAILCRAFT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"to": ["…"], "subject": "Hello", "text": "Sent by my agent."}'
A message needs 1 to 50 recipients across to, cc and bcc; it can carry text, html and base64 attachments. The Idempotency-Key header (1 to 255 characters) is required: reuse it when you retry, and the same request gets the same answer instead of sending twice; the same key with a different request is a 422.
Two optional fields shape the headers. replyTo is 1 to 5 addresses that replies should go to; they are not recipients, so they are not checked against the suppression list, not metered and not part of the 50-recipient count. headers is an object of at most 20 custom headers. Each name matches ^X-[A-Za-z0-9-]{1,62}$, and X-SES-*, X-MailCraft-* and X-Mailer are refused. Each value is 1 to 997 printable ASCII characters with at least one non-space (leading spaces may be trimmed by the recipient's mail client), and the names and values together are at most 8 KiB. A refusal is a 422 that names the field. Both fields work on a reply and on a draft; on PATCH of a draft, null, [] (for replyTo) or {} (for headers) clears them.
The answer is 202 once the message is queued: {id, threadId, status: "queued", recipients}. What happens next arrives as events: message.sent, then message.delivered, message.bounced or message.complained per recipient, or message.failed. If the inbox requires approval, the send is held for an owner or admin instead and the answer is 202 {status: "pending_approval", draftId}; see Human approval.
6. Reply
curl https://api.mailcraft.ntconnect.com/v0/messages/$MESSAGE_ID/reply \
-H "Authorization: Bearer $MAILCRAFT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"text": "Thanks, on it."}'
A reply goes from the inbox the message arrived in and joins its thread. Without to it goes to the original's Reply-To, or else its sender (for a message you sent, to its original To recipients); without subject it is Re: and the original subject.
To pass a message on, POST /v0/messages/{messageId}/forward with to (and optionally cc, bcc and a text or html note). It goes from the message's inbox, laid out like a mail client's Forward, with the original's attachments unless includeAttachments is false; the recipient gets a new conversation. Like a reply, it needs an Idempotency-Key header.
The same in Python and TypeScript
Steps 2 to 6 as one script, in either language, with no packages to install. It creates an inbox, emails the address in MY_EMAIL from it, waits up to 10 minutes for your reply on the event feed, reads the thread and answers. It sends real mail and leaves the inbox in place.
Python
quickstart.py: standard library only.
"""MailCraft quickstart in Python: standard library only (Python 3.8+).
Creates an inbox, emails you from it, waits for your reply on the event feed,
reads the thread and answers. It sends real mail.
export MAILCRAFT_API_KEY=mc_live_...
export MY_EMAIL=you@example.com
python3 quickstart.py
"""
import json
import os
import time
import urllib.error
import urllib.request
import uuid
API = "https://api.mailcraft.ntconnect.com"
KEY = os.environ["MAILCRAFT_API_KEY"]
def call(method, path, body=None, idempotent=False):
headers = {"Authorization": "Bearer " + KEY}
data = None
if body is not None:
headers["Content-Type"] = "application/json"
data = json.dumps(body).encode()
if idempotent:
headers["Idempotency-Key"] = str(uuid.uuid4())
req = urllib.request.Request(API + path, data=data, method=method, headers=headers)
try:
with urllib.request.urlopen(req) as res:
return json.load(res)
except urllib.error.HTTPError as e:
problem = json.load(e) # every error is application/problem+json
raise SystemExit(f"{e.code} {problem['title']}: {problem.get('detail', '')}")
# 2. Create an inbox.
inbox = call("POST", "/v0/inboxes", {"displayName": "Quickstart"})
print("inbox:", inbox["address"])
# Read the event feed from its newest event on.
newest = call("GET", "/v0/events?order=desc&limit=1")["data"]
since = newest[0]["id"] if newest else None
# 5. Send a message.
sent = call(
"POST",
"/v0/inboxes/" + inbox["id"] + "/messages",
{
"to": [os.environ["MY_EMAIL"]],
"subject": "Hello from MailCraft",
"text": "Reply to this email and the quickstart will answer.",
},
idempotent=True,
)
print("sent:", sent["id"])
# 3. Wait for your reply on the event feed (a webhook is the other way).
received = None
deadline = time.time() + 600
while received is None and time.time() < deadline:
time.sleep(5)
page = call("GET", "/v0/events" + ("?since=" + since if since else ""))
for event in page["data"]:
since = event["id"]
if event["type"] == "message.received" and event["data"]["inbox_id"] == inbox["id"]:
received = event["data"]
break
if received is None:
raise SystemExit("No reply within 10 minutes.")
# 4. Read the thread and the message.
thread = call("GET", "/v0/threads/" + received["thread_id"])
message = call("GET", "/v0/messages/" + received["message_id"])
print(len(thread["messages"]), "messages in the thread; you wrote:", message["text"])
# 6. Reply.
answer = call(
"POST",
"/v0/messages/" + received["message_id"] + "/reply",
{"text": "Thanks, on it."},
idempotent=True,
)
print("replied:", answer["id"])
TypeScript
quickstart.mts: fetch only.
// MailCraft quickstart in TypeScript: fetch only, no packages (Node 22.6+).
//
// Creates an inbox, emails you from it, waits for your reply on the event feed,
// reads the thread and answers. It sends real mail.
//
// export MAILCRAFT_API_KEY=mc_live_...
// export MY_EMAIL=you@example.com
// node --experimental-strip-types quickstart.mts
const API = "https://api.mailcraft.ntconnect.com";
const KEY = process.env.MAILCRAFT_API_KEY ?? "";
async function call(method: string, path: string, body?: unknown, idempotent = false): Promise<any> {
const headers: Record<string, string> = { Authorization: `Bearer ${KEY}` };
if (body !== undefined) headers["Content-Type"] = "application/json";
if (idempotent) headers["Idempotency-Key"] = crypto.randomUUID();
const res = await fetch(API + path, {
method,
headers,
body: body === undefined ? undefined : JSON.stringify(body),
});
const json = await res.json();
if (!res.ok) throw new Error(`${res.status} ${json.title}: ${json.detail ?? ""}`);
return json;
}
// 2. Create an inbox.
const box = await call("POST", "/v0/inboxes", { displayName: "Quickstart" });
console.log("inbox:", box.address);
// Read the event feed from its newest event on.
const newest = (await call("GET", "/v0/events?order=desc&limit=1")).data;
let since: string | undefined = newest[0]?.id;
// 5. Send a message.
const sent = await call(
"POST",
`/v0/inboxes/${box.id}/messages`,
{
to: [process.env.MY_EMAIL],
subject: "Hello from MailCraft",
text: "Reply to this email and the quickstart will answer.",
},
true,
);
console.log("sent:", sent.id);
// 3. Wait for your reply on the event feed (a webhook is the other way).
let received: { message_id: string; thread_id: string } | undefined;
const deadline = Date.now() + 600_000;
while (!received && Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 5000));
const page = await call("GET", `/v0/events${since ? `?since=${since}` : ""}`);
for (const event of page.data) {
since = event.id;
if (event.type === "message.received" && event.data.inbox_id === box.id) {
received = event.data;
break;
}
}
}
if (!received) throw new Error("No reply within 10 minutes.");
// 4. Read the thread and the message.
const thread = await call("GET", `/v0/threads/${received.thread_id}`);
const mail = await call("GET", `/v0/messages/${received.message_id}`);
console.log(thread.messages.length, "messages in the thread; you wrote:", mail.text);
// 6. Reply.
const answer = await call("POST", `/v0/messages/${received.message_id}/reply`, { text: "Thanks, on it." }, true);
console.log("replied:", answer.id);
Lists and errors
Lists come in pages of {data, nextCursor}: limit is 1 to 100 (25 by default), and a response with a nextCursor has more; pass it back as cursor. Errors are JSON with a title, a status and usually a detail that says what to change.
Search. GET /v0/inboxes/{inboxId}/threads and GET /v0/threads (every inbox, or one with inbox) take filters; a thread is listed when one message matches all of them, newest first. q matches words anywhere in the subject, the addresses and the text: -word leaves a word out, "quoted words" match as a phrase, a whole address, its part before the @ or its domain matches, and a code like INV-4417 also matches 4417. Typos, word stems and the contents of attachments do not match. from and subject narrow by sender and subject, after and before take an ISO 8601 time with a zone, and hasAttachments takes true or false. /v0/threads needs at least one filter. There is no ranking; page with cursor as usual. A bad filter is 422, and a search that runs too long is 503: narrow it.
curl -G https://api.mailcraft.ntconnect.com/v0/threads \
-H "Authorization: Bearer $MAILCRAFT_API_KEY" \
--data-urlencode 'q=invoice -draft' \
--data-urlencode 'after=2026-11-01T00:00:00Z' \
-d hasAttachments=true
Every id starts with a prefix that names its kind: ibx_ an inbox, thr_ a thread, msg_ a message, key_ an API key, whk_ a webhook endpoint, usr_ a member, and so on. An id of the wrong kind is answered as an unknown one.
API changes, 2026-11-25. A message with nothing in it (text and html missing, empty or only whitespace, and no attachment) is refused with 422 on send, reply, a draft's send and submitting a draft. JSON bodies are no longer type-coerced: a number, boolean or null where a string is expected, "3" for an integer, "true" or 1 for a boolean, or a bare string where an array is expected is now 422; query strings are unchanged. Drafts refuse a malformed address at create and update (422). Pattern errors are in plain English, and every bad-cursor 400 has a detail. An API key's 401 carries WWW-Authenticate: Bearer. Webhook deliveries carry User-Agent, Mailcraft-Event-Id, Mailcraft-Delivery-Id and Mailcraft-Delivery-Attempt headers. The API reference lists every status each operation can answer.
API changes, 2026-11-23. The draft.submitted, draft.sent and draft.rejected events also say who acted by name: author_name, approved_by_name and rejected_by_name (an API key's name, or a person's name or, without one, their email).
API changes, 2026-11-20. API key, webhook endpoint, delivery, member and invitation ids (and a draft's author and reviewer) are now prefixed like every other id; paths and bodies still accept the raw UUIDs they used to carry. Events carry createdAt; created_at, the same value, is deprecated and will be removed on or after 2026-12-21: read createdAt. Creating an inbox now answers its heldCount (0).
Next: the API reference lists every operation, and the MCP server gives an agent the same inboxes as tools.