Receive Emails: Send & trust
Reply
Reply inside the same conversation. The reply is saved in Sent and INBOX, and the subject becomes Re: original.
https://g.sendcorex.com/v1command: replyThe recipient is the reply_to (or from) of the original message. If the id is a message you sent, the reply goes to the last client who wrote in the conversation, not to yourself. The labels of the original are kept.
Recipients who refused tracking on the preferences page are never tracked, even with true.
Emails sent from the mailbox carry no List-Unsubscribe header or unsubscribe link unless you send unsubscribe: true, because they are personal emails.
Everyone who receives an email from the mailbox becomes a contact in the account’s “Webmail” list and is trusted in this mailbox: their replies go to the Inbox and the address shows up in autocomplete. Senders the mailbox blocked stay blocked.
With unsubscribe: true, recipients who already unsubscribed from this mailbox are refused with RECIPIENT_UNSUBSCRIBED, and recipients lists them. Replies are never blocked.
Arguments
idstringrequiredThe
message_uidof the message you are replying to.htmlstringoptionalHTML body. Send
htmlortext.textstringoptionalPlain text body.
reply_allbooleanoptionalEveryone in the To and Cc of the original goes in Cc, except you and the person you reply to.
ccstring[]optionalExtra recipients in copy.
bccstring[]optionalExtra recipients in blind copy.
template_idstringoptionalFill the body from a template.
attachmentsobject[]optionalFiles in base64, same format as Send Email.
compose_uidstringoptionalAttachments uploaded before with
upload_attachment.followup_atstringoptionalRemind you if nobody replies by this date. Without it, a reminder already set on the conversation is removed (you just replied).
track_opensbooleanoptionalTrack when each recipient opens the email (invisible pixel). Default
true.track_clicksbooleanoptionalTrack clicks on the links (each link goes through a redirect). Default
true.unsubscribebooleanoptionalAdd an unsubscribe link. Put
[unsubscribe]in the body (as a linkhrefor as plain text) where the link should go; without it, a default line is added at the end. Defaultfalse.idempotency_keystringoptionalYour own key for this email (1–255 characters: letters, numbers,
_ - : .), valid for 24 hours. A retry with the same key and the same args returns the first result withidempotent_replayed: true, and nothing is sent again.recipientstringoptionalOnly on emails this mailbox sent: who gets the follow-up, in the same conversation with “Re:”. The person must have received that email (otherwise
INVALID_RECIPIENT). Without it, a reply to a sent email goes to its recipient, never back to the mailbox.
Retrying? Use an idempotency key so the email is never sent twice. Idempotency →
Quick start
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1',
{
commands: [
{
command: "reply",
args: {
id: "Vj0xQUJDMTIz",
text: "Received, thank you!",
reply_all: true
}
}
]
},
{ headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);
const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);Response
{
"type": "SUCCESS",
"results": [
{
"command": "reply",
"id": "0",
"type": "SUCCESS",
"data": {
"message_uid": "Vj0xQUJDMTIz",
"thread_id": "thr_9a1c4e72",
"message_id": "<5e0b9c1a-3d7f-4a21-9a6e-2f1c8d4b7e90>",
"queued": true
}
}
]
}Response fields
message_uidThe id of the reply.
thread_idThe same conversation as the original message.
message_idA provisional Message-ID, replaced by the real SMTP one shortly after.
queuedtrue= saved and queued, not delivered.idempotent_replayedOnly on a retry:
truewhen this is the stored result of an earlier call with the sameidempotency_key. Nothing was sent again.
Reply to the last email of a sender
Search by sender, then reply to the newest result. Search returns the newest message first.
Node.js
const [s] = await call({
command: 'search',
args: { query: 'ana@client.com', field: 'from', limit: 5 },
});
const last = s.data.messages[0]; // newest first
if (last) {
const [r] = await call({
command: 'reply',
args: { id: last.message_uid, html: '<p>Hi Ana, received!</p>' },
});
console.log(r.data); // { message_uid, thread_id, message_id, queued: true }
}Reply to every unread conversation
Reply and mark the conversation as read in the same request, so the next poll does not answer it again.
Node.js
const [l] = await call({ command: 'list_threads', args: { is_read: false, limit: 20 } });
for (const t of l.data.threads) {
await call([
{ command: 'reply', args: { id: t.last_message_uid, text: 'We got your message and will get back to you.' } },
{ command: 'set_flags', args: { id: t.last_message_uid, is_read: true, scope: 'thread' } },
]);
}You can also chain list_threads and reply in one request with $ref, using the last_message_uid of each thread.
Safe retries
Always send an idempotency_key (for example a UUID per email). If a call times out, retry with the same key: the email is never sent twice. Only a successful send is stored, so if the send failed, a retry with the same key runs again. Keys are per mailbox: the same key in another mailbox or in POST /v3.0/send does not conflict.
Request body
{
"commands": [
{
"command": "reply",
"args": {
"idempotency_key": "ticket-552-reply-1",
"id": "Vj0xQUJDMTIz",
"html": "<p>Thanks, we are on it.</p>"
}
}
]
}Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 401
TOKEN_EXPIREDThe access token has expired. Call Refresh Token and repeat the request.
- 401
INVALID_TOKENThe token is malformed, unknown or revoked.
- 429
RATE_LIMITEDMore than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.
- CMD
INVALID_IDEMPOTENCY_KEY`idempotency_key` must have 1–255 characters: letters, numbers, `_ - : .`.
- CMD
IDEMPOTENCY_KEY_REUSEDThis `idempotency_key` was already used with different args. Use a new key for every new email.
- CMD
IDEMPOTENCY_IN_PROGRESSA call with the same `idempotency_key` is still running. Try again in 1 second with the same key.
- CMD
INVALID_RECIPIENTThe recipient is missing or not a valid email.
- CMD
RECIPIENT_UNSUBSCRIBEDOne or more recipients unsubscribed from this mailbox. `recipients` lists them: remove them or send again with `unsubscribe: false`.
- CMD
INVALID_ARGSA required argument is missing or invalid.
- CMD
NOT_FOUNDThe message, thread or folder does not exist for this token.
- CMD
NO_RECIPIENTThe conversation has no recipient to reply to.
- CMD
RECIPIENT_LIMIT_EXCEEDEDto, cc and bcc together have more than 50 addresses.
- CMD
FILE_BLOCKEDA file was blocked by the security scan.
- CMD
ATTACHMENTS_TOO_LARGEThe attachments of the email add up to more than 25 MB, or the mailbox already has 500 MB of uploads waiting to be sent.
- CMD
NO_CREDITSThe account has fewer email credits than recipients (1 credit per copy).
- CMD
SENDER_NOT_FOUNDThe sender behind the token is not registered.
- CMD
SENDER_NO_DOMAINThe sender behind the token has no domain.
- CMD
INTERNALServer error. The detail is only written to the server log.