Receive Emails: Send & trust

Reply

Reply inside the same conversation. The reply is saved in Sent and INBOX, and the subject becomes Re: original.

POSThttps://g.sendcorex.com/v1command: reply
i

The 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

  • idstringrequired

    The message_uid of the message you are replying to.

  • htmlstringoptional

    HTML body. Send html or text.

  • textstringoptional

    Plain text body.

  • ccstring[]optional

    Extra recipients in copy.

  • bccstring[]optional

    Extra 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_uid

    The id of the reply.

  • thread_id

    The same conversation as the original message.

  • message_id

    A provisional Message-ID, replaced by the real SMTP one shortly after.

  • queued

    true = 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' } },
  ]);
}
i

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.

  • 401TOKEN_EXPIRED

    The access token has expired. Call Refresh Token and repeat the request.

  • 401INVALID_TOKEN

    The token is malformed, unknown or revoked.

  • 429RATE_LIMITED

    More than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.

  • CMDINVALID_ARGS

    A required argument is missing or invalid.

  • CMDNOT_FOUND

    The message, thread or folder does not exist for this token.

  • CMDNO_RECIPIENT

    The conversation has no recipient to reply to.

  • CMDNO_CREDITS

    The account has no email credits left.

  • CMDSENDER_NOT_FOUND

    The sender behind the token is not registered.

  • CMDSENDER_NO_DOMAIN

    The sender behind the token has no domain.

  • CMDINTERNAL

    Server error. The detail is only written to the server log.