Codes
The newest one-time code an address received.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
codes.latest
The newest one-time code mailed to an address you can read.
POST/v1/codes.latest
Parameters
The address the code was mailed to: a mailbox you can read, or an alias, +tag, catch-all or group that delivers into one.
Only mail from this sender: an address, or a domain with its subdomains (
yahoo.com).How far back to look:
30m,2h,1d, or minutes as a number. 30 minutes unless given, a day at most.
Returns
data is an object with:
The code, as it was mailed: 4 to 8 digits, or 6 to 8 capitals and digits.
The sender’s address.
The subject of the message it came in.
When the message arrived, in ms since the epoch.
The mailbox the message is in.
import { Mailset } from 'mailset';
// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();
const answer = await mailset.codes.latest({
from: "yahoo.com",
within: "10m",
to: "moc.elpmaxe@ana",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_KEY from the environment.
mailset = Mailset()
answer = mailset.codes.latest(
{
"from": "yahoo.com",
"within": "10m",
"to": "moc.elpmaxe@ana",
}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_KEY from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.CodesLatestParams{
require 'mailset'
# Reads MAILSET_KEY from the environment.
mailset = Mailset::Client.new
answer = mailset.codes.latest(
from: 'yahoo.com',
within: '10m',
to: 'moc.elpmaxe@ana'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->codes->latest([
'from' => 'yahoo.com',
'within' => '10m',
'to' => 'moc.elpmaxe@ana',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.CodeFound;
import app.mailset.model.CodesLatestParams;
// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();
var params = CodesLatestParams.builder()
.from("yahoo.com")
.within("10m")
.to("moc.elpmaxe@ana")
.build();
CodeFound answer = mailset.codes().latest(params);
System.out.println(answer);
use mailset::types::CodesLatestParams;
// Reads MAILSET_KEY from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.codes()
.latest(CodesLatestParams {
to: "moc.elpmaxe@ana".into(),
from: Some("yahoo.com".into()),
within: Some("10m".into()),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/codes.latest \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"from":"yahoo.com","within":"10m","to":"moc.elpmaxe@ana"}}'
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 codes latest moc.elpmaxe@ana --from yahoo.com --within 10m
{
"ok": true,
"data": {
"code": "482913",
"from": "moc.elpmaxe@olleh",
"subject": "Your Acme receipt",
"receivedAt": 1796048940000,
"mailboxAddress": "moc.elpmaxe@olleh"
}
}