API tokens
A person’s own login for scripts.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
The API token object
A person’s own login for scripts: its name and when it was used.
Attributes
The token’s id: what
tokens revoketakes.The name it was given.
When it was made, in ms since the epoch.
When it last made a call, in ms since the epoch.
When it stops working, in ms since the epoch.
Answered by
{
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"createdAt": 1796048940000,
"lastSeenAt": 1796048940000,
"expiresAt": 1796048940000
}
tokens.list
List your API tokens.
POST/v1/tokens.list
Parameters
It takes no input: send an empty object.
Returns
data is a list of API token objects.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.tokens.list();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.tokens.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.Tokens.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.tokens.list
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->tokens->list();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Token;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
List<Token> answer = mailset.tokens().list();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.tokens().list().await?;
println!("{answer:?}");
curl https://mailset.app/v1/tokens.list \
-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 tokens list
{
"ok": true,
"data": [
{
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"createdAt": 1796048940000,
"lastSeenAt": 1796048940000,
"expiresAt": 1796048940000
}
]
}
tokens.create
Create an API token. It is shown once.
POST/v1/tokens.create
Parameters
A name to tell it by, up to 64 characters.
At most 64 characters.
Beside input
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 token’s id: what
tokens revoketakes.The name it was given.
The token itself, shown this once. It starts with
mst_.When it stops working, in ms since the epoch: a year from now.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.tokens.create({
name: "Deploy script",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.tokens.create({"name": "Deploy script"})
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.TokensCreateParams{
Name: "Deploy script",
}
answer, err := client.Tokens.Create(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.tokens.create(name: 'Deploy script')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->tokens->create([
'name' => 'Deploy script',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.TokensCreateParams;
import app.mailset.model.TokensCreateResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = TokensCreateParams.builder()
.name("Deploy script")
.build();
TokensCreateResult answer =
mailset.tokens().create(params);
System.out.println(answer);
use mailset::types::TokensCreateParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.tokens()
.create(TokensCreateParams {
name: "Deploy script".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/tokens.create \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"name":"Deploy script"}}'
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 tokens create "Deploy script"
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"name": "Acme API",
"token": "text",
"expiresAt": 1796048940000
}
}
tokens.revoke
Revoke an API token.
POST/v1/tokens.revoke
Parameters
The token’s id, from
tokens list.
Returns
data is an object with:
True when the token was there to revoke.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.tokens.revoke({
id: "d_4b8e2a6c9f1d3057b3e8a2c6",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.tokens.revoke(
{"id": "d_4b8e2a6c9f1d3057b3e8a2c6"}
)
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.TokensRevokeParams{
ID: "d_4b8e2a6c9f1d3057b3e8a2c6",
}
answer, err := client.Tokens.Revoke(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.tokens.revoke(
id: 'd_4b8e2a6c9f1d3057b3e8a2c6'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->tokens->revoke([
'id' => 'd_4b8e2a6c9f1d3057b3e8a2c6',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.TokensRevokeParams;
import app.mailset.model.TokensRevokeResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = TokensRevokeParams.builder()
.id("d_4b8e2a6c9f1d3057b3e8a2c6")
.build();
TokensRevokeResult answer =
mailset.tokens().revoke(params);
System.out.println(answer);
use mailset::types::TokensRevokeParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.tokens()
.revoke(TokensRevokeParams {
id: "d_4b8e2a6c9f1d3057b3e8a2c6".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/tokens.revoke \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"d_4b8e2a6c9f1d3057b3e8a2c6"}}'
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 tokens revoke d_4b8e2a6c9f1d3057b3e8a2c6
{
"ok": true,
"data": {
"revoked": true
}
}