Drafts
Save a draft, attach files, and throw one away.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
The Draft object
A message being written: its addresses, its words and its files.
Attributes
The draft’s id.
The mailbox it would be sent from.
The From address: the mailbox’s own or one of its aliases.
The To addresses, as typed.
The Cc addresses, as typed.
The Bcc addresses, as typed.
Its subject.
Its text.
The conversation it answers, or null for a new one.
When it was last saved, in milliseconds since 1970.
Its files.
The text carries formatting marks, so it goes out formatted.
Answered by
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"cc": "text",
"bcc": "text",
"subject": "Your Acme receipt",
"text": "text",
"threadId": "out_3f9a1c0e7b2d",
"updatedAt": 1796048940000,
"files": [
{
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"contentType": "text",
"size": 20480,
"scan": "clean"
}
],
"markdown": true
}
drafts.save
Save a draft, new or by id.
POST/v1/drafts.save
Parameters
The draft to change. Left out: a new draft.
One of your addresses.
Who it goes to, as typed: addresses with commas between them.
At most 10,000 characters.
Who gets a copy, as typed.
At most 10,000 characters.
Who gets a hidden copy, as typed.
At most 10,000 characters.
The subject, on one line.
At most 998 characters.
The draft’s text.
At most 1,000,000 characters.
The conversation it answers.
texthas Markdown to send as formatting.Default
false.
Returns
data is the Draft object.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.drafts.save({
from: "moc.elpmaxe@ana",
to: "moc.elpmaxe@airam",
subject: "Quote for March",
text: "Hi Maria, the quote is attached.",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.drafts.save(
{
"from": "moc.elpmaxe@ana",
"to": "moc.elpmaxe@airam",
"subject": "Quote for March",
"text": "Hi Maria, the quote is attached.",
}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.DraftsSaveParams{
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.drafts.save(
from: 'moc.elpmaxe@ana',
to: 'moc.elpmaxe@airam',
subject: 'Quote for March',
text: 'Hi Maria, the quote is attached.'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->drafts->save([
'from' => 'moc.elpmaxe@ana',
'to' => 'moc.elpmaxe@airam',
'subject' => 'Quote for March',
'text' => 'Hi Maria, the quote is attached.',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Draft;
import app.mailset.model.DraftsSaveParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = DraftsSaveParams.builder()
.from("moc.elpmaxe@ana")
.to("moc.elpmaxe@airam")
.subject("Quote for March")
.text("Hi Maria, the quote is attached.")
.build();
Draft answer = mailset.drafts().save(params);
System.out.println(answer);
use mailset::types::DraftsSaveParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.drafts()
.save(DraftsSaveParams {
from: "moc.elpmaxe@ana".into(),
to: Some("moc.elpmaxe@airam".into()),
subject: Some("Quote for March".into()),
text: Some(
"Hi Maria, the quote is attached.".into(),
),
..Default::default()
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/drafts.save \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"from":"moc.elpmaxe@ana","to":"moc.elpmaxe@airam","subject":"Quote for March","text":"Hi Maria, the quote is attached."}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset drafts save --from moc.elpmaxe@ana --to moc.elpmaxe@airam --subject "Quote for March" --text "Hi Maria, the quote is attached."
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"cc": "text",
"bcc": "text",
"subject": "Your Acme receipt",
"text": "text",
"threadId": "out_3f9a1c0e7b2d",
"updatedAt": 1796048940000,
"files": [
{
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"contentType": "text",
"size": 20480,
"scan": "clean"
}
],
"markdown": true
}
}
drafts.list
List your drafts.
POST/v1/drafts.list
Parameters
It takes no input: send an empty object.
Returns
data is a list of Draft objects.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.drafts.list();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.drafts.list()
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
answer, err := client.Drafts.List(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.drafts.list
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->drafts->list();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Draft;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
List<Draft> answer = mailset.drafts().list();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.drafts().list().await?;
println!("{answer:?}");
curl https://mailset.app/v1/drafts.list \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset drafts list
{
"ok": true,
"data": [
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"cc": "text",
"bcc": "text",
"subject": "Your Acme receipt",
"text": "text",
"threadId": "out_3f9a1c0e7b2d",
"updatedAt": 1796048940000,
"files": [
{
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"contentType": "text",
"size": 20480,
"scan": "clean"
}
],
"markdown": true
}
]
}
drafts.remove
Throw a draft away.
POST/v1/drafts.remove
Parameters
The draft’s id.
Returns
data is an object with:
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.drafts.remove({
id: "dr_7a4f2e9c1b6d3058e2c9a4f1",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.drafts.remove(
{"id": "dr_7a4f2e9c1b6d3058e2c9a4f1"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.DraftsRemoveParams{
ID: "dr_7a4f2e9c1b6d3058e2c9a4f1",
}
answer, err := client.Drafts.Remove(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.drafts.remove(
id: 'dr_7a4f2e9c1b6d3058e2c9a4f1'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->drafts->remove([
'id' => 'dr_7a4f2e9c1b6d3058e2c9a4f1',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.DraftsRemoveParams;
import app.mailset.model.DraftsRemoveResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = DraftsRemoveParams.builder()
.id("dr_7a4f2e9c1b6d3058e2c9a4f1")
.build();
DraftsRemoveResult answer =
mailset.drafts().remove(params);
System.out.println(answer);
use mailset::types::DraftsRemoveParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.drafts()
.remove(DraftsRemoveParams {
id: "dr_7a4f2e9c1b6d3058e2c9a4f1".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/drafts.remove \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"dr_7a4f2e9c1b6d3058e2c9a4f1"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset drafts remove dr_7a4f2e9c1b6d3058e2c9a4f1
{
"ok": true,
"data": {
"removed": true
}
}
drafts.attach
Attach a file to a draft.
POST/v1/drafts.attach
Parameters
The draft’s id.
The file’s name.
At most 255 characters.
Its media type.
Default
application/octet-stream. At most 120 characters.The file, base64.
The body may be up to 20 MB.
Returns
data is an object with:
The file’s id.
Its file name.
Its media type.
Its size in bytes.
What the virus scan said.
One of
cleaninfectedunscanned
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.drafts.attach({
contentType: "application/pdf",
id: "dr_7a4f2e9c1b6d3058e2c9a4f1",
name: "quote.pdf",
data: "<the message as base64>",
});
console.log(answer);
<the message as base64> is a whole email, headers and body: Send your own MIME.
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.drafts.attach(
{
"content_type": "application/pdf",
"id": "dr_7a4f2e9c1b6d3058e2c9a4f1",
"name": "quote.pdf",
"data": "<the message as base64>",
}
)
print(answer)
<the message as base64> is a whole email, headers and body: Send your own MIME.
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.DraftsAttachParams{
<the message as base64> is a whole email, headers and body: Send your own MIME.
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.drafts.attach(
content_type: 'application/pdf',
id: 'dr_7a4f2e9c1b6d3058e2c9a4f1',
name: 'quote.pdf',
data: '<the message as base64>'
)
p answer
<the message as base64> is a whole email, headers and body: Send your own MIME.
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->drafts->attach([
'contentType' => 'application/pdf',
'id' => 'dr_7a4f2e9c1b6d3058e2c9a4f1',
'name' => 'quote.pdf',
'data' => '<the message as base64>',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
<the message as base64> is a whole email, headers and body: Send your own MIME.
import app.mailset.Mailset;
import app.mailset.model.DraftFile;
import app.mailset.model.DraftsAttachParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = DraftsAttachParams.builder()
.contentType("application/pdf")
.id("dr_7a4f2e9c1b6d3058e2c9a4f1")
.name("quote.pdf")
.data("<the message as base64>")
.build();
DraftFile answer = mailset.drafts().attach(params);
System.out.println(answer);
<the message as base64> is a whole email, headers and body: Send your own MIME.
use mailset::types::DraftsAttachParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.drafts()
.attach(DraftsAttachParams {
id: "dr_7a4f2e9c1b6d3058e2c9a4f1".into(),
name: "quote.pdf".into(),
content_type: Some("application/pdf".into()),
data: "<the message as base64>".into(),
})
.await?;
println!("{answer:?}");
<the message as base64> is a whole email, headers and body: Send your own MIME.
curl https://mailset.app/v1/drafts.attach \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"contentType":"application/pdf","id":"dr_7a4f2e9c1b6d3058e2c9a4f1","name":"quote.pdf","data":"<base64 of the file>"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset drafts attach dr_7a4f2e9c1b6d3058e2c9a4f1 --file quote.pdf --content-type application/pdf
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"contentType": "text",
"size": 20480,
"scan": "clean"
}
}
drafts.detach
Take a file off a draft.
POST/v1/drafts.detach
Parameters
The attached file’s id, from the draft’s
files.
Returns
data is an object with:
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.drafts.detach({
file: "att_3c9e1f7a5b2d4086c7e1a9f2",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.drafts.detach(
{"file": "att_3c9e1f7a5b2d4086c7e1a9f2"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.DraftsDetachParams{
File: "att_3c9e1f7a5b2d4086c7e1a9f2",
}
answer, err := client.Drafts.Detach(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.drafts.detach(
file: 'att_3c9e1f7a5b2d4086c7e1a9f2'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->drafts->detach([
'file' => 'att_3c9e1f7a5b2d4086c7e1a9f2',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.DraftsDetachParams;
import app.mailset.model.DraftsDetachResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = DraftsDetachParams.builder()
.file("att_3c9e1f7a5b2d4086c7e1a9f2")
.build();
DraftsDetachResult answer =
mailset.drafts().detach(params);
System.out.println(answer);
use mailset::types::DraftsDetachParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.drafts()
.detach(DraftsDetachParams {
file: "att_3c9e1f7a5b2d4086c7e1a9f2".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/drafts.detach \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"file":"att_3c9e1f7a5b2d4086c7e1a9f2"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset drafts detach att_3c9e1f7a5b2d4086c7e1a9f2
{
"ok": true,
"data": {
"removed": true
}
}
drafts.forward
Copy a message’s attachments onto a draft.
POST/v1/drafts.forward
Parameters
The draft’s id.
The message whose attachments are copied.
Returns
data is an object with:
The files now on the draft from that message.
How many didn’t fit, or can’t be sent on.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.drafts.forward({
messageId: "msg_91b7e4c2a6f03d58b1c4e7a9",
id: "dr_7a4f2e9c1b6d3058e2c9a4f1",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.drafts.forward(
{
"message_id": "msg_91b7e4c2a6f03d58b1c4e7a9",
"id": "dr_7a4f2e9c1b6d3058e2c9a4f1",
}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.DraftsForwardParams{
MessageID: "msg_91b7e4c2a6f03d58b1c4e7a9",
ID: "dr_7a4f2e9c1b6d3058e2c9a4f1",
}
answer, err := client.Drafts.Forward(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.drafts.forward(
message_id: 'msg_91b7e4c2a6f03d58b1c4e7a9',
id: 'dr_7a4f2e9c1b6d3058e2c9a4f1'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->drafts->forward([
'messageId' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
'id' => 'dr_7a4f2e9c1b6d3058e2c9a4f1',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.DraftsForwardParams;
import app.mailset.model.DraftsForwardResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = DraftsForwardParams.builder()
.messageId("msg_91b7e4c2a6f03d58b1c4e7a9")
.id("dr_7a4f2e9c1b6d3058e2c9a4f1")
.build();
DraftsForwardResult answer =
mailset.drafts().forward(params);
System.out.println(answer);
use mailset::types::DraftsForwardParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.drafts()
.forward(DraftsForwardParams {
id: "dr_7a4f2e9c1b6d3058e2c9a4f1".into(),
message_id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/drafts.forward \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"messageId":"msg_91b7e4c2a6f03d58b1c4e7a9","id":"dr_7a4f2e9c1b6d3058e2c9a4f1"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset drafts forward dr_7a4f2e9c1b6d3058e2c9a4f1 --message-id msg_91b7e4c2a6f03d58b1c4e7a9
{
"ok": true,
"data": {
"files": [
{
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"contentType": "text",
"size": 20480,
"scan": "clean"
}
],
"skipped": 1
}
}