DNS connection
Let Mailset write the records in your own DNS account.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
dns.status
Whether the org’s own Cloudflare is connected, the accounts and zones it sees, and whose token writes each domain.
POST/v1/dns.status
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:
Whether connecting Cloudflare is offered.
Show child attributesHide child attributes
Always
cloudflarebroken: Cloudflare refused the grant, so records go in by hand until it’s connected again.One of
connectedbrokenWhy it broke, or what last went wrong with it.
Who connected it.
When Mailset last renewed its access. Null: never needed to.
When the access token runs out. Null: Cloudflare didn’t say.
The Cloudflare accounts the grant reaches, by the zones it sees.
The zones the grant sees, by name.
The grant sees more zones than listed.
Each of the org’s domains, and whose token writes its records.
Why the zones couldn’t be read just now.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.dns.status();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.dns.status()
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.DNS.Status(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.dns.status
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->dns->status();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.DnsStatus;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
DnsStatus answer = mailset.dns().status();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.dns().status().await?;
println!("{answer:?}");
curl https://mailset.app/v1/dns.status \
-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 dns status
{
"ok": true,
"data": {
"available": true,
"connection": {
"provider": "cloudflare",
"state": "connected",
"problem": "text",
"connectedBy": "text",
"connectedAt": 1796048940000,
"refreshedAt": 1796048940000,
"expiresAt": 1796048940000,
"scopes": [
"text"
]
},
"accounts": [
{
dns.connect
Let Mailset write your domains’ DNS records in your own Cloudflare: cloudflare (gives a Mailset page to open, signed in).
POST/v1/dns.connect
Parameters
The DNS provider to connect:
cloudflare.Always
cloudflare
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
A Mailset page to open, signed in, that starts the connection.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.dns.connect({
provider: "cloudflare",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.dns.connect({"provider": "cloudflare"})
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.DNSConnectParams{
Provider: mailset.DNSProviderCloudflare,
}
answer, err := client.DNS.Connect(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.dns.connect(provider: 'cloudflare')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->dns->connect([
'provider' => 'cloudflare',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.DnsConnectParams;
import app.mailset.model.DnsConnectResult;
import app.mailset.model.DnsProvider;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = DnsConnectParams.builder()
.provider(DnsProvider.CLOUDFLARE)
.build();
DnsConnectResult answer = mailset.dns().connect(params);
System.out.println(answer);
use mailset::types::{DnsConnectParams, DnsProvider};
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.dns()
.connect(DnsConnectParams {
provider: DnsProvider::Cloudflare,
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/dns.connect \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"provider":"cloudflare"},"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 dns connect cloudflare
{
"ok": true,
"data": {
"url": "https://hooks.example.com/mailset"
}
}
dns.disconnect
End Mailset’s access to your Cloudflare at Cloudflare, and go back to adding records by hand.
POST/v1/dns.disconnect
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.
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:
Cloudflare was told. False: Cloudflare connect isn’t set up here, so end it there too.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.dns.disconnect();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.dns.disconnect()
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.DNS.Disconnect(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.dns.disconnect
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->dns->disconnect();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.DnsDisconnectResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
DnsDisconnectResult answer = mailset.dns().disconnect();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.dns().disconnect().await?;
println!("{answer:?}");
curl https://mailset.app/v1/dns.disconnect \
-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 dns disconnect
{
"ok": true,
"data": {
"disconnected": true,
"revoked": true
}
}