Send in your language
The Email API is a single POST of JSON, so you can send from any language with an HTTP client. Below are complete send examples in PHP, Java, Ruby, and Go. Each does the same thing: POST to https://connect.routee.net/transactional-email with a Bearer token.
PrerequisiteYou need a Bearer token and a verified authorized sender. See Send your first email (HTTP API) for the cURL, Python, and Node.js versions and Get authenticated for obtaining a token.
PHP
<?php
$payload = [
"from" => ["name" => "Acme Support", "address" => "[email protected]"],
"to" => [["name" => "Jane Customer", "address" => "[email protected]"]],
"subject" => "Your order is confirmed",
"content" => ["html" => "<p>Thank you for your order, Jane.</p>"],
];
$ch = curl_init("https://connect.routee.net/transactional-email");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_ACCESS_TOKEN",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE) . " " . $response;
curl_close($ch);Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SendEmail {
public static void main(String[] args) throws Exception {
String body = """
{
"from": { "name": "Acme Support", "address": "[email protected]" },
"to": [{ "name": "Jane Customer", "address": "[email protected]" }],
"subject": "Your order is confirmed",
"content": { "html": "<p>Thank you for your order, Jane.</p>" }
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://connect.routee.net/transactional-email"))
.header("Authorization", "Bearer YOUR_ACCESS_TOKEN")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}Ruby
require "net/http"
require "json"
require "uri"
uri = URI("https://connect.routee.net/transactional-email")
payload = {
from: { name: "Acme Support", address: "[email protected]" },
to: [{ name: "Jane Customer", address: "[email protected]" }],
subject: "Your order is confirmed",
content: { html: "<p>Thank you for your order, Jane.</p>" }
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts "#{response.code} #{response.body}"Go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{
"from": {"name": "Acme Support", "address": "[email protected]"},
"to": [{"name": "Jane Customer", "address": "[email protected]"}],
"subject": "Your order is confirmed",
"content": {"html": "<p>Thank you for your order, Jane.</p>"}
}`)
req, _ := http.NewRequest("POST", "https://connect.routee.net/transactional-email", bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}A 200 response means the message was accepted and returns a trackingId. See Send your first email (HTTP API) for how to read the response.
Next steps
- Drop-in SendGrid SDK — reuse the official SendGrid client against Routee
- Track delivery & receive callbacks — confirm delivery and engagement
- Full reference: Send a transactional email

