Skip to main content
POST
/
api
/
v1
/
attachments
/
{id}
/
confirm
Confirm Attachment Upload
curl --request POST \
  --url https://api.example.com/api/v1/attachments/{id}/confirm
{
  "success": true
}

Documentation Index

Fetch the complete documentation index at: https://docs.mailbreeze.com/llms.txt

Use this file to discover all available pages before exploring further.

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

id
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],
});

Response

success
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

StatusDescription
pendingUpload URL created but file not yet uploaded
uploadedFile uploaded and confirmed, ready for use
expiredUpload URL or attachment has expired

Errors

CodeHTTP StatusDescription
UPLOAD_NOT_FOUND404Invalid or expired upload token
UPLOAD_NOT_COMPLETE400File not yet uploaded to presigned URL
UPLOAD_EXPIRED400Upload URL has expired
FILE_SIZE_MISMATCH400Uploaded 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],
  // ...
});