Send batch emails
POST
https://api.postwick.dev /emails/batch Send up to 100 emails in one request.
Request body application/json
[
{
"from": "string",
"to": [
"string"
],
"subject": "string",
"html": "string",
"text": "string",
"cc": [
"string"
],
"reply_to": "string",
"scheduled_at": "string",
"tags": [
{}
]
}
]Code samples
cURL
curl -X POST "https://api.postwick.dev/emails/batch" \
-H "Content-Type: application/json" \
-d '[{"from":"string","to":["string"],"subject":"string","html":"string","text":"string","cc":["string"],"reply_to":"string","scheduled_at":"string","tags":[{}]}]'TypeScript
const res = await fetch('https://api.postwick.dev/emails/batch', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify([{"from":"string","to":["string"],"subject":"string","html":"string","text":"string","cc":["string"],"reply_to":"string","scheduled_at":"string","tags":[{}]}]),
});
const data = await res.json();Python
import requests
res = requests.request(
"POST",
"https://api.postwick.dev/emails/batch",
headers={
"Content-Type": "application/json",
},
json=[{"from": "string", "to": ["string"], "subject": "string", "html": "string", "text": "string", "cc": ["string"], "reply_to": "string", "scheduled_at": "string", "tags": [{}]}],
)
data = res.json()Go
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, _ := http.NewRequest("POST", "https://api.postwick.dev/emails/batch", strings.NewReader(`[{"from":"string","to":["string"],"subject":"string","html":"string","text":"string","cc":["string"],"reply_to":"string","scheduled_at":"string","tags":[{}]}]`))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.postwick.dev/emails/batch');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"from":"string","to":["string"],"subject":"string","html":"string","text":"string","cc":["string"],"reply_to":"string","scheduled_at":"string","tags":[{}]}]');
$response = curl_exec($ch);
curl_close($ch);
echo $response;Ruby
require 'net/http'
require 'uri'
uri = URI('https://api.postwick.dev/emails/batch')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req.body = '[{"from":"string","to":["string"],"subject":"string","html":"string","text":"string","cc":["string"],"reply_to":"string","scheduled_at":"string","tags":[{}]}]'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(req)
end
puts res.bodyJava
import java.net.URI;
import java.net.http.*;
import java.net.http.HttpRequest.BodyPublishers;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.postwick.dev/emails/batch"))
.header("Content-Type", "application/json")
.method("POST", BodyPublishers.ofString("[{\"from\":\"string\",\"to\":[\"string\"],\"subject\":\"string\",\"html\":\"string\",\"text\":\"string\",\"cc\":[\"string\"],\"reply_to\":\"string\",\"scheduled_at\":\"string\",\"tags\":[{}]}]"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());Responses
200 OK
{
"data": [
{
"id": "ae2014de"
},
{
"id": "faccb7a5"
}
]
}Updated
Was this page helpful?