Confirm Attachment Upload
curl --request POST \
--url https://api.example.com/api/v1/attachments/{id}/confirmimport requests
url = "https://api.example.com/api/v1/attachments/{id}/confirm"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/attachments/{id}/confirm', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/attachments/{id}/confirm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/attachments/{id}/confirm"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/attachments/{id}/confirm")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/attachments/{id}/confirm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"success": true
}Attachments
Confirm Attachment Upload
Confirm that an attachment has been uploaded
POST
/
api
/
v1
/
attachments
/
{id}
/
confirm
Confirm Attachment Upload
curl --request POST \
--url https://api.example.com/api/v1/attachments/{id}/confirmimport requests
url = "https://api.example.com/api/v1/attachments/{id}/confirm"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/attachments/{id}/confirm', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/attachments/{id}/confirm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/attachments/{id}/confirm"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/attachments/{id}/confirm")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/attachments/{id}/confirm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"success": true
}Confirm that a file has been successfully uploaded to the presigned URL. This step is required before the attachment can be used in emails.
Path Parameters
string
required
The attachment ID received from the
createUpload endpoint (e.g., att_abc123).Examples
import { MailBreeze } from "mailbreeze";
const mailbreeze = new MailBreeze({ apiKey: "sk_live_xxx" });
// After uploading the file to the presigned URL...
const attachment = await mailbreeze.attachments.confirm({
uploadToken: "token_xyz789",
});
console.log(attachment.id); // "att_abc123"
console.log(attachment.fileName); // "report.pdf"
console.log(attachment.status); // "uploaded"
console.log(attachment.fileSize); // 1024000
// Now use it in an email
await mailbreeze.emails.send({
from: "hello@yourdomain.com",
to: "user@example.com",
subject: "Your report",
html: "<p>Report attached.</p>",
attachmentIds: [attachment.id],
});
from mailbreeze import MailBreeze
client = MailBreeze(api_key="sk_live_xxx")
# After uploading the file to the presigned URL...
attachment = await client.attachments.confirm(
upload_token="token_xyz789",
)
print(attachment.id) # "att_abc123"
print(attachment.file_name) # "report.pdf"
print(attachment.status) # "uploaded"
print(attachment.file_size) # 1024000
# Now use it in an email
await client.emails.send(
from_="hello@yourdomain.com",
to="user@example.com",
subject="Your report",
html="<p>Report attached.</p>",
attachment_ids=[attachment.id],
)
client := mailbreeze.NewClient("sk_live_xxx")
// After uploading the file to the presigned URL...
attachment, err := client.Attachments.Confirm(ctx, &mailbreeze.ConfirmAttachmentParams{
UploadToken: "token_xyz789",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(attachment.ID) // "att_abc123"
fmt.Println(attachment.FileName) // "report.pdf"
fmt.Println(attachment.Status) // "uploaded"
fmt.Println(attachment.FileSize) // 1024000
// Now use it in an email
client.Emails.Send(ctx, &mailbreeze.SendEmailParams{
From: "hello@yourdomain.com",
To: []string{"user@example.com"},
Subject: "Your report",
HTML: "<p>Report attached.</p>",
AttachmentIds: []string{attachment.ID},
})
$mailbreeze = new MailBreeze('sk_live_xxx');
// After uploading the file to the presigned URL...
$result = $mailbreeze->attachments->confirm('att_abc123');
echo $result['success'] ? 'Confirmed!' : 'Failed';
// Now use it in an email
$mailbreeze->emails->send([
'from' => 'hello@yourdomain.com',
'to' => 'user@example.com',
'subject' => 'Your report',
'html' => '<p>Report attached.</p>',
'attachmentIds' => ['att_abc123'],
]);
let client = Client::new("sk_live_xxx");
// After uploading the file to the presigned URL...
let attachment = client.attachments().confirm(ConfirmAttachmentParams {
upload_token: "token_xyz789".to_string(),
}).await?;
println!("{}", attachment.id); // "att_abc123"
println!("{}", attachment.file_name); // "report.pdf"
println!("{}", attachment.status); // "uploaded"
println!("{}", attachment.file_size); // 1024000
// Now use it in an email
client.emails().send(SendEmailParams {
from: "hello@yourdomain.com".to_string(),
to: vec!["user@example.com".to_string()],
subject: Some("Your report".to_string()),
html: Some("<p>Report attached.</p>".to_string()),
attachment_ids: Some(vec![attachment.id]),
..Default::default()
}).await?;
curl -X POST https://api.mailbreeze.com/api/v1/attachments/att_abc123/confirm \
-H "Authorization: Bearer sk_live_xxx"
Response
boolean
Indicates whether the confirmation was successful.
Example Response
{
"success": true,
"data": null,
"meta": {
"timestamp": "2024-01-15T10:30:00.000Z",
"requestId": "req_abc123",
"path": "/api/v1/attachments/att_abc123/confirm"
}
}
Attachment Status
| Status | Description |
|---|---|
pending | Upload URL created but file not yet uploaded |
uploaded | File uploaded and confirmed, ready for use |
expired | Upload URL or attachment has expired |
Errors
| Code | HTTP Status | Description |
|---|---|---|
UPLOAD_NOT_FOUND | 404 | Invalid or expired upload token |
UPLOAD_NOT_COMPLETE | 400 | File not yet uploaded to presigned URL |
UPLOAD_EXPIRED | 400 | Upload URL has expired |
FILE_SIZE_MISMATCH | 400 | Uploaded file size doesn’t match declared size |
Attachments expire 7 days after confirmation. If you need to send the same file again after expiration, you’ll need to create a new upload.
Reusing Attachments
Once confirmed, an attachment ID can be reused in multiple emails until it expires:// Same attachment in multiple emails
const attachmentId = "att_abc123";
await mailbreeze.emails.send({
to: "user1@example.com",
attachmentIds: [attachmentId],
// ...
});
await mailbreeze.emails.send({
to: "user2@example.com",
attachmentIds: [attachmentId],
// ...
});