Inbound routes
Email to a subdomain, delivered to your webhook.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
The Inbound route object
A subdomain whose incoming email is posted to your webhook.
Attributes
The domain whose mail goes to the hook.
The hook’s URL: each message is POSTed there.
Where its MX stands:
okpoints at Mailset,missinghas none,elsewherepoints somewhere else.One of
okmissingelsewhereWhat its MX answered at the last check, when it doesn’t point at Mailset.
Messages waiting for the hook.
Messages the hook took in the last day.
Messages Mailset gave up on in the last day.
Why the last try failed, while one is waiting.
When the route was added, in ms since the epoch.
Answered by
{
"domain": "example.com",
"url": "https://hooks.example.com/mailset",
"mx": "ok",
"mxFound": [
"text"
],
"waiting": 12,
"delivered": 1,
"failed": 1,
"lastError": "text",
"createdAt": 1796048940000
}
routes.list
List the inbound routes: domains whose mail goes to a webhook.
POST/v1/routes.list
Parameters
It takes no input: send an empty object.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is a list of Inbound route objects.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.routes.list();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.routes.list()
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
answer, err := client.Routes.List(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.routes.list
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->routes->list();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Route;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
List<Route> answer = mailset.routes().list();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.routes().list().await?;
println!("{answer:?}");
curl https://mailset.app/v1/routes.list \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{},"org":"org_3f9a1c0e7b2d"}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset routes list
{
"ok": true,
"data": [
{
"domain": "example.com",
"url": "https://hooks.example.com/mailset",
"mx": "ok",
"mxFound": [
"text"
],
"waiting": 12,
"delivered": 1,
"failed": 1,
"lastError": "text",
"createdAt": 1796048940000
}
]
}
routes.add
Send every message to a subdomain to a webhook.
POST/v1/routes.add
Parameters
The route’s domain: every address at it goes to the hook.
Where each message is POSTed: an https URL on a public host name.
At most 500 characters.
Beside input
The org this is about. Needed when the caller is in more than one.
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is an object with:
The route as it is now.
The signing secret, shown this once. Keep it where the hook can read it.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.routes.add({
url: "https://app.example.com/hooks/inbound",
domain: "in.example.com",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.routes.add(
{
"url": "https://app.example.com/hooks/inbound",
"domain": "in.example.com",
}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.RoutesAddParams{
URL: "https://app.example.com/hooks/inbound",
Domain: "in.example.com",
}
answer, err := client.Routes.Add(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.routes.add(
url: 'https://app.example.com/hooks/inbound',
domain: 'in.example.com'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->routes->add([
'url' => 'https://app.example.com/hooks/inbound',
'domain' => 'in.example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.RouteWithSecret;
import app.mailset.model.RoutesAddParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RoutesAddParams.builder()
.url("https://app.example.com/hooks/inbound")
.domain("in.example.com")
.build();
RouteWithSecret answer = mailset.routes().add(params);
System.out.println(answer);
use mailset::types::RoutesAddParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.routes()
.add(RoutesAddParams {
domain: "in.example.com".into(),
url: "https://app.example.com/hooks/inbound"
.into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/routes.add \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"url":"https://app.example.com/hooks/inbound","domain":"in.example.com"},"org":"org_3f9a1c0e7b2d"}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset routes add in.example.com --url https://app.example.com/hooks/inbound
{
"ok": true,
"data": {
"route": {
"domain": "example.com",
"url": "https://hooks.example.com/mailset",
"mx": "ok",
"mxFound": [
"text"
],
"waiting": 12,
"delivered": 1,
"failed": 1,
"lastError": "text",
"createdAt": 1796048940000
},
"secret": "whsec_3f9a1c0e7b2d4a58"
}
}
routes.check
Check that a route’s MX points at Mailset.
POST/v1/routes.check
Parameters
The route’s domain: every address at it goes to the hook.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Inbound route object.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.routes.check({
domain: "in.example.com",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.routes.check(
{"domain": "in.example.com"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.RoutesCheckParams{
Domain: "in.example.com",
}
answer, err := client.Routes.Check(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.routes.check(domain: 'in.example.com')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->routes->check([
'domain' => 'in.example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Route;
import app.mailset.model.RoutesCheckParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RoutesCheckParams.builder()
.domain("in.example.com")
.build();
Route answer = mailset.routes().check(params);
System.out.println(answer);
use mailset::types::RoutesCheckParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.routes()
.check(RoutesCheckParams {
domain: "in.example.com".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/routes.check \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"domain":"in.example.com"},"org":"org_3f9a1c0e7b2d"}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset routes check in.example.com
{
"ok": true,
"data": {
"domain": "example.com",
"url": "https://hooks.example.com/mailset",
"mx": "ok",
"mxFound": [
"text"
],
"waiting": 12,
"delivered": 1,
"failed": 1,
"lastError": "text",
"createdAt": 1796048940000
}
}
routes.apply
Write a route’s MX to its DNS host.
POST/v1/routes.apply
Parameters
The route’s domain: every address at it goes to the hook.
Beside input
The org this is about. Needed when the caller is in more than one.
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is the Inbound route object.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.routes.apply({
domain: "in.example.com",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.routes.apply(
{"domain": "in.example.com"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.RoutesApplyParams{
Domain: "in.example.com",
}
answer, err := client.Routes.Apply(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.routes.apply(domain: 'in.example.com')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->routes->apply([
'domain' => 'in.example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Route;
import app.mailset.model.RoutesApplyParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RoutesApplyParams.builder()
.domain("in.example.com")
.build();
Route answer = mailset.routes().apply(params);
System.out.println(answer);
use mailset::types::RoutesApplyParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.routes()
.apply(RoutesApplyParams {
domain: "in.example.com".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/routes.apply \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"domain":"in.example.com"},"org":"org_3f9a1c0e7b2d"}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset routes apply in.example.com
{
"ok": true,
"data": {
"domain": "example.com",
"url": "https://hooks.example.com/mailset",
"mx": "ok",
"mxFound": [
"text"
],
"waiting": 12,
"delivered": 1,
"failed": 1,
"lastError": "text",
"createdAt": 1796048940000
}
}
routes.rotate
Make a route a new signing secret; the old one stops at once.
POST/v1/routes.rotate
Parameters
The route’s domain: every address at it goes to the hook.
Beside input
The org this is about. Needed when the caller is in more than one.
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is an object with:
The route as it is now.
The signing secret, shown this once. Keep it where the hook can read it.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.routes.rotate({
domain: "in.example.com",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.routes.rotate(
{"domain": "in.example.com"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.RoutesRotateParams{
Domain: "in.example.com",
}
answer, err := client.Routes.Rotate(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.routes.rotate(domain: 'in.example.com')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->routes->rotate([
'domain' => 'in.example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.RouteWithSecret;
import app.mailset.model.RoutesRotateParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RoutesRotateParams.builder()
.domain("in.example.com")
.build();
RouteWithSecret answer = mailset.routes().rotate(params);
System.out.println(answer);
use mailset::types::RoutesRotateParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.routes()
.rotate(RoutesRotateParams {
domain: "in.example.com".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/routes.rotate \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"domain":"in.example.com"},"org":"org_3f9a1c0e7b2d"}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset routes rotate in.example.com
{
"ok": true,
"data": {
"route": {
"domain": "example.com",
"url": "https://hooks.example.com/mailset",
"mx": "ok",
"mxFound": [
"text"
],
"waiting": 12,
"delivered": 1,
"failed": 1,
"lastError": "text",
"createdAt": 1796048940000
},
"secret": "whsec_3f9a1c0e7b2d4a58"
}
}
routes.remove
Remove a route; mail still waiting for its hook is dropped.
POST/v1/routes.remove
Parameters
The route’s domain: every address at it goes to the hook.
Beside input
The org this is about. Needed when the caller is in more than one.
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is an object with:
True when the route was there to remove.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.routes.remove({
domain: "in.example.com",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.routes.remove(
{"domain": "in.example.com"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.RoutesRemoveParams{
Domain: "in.example.com",
}
answer, err := client.Routes.Remove(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.routes.remove(domain: 'in.example.com')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->routes->remove([
'domain' => 'in.example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.RoutesRemoveParams;
import app.mailset.model.RoutesRemoveResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RoutesRemoveParams.builder()
.domain("in.example.com")
.build();
RoutesRemoveResult answer =
mailset.routes().remove(params);
System.out.println(answer);
use mailset::types::RoutesRemoveParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.routes()
.remove(RoutesRemoveParams {
domain: "in.example.com".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/routes.remove \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"domain":"in.example.com"},"org":"org_3f9a1c0e7b2d"}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset routes remove in.example.com
{
"ok": true,
"data": {
"removed": true
}
}