Receive Emails: Drafts
Save Draft
Save an email in Drafts without sending it. It opens in the webmail like any other draft, and you can send it later with send_draft.
https://g.sendcorex.com/v1command: save_draftA draft can be incomplete: every field is optional. What you send is checked (a to that is not an email fails), what you leave out is not.
To edit a draft, send its draft_id. Fields you leave out are kept (body, recipients, subject, attachments, follow-up). Every save returns a NEW draft_id and the old one stops working, so always keep the last one.
If track_opens or track_clicks is omitted, the draft keeps the choice it already had. send_draft and the scheduled send use that choice.
Recipients who refused tracking on the preferences page are never tracked, even with true.
Arguments
draft_idstringoptionalEdit this draft instead of creating a new one.
modestringoptionalnew(default),replyorforward. When editing, the draft keeps its mode.idstringoptionalThe original message, for
replyandforward. The subject defaults to Re: / Fwd: original.tostring | string[]optionalRecipient, or an array of up to 30 for
new(paid plans). Ignored forreply: it goes to the sender of the original.ccstring[]optionalVisible copies.
bccstring[]optionalHidden copies.
subjectstringoptionalSubject.
htmlstringoptionalHTML body. Or
text, ortemplate_id.textstringoptionalPlain text body, turned into simple HTML.
template_idstringoptionalFill the body (and the subject) from a template.
variablesobjectoptionalValues for the template variables, like
{ "first_name": "Ana" }.followup_after_hoursnumber | nulloptionalRemind you if nobody replies this many hours after it is sent (up to 8760).
nullremoves it.attachmentsobject[]optionalFiles to attach:
[{ file_name, content, content_type }],contentin base64. They are added to the files the draft already has.compose_uidstringoptionalFiles uploaded before with
upload_attachmentor Upload Large File.attachment_idsstring[]optionalWhich of the uploaded files to use. Without it, all of them.
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.audiencestringoptionalSend to an audience instead of addresses:
subscribed,opened,clicked,both,seg:<segment_id>ormsg:<message_uid>:opened|clicked|not_opened.tobecomes optional. Up to 5,000 people. The unsubscribe link is turned on and the email goes out as marketing. Paid plans.
Quick start
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1',
{
commands: [
{
command: "save_draft",
args: {
to: "ana@client.com",
subject: "Proposal",
html: "<p>Hi Ana, here is the proposal.</p>"
}
}
]
},
{ 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": "save_draft",
"id": "0",
"type": "SUCCESS",
"data": {
"draft_id": "Vj0xRFJBRlQx",
"thread_id": "thr_9a1c4e72"
}
}
]
}Response fields
draft_idThe draft. Use it to edit, read, send or delete it. Changes on every save.
thread_idThe conversation the draft belongs to.
Edit a draft
Only the subject changes here. The body, recipients and attachments stay as they were.
Request body
{
"commands": [
{
"command": "save_draft",
"args": {
"draft_id": "Vj0xRFJBRlQx",
"subject": "Proposal (v2)"
}
}
]
}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_AUDIENCEThe audience is not valid: unknown group, a segment of another mailbox or a message this mailbox didn’t send.
- CMD
INVALID_ARGSA required argument is missing or invalid.
- CMD
PAID_PLAN_REQUIREDMore than one address in `to` needs a paid plan.
- CMD
TOO_MANY_RECIPIENTS`to` has more than 30 addresses.
- CMD
DRAFT_NOT_FOUNDThe draft does not exist anymore: it was sent, deleted, or saved again (every save returns a new draft_id).
- CMD
MISSING_TARGETReply and forward need the original email, and it must still exist.
- CMD
INVALID_RECIPIENTThe recipient is missing or not a valid email.
- CMD
INVALID_CCADDRESSOne of the cc addresses is not a valid email.
- CMD
INVALID_BCCADDRESSOne of the bcc addresses is not a valid email.
- CMD
RECIPIENT_LIMIT_EXCEEDEDto, cc and bcc together have more than 50 addresses.
- CMD
INVALID_ATTACHMENTAn attachment content is not valid base64.
- 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
ATTACHMENT_MISSINGAn uploaded attachment no longer exists (uploads not sent within 48 hours, and not used by a draft or scheduled email, are deleted). Upload it again.
- CMD
INTERNALServer error. The detail is only written to the server log.