Event hook
The webhook that hears what became of your product’s email.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
The Event object
One thing that happened to one message for one recipient, as your hook receives it.
Attributes
Stable for this message, recipient and happening, so dedupe on it. For
unsubscribed, stable for that opt-out: someone let back in who leaves again has a new one.What happened.
One of
queuedsentdeliveredbouncedcomplainedfailedexpiredunsubscribedtestWhen it happened, in milliseconds since 1970.
Mailset’s id for the message: the
idits send answered. On every event about a message, and onunsubscribedwhen the message the link was in is known.The message’s Message-ID header, without the angle brackets. Present whenever
messageis.The one address this event is about. Absent only on
test.The app key that sent the mail, by the name it was approved with.
Present when the same content went to this recipient from the same address less than 10 minutes before, under another Message-ID: the
messageof that earlier send. Both were sent. Give the send an idempotency key to stop it.queued: when it should go out, in milliseconds since 1970.queued,failed,expired: why, in words.bounced: what kind of bounce it was.Show child attributesHide child attributes
hardwon’t change.softmay go on a later try.One of
hardsoftWhat the bounce says about the address:
mailboxanddomainmean it can’t get mail.One of
mailboxdomainfulltoo_largepolicysuppressedotherWhat the receiving server replied, with its SMTP code. For
suppressed, why Mailset didn’t send it.
Where it comes from
{
"id": "evt_5b1f0c9a7e3d",
"type": "bounced",
"at": 1796048940000,
"message": "out_3f9a1c0e7b2d",
"messageId": "moc.elpmaxe@85a4d2b7e0c1a9f3",
"recipient": "gro.elpmaxe@ana",
"app": "Acme API",
"bounce": {
"kind": "hard",
"class": "mailbox",
"reason": "smtp; 550 5.1.1 The email account that you tried to reach does not exist."
}
}
hooks.get
Show where your products’ mail events go, and what waits for the hook.
POST/v1/hooks.get
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 an object with:
The org’s hook, or null when it has none.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.hooks.get();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.hooks.get()
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.Hooks.Get(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.hooks.get
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->hooks->get();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.HookStatus;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
HookStatus answer = mailset.hooks().get();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.hooks().get().await?;
println!("{answer:?}");
curl https://mailset.app/v1/hooks.get \
-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 hooks get
{
"ok": true,
"data": {
"hook": {
"url": "https://hooks.example.com/mailset",
"setAt": 1796048940000,
"waiting": 12,
"lastError": "text"
}
}
}
hooks.set
Send events for your products’ mail to a webhook.
POST/v1/hooks.set
Parameters
Where Mailset posts the events: https, port 443, 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.
Returns
data is an object with:
The signing secret, shown this once. Each post’s
Mailset-Signatureis made with it.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.hooks.set({
url: "https://app.example.com/hooks/mailset",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.hooks.set(
{"url": "https://app.example.com/hooks/mailset"}
)
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.HooksSetParams{
URL: "https://app.example.com/hooks/mailset",
}
answer, err := client.Hooks.Set(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.hooks.set(
url: 'https://app.example.com/hooks/mailset'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->hooks->set([
'url' => 'https://app.example.com/hooks/mailset',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.HookSecret;
import app.mailset.model.HooksSetParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = HooksSetParams.builder()
.url("https://app.example.com/hooks/mailset")
.build();
HookSecret answer = mailset.hooks().set(params);
System.out.println(answer);
use mailset::types::HooksSetParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.hooks()
.set(HooksSetParams {
url: "https://app.example.com/hooks/mailset"
.into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/hooks.set \
-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/mailset"},"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 hooks set --url https://app.example.com/hooks/mailset
{
"ok": true,
"data": {
"secret": "whsec_3f9a1c0e7b2d4a58"
}
}
hooks.rotate
A new signing secret for the products’ hook; the old one stops.
POST/v1/hooks.rotate
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 an object with:
The signing secret, shown this once. Each post’s
Mailset-Signatureis made with it.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.hooks.rotate();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.hooks.rotate()
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.Hooks.Rotate(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.hooks.rotate
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->hooks->rotate();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.HookSecret;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
HookSecret answer = mailset.hooks().rotate();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.hooks().rotate().await?;
println!("{answer:?}");
curl https://mailset.app/v1/hooks.rotate \
-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 hooks rotate
{
"ok": true,
"data": {
"secret": "whsec_3f9a1c0e7b2d4a58"
}
}
hooks.remove
Stop sending product mail events; what was waiting is dropped.
POST/v1/hooks.remove
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 an object with:
True when there was a hook to remove.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.hooks.remove();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.hooks.remove()
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.Hooks.Remove(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.hooks.remove
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->hooks->remove();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.HooksRemoveResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
HooksRemoveResult answer = mailset.hooks().remove();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.hooks().remove().await?;
println!("{answer:?}");
curl https://mailset.app/v1/hooks.remove \
-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 hooks remove
{
"ok": true,
"data": {
"removed": true
}
}
hooks.test
Post one signed test event to the products’ hook now.
POST/v1/hooks.test
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 an object with:
Where the test event was posted.
Whether the hook answered 2xx.
The hook’s HTTP status, or null when it couldn’t be reached.
Why the post wasn’t taken, in a few words, or null.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.hooks.test();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.hooks.test()
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.Hooks.Test(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.hooks.test
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->hooks->test();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.HookTest;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
HookTest answer = mailset.hooks().test();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.hooks().test().await?;
println!("{answer:?}");
curl https://mailset.app/v1/hooks.test \
-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 hooks test
{
"ok": true,
"data": {
"url": "https://hooks.example.com/mailset",
"took": true,
"status": 1,
"error": "text"
}
}