# Policies

The org’s rules on forwarding and sessions.

An SDK signs every request with your key: [Authentication](https://mailset.app/docs/authentication.md). To sign one yourself, see [Calling the API without an SDK](https://mailset.app/docs/authentication/http.md).

## 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`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is an object with:

- `forwarding` (enum, optional): Forwarding rules: allowed with a `passkey` check, or `never`. One of `passkey`, `never`. Default `passkey`.
- `sharedAi` (boolean, optional): Whether AI runs on shared mailboxes. Default `true`.
- `sessionDays` (number, optional): How long a new sign-in lasts, in days: 30, 7 or 0.5 (12 hours). Default `30`.

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

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

const answer = await mailset.policies.get();
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.policies.get()
print(answer)
```

Go:

```go
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)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.policies.get
p answer
```

PHP:

```php
<?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;
```

Java:

```java
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);
```

Rust:

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

let answer = mailset.policies().get().await?;
println!("{answer:?}");
```

curl:

```bash
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](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset policies get
```

### Response

```json
{
  "ok": true,
  "data": {
    "forwarding": "passkey",
    "sharedAi": true,
    "sessionDays": 30
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/policies#policies-get)

## policies.set

Change the org’s policies.

`POST /v1/policies.set`

An admin or owner of the org. It can stop for a passkey approval.

### Parameters

- `forwarding` (enum, optional): Forwarding rules: allowed with a `passkey` check, or `never`. One of `passkey`, `never`.
- `sharedAi` (boolean, optional): Whether AI runs on shared mailboxes.
- `sessionDays` (number, optional): How long a new sign-in lasts, in days: 30, 7 or 0.5 (12 hours).

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.
- `approval` (string, optional): 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:

- `forwarding` (enum, optional): Forwarding rules: allowed with a `passkey` check, or `never`. One of `passkey`, `never`. Default `passkey`.
- `sharedAi` (boolean, optional): Whether AI runs on shared mailboxes. Default `true`.
- `sessionDays` (number, optional): How long a new sign-in lasts, in days: 30, 7 or 0.5 (12 hours). Default `30`.

### Request

TypeScript:

```typescript
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);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.policies.set(
    {"forwarding": "never", "session_days": 7}
)
print(answer)
```

Go:

```go
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)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.policies.set(
  forwarding: 'never',
  session_days: 7
)
p answer
```

PHP:

```php
<?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;
```

Java:

```java
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);
```

Rust:

```rust
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:

```bash
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](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset policies set --forwarding never --session-days 7
```

### Response

```json
{
  "ok": true,
  "data": {
    "forwarding": "passkey",
    "sharedAi": true,
    "sessionDays": 30
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/policies#policies-set)

---

© 2026 Intenseloop, Inc. Mailset’s site, docs and guides are copyrighted. You may read them and use their code to build with Mailset. Don’t republish them or use them to build a copy of Mailset. Terms: https://mailset.app/terms#content