Receive Emails: Routes

Raw Message

Download the raw .eml of a message or one of its attachments as binary data.

GEThttps://g.sendcorex.com/v1/raw
i

Message ids are base64, so they contain +, / and =. URL-encode them. HTTP libraries do this for you when you pass them as query parameters, as in the examples below.

!

Attachments are always served as attachment with application/octet-stream. The original type is in the X-Original-Content-Type response header. Treat attachments as untrusted files.

Query parameters

  • message_idstringrequired

    The message_uid of the message.

  • attachment_idstringoptional

    The attachment_id returned by get_messages. When set, the attachment is returned instead of the whole email.

Quick start

import axios from 'axios';
import { writeFileSync } from 'node:fs';

const response = await axios.get('https://g.sendcorex.com/v1/raw', {
  params: { message_id: 'Vj0xQUJDMTIz', attachment_id: 'Vj0xQVRUMDE' },
  headers: { Authorization: process.env.SENDCOREX_TOKEN },
  responseType: 'arraybuffer',
});

writeFileSync('attachment.bin', Buffer.from(response.data));

Response

HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment
X-Original-Content-Type: application/pdf

<binary data>

Response fields

  • Content-Type

    message/rfc822 for the raw email, or application/octet-stream for an attachment.

  • X-Original-Content-Type

    The real MIME type of the attachment, such as application/pdf.

Download the whole email

Leave out attachment_id to get the original message as an .eml file.

Node.js

import axios from 'axios';
import { writeFileSync } from 'node:fs';

const res = await axios.get('https://g.sendcorex.com/v1/raw', {
  params: { message_id: 'Vj0xQUJDMTIz' },
  headers: { Authorization: process.env.SENDCOREX_TOKEN },
  responseType: 'arraybuffer',
});

writeFileSync('message.eml', Buffer.from(res.data));

Errors

HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.

  • 401MISSING_AUTH_HEADER

    No Authorization header was sent.

  • 401INVALID_TOKEN

    The token is malformed, unknown or revoked.

  • 401TOKEN_EXPIRED

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

  • 429RATE_LIMITED

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