Attachments
Download a file from a message.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
attachments.get
Download an attachment.
POST/v1/attachments.get
App key with readAPI token
Parameters
The attachment’s id, from the message it came on in
threads get.
Returns
data is an object with:
The file’s name.
Its media type, as the message declared it.
Its size in bytes.
The file, base64.
import { Mailset } from 'mailset';
// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();
const answer = await mailset.attachments.get({
id: "att_3c9e1f7a5b2d4086c7e1a9f2",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_KEY from the environment.
mailset = Mailset()
answer = mailset.attachments.get(
{"id": "att_3c9e1f7a5b2d4086c7e1a9f2"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_KEY from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.AttachmentsGetParams{
ID: "att_3c9e1f7a5b2d4086c7e1a9f2",
}
answer, err := client.Attachments.Get(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_KEY from the environment.
mailset = Mailset::Client.new
answer = mailset.attachments.get(
id: 'att_3c9e1f7a5b2d4086c7e1a9f2'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->attachments->get([
'id' => 'att_3c9e1f7a5b2d4086c7e1a9f2',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AttachmentsGetParams;
import app.mailset.model.AttachmentsGetResult;
// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();
var params = AttachmentsGetParams.builder()
.id("att_3c9e1f7a5b2d4086c7e1a9f2")
.build();
AttachmentsGetResult answer =
mailset.attachments().get(params);
System.out.println(answer);
use mailset::types::AttachmentsGetParams;
// Reads MAILSET_KEY from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.attachments()
.get(AttachmentsGetParams {
id: "att_3c9e1f7a5b2d4086c7e1a9f2".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/attachments.get \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"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 attachments get att_3c9e1f7a5b2d4086c7e1a9f2 --out invoice.pdf
{
"ok": true,
"data": {
"name": "Acme API",
"contentType": "text",
"size": 20480,
"data": "<base64>"
}
}