Xuda AImail API Reference
Xuda AImail API Reference
This reference covers the full method surface of Xuda AImail: the eight methods an external developer API key can call, and the seventeen dashboard methods that drive the plan ladder, the hosted mailbox claim flow, outgoing templates and profile bindings. It is written for developers who want to read a customer's mail index from their own code, trigger a pull or a reprocess, disconnect a mailbox, or understand exactly what each screen in Email setup does. Every method key, parameter name, type and required flag below is taken from the shipped method contract.
How To Call These Methods
Every method here is a CPI method. CPI methods are dispatched by name over the Xuda API and MCP layer, and the normal credential for that layer is the account API key. For the transport-level detail, including how requests are framed and how the MCP layer exposes methods, see /api-mcp-integration.
AImail ships 25 methods. All 25 carry user clearance, so there is nothing operator-only and nothing unauthenticated in this product. None of them carries a min_plan key either, which means the platform membership gate never fires here: every entitlement decision is made inside the module against the account's email plan.
What splits the surface in two is the private flag. A private method is excluded from the API-key catalog and refused for API-key callers, so it is a dashboard-session method. That leaves:
- Eight API-key methods:
get_user_emails,get_user_mailboxes,archive_email,unread_email,refresh_mailboxes,process_pending_email,test_emailanddelete_email_account. Seven of those eight are in the curated Email scope group that API keys can be granted.delete_email_accountis not in that group, so a scoped key cannot reach it and only afullkey can. - Seventeen dashboard-session methods, covering the plan ladder, definitions, profile bindings, previews and the whole Xuda-hosted mailbox lifecycle. They are documented in full because they define the product's behavior, but do not build against them with an API key. They will be refused.
One shared rule across the whole surface: uid is injected by the HTTP layer from the authenticated session or API key. You never supply it, even on the methods whose catalog entry marks it mandatory.
What The Availability Labels Mean
Every method below carries one explicit availability line. Read it first, because it tells you whether you can call the method from your own code today.
- Availability: API key means an external developer API key or the MCP layer can call it. Eight AImail methods carry this label.
- Availability: Dashboard session means a signed-in user in the Xuda dashboard can call it, and an API key cannot. The account identity comes from the session, never from a parameter. Seventeen AImail methods carry this label.
- Availability: Public endpoint means no authentication at all. No AImail method currently carries this label.
- Availability: Operator only means Xuda staff, listed only for completeness. No AImail method currently carries this label.
Method Index
| Method | What It Does |
|---|---|
| get_user_emails | Queries the account's mail index by mailbox, date range, search term and read state. |
| get_user_mailboxes | Returns per-mailbox message counts for the active account profile. |
| refresh_mailboxes | Pulls new mail for the account's verified mailboxes. |
| process_pending_email | Runs the AI and contact-matching pass on one pending message. |
| archive_email | Archives one message so it drops out of the list and the counts. |
| unread_email | Marks a message and its conversation item unread again. |
| test_email | Sends a fixed test message through the platform submission server. |
| delete_email_account | Disconnects a mailbox, stops its subscription and frees the plan seat. |
| get_email_plans | Reads the four-tier email ladder, the account's tier, usage and billing total. |
| set_email_plan | Moves the account's tier and reprices every mailbox subscription. |
| get_email_definitions | Reads every mailbox with its template, signature, from name and bound profiles. |
| set_email_definitions | Saves the template style, signature and from name for one mailbox. |
| preview_email_message | Renders a draft exactly as the recipient will receive it, saving nothing. |
| get_profile_email_templates | Returns the styles catalog with previews for the profile setup tab. |
| attach_profile_email_account | Gives a profile an address to send and receive from. |
| detach_profile_email_account | Takes the address off a profile without disconnecting it. |
| get_hosted_email_status | Reports the account's Xuda mailbox, its domains and whether one can be claimed. |
| get_hosted_email_suggestion | Suggests an available Xuda mailbox address for this account. |
| check_hosted_email_address | Checks one name for availability, with the reason and alternatives. |
| create_hosted_email_account | Claims and provisions the account's Xuda hosted mailbox. |
| suspend_hosted_email_account | Reversibly suspends the hosted mailbox by stripping its login credential. |
| delete_hosted_email_account | Destroys the hosted mailbox and stops its subscription. |
| sync_hosted_emails | Syncs the hosted mailbox into the dashboard mail index. |
| rebuild_hosted_email_compat_doc | Repair tool that rebuilds the hosted mailbox's compatibility account document. |
| resend_verification_email | Resends the account verification email using the onboarding topic. |
get_user_emails
Get User Emails
Queries and returns a user's emails filtered by mailbox, date range, search term and read status. Results are read from the account's project database, sorted newest first on raw_message.envelope.date, and each returned document is enriched: contact_id is resolved into a user_contact object, every entry in other_contacts gets the same treatment, and a computed read flag is set from is_seen || is_sent || a non-empty read map. The response carries { docs, bookmark, total_emails }, where total_emails is the sum over the email_counts view. mailbox_name is interpreted as inbox (is_sent: false), sent (is_sent: true), or otherwise as a literal mailbox_path.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
uid |
string | Yes (injected from session) | Unique identifier of the user whose emails are queried. |
mailbox_name |
string | No (undocumented in catalog) | inbox, sent, or an exact IMAP mailbox path. |
date_from |
number | No (undocumented in catalog) | Lower bound on email_date_ts, epoch milliseconds. |
date_to |
number | No (undocumented in catalog) | Upper bound on email_date_ts, epoch milliseconds. |
search |
string | No (undocumented in catalog) | Case-insensitive regex matched against subject, from name and to name. |
email_account_id |
string | No (undocumented in catalog) | Restrict to one connected mailbox. |
read |
boolean | No (undocumented in catalog) | Restrict to read (true) or unread (false). |
email_id |
string | No (undocumented in catalog) | Fetch one specific email document. |
skip |
number | No (undocumented in catalog) | Offset, default 0. |
limit |
number | No (undocumented in catalog) | Page size, default 9999. |
bookmark |
string | No (undocumented in catalog) | CouchDB Mango bookmark for the next page; 'nil' is ignored. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - Only
uidis declared in the catalog field list. Every other parameter is read straight from the request body, which is why they are marked undocumented above. They are all honored. - A
date_tobelowdate_fromis refused with code-2. - Page with
bookmarkrather than withskipon large mailboxes. The literal string'nil'is ignored, so you can pass the previous response's bookmark back unconditionally. - Search is a full scan. The search selector is an
$orof five$regexclauses, and Mango never uses an index for$oror$regex, so a search over a large mail index reads every email document on the account.
get_user_mailboxes
Get User Mailboxes
Returns per-mailbox email counts for the user's active account profile by querying the CouchDB view email_counts with group_level: 999. The view emits [email_account_id, mailbox_path, stat] for every email document with stat < 4 and reduces with _count, so the response is the raw view rows. The left navigation uses it to build the per-account folder list.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
uid |
string | Yes (injected from session) | Unique identifier of the user whose mailbox counts are returned. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - Archived messages (
stat5) and errored ones (stat4 and above) are excluded by the view, so these counts and the counts you get fromget_user_emailsagree. - Use it to discover the exact
mailbox_pathvalues to pass toget_user_emails, including IMAP folders the customer created themselves.
refresh_mailboxes
Refresh Mailboxes
Fetches new emails for the user's verified email accounts across their active account profiles. It walks account_profile documents at stat: 3, skips profiles with no attached account, skips accounts that are not email_verified or that are flagged reauth_required, then pulls: a Xuda-hosted account is synced through sync_hosted_emails, and a Gmail account gets a fresh access token and is read over IMAP. Reads are bounded by a concurrency limit of 15. Returns { code: 22, data: <new email count> }.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_account_id |
string | No (undocumented in catalog) | Restrict the pull to one connected mailbox. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - The catalog declares no fields for this method;
email_account_idis read from the request body. - This pulls mail into the index. It does not run the AI pass. Summarizing, contact matching and threading happen on the per-minute processing pass, or on demand through
process_pending_email. - Xuda already calls this for every active account every 10 minutes, so calling it yourself is a way to shorten that window, not a requirement. Accounts on both the free membership plan and the free AI workspace plan are skipped by the platform cron, and an account with no active profile is skipped.
- Each mailbox keeps a high-water mark on the IMAP
message.seq, so a repeat call only stores messages newer than the last one it saw. - Known limitation: the profile loop breaks after the first profile that has an attached account, so an account with several profiles bound to different mailboxes only pulls the first one per call. Pass
email_account_idwhen you need a specific mailbox refreshed.
process_pending_email
Process Pending Email
Processes a pending email for the user's verified email account, optionally resetting its error state. It runs the AI credit check first, then finds the first active profile with a verified attached account and hands the email to the full processing pipeline with read: true, so opening a message in the dashboard both processes it and marks it read. The pipeline fetches the raw message, parses it, summarizes the body, matches or creates the sender contact, opens or finds the email conversation, threads the message, files attachments into Xuda Drive and stamps the result on the email document.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_id |
string | Yes | Unique identifier of the pending email to process. |
reset_error |
boolean | No (undocumented in catalog) | Force processing even for a message the spam or archive check would skip (force_process). The dashboard sends it when stat_attempts > 4. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - Processing runs in eight steps and the progress is recorded on the email document as
progress_current_stepagainstprogress_total_stepsof 8, so you can poll a message and watch it move. - Summaries come from GPT-5 Nano (model code
gpt-1), with the instruction to condense the message and omit the signature and any legal disclaimers. A body of 100 characters or fewer is stored verbatim rather than summarized. - Attachments are validated, uploaded into the Drive folder
/Chat Attachments, then removed from the temporary path. Only the filename, size, Drive file name, file URL and file path are kept on the email record. - Credits: this spends the account's AI credits. The pass is refused with "ai credits reach to hard limit" when the account's remaining credit balance is below zero. There is no separate per-message email fee.
- Skips: a message whose sender contact is flagged as spam or is archived is stored with
process_stat: 'partial'and no AI pass, unlessreset_errorforces it. A message whose Message-ID already has a sent conversation item is refused with "the email already processed". - Retries stop at six. A message that keeps failing increments
stat_attemptsand is abandoned at 6.
archive_email
Archive Email
Archives an email by setting its document stat to 5, stamping stat_ts and writing stat_reason: 'archived by the user'. An archived email drops out of the counts view and the dashboard removes the row from the list.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_id |
string | Yes | Unique identifier of the email to process. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - Archiving is a state change on the Xuda email document. It does not move or delete anything in the customer's Gmail account or on the hosted mailbox.
- Repeating the call on an already archived message rewrites the same state, so it is safe to retry.
- Archiving also takes the message out of the AI processing queue, because the spam and archive check refuses to run the pass on a message at
stat5.
unread_email
Unread Email
Marks an email and its linked chat conversation item as unread: it sets read: false on the email document and clears the read map on the chat_conversation_item the email points at.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_id |
string | Yes | Unique identifier of the email to process. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - A missing or unreadable conversation item makes the whole call fail with
-22. An email that has not been processed yet has no conversation item, so call this on processed messages only. - Because it clears the conversation item's read map as well, the contact's thread in the workspace shows the message as unread too. The two views never drift apart.
test_email
Test Email
Runs a test for email. It sends a fixed message with the subject "Test email" and the body "This is a test email." to the given address through the platform's own submission server.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email |
string | Yes | Destination email address to send the test message to. |
app_id |
string | No (undocumented in catalog) | App whose branding is applied to the message template. |
from |
string | No (undocumented in catalog) | Override the sending mailbox; its submission credential must exist in the platform's configured mailbox list. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - Declared
broadcast: true, so the dashboard surfaces the outcome as a job toast rather than as an inline response. fromonly accepts a mailbox the platform holds a submission credential for. It is not a way to send as an arbitrary address.- This is a delivery check for the platform submission path. It is not the customer send path: outgoing customer mail goes out from the customer's own connected mailbox so that DKIM stays aligned.
delete_email_account
Delete Email Account
Soft-deletes a connected email account by marking its document stat as deleted. For a Xuda-hosted account it delegates to delete_hosted_email_account, which also destroys the mailbox on the mail server. For a Gmail account it stops the mailbox's Stripe subscription with the reason mailbox_disconnected, clears billing, sets stat: 4 and writes stat_reason: 'deleted by the user'. The plan's mailbox seat frees at the same moment.
Availability: API key
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_account_id |
string | Yes | Unique identifier of the connected email account to use. |
Notes
- Auth:
userclearance, not private, so an API key can call it. Nomin_plan. - It is not in the curated Email scope group, so a scoped API key cannot reach it. Only a
fullkey can. - Billing stops here. Every mailbox carries its own subscription, so disconnecting one mailbox cancels exactly that subscription and leaves the others alone.
- For a hosted mailbox this is destructive: the mail server account is destroyed. For a Gmail account nothing is touched at Google, only the Xuda side of the connection.
- Mail already synced and processed stays in the account's index and in the contact conversations. This disconnects a source, it does not erase history.
get_email_plans
Get Email Plans
Returns the account's email plan ladder: the tiers with their prices, features, mailbox and AI throughput allowances, which tier the account is on, whether the plan has been activated, and what it is already using. The response carries plans (the ordered catalog with tier, id, name, tagline, price, rank, features, ai, usage and cumulative flags), current_tier, current_rank, plan_active, plan_chosen, activated_ts, entitlements, usage (mailboxes, profiles_attached, hosted_mailbox), billing (per_mailbox, billed_mailboxes, monthly_total and a human note) and verification, which is the mailbox identity gate result as allow, required_level, level and message.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user,
uidinjected from the session.userclearance,private: true, so an API key cannot call it. Nomin_plan. plan_activeis alwaystrue. Email has no activation wall: every account is on Free and fully working from day one.plan_chosenis the flag that records whether a tier was picked deliberately.- Prices are per mailbox per month, not per account.
billing.monthly_totalis the per-mailbox price multiplied by the mailboxes the account holds. entitlementsare cumulative up the ladder, so a tier's flags are its own plus every flag below it.verificationreports themailboxidentity gate. The gate asks for verification level 2, but it currently runs in shadow mode, so it reports what it would do and allows.
set_email_plan
Set Email Plan
Activates, upgrades or downgrades the account's email plan. A downgrade that would strand connected accounts or a Xuda mailbox is refused with the count rather than silently leaving the account over its limit. Every live mailbox subscription is repriced with proration_behavior: 'create_prorations' before the tier moves, and if any reprice fails the tier does not move at all. The response reports plan_id, tier, name, previous_tier, direction (activate, upgrade or downgrade), entitlements, price_per_mailbox and the list of repriced mailboxes.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
plan_id |
string | Yes | The plan id (email_free, email_starter, email_growth, email_scale) or the bare tier (free, starter, growth, scale). |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Changing plan reprices every mailbox the account already holds, prorated from today.
- The move is all or nothing. A single failed reprice returns
-402naming the mailbox that refused, and the account keeps the tier it was on. - A downgrade names the obstacle in the refusal, for example that the account holds three connected email accounts against a tier that includes three, and how many must be disconnected first.
- Xuda's own staff accounts are exempt from billing and from the identity gate. Their entitlements still follow whatever tier they are actually on.
get_email_definitions
Get Email Definitions
Returns every connected email account with how its mail goes out (template, signature, from name) and which profiles are attached to it, plus the template catalog and whether the plan unlocks the branded styles. Each account entry carries _id, email, name, vendor, email_verified, reauth_required, hosted_mailbox, the resolved definitions, a styles array where every one of the four styles has a preview_html rendered with that address's own signature and the bound profile's branding, and the list of profiles using it. The top level also returns templates_locked, templates_plan (the name of the cheapest tier that unlocks branded styles), the flat styles catalog and every profile with its current email_account_id.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - This is the read side of both the Definitions tab and the Profiles tab. Use it to discover an account's mailbox ids, its bindings and its current template.
reauth_requiredis the flag to watch. When a Google token can no longer be refreshed the account is marked for reconnection, mail pulling stops for it, and the customer is emailed and shown a banner.- The
preview_htmlon each style is rendered with the real signature and real branding for that address, so it is a true preview rather than a generic sample.
set_email_definitions
Set Email Definitions
Saves how mail leaving one connected email account looks: its template style, signature and from name. A branded template is refused when the email plan does not include it, with a message naming the tier that unlocks it, rather than being silently downgraded to plain.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_account_id |
string | Yes | The connected mailbox whose definitions are being saved. |
template_style |
string | No | plain, card, accent or minimal. |
signature |
string | No | Signed off at the end of every message sent from this address. Trimmed to 2000 characters. |
from_name |
string | No | The name recipients see. Trimmed to 120 characters. |
Notes
- Auth: session user, ownership enforced. A mailbox belonging to another account answers
-404.userclearance,private: true, so an API key cannot call it. Nomin_plan. - Plan gate: the three branded styles (
card,accent,minimal) need Starter or above. On Free the save is refused with the name of the tier that unlocks them. - Definitions belong to the address, not to the profile. Every profile attached to this mailbox inherits its template, signature and from name.
- Limits enforced on save: the signature is trimmed to 2000 characters and the from name to 120.
- A successful save pushes an
email_account_doc_updatedwebsocket message to the dashboard so open screens update without a reload.
preview_email_message
Preview Email Message
Renders a draft email exactly as the recipient will receive it, with the sending address's template and signature applied. Nothing is saved and nothing is sent. It uses the same renderer as the send path, so the preview and the delivered mail cannot drift apart, including the avatar fallback rule that substitutes an initials monogram when there is no usable absolute image. Returns { style, html }.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email_account_id |
string | No | Mailbox the message would be sent from. Optional when the account holds a single mailbox. |
template_style |
string | No | Template to render with. Falls back to the address's saved default when absent or unknown. |
body_html |
string | No | The composed message body as HTML. |
body_text |
string | No | The composed message body as plain text, used when no HTML is given. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - With no
email_account_idand exactly one mailbox on the account, that mailbox is used. With none resolvable the call answers-63, "no mailbox to preview from". - An unknown
template_stylefalls back to the address's saved default rather than erroring, so a stale style name never breaks a preview. - The
plainstyle deliberately renders tonull, because plain mail leaves the raw-text send path untouched. - Previewing costs nothing and changes nothing. It is safe to call on every keystroke if you debounce it.
get_profile_email_templates
Get Profile Email Templates
Styles catalog for the profile setup Email Template tab: plain plus the styled variants (card, accent, minimal), each with a rendered preview using the caller's profile branding. Returns { styles: [{ id, name, description, preview_html }] } rendered against a fixed sample message.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_name |
string | No | Profile display name used in the previews. |
signature |
string | No | Profile signature used in the previews. |
avatar_url |
string | No | Profile avatar used in the previews. |
brand_color |
string | No | Accent color (#hex) used in the previews. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Because
plainrenders tonullon the send path, itspreview_htmlisnullhere too. The Email setup picker usesget_email_definitionsinstead, which builds a real plain preview. - The previews here are drawn against a fixed sample message and whatever branding you pass in, so this is the catalog method. For the live per-address previews, use
get_email_definitions.
attach_profile_email_account
Attach Email Account To Profile
Gives a profile an address to send and receive from. One connected account can serve several profiles; a profile holds one address, so attaching replaces whatever it had.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | Yes | The account profile that will send from this address. |
email_account_id |
string | Yes | The connected mailbox to attach. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Plan gate: the tier's
profilesallowance caps how many profiles may hold an address. Exceeding it is refused with the number, for example that the plan covers an address on one profile and one must be detached first. - Re-pointing a profile that already holds an address is free and is not counted again. Only a genuinely new attachment consumes an allowance slot.
- A disconnected account (
stat: 4) is refused.
detach_profile_email_account
Detach Email Account From Profile
Takes the address off a profile. The account stays connected and the mail already synced is untouched: this unbinds, it does not disconnect.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
profile_id |
string | Yes | The account profile to unbind. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Idempotent. Detaching a profile that holds nothing returns success with
unchanged: true. - Detaching frees a slot against the plan's
profilesallowance, which is the documented way out of an attach refusal. - A profile with no address attached cannot send or receive mail, but the mailbox itself keeps working and keeps being billed until it is disconnected with
delete_email_account.
get_hosted_email_status
Get Hosted Email Status
Returns the current account's Xuda hosted mailbox metadata plus everything the connect screen needs to decide what to offer: mailbox (the stored metadata), has_mailbox, domain (the account's default hosted domain), domains (every hosted domain this account may claim on, best default first), eligible (the plan gate alone), can_create (the plan gate and the one-mailbox-per-account rule), reason and reason_code when refused, plus email_plan and email_plan_chosen.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Read
eligibleandcan_createseparately.eligibleis the plan alone;can_createis the plan and the rule that an account may hold one Xuda mailbox. - Customer mailboxes are created on
xuda.app. Xuda's own staff accounts are additionally offeredxuda.ai. There is no custom-domain hosting anywhere in this product. - A Xuda mailbox is included on every tier, including Free.
get_hosted_email_suggestion
Get Hosted Email Suggestion
Suggests an available Xuda mailbox address for the current account. It prefers the account's own username or first and last name, validates and normalizes it, and returns it when free. When that name is taken or unusable it returns the closest free numbered variant plus up to three suggestions, along with adjusted_from and adjusted_reason so the form can explain itself.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
local_part |
string | No | Optional preferred name before the @. Defaults to the account name. |
domain |
string | No | Which hosted domain to claim the mailbox on. Must be one this account is entitled to; anything else falls back to its default. |
username |
string | No (undocumented in catalog) | Alternative source for the preferred name. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - It never returns a taken address, so the value you get back is safe to prefill a claim form with.
- A plan that does not include a Xuda mailbox answers
-67with the reason. - A
domainthe account is not entitled to silently falls back to the account's default rather than erroring.
check_hosted_email_address
Check Hosted Email Address
Checks whether a Xuda mailbox name is available, with the reason and alternatives when it is not. This is advisory only: create_hosted_email_account re-validates everything. It always returns code: 1 with { available, domain, local_part, email, reason, reason_code, suggestions }.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
local_part |
string | Yes | The name to check, without the domain. |
domain |
string | No | Which hosted domain to claim the mailbox on. Must be one this account is entitled to; anything else falls back to its default. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. reason_codeis one ofok,empty,too_short,too_long,bad_start,reserved,takenorplan.- Suggestions are withheld for
too_shortandempty, because there is nothing yet to vary. - The name rules: 5 to 64 characters, it must start with a letter or a digit, and it may contain only letters, digits, dots, dashes and underscores. Anything else is normalized away before the check runs.
- 28 names are reserved and can never be claimed, among them
abuse,admin,billing,info,support,postmasterandxuda. - This call never fails on an unavailable name. It answers
code: 1withavailable: false, so treat the payload rather than the code as the answer.
create_hosted_email_account
Create Hosted Email Account
Creates one Xuda hosted mailbox for the current account. The order is deliberate and every step can refuse: existing-mailbox check (-54), plan gate (-67), mailbox seat allowance (-67), name validation (-51), address-taken check (-55), identity gate (-412 with verification_required), the subscription, then provisioning on the mail server. On success the address, the generated mailbox secret, the quota, the mailbox id and the billing record are written to the account document, and a compatibility email_account document is written into the account's project database so the rest of the product treats the hosted mailbox exactly like a connected one.
Availability: Dashboard session
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
local_part |
string | No | Optional mailbox name before the @. Defaults to the suggested address. |
payment_method_id |
string | No | Stripe payment method for the mailbox subscription. Falls back to the account default when omitted. |
domain |
string | No | Which hosted domain to claim the mailbox on. Must be one this account is entitled to; anything else falls back to its default. |
username |
string | No (undocumented in catalog) | Older name for local_part, still accepted. |
skip_stalwart_provision |
boolean | No (undocumented in catalog) | Records the mailbox with status pending_stalwart without provisioning it on the mail server. Test and recovery path. |
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - One Xuda mailbox per account. A second claim answers
-54, "hosted email already exists for this account". - Billing: the mailbox's own subscription is created before the mailbox exists, and a provisioning failure cancels it before the error is returned, so a customer is never charged for a mailbox that does not exist. The subscription is created so that an incomplete payment is rejected outright, which means a failed card means no mailbox.
- The seat check counts Gmail connections and Xuda mailboxes alike against the tier's mailbox allowance.
- Identity gate: the
mailboxgate is checked before anything is charged or provisioned. It asks for verification level 2 and refuses with-412and averification_requiredpayload. The gate currently runs in shadow mode, so it reports and allows, and a gate that cannot be reached allows rather than blocks. - Every hosted mailbox gets 1 GiB of storage, enforced as the account quota on the mail server.
- The generated mailbox secret is held server side and is never shown to the customer. There is no IMAP or SMTP password to hand out for a Xuda mailbox.
suspend_hosted_email_account
Suspend Hosted Email Account
Suspends the current account's Xuda hosted mailbox by stripping its login credential on the mail server, which is reversible and leaves the mailbox and its data in place. The account state moves to status: 'suspended' with a suspended_ts, and the compatibility email_account document is rewritten.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Suspension is not deletion. Mail is preserved and the mailbox can be brought back; only the ability to log in is removed.
- No dashboard control calls this today. It is a registered method with a working implementation, listed here for completeness.
delete_hosted_email_account
Delete Hosted Email Account
Deactivates the current account's Xuda hosted mailbox: it destroys the account on the mail server, stops the mailbox's subscription with the reason mailbox_deleted, and sets the account state to enabled: false, status: 'deleted' and billing: null with a deleted_ts.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - This is destructive on the mail server side and is not the same as suspension.
delete_email_accountroutes here automatically when the target is a hosted mailbox, which is how the dashboard's trash icon reaches this behavior.- Availability is queried against hosted mailboxes whose status is not
deleted, so a deleted address is free to be claimed again.
sync_hosted_emails
Sync Hosted Emails
Syncs the current account's hosted mailbox into the dashboard email index. It logs in over IMAPS with the server-held mailbox secret, lists folders, skips anything matching junk, spam, trash, deleted or draft, marks folders carrying the \Sent special-use flag (or a path starting with sent) as sent mail, and stores new messages. Returns { synced, account_hosted_email } and stamps last_sync_ts.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Refuses with
-64when the mailbox is notactive, and with-66when the mailbox credential is missing. refresh_mailboxescalls this internally for a hosted mailbox, andrefresh_mailboxesis the API-key reachable way to trigger the same pull.- Like the Gmail path, this stores messages only. The AI pass runs separately, on the per-minute processing loop or through
process_pending_email.
rebuild_hosted_email_compat_doc
Rebuild Hosted Email Compatibility Doc
Rebuilds the hosted email compatibility account document in the user's default project from the hosted mailbox metadata on the account document. This is a repair tool for an account whose email_account document was lost or drifted.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Refuses with
-52when the account has no hosted mailbox. - There is no dashboard control for it. It is maintenance in practice, but it is a
userclearance method rather than an operator one, so it runs on the caller's own account and cannot touch anyone else's. - Reach for it when a hosted mailbox exists on the account but does not appear in
get_email_definitionsor in the mailbox list.
resend_verification_email
Resend Verification Email
Sends an account verification email containing a verification link to the user, using the same onboarding_verify notification topic that signup sends, so the banner's "Resend email" delivers the identical welcome and verify message rather than a bare link.
Availability: Dashboard session
Parameters
This method takes no parameters.
Notes
- Auth: session user.
userclearance,private: true, so an API key cannot call it. Nomin_plan. - Declared
broadcast: true, so the dashboard surfaces the result as a job toast. - This is account onboarding rather than mailbox functionality. It lives in the email module for historical reasons and is documented here so the surface is complete.
The Email Plan Ladder And What It Gates
Prices are per mailbox per month, not per account, and entitlements are cumulative: each tier carries everything below it.
| Tier | Plan id | Price | Mailboxes | Xuda mailbox | AI messages per minute | Branded templates | Profiles that may hold an address |
|---|---|---|---|---|---|---|---|
| Free | email_free |
$0 | 1 | yes | 1 | no | 1 |
| Starter | email_starter |
$9 | 3 | yes | 5 | yes | 3 |
| Growth | email_growth |
$19 | 50 | yes | 10 | yes | 50 |
| Scale | email_scale |
$49 | 200 | yes | 20 | yes | unlimited (-1) |
Three things about this ladder are worth knowing before you plan an integration:
- Free is the default and the floor. An account that has never touched the ladder is on Free and fully working. There is no activation wall, and
plan_activeis alwaystrue. - The AI is on every tier, including Free. What the ladder sells is throughput, never whether mail is read at all. The per-minute figure is used directly as the query limit on each processing pass.
- No method carries a
min_plan. Every gate above is enforced inside the module against the account's email plan, not at the HTTP boundary, so a refusal arrives as a method-level error rather than as a platform plan rejection.
Xuda's own staff accounts are exempt from billing and from the identity gate. Their entitlements still follow whatever tier they are actually on.
Errors
Method-level error codes, returned on the CPI envelope:
| Code | Where | Meaning |
|---|---|---|
-2 |
get_user_emails |
date_to is below date_from. |
-22 |
unread_email |
The email's linked conversation item is missing or unreadable. |
-51 |
create_hosted_email_account |
The requested mailbox name failed validation. |
-52 |
rebuild_hosted_email_compat_doc |
The account has no hosted mailbox to rebuild from. |
-54 |
create_hosted_email_account |
A hosted mailbox already exists for this account. |
-55 |
create_hosted_email_account |
The address is already taken. |
-63 |
preview_email_message |
No mailbox to preview from. |
-64 |
sync_hosted_emails |
The hosted mailbox is not active. |
-66 |
sync_hosted_emails |
The hosted mailbox credential is missing. |
-67 |
hosted mailbox methods | Plan gate refusal, or the mailbox seat allowance is spent. |
-402 |
set_email_plan |
A mailbox subscription reprice failed, so the tier did not move. |
-404 |
set_email_definitions |
The mailbox belongs to another account. |
-412 |
create_hosted_email_account |
The identity gate refused, with a verification_required payload. |
Two success codes are worth calling out because they are not the usual shape. check_hosted_email_address always answers code: 1 and puts the real answer in the payload, so read available and reason_code rather than the code. refresh_mailboxes answers { code: 22, data: <new email count> }.
Beyond the codes, two refusals arrive as thrown messages rather than as numbered codes: "the email already processed" when a message's Message-ID already has a sent conversation item, and "ai credits reach to hard limit" when the account's remaining AI credit balance is below zero.
Rate Limits And Processing Cadence
There is no request-per-second limit on these methods. The limit that actually shapes an integration is AI throughput, and it is set by the plan.
| Scope | Limit |
|---|---|
| Messages summarized per minute | 1 on Free, 5 on Starter, 10 on Growth, 20 on Scale |
| Concurrent mailbox reads on a pull | 15 |
| Processing attempts per message | 6, then the message is abandoned |
| Storage per hosted mailbox | 1 GiB |
| Signature length | 2000 characters |
| From name length | 120 characters |
The platform's own cadence, which runs whether or not you call anything:
| Job | Cadence | What it does |
|---|---|---|
| Mail pull | every 10 minutes | Runs the equivalent of refresh_mailboxes for every active account. Accounts on both the free membership plan and the free AI workspace plan are skipped, as is an account with no active profile. |
| AI pass | every minute | Processes up to the tier's per-minute allowance, sent mail first so that replies thread correctly. |
Two consequences for callers. First, refresh_mailboxes shortens the pull window but does not raise the processing rate: that is the plan's number. Second, because sent mail is processed before incoming mail, a reply you send and a reply you receive settle into the same conversation in the right order without you doing anything.
AI credits are a separate pool from the email plan. Summarization spends the account's AI credits, and the credit check runs before every pass. The summarizer is GPT-5 Nano (model code gpt-1). There is no separate per-message email fee.
Idempotency And Repeat Calls
- Pulls are watermarked. Each mailbox keeps a high-water mark on the IMAP message sequence, so calling
refresh_mailboxesrepeatedly only ever stores messages it has not seen. It is safe to call on a loop. - Processing refuses a duplicate. A message whose Message-ID already has a sent conversation item is refused with "the email already processed" rather than being threaded twice.
- State writes are safe to retry.
archive_emailandunread_emailwrite a state, so repeating them rewrites the same state. - Detach is safe to repeat. Detaching a profile that holds nothing returns success with
unchanged: true. - Re-attaching is free. Re-pointing a profile that already holds an address is not counted again against the plan's profiles allowance. Only a genuinely new attachment consumes a slot.
- Claiming a mailbox is not. One Xuda mailbox per account: a second
create_hosted_email_accountanswers-54. If provisioning fails after the subscription was created, the subscription is cancelled before the error is returned, so a retry does not stack charges. - Plan moves are all or nothing.
set_email_planreprices every mailbox subscription first and only moves the tier if all of them succeeded, so a partial failure leaves the account exactly where it was. - Availability checks are advisory.
check_hosted_email_addressandget_hosted_email_suggestionnever reserve anything.create_hosted_email_accountre-validates the name, the plan, the seat and the identity gate from scratch.
Webhooks
AImail publishes no webhooks of its own. There is nothing to subscribe to and no callback URL to register.
What it does emit is websocket push to the dashboard, which is server to browser and not an integration surface: email_account_doc_updated when a hosted mailbox or a set of definitions changes, and email_doc_updated when an email document moves.
It also raises account notifications through the platform's notification system rather than through webhooks:
| Topic | When |
|---|---|
email_reauth_required |
A Google token can no longer be refreshed. Mail pulling stops for that account, the customer is emailed and a banner titled "Reconnect your email account" appears. |
onboarding_verify |
Sent by resend_verification_email, the same topic signup uses. |
Two further topics, email_bounce_update_required and email_bounce_suspended, are raised by the account module rather than by AImail.
A Note On The Rest Of The Surface
Two gaps in this surface are deliberate and you should plan around them rather than look for the method.
There is no send method here. The functions that actually deliver mail (send_email, send_profile_email, sendEmailFromAccount and the template renderer render_profile_email) are exported for the broker but are not registered as CPI methods, so they have no HTTP route and no API surface. The customer-facing send path is the AI composer on a contact conversation, which reaches them internally. test_email is a delivery check for the platform submission server, not a general send.
Connecting a Gmail account is not a single method either. The OAuth link is minted by the account module, and the code exchange that saves the mailbox (oauth_consent) is an internal function rather than a CPI method. Only the Xuda-hosted mailbox path is claimable end to end from the methods documented above.
The other broker-only functions in this module, read_emails, process_emails, get_email_accounts and scan_platform_bounces, are likewise unreachable over HTTP and are not part of any documented or supported surface.