Sending transactional emails
Sending transactional emails with Plunk unlocks another layer of connectivity.
POST /v1/send
Used to send transactional emails to a single recipient or multiple recipients at once. Transactional emails are programmatically sent emails that are considered to be part of your application's workflow. This could be a password reset email, a billing email or other non-marketing emails.
Authorization
This endpoint can only be accessed with a secret key.
Example
await fetch('https://api.useplunk.com/v1/send', {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer SECRET_KEY", // Put your API key here
},
body: JSON.stringify({
"to": "hello@useplunk.com",
"subject": "Please confirm your email",
"body": "<h1>Confirm your email</h1><p>Click <a href='https://app.useplunk.com/subscribe/ID'>here</a> to confirm your email.</p>",
}),
});
import requests
requests.post(
"https://api.useplunk.com/v1/send",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer SECRET_KEY" # Put your API key here
},
json={
"to": "hello@useplunk.com",
"subject": "Please confirm your email",
"body": "<h1>Confirm your email</h1><p>Click <a href='https://app.useplunk.com/subscribe/ID'>here</a> to confirm your email.</p>",
},
)
curl --location --request POST 'https://api.useplunk.com/v1/send' \
--header 'Authorization: Bearer SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"to": "hello@useplunk.com", "subject": "Please confirm your email", "body": "<h1>Confirm your email</h1><p>Click <a href='https://app.useplunk.com/subscribe/ID'>here</a> to confirm your email.</p>"}'
<?php
$client = new Client();
$request = new Request('POST', 'https://api.useplunk.com/v1/send', ['Authorization' => 'Bearer SECRET_KEY', 'Content-Type' => 'application/json'], '{
"to": "hello@useplunk.com",
"subject": "Please confirm your email",
"body": "<h1>Confirm your email</h1><p>Click <a href='https://app.useplunk.com/subscribe/ID'>here</a> to confirm your email.</p>",
}');
$res = $client->sendAsync($request)->wait();
require "uri"
require "json"
require "net/http"
url = URI("https://api.useplunk.com/v1/send")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer SECRET_KEY" # Put your API key here
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"to": "hello@useplunk.com",
"subject": "Please confirm your email",
"body": "<h1>Confirm your email</h1><p>Click <a href='https://app.useplunk.com/subscribe/ID'>here</a> to confirm your email.</p>",
})
response = https.request(request)
Using Markdown
It is possible to use Markdown when sending a transactional email. Plunk will automatically apply the same styling as the email templates you make in the editor.
Any email with a body that starts with #
will be treated as Markdown.
await fetch('https://api.useplunk.com/v1/send', {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer SECRET_KEY", // Put your API key here
},
body: JSON.stringify({
"to": "hello@useplunk.com",
"subject": "Welcome!",
"body": "# Hello",
}),
});
import requests
requests.post(
"https://api.useplunk.com/v1/send",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer SECRET_KEY" # Put your API key here
},
json={
"to": "hello@useplunk.com",
"subject": "Welcome!",
"body": "# Hello",
},
)
curl --location --request POST 'https://api.useplunk.com/v1/send' \
--header 'Authorization: Bearer SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"to": "hello@useplunk.com", "subject": "Welcome!", "body": "# Hello"}'
<?php
$client = new Client();
$request = new Request('POST', 'https://api.useplunk.com/v1/send', ['Authorization' => 'Bearer SECRET_KEY', 'Content-Type' => 'application/json'], '{
"to": "hello@useplunk.com",
"subject": "Welcome",
"body": "# Hello",
}');
$res = $client->sendAsync($request)->wait();
require "uri"
require "json"
require "net/http"
url = URI("https://api.useplunk.com/v1/send")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer SECRET_KEY" # Put your API key here
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"to": "hello@useplunk.com",
"subject": "Welcome!",
"body": "# Hello",
})
response = https.request(request)
Last updated on January 17, 2023