Emails
Send email
POST
/emails Start sending email through the Postwick API.
Parameters
fromstringrequiredSender address. Add a friendly name as
Name <address>.tostring[]requiredRecipient addresses. Up to 50.
subjectstringrequiredSubject line.
htmlstringThe HTML body.
textstringThe plain-text body. Generated from
html when omitted.ccstring[]Carbon-copy recipients.
reply_tostringWhere replies go.
scheduled_atstringWhen to deliver, ISO 8601 or natural language.
tagsobject[]Key/value pairs for filtering.
{
"from": "string",
"to": [
"string"
],
"subject": "string",
"html": "string",
"text": "string",
"cc": [
"string"
],
"reply_to": "string",
"scheduled_at": "string",
"tags": [
{}
]
}Code samples
TypeScript
import { Postwick } from 'postwick';
const postwick = new Postwick('pw_xxxxxxxxx');
const { data, error } = await postwick.emails.send({
from: 'Lumen <hello@mail.lumen.dev>',
to: ['ada@example.com'],
subject: 'hello world',
html: '<p>it works!</p>',
});PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.postwick.dev/emails');
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;Python
import postwick
postwick.api_key = 'pw_xxxxxxxxx'
postwick.Emails.send({
'from': 'Lumen <hello@mail.lumen.dev>',
'to': ['ada@example.com'],
'subject': 'hello world',
'html': '<p>it works!</p>',
})Ruby
require 'net/http'
require 'uri'
uri = URI('https://api.postwick.dev/emails')
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.bodyGo
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, _ := http.NewRequest("POST", "https://api.postwick.dev/emails", 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))
}cURL
curl -X POST 'https://api.postwick.dev/emails' \
-H 'Authorization: Bearer pw_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"from":"Lumen <hello@mail.lumen.dev>","to":["ada@example.com"],"subject":"hello world","html":"<p>it works!</p>"}'Responses
200 OK
Example
{
"id": "4ee5d4c7-1b8b-4a52-a1a6-23c1d8b0e8f2"
}Schema
idstringWas this page helpful?