Key status
What the key making a call may do, and when it stops.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
The Key status object
An app key as Mailset sees it: its name, what it reaches, and when it stops.
Attributes
The app’s id: what
grants revoke,grants renewandgrants resumetake.The name it was approved with.
When it was connected, in ms since the epoch.
When it last made a call, in ms since the epoch.
When its key stops working, in ms since the epoch: 90 days after its last call. Moves forward whenever the app uses it.
Why its own brake stopped its mail, or null while it may send.
Default
null.The mailboxes it reaches, and what it may do with each.
Show child attributesHide child attributes
The mailbox’s address.
What the app may do with it:
read,sendor both.One of
readsendThe addresses it may send as. Empty without send access.
Whether the mailbox’s domain can send:
pending,readyorblocked.One of
pendingreadyblocked
For a domain key: the sending-only domain it sends from, with no mailbox, and the addresses it sends as there. Empty for any other key.
Default
[].Show child attributesHide child attributes
The domain’s name.
Whether the domain can send:
pending,readyorblocked.One of
pendingreadyblockedThe addresses it sends as, on that domain. Null: any address there, the opt-in for a domain where nobody has an address of their own.
The org whose campaigns it runs, for a campaigns key. Null for any other.
Answered by
{
"id": "grant_3f9a1c0e7b2d",
"name": "Acme API",
"createdAt": 1793456940000,
"lastSeenAt": 1796048940000,
"expiresAt": 1803824940000,
"paused": null,
"mailboxes": [
{
"address": "moc.elpmaxe@olleh",
"access": [
"send"
],
"sendAs": [
"moc.elpmaxe@olleh"
],
"sending": "ready"
}
],
"domains": [],
"campaigns": null
}
{
"id": "grant_8c1e4b7a2d9f",
"name": "Acme receipts",
"createdAt": 1793456940000,
"lastSeenAt": 1796048940000,
"expiresAt": 1803824940000,
"paused": null,
"mailboxes": [],
"domains": [
{
"name": "example.com",
"sending": "ready",
"from": [
"moc.elpmaxe@stpiecer",
"moc.elpmaxe@ylperon"
]
}
],
"campaigns": null
}
grants.current
Show what this app key may do: its mailbox or sending domain, and whether it can send.
POST/v1/grants.current
Parameters
It takes no input: send an empty object.
Returns
data is the Key status object.
import { Mailset } from 'mailset';
// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();
// When the server starts, and once a day.
const status = await mailset.key.check();
if (status.paused) console.warn('Paused:', status.paused);
console.log('Works until', new Date(status.expiresAt));
// A mailbox key sends as its mailbox.
for (const { address, sending } of status.mailboxes)
if (sending !== 'ready') console.warn(address, sending);
// A domain key sends as the addresses it names.
for (const { name, sending, from } of status.domains) {
const as = from?.join(', ') ?? 'any address';
console.log(name, 'sends as', as);
if (sending !== 'ready') console.warn(name, sending);
}
from datetime import datetime, timezone
from mailset import Mailset
# Reads MAILSET_KEY from the environment.
mailset = Mailset()
# When the server starts, and once a day.
status = mailset.key.check()
if status["paused"]:
print("Paused:", status["paused"])
ends = status["expires_at"] / 1000
until = datetime.fromtimestamp(ends, timezone.utc)
print("Works until", until)
# A mailbox key sends as its mailbox.
for box in status["mailboxes"]:
if box["sending"] != "ready":
import (
"context"
"fmt"
"log"
"strings"
"time"
mailset "mailset.app/go"
)
client, err := mailset.NewClient() // reads MAILSET_KEY
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
require 'mailset'
mailset = Mailset::Client.new
# When the server starts, and once a day.
status = mailset.key.check
warn "Paused: #{status.paused}" if status.paused
puts "Works until #{Time.at(status.expires_at / 1000)}"
# A mailbox key sends as its mailbox.
status.mailboxes.each do |box|
next if box.sending == 'ready'
warn "#{box.address}: #{box.sending}"
end
# A domain key sends as the addresses it names.
status.domains.each do |domain|
as = domain.from&.join(', ') || 'any address'
puts "#{domain.name} sends as #{as}"
next if domain.sending == 'ready'
warn "#{domain.name}: #{domain.sending}"
end
<?php
require 'vendor/autoload.php';
use Mailset\Types\SendingState;
// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();
// When the server starts, and once a day.
$status = $mailset->key->check();
if ($status->paused !== null) {
error_log("Paused: {$status->paused}");
}
$until = intdiv($status->expiresAt, 1000);
echo 'Works until ', gmdate('c', $until), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.GrantDomain;
import app.mailset.model.GrantMailbox;
import app.mailset.model.KeyStatus;
import java.time.Instant;
// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();
// When the server starts, and once a day.
KeyStatus status = mailset.key().check();
status.paused().ifPresent(why ->
System.err.println("Paused: " + why));
System.out.println("Works until "
+ Instant.ofEpochMilli(status.expiresAt()));
// A mailbox key sends as its mailbox.
for (GrantMailbox box : status.mailboxes())
use mailset::types::SendingState;
use mailset::Client;
// Reads MAILSET_KEY from the environment.
let mailset = Client::from_env()?;
// When the server starts, and once a day.
let status = mailset.key().check().await?;
if let Some(paused) = &status.paused {
eprintln!("Paused: {paused}");
}
println!("Works until {} (ms)", status.expires_at);
// A mailbox key sends as its mailbox.
for b in &status.mailboxes {
if b.sending != SendingState::Ready {
eprintln!("{} {}", b.address, b.sending);
}
curl https://mailset.app/v1/grants.current \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{}}'
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 grants current
{
"ok": true,
"data": {
"id": "grant_3f9a1c0e7b2d",
"name": "Acme API",
"createdAt": 1793456940000,
"lastSeenAt": 1796048940000,
"expiresAt": 1803824940000,
"paused": null,
"mailboxes": [
{
"address": "moc.elpmaxe@olleh",
"access": [
"send"
],
"sendAs": [
"moc.elpmaxe@olleh"
],
"sending": "ready"
}
],
"domains": [],
"campaigns": null
}
}