Skip to main content
POST
/
emails
/
attachments
Upload an attachment
curl --request POST \
  --url https://smtp.sendmux.ai/api/v1/emails/attachments \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Length: <content-length>' \
  --header 'Content-Type: application/octet-stream' \
  --data '"<string>"'
import requests

url = "https://smtp.sendmux.ai/api/v1/emails/attachments"

payload = "<string>"
headers = {
    "Content-Length": "<content-length>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/octet-stream"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {
    'Content-Length': '<content-length>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/octet-stream'
  },
  body: JSON.stringify('<string>')
};

fetch('https://smtp.sendmux.ai/api/v1/emails/attachments', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://smtp.sendmux.ai/api/v1/emails/attachments"

	payload := strings.NewReader("\"<string>\"")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Length", "<content-length>")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/octet-stream")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
{
  "ok": true,
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  },
  "data": {
    "attachment_id": "att_tz4a98xxat96iws9zmbrgj3a",
    "filename": "analysis.pdf",
    "content_type": "application/pdf",
    "size_bytes": 20480,
    "expires_at": "2026-07-07T08:15:00.000Z"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}
{
  "ok": false,
  "error": {
    "code": "validation_error",
    "message": "<string>",
    "retryable": true,
    "param": "<string>",
    "doc_url": "<string>",
    "errors": [
      {
        "field": "to.email",
        "code": "invalid_string",
        "message": "<string>"
      }
    ]
  },
  "meta": {
    "request_id": "req_clxxxxxxxxxxxxxxxxxxxxxxxxx"
  }
}

Authorizations

Authorization
string
header
required

Sendmux API key (smx_...)

Headers

Idempotency-Key
string

Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.

Maximum string length: 255
Content-Length
integer<int64>
required

Exact number of bytes in the binary request body.

Required range: x >= 1

Query Parameters

filename
string
required

Filename to associate with the uploaded attachment.

Required string length: 1 - 255
content_type
string

MIME type override for the uploaded attachment.

Maximum string length: 255

Body

application/octet-stream

The body is of type file.

Response

Attachment uploaded successfully

ok
enum<boolean>
required
Available options:
true
meta
object
required
data
object
required