Content-Type for Multipart Mixed Messages

Set the Content-Type header for multipart/mixed messages. Covers batch requests, email composition, and combining different content types in one request.

Best Practices

Detailed Explanation

Multipart Mixed

multipart/mixed is used when a message body contains multiple parts of different content types that are independent of each other.

The Header Value

Content-Type: multipart/mixed; boundary=batch_boundary_001

Common Use Cases

  1. Batch API requests (Google APIs, OData)
  2. Email with attachments (MIME email)
  3. Combining JSON metadata with binary file

Batch API Request Example

Google APIs use multipart/mixed for batch requests:

Content-Type: multipart/mixed; boundary=batch_abc123

--batch_abc123
Content-Type: application/http

GET /api/users/1 HTTP/1.1
Host: api.example.com

--batch_abc123
Content-Type: application/http

GET /api/users/2 HTTP/1.1
Host: api.example.com

--batch_abc123--

JSON + File Upload

Combining metadata with a file in one request:

Content-Type: multipart/mixed; boundary=mixed_boundary

--mixed_boundary
Content-Type: application/json

{"name": "report.pdf", "folder": "/documents"}

--mixed_boundary
Content-Type: application/pdf
Content-Transfer-Encoding: binary

[PDF binary data]

--mixed_boundary--

Related Multipart Types

Type Use Case
multipart/form-data HTML form uploads
multipart/mixed Independent parts of different types
multipart/alternative Same content in different formats (email)
multipart/related Parts that reference each other (HTML + images)

curl Example

curl -X POST \
  -H "Content-Type: multipart/mixed; boundary=batch_001" \
  --data-binary @batch-request.txt \
  https://api.example.com/batch

Use Case

Use this for batch API requests (Google APIs, Microsoft Graph), sending JSON metadata alongside binary files in a single request, or composing MIME email messages programmatically.

Try It — Content-Type Header Builder

Open full tool