Inbound routes

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
  1. The Inbound route object
  2. routes.list
  3. routes.add
  4. routes.check
  5. routes.apply
  6. routes.rotate
  7. routes.remove

The Inbound route object

A subdomain whose incoming email is posted to your webhook.

Attributes

  • domainstring

    The domain whose mail goes to the hook.

  • urlstring

    The hook’s URL: each message is POSTed there.

  • mxenum

    Where its MX stands: ok points at Mailset, missing has none, elsewhere points somewhere else.

    One ofokmissingelsewhere

  • mxFoundarray of strings

    What its MX answered at the last check, when it doesn’t point at Mailset.

  • waitingnumber

    Messages waiting for the hook.

  • deliverednumber

    Messages the hook took in the last day.

  • failednumber

    Messages Mailset gave up on in the last day.

  • lastErrornullable string

    Why the last try failed, while one is waiting.

  • createdAtnumber

    When the route was added, in ms since the epoch.

Answered by

routes.listroutes.addroutes.checkroutes.applyroutes.rotate

The Inbound route object
{
  "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

Admin or owner

Parameters

It takes no input: send an empty object.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

Returns

data is a list of Inbound route objects.

In the CLIErrors

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
Response
{
  "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

Admin or ownerPasskey

Parameters

  • domainstringrequired

    The route’s domain: every address at it goes to the hook.

  • urlstringrequired

    Where each message is POSTed: an https URL on a public host name.

    At most 500 characters.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

  • approvalstringoptional

    An approval’s id, once someone approved it with their passkey. Without one, the answer is step_up_required and names what to approve.

Returns

data is an object with:

  • routeInbound route object

    The route as it is now.

  • secretstring

    The signing secret, shown this once. Keep it where the hook can read it.

In the CLIErrors

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
Response
{
  "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

Admin or owner

Parameters

  • domainstringrequired

    The route’s domain: every address at it goes to the hook.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

Returns

data is the Inbound route object.

In the CLIErrors

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
Response
{
  "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

Admin or ownerPasskey

Parameters

  • domainstringrequired

    The route’s domain: every address at it goes to the hook.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

  • approvalstringoptional

    An approval’s id, once someone approved it with their passkey. Without one, the answer is step_up_required and names what to approve.

Returns

data is the Inbound route object.

In the CLIErrors

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
Response
{
  "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

Admin or ownerPasskey

Parameters

  • domainstringrequired

    The route’s domain: every address at it goes to the hook.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

  • approvalstringoptional

    An approval’s id, once someone approved it with their passkey. Without one, the answer is step_up_required and names what to approve.

Returns

data is an object with:

  • routeInbound route object

    The route as it is now.

  • secretstring

    The signing secret, shown this once. Keep it where the hook can read it.

In the CLIErrors

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
Response
{
  "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

Admin or ownerPasskey

Parameters

  • domainstringrequired

    The route’s domain: every address at it goes to the hook.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

  • approvalstringoptional

    An approval’s id, once someone approved it with their passkey. Without one, the answer is step_up_required and names what to approve.

Returns

data is an object with:

  • removedboolean

    True when the route was there to remove.

In the CLIErrors

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
Response
{
  "ok": true,
  "data": {
    "removed": true
  }
}