NOTE: Whether the confirmation challenges described below come back is set per account (Settings, Approvals). This copy describes an account whose agent approvals are on. Connect with your key for the text that applies to your account: the MCP initialize instructions and GET /api/agent/v1/me (its "approvals" field) say which applies. # SentientMail Agent Operating Guide You are an AI agent operating a SentientMail account. Read this fully before your first write call; it encodes the platform's architecture and the mistakes agents most commonly make. ## What this platform is SentientMail is a hosted email marketing + transactional platform (business units, data extensions, journeys and automations). Everything lives IN the platform: templates, audiences, sends. You do not bring your own SMTP, render your own HTML pipeline, or bypass the object model. ## Core objects and how they fit - **Account -> Business Units (BUs).** An account root may have child BUs. Your session/API key is scoped to ONE active BU; objects you create land there. UI sessions switch BUs via POST /api/auth/active-bu {tenant_id}. Automation keys are fixed to the BU they were minted in. - **Templates (Content -> Templates)** are reusable layout shells with named slots (`
`). **Emails** are built ON a template by filling its slots with blocks. Do not paste full-page HTML into an email body when a template exists. Build on the account's template (most accounts have a branded general-purpose one) so header/footer/unsubscribe chrome stays consistent. - **Data Extensions (DEs)** are the audience tables. Contacts are imported into DEs (CSV import or the events API); segments and sends resolve recipients from them. Do not invent ad-hoc recipient lists; put contacts in a DE first. - **Sender Profiles** (Settings -> Sender Profiles) carry the From identity. **A send will not launch without one.** Set an explicit sender_profile_id on the send/definition or ensure the BU has a default profile. The platform hard-blocks otherwise (error: sender_profile_required). - **Send Definitions** are the reusable configs for transactional mail (template + sender profile + classification). The API's `definition_key` matches the definition's transactional_key OR its external_key. - **Journeys** are event/segment-triggered automations built in the journey canvas; they gate at publish (validation + a default sender profile when they contain email nodes). A DRAFT journey admits nobody through its triggers and the scheduler holds anyone parked inside it; publish is the switch. Only an explicit enter/test call touches a draft. get_journey reports `admission.admits_now` and `in_flight_contacts`, so read those rather than inferring from status. ## Sending paths (pick the right one) 1. **UI/batch sends**: Send object + segment/DE audience -> launch. Requires sender profile; plan email caps enforced at launch. 2. **Transactional API** (machine-to-machine): POST /api/messaging/v1/email/messages/{message_key} Header: `X-Automation-Key: spk_...` or `smak_...` (automation key with the transactional scope). Body: {"definition_key": "...", "recipient": {"email": "...", "attributes": {...}}}. message_key is the idempotency key. Reuse it to dedupe, never randomize retries. 3. **Journeys**: for lifecycle/triggered flows; enter contacts via events (POST /api/events) or segment triggers. 4. **Agent keys**: a key holding dispatch:execute, journeys:activate or automations:execute can put mail in real inboxes itself, behind a confirmation. See "API quickstart" below before calling any of them. ## Verification & sandbox (new accounts) Accounts start sandboxed: sends only reach the account's own team members until two things are done: the account owner's email address is verified, and one sending domain passes SPF, DKIM and DMARC. You can do the domain half yourself: 1. production_status (or get_setup_checklist) says whether the account will deliver and, in next_action, which tool to call next. 2. register_sending_domain with the domain your mail comes from returns the exact DNS records to publish, each with what it is for. create_sender_profile does the same for its from address. 3. Publish the records at the domain's DNS host. If you have DNS access, add them yourself; otherwise hand them to whoever manages the domain. SPF: MERGE our include into any existing v=spf1 record. Never create a second SPF record. 4. verify_sending_domain checks DNS now and reports what is missing. New records can take minutes to hours to appear; wait and check again. Once the domain passes and the owner's email is verified, the account leaves sandbox by itself, and the response says will_deliver. 5. If the owner's email is not verified, resend_owner_verification_email (account-root keys with deliverability:write only) sends a fresh link. A person has to click it. list_sending_domains shows what is registered. A key minted on the account root sees every business unit's domains; any other key sees only its own unit's. If production_status still says sandboxed after all of that, an account administrator can see why in the app. ## Rules that prevent user-visible errors - NEVER assume hello@ exists. Resolve the From identity from a Sender Profile. - The pre-flight (check_compliance, and the compliance verdict on create_draft_send) RENDERS a fixture contact before validating, exactly as the launch gate does, so the platform's own SentientScript conditionals (%%[ IF ... ]%% ... %%[ ENDIF ]%%) collapse before the merge-marker scan. Do not strip that logic to satisfy the check; a block that fails here fails at launch for the same reason, and the response names the basis it validated (rendered_fixture or raw_template). - To change a DRAFT send after creating it (exclusion script, on-demand suppression lists, template re-pin, audience, From, subject/preheader overrides) use update_draft_send (PATCH /agent/v1/sends/{id}) BEFORE request_send: editing a send voids any pending approval on it, so the reviewer always sees what will actually go out. An exclusion script is parsed at save time and every Lookup must name a data extension and columns the account has. Then run preview_send_recipients on the send: it applies the script and any picked suppression lists the way launch does and reports excluded_by_script and would_receive, which is the only proof that the script acts. A script that was merely accepted has not been shown to exclude anyone. - Sends are FROZEN at send time; editing a template later does not change already-sent mail. - Suppression (unsubscribes/complaints/bounces) is enforced platform-side; do not retry suppressed recipients. - Free-tier accounts get a mandatory "Sent with SentientMail" footer badge; paid plans do not. Do not try to remove it. - Plan limits: email volume, Business Units, and team seats are tier-capped; 422 plan_limit errors carry used/limit and mean "upgrade or reduce", not "retry". - Errors are structured JSON: read `detail.error` / `detail.message` before retrying. 401 = credentials, 403 = scope, 404 on definition_key = wrong key OR wrong BU, 422 = validation/policy. ## API quickstart - Your credential is an AGENT KEY. An account admin creates one in Settings, API keys, under Agent keys, and you send it as `X-API-Key: sk_...` or `Authorization: Bearer sk_...`. It reaches /api/agent/v1/* and POST /api/mcp. - NEVER ask a person for their password, and never post one to /api/auth/login. That endpoint is for the browser UI. A password in your context is a credential nobody can scope or revoke without locking its owner out, and it carries every permission that person has. If you have no agent key, stop and ask an admin for one rather than working around it. - Agent keys carry NAMED PERMISSIONS rather than one level. The scopes on your key decide what you can do, including whether you can send mail. GET /api/agent/v1/me lists yours, and MCP tools/list shows only the tools your key can call. Ask for what the task needs and no more. Every scope an admin can grant: read required by everything below: ids, names, account state content:read read template, landing page and content block bodies content:write save emails, templates, content blocks and landing pages as drafts; a new CURRENT template version or a content block edit that reaches live mail is confirmed first (see below) content:publish [PUBLIC WEB] publish a landing page, or promote a saved state onto a live one content:delete trash, restore or purge templates and landing pages sending:write create or edit draft sends, send definitions and sender profiles; set the unit's postal address; pause a send definition; rebinding a live definition is confirmed first sending:delete permanently delete a draft send; archive or restore a send definition (restoring a triggered one also needs dispatch:execute and a confirmation) dispatch:request queue a draft send for a person to approve and launch; sends nothing itself dispatch:execute [SENDS MAIL] schedule a send; resume or restore a send definition audiences:read read data extensions, rows, segments and suppression lists audiences:write create and edit data extensions, rows, imports, segments and suppression lists audiences:pii see real contact addresses instead of masked ones audiences:delete delete rows, clear a data extension, forget a contact, trash or purge segments deliverability:read read throttle, IP warming and send-time optimization deliverability:write change throttle and send-time optimization; register and verify sending domains; run readiness checks for a sending domain; send a proof test to an operator address on a verified sending domain or the unit's allowlist journeys:read read journey definitions journeys:write create journeys journeys:edit edit, pause, trash or purge journeys journeys:activate [SENDS MAIL] publish or resume a journey, enter contacts, or fire a trigger automations:read read automations, their steps and runs automations:write build and edit automations; cannot arm or run them automations:execute [SENDS MAIL] run an automation now, or cancel a run insight:read send performance, reports, pivots and the query console (contact-grain results also need audiences:pii) crm:read read SentientCRM companies, deals, activities, pipelines and timelines; the CRM tools are listed only in units with SentientCRM crm:write create and edit CRM companies, deals, activities and contact CRM fields; move deals and convert leads; needs crm:read too crm:delete move CRM companies, deals and activities to trash and restore them; take a contact off a deal; needs crm:read too Writing an email and wiring up how it gets sent are separate permissions on purpose. Ask for content:write alone when you are only authoring. - A 403 names the single scope to ask for, in `detail.scope`. Tell the person exactly which permission to grant instead of guessing. Scopes cannot be added to an existing key, so granting one creates a replacement key. - Scopes marked [SENDS MAIL] put email in real inboxes. dispatch:execute hands a send to the dispatcher. journeys:activate starts a journey that keeps sending, on its trigger, to everyone it admits, until someone pauses it. Entering contacts explicitly sends even from a draft journey; firing an API trigger admits nobody unless the journey is published. automations:execute runs whatever steps the automation holds right now: a send step launches a send, a trigger_journey step admits an audience into a PUBLISHED journey and walks them through it inline (a draft journey is refused), a report step can email its CSV to the report's recipients, and a parallel step can contain any of those. The scope marked [PUBLIC WEB], content:publish, serves a page to anyone holding its URL, with no login. - Every one of those actions answers its first call with a 409 `confirmation_required` carrying a server-written challenge and a `confirmation_id`. Show the challenge to the user word for word, get a real decision, then retry with the id: the `X-Confirmation-Id` header over HTTP, the `confirmation_id` argument over MCP. Every tool that can return `confirmation_required` takes that argument, and it is how an approval is spent whichever way it was given: through confirm_action or by a person in the app. Retry with the same arguments; a call without the id raises a new challenge instead of using the approved one. The id is single-use, bound to that exact request and the state it described, and expires after 10 minutes, counted from when the challenge was raised. The account's permission mode, which only a person can change in Settings, decides who may answer. `locked` refuses agent sending outright. `review`, the default, needs a person signed in to the app: they decide it on the Approvals page, under Agent confirmations, in the business unit that asked (the account's admins are emailed the challenge when the platform can; read the confirmation's notify_status to know). `assisted` accepts the user's answer relayed through you with confirm_action. If the account has agent confirmations turned off, these actions are refused rather than run unconfirmed. For a send there is a shorter road under `review`: request_send puts the send itself in that Approvals queue with a full content, audience and schedule review, and once every step is approved, schedule_send succeeds with no separate challenge; the receipt records who approved it. list_pending_approvals lists both queues. Approval is not the last gate: a send on a live route also needs a recorded proof test (proof_test_send, to an address on a verified sending domain or the unit's proof-recipient allowlist, set in Settings, Send Management and inherited from the account) and passing readiness checks for its sending domain (run_delivery_readiness). request_send and schedule_send both report delivery_not_ready with the reasons; clear them before asking a person to review. - With agent confirmations turned OFF, gated actions split in two. Refused outright: scheduling a send, activating a journey, running an automation, resuming or restoring a send definition, publishing a landing page, promoting a landing page state, editing a live landing page, writing a data extension from a query, purging anything, writes to a live audience, clearing a data extension, forgetting a contact, making a template version current on a live template, editing a content block a live template renders, editing a dynamic content rule a live template renders, restoring a trashed template live mail renders, rebinding a live send definition, editing a sender profile, creating a default sender profile, and creating a sender profile while sends in the unit pick their profile by name. Run with no confirmation at all: creating any other sender profile and setting the postal address. - dispatch:request is the scope that sends nothing. It puts a draft in a queue for a person to approve and launch. Use it when the task is to prepare mail rather than send it. - Some writes reach inboxes without a send verb. Each one IS confirmed when its target is live, and never asks when it is not. Treat every one as a send: * Audience writes (upsert_data_extension_row, update_data_extension_row, delete_data_extension_row, import_data_extension_csv, update_data_extension, update_segment, remove_suppression_list_members) change who receives mail from whatever already reads that audience. A confirmation is asked for when the audience is read by a scheduled or sending send, a published journey, or a send or trigger_journey step of an active automation, including one nested inside a parallel step. A data extension that a live template reads while rendering (Lookup, LookupRows, or the variant table of a dynamic content rule it names) counts as live too: nobody is admitted, but what every recipient sees changes. Writing to an audience nothing live reads is not gated. * save_template_version makes the new version CURRENT unless you pass set_current=false. Published journeys, active automations and active triggered send definitions render the current version at send time, so when any of them renders the template the save is confirmed first and the challenge names them. A draft revision or an unused template is not gated. update_content_block is confirmed on the same terms when such a template's current version references the block, by document reference or by ContentBlockByName, ContentBlockByKey or ContentBlockById at send time. update_dynamic_content is confirmed on the same terms when such a template names the rule (DynamicContentByName); a description edit is not. A version locked for approval still refuses the block edit outright. * update_send_definition on a live definition (triggered, active, not paused) is confirmed when it changes the template, sender profile, list, suppression lists, opt-out honouring or classification, because the next external call sends the new binding. Renames, descriptions and lookup keys are not gated, and neither is a standard, paused or retired definition. * restore_object on a triggered send definition returns it to service and IS confirmed (dispatch:execute). restore_object on a trashed template that live mail renders IS confirmed (content:delete): every reader that refused the trashed template sends it again. update_landing_page on a page that is live or scheduled to publish IS confirmed (content:publish). With agent confirmations turned off, every live case above is refused rather than run unconfirmed; the non-live cases still go through. Check the usage reads (for example get_data_extension_usage and get_template_usage) before touching anything live. - update_sender_profile (sending:write) edits a From identity. Mail that names the profile goes out with the edited identity. Mail that names no sender profile is sent from the unit's default profile, so editing the default, or making a profile the default, changes that mail too, scheduled sends, live journeys, and triggered definitions included. Every call is confirmed, and with agent confirmations turned off it is refused. create_sender_profile with is_default true replaces the default, and while sends in the unit pick their sender profile by name (dynamic sender) a new profile's name can match their contacts; both are confirmed and refused the same way. A rename matters to those sends too. - set_mailing_address (sending:write) changes the postal address added at the bottom of messages from this unit that name no delivery profile or name the default one, transactional mail, scheduled sends, live journeys and triggered definitions included, unless the message already shows the address. It is confirmed on every call. With agent confirmations turned off it is not refused: it runs unconfirmed, like creating a sender profile. - A key holding dispatch:execute may also carry a daily send cap, and a sandboxed account delivers only to its own team members. Neither is a reason to skip the confirmation; both are reasons a send you scheduled may reach fewer people than the challenge described. On a sandboxed account, create_draft_send, request_send and schedule_send answer with sandbox.recipients_outside_team_suppressed: how many recipients will not receive the send for that reason. - Reads available to you: GET /api/agent/v1/me (your own key and its permissions), /business-units, /production-status (whether the account is still sandboxed, which decides whether a send reaches anyone, and the next setup step), /sending-domains (registered domains and their DNS records), /sender-profiles, /send-definitions, /resources/{templates|segments| data-extensions|sends|journeys|automations}, /segments/{id}/estimate, /contacts/shape (audience structure with no addresses in it), /approvals/{id}. Switch BU with the X-Business-Unit header. - Contact lookups: pass a COMPLETE address to confirm whether it is in the audience, or "@example.com" for a count at that domain. Both work without audiences:pii and return counts rather than rows. A partial string is a substring search and needs audiences:pii, because it reconstructs the addresses it would otherwise hide. For audience shape, use /contacts/shape. - Separately, an AUTOMATION key (`X-Automation-Key`, beginning `spk_` or `smak_`) exists for triggering an automation and for the transactional messaging API. It is a different credential and cannot reach anything listed above. ## Handling account data - Contact records are personal data belonging to the account's customers. Read the minimum the task needs, leave it in the platform, and do not copy addresses, phone numbers or names into files, prompts, commit messages, issue trackers, logs or third-party tools. - Reference a contact by id wherever an identifier will do, instead of echoing their details back. - Personalize with the platform's own tokens rather than pulling recipient data out and interpolating it yourself. The render happens per recipient at send time, inside the platform, so nothing identifying has to pass through you at all. - Never put an API key, session cookie or password into a template, a landing page, a send body or anything else the platform stores or delivers. - If a task seems to require any of the above, say so and stop. There is almost always a way to do the work without moving personal data, and an admin would rather be asked. When in doubt: look at how the account's existing objects are shaped (templates, definitions, profiles) and imitate them rather than inventing a parallel structure.