DNS connection

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
  1. dns.status
  2. dns.connect
  3. dns.disconnect

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

Admin or owner

Parameters

It takes no input: send an empty object.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

Returns

data is an object with:

  • availableboolean

    Whether connecting Cloudflare is offered.

  • connectionnullable object
    Show child attributesHide child attributes
    • providerenum

      Alwayscloudflare

    • stateenum

      broken: Cloudflare refused the grant, so records go in by hand until it’s connected again.

      One ofconnectedbroken

    • problemnullable string

      Why it broke, or what last went wrong with it.

    • connectedBynullable string

      Who connected it.

    • connectedAtnumber
    • refreshedAtnullable number

      When Mailset last renewed its access. Null: never needed to.

    • expiresAtnullable number

      When the access token runs out. Null: Cloudflare didn’t say.

    • scopesarray of strings
  • accountsarray of objects

    The Cloudflare accounts the grant reaches, by the zones it sees.

    Show child attributesHide child attributes
    • idstring
    • namestring
  • zonesarray of strings

    The zones the grant sees, by name.

  • moreZonesboolean

    The grant sees more zones than listed.

  • domainsarray of objects

    Each of the org’s domains, and whose token writes its records.

    Show child attributesHide child attributes
    • namestring
    • zonenullable string

      The zone the domain is in, when its nameservers answer.

    • writerenum

      One oforgmailsetby_hand

  • problemnullable string

    Why the zones couldn’t be read just now.

In the CLIErrors

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
Response
{
  "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

Admin or owner

Parameters

  • providerenumrequired

    The DNS provider to connect: cloudflare.

    Alwayscloudflare

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

Returns

data is an object with:

  • urlstring

    A Mailset page to open, signed in, that starts the connection.

In the CLIErrors

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
Response
{
  "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

Admin or ownerPasskey

Parameters

It takes no input: send an empty object.

Beside input

  • orgstringoptional

    The org this is about. Needed when the caller is in more than one.

  • approvalstringoptional

    An approval’s id, once someone approved it with their passkey. Without one, the answer is step_up_required and names what to approve.

Returns

data is an object with:

  • disconnectedboolean
  • revokedboolean

    Cloudflare was told. False: Cloudflare connect isn’t set up here, so end it there too.

In the CLIErrors

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
Response
{
  "ok": true,
  "data": {
    "disconnected": true,
    "revoked": true
  }
}