Skip to main content
POST
/
emails
/
attachment-uploads
Create an attachment upload URL
curl --request POST \
  --url https://smtp.sendmux.ai/api/v1/emails/attachment-uploads \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "filename": "analysis.pdf",
  "size_bytes": 20480
}
'
import requests

url = "https://smtp.sendmux.ai/api/v1/emails/attachment-uploads"

payload = {
    "filename": "analysis.pdf",
    "size_bytes": 20480
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({filename: 'analysis.pdf', size_bytes: 20480})
};

fetch('https://smtp.sendmux.ai/api/v1/emails/attachment-uploads', 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/attachment-uploads"

	payload := strings.NewReader("{\n  \"filename\": \"analysis.pdf\",\n  \"size_bytes\": 20480\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	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": {
    "upload_id": "upl_tz4a98xxat96iws9zmbrgj3a",
    "upload_url": "https://smtp.sendmux.ai/api/v1/emails/attachment-uploads/upl_tz4a98xxat96iws9zmbrgj3a",
    "method": "PUT",
    "expires_at": "2026-07-07T08:15:00.000Z",
    "max_size_bytes": 18874368,
    "headers": {
      "Content-Type": "application/pdf",
      "Content-Length": "20480",
      "X-Sendmux-Upload-Token": "smx_upload_..."
    }
  }
}
{
  "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

Body

application/json
filename
string
required

Filename to associate with the uploaded attachment.

Required string length: 1 - 255
Example:

"analysis.pdf"

size_bytes
integer
required

Exact byte size that will be uploaded.

Example:

20480

content_type
string

MIME type expected for the upload.

Maximum string length: 255
Example:

"application/pdf"

sha256
string

Optional SHA-256 hex digest for the upload bytes.

Pattern: ^[a-f0-9]{64}$
Example:

"0000000000000000000000000000000000000000000000000000000000000000"

Response

Attachment upload URL created

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