POST/api/v1/projects/{project_id}/templates/{template_id}/test-send
send_test_email
Sends a message template as a test to a few addresses through the project’s transport: rendered as preview_template renders it with sample_attributes (with none, every attribute is the text sample), from the project’s settings.from_email, the subject prefixed [TEST] , with the header X-Postwind-Test: 1.
- Call it
- to see a template in a real mailbox before a campaign; each call sends again (there is no idempotency in MCP).
- Needs
- an admin key with
project_id, or a project key with scopesend(its own project; the argument is ignored), a project that is not deleted, a message template (a partial isvalidation_failedontemplate_id), 1 to 10 valid addresses into(validation_failed,toorto.<index>), and, asprecondition_failed: asettings.from_emailon the project and a transport this node can send through (transport_unavailable;get_server_infolists them inavailable_transports). An address in the project’s suppression list is not sent to. - Returns
transport,from_email,subjectandresults, one per distinct address (email,outcome:accepted,deferred,rejected,suppressedorfailed,message_id,smtp_code,smtp_text,stage), the same asPOST /api/v1/projects/{project_id}/templates/{template_id}/test-send.
Arguments
- object
-
template_idstring · uuidrequiredThe message template’s id.
-
toarray of stringrequired1 to 10 addresses to send the test message to.
example
["me@example.com"] -
project_idstring · uuid | nullThe template’s project. An admin key must pass it; a project key’s own project is used and this is ignored.
-
sample_attributesmap of string → string | number | boolean | nullAttributes to render with, as a subscriber’s (string, number or boolean values); without them every attribute is the text
sample.
No other arguments are accepted.
Result
The result comes back as structuredContent, with the same JSON as a text block.
- object · all fields required
-
from_emailstringThe sender: the project’s
settings.from_email. -
resultsarray of TestSendResultOutputOne per distinct address, in the order of the request.
6 fields
- TestSendResultOutput object · all fields required
-
emailstringThe address, normalized.
-
message_idstring | nullThe message’s
Message-ID, without angle brackets;nullwhen it was not sent (suppressed). -
outcomeTestSendOutcomeOutputHow the test message to one address went.
acceptedThe recipient’s server took it.deferredA temporary refusal (4xx); a test message is not tried again.rejectedA permanent refusal (5xx) atstage.suppressedThe address is in the project’s suppression list: not sent.failedThe transport could not attempt it; the reason is in the node’s log. -
smtp_codeinteger · uint16 | nullThe reply code of a refusal (
deferred,rejected); otherwisenull.0–65535
-
smtp_textstring | nullThe reply text of a refusal (
deferred,rejected); otherwisenull. -
stageRejectStageOutput | nullThe stage of a
rejected; otherwisenull.- connect
- rcpt
- data
-
subjectstringThe subject every message carries:
[TEST]and the rendered one. -
transportstringThe transport the messages went through:
direct,relay:<name>.
Definitions
RejectStageOutput
The session stage a refusal happened at.
string · enum
- connect
- rcpt
- data
TestSendOutcomeOutput
How the test message to one address went.
string · enum
accepted The recipient’s server took it.
deferred A temporary refusal (4xx); a test message is not tried again.
rejected A permanent refusal (5xx) at stage.
suppressed The address is in the project’s suppression list: not sent.
failed The transport could not attempt it; the reason is in the node’s log.
TestSendResultOutput
The test message to one address.
- object · all fields required
-
emailstringThe address, normalized.
-
message_idstring | nullThe message’s
Message-ID, without angle brackets;nullwhen it was not sent (suppressed). -
outcomeTestSendOutcomeOutputHow the test message to one address went.
acceptedThe recipient’s server took it.deferredA temporary refusal (4xx); a test message is not tried again.rejectedA permanent refusal (5xx) atstage.suppressedThe address is in the project’s suppression list: not sent.failedThe transport could not attempt it; the reason is in the node’s log. -
smtp_codeinteger · uint16 | nullThe reply code of a refusal (
deferred,rejected); otherwisenull.0–65535
-
smtp_textstring | nullThe reply text of a refusal (
deferred,rejected); otherwisenull. -
stageRejectStageOutput | nullThe stage of a
rejected; otherwisenull.- connect
- rcpt
- data
Errors
A failed call answers isError: true with a code from the same table as the HTTP API, and detail. How tools report errors
HTTP API
The same operation over HTTP: POST /api/v1/projects/{project_id}/templates/{template_id}/test-send