Policies

Policies

The org’s rules on forwarding and sessions.

An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.

On this page
  1. policies.get
  2. policies.set

policies.get

Show the org’s policies.

POST/v1/policies.get

Anyone in the org

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:

  • forwardingenumoptional

    Forwarding rules: allowed with a passkey check, or never.

    One ofpasskeynever

    Default passkey.

  • sharedAibooleanoptional

    Whether AI runs on shared mailboxes.

    Default true.

  • sessionDaysnumberoptional

    How long a new sign-in lasts, in days: 30, 7 or 0.5 (12 hours).

    Default 30.

In the CLIErrors

import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.policies.get();
console.log(answer);
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.policies.get()
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.Policies.Get(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.policies.get
p answer
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->policies->get();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Policies;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

Policies answer = mailset.policies().get();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.policies().get().await?;
println!("{answer:?}");
curl https://mailset.app/v1/policies.get \
  -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 policies get
Response
{
  "ok": true,
  "data": {
    "forwarding": "passkey",
    "sharedAi": true,
    "sessionDays": 30
  }
}

policies.set

Change the org’s policies.

POST/v1/policies.set

Admin or ownerPasskey

Parameters

  • forwardingenumoptional

    Forwarding rules: allowed with a passkey check, or never.

    One ofpasskeynever

  • sharedAibooleanoptional

    Whether AI runs on shared mailboxes.

  • sessionDaysnumberoptional

    How long a new sign-in lasts, in days: 30, 7 or 0.5 (12 hours).

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:

  • forwardingenumoptional

    Forwarding rules: allowed with a passkey check, or never.

    One ofpasskeynever

    Default passkey.

  • sharedAibooleanoptional

    Whether AI runs on shared mailboxes.

    Default true.

  • sessionDaysnumberoptional

    How long a new sign-in lasts, in days: 30, 7 or 0.5 (12 hours).

    Default 30.

In the CLIErrors

import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.policies.set({
	forwarding: "never",
	sessionDays: 7,
});
console.log(answer);
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.policies.set(
    {"forwarding": "never", "session_days": 7}
)
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.PoliciesSetParams{
		Forwarding:  mailset.SettingsForwardingNever,
		SessionDays: mailset.Int(7),
	}
	answer, err := client.Policies.Set(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.policies.set(
  forwarding: 'never',
  session_days: 7
)
p answer
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->policies->set([
    'forwarding' => 'never',
    'sessionDays' => 7,
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Policies;
import app.mailset.model.PoliciesSetParams;
import app.mailset.model.SettingsForwarding;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

var params = PoliciesSetParams.builder()
        .forwarding(SettingsForwarding.NEVER)
        .sessionDays(7L)
        .build();
Policies answer = mailset.policies().set(params);
System.out.println(answer);
use mailset::types::{
    PoliciesSetParams, SettingsForwarding,
};

// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .policies()
    .set(PoliciesSetParams {
        forwarding: Some(SettingsForwarding::Never),
        session_days: Some(7),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/policies.set \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"forwarding":"never","sessionDays":7},"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 policies set --forwarding never --session-days 7
Response
{
  "ok": true,
  "data": {
    "forwarding": "passkey",
    "sharedAi": true,
    "sessionDays": 30
  }
}