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.
Arguments
idstringrequiredThe
message_uidof the message you are replying to.htmlstringoptionalHTML body. Send
htmlortext.textstringoptionalPlain text body.
ccstring[]optionalExtra recipients in copy.
bccstring[]optionalExtra recipients in blind copy.
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!"
}
}
]
},
{ 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.
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.
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_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
NO_CREDITSThe account has no email credits left.
- 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.