# Key status

What the key making a call may do, and when it stops.

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).

## The Key status object

An app key as Mailset sees it: its name, what it reaches, and when it stops.

### Attributes

- `id` (string): The app’s id: what `grants revoke`, `grants renew` and `grants resume` take.
- `name` (string): The name it was approved with.
- `createdAt` (number): When it was connected, in ms since the epoch.
- `lastSeenAt` (number): When it last made a call, in ms since the epoch.
- `expiresAt` (number): When its key stops working, in ms since the epoch: 90 days after its last call. Moves forward whenever the app uses it.
- `paused` (nullable string, optional): Why its own brake stopped its mail, or null while it may send. Default `null`.
- `mailboxes` (array of objects): The mailboxes it reaches, and what it may do with each.
  - `address` (string): The mailbox’s address.
  - `access` (array of enums): What the app may do with it: `read`, `send` or both. One of `read`, `send`.
  - `sendAs` (array of strings): The addresses it may send as. Empty without send access.
  - `sending` (enum): Whether the mailbox’s domain can send: `pending`, `ready` or `blocked`. One of `pending`, `ready`, `blocked`.
- `domains` (array of objects, optional): For a domain key: the sending-only domain it sends from, with no mailbox, and the addresses it sends as there. Empty for any other key. Default `[]`.
  - `name` (string): The domain’s name.
  - `sending` (enum): Whether the domain can send: `pending`, `ready` or `blocked`. One of `pending`, `ready`, `blocked`.
  - `from` (nullable array of strings, optional): The addresses it sends as, on that domain. Null: any address there, the opt-in for a domain where nobody has an address of their own.
- `campaigns` (nullable object, optional): The org whose campaigns it runs, for a campaigns key. Null for any other.
  - `org` (string): The org’s id.
  - `name` (string): The org’s name.

```json
{
  "id": "grant_3f9a1c0e7b2d",
  "name": "Acme API",
  "createdAt": 1793456940000,
  "lastSeenAt": 1796048940000,
  "expiresAt": 1803824940000,
  "paused": null,
  "mailboxes": [
    {
      "address": "hello@example.com",
      "access": [
        "send"
      ],
      "sendAs": [
        "hello@example.com"
      ],
      "sending": "ready"
    }
  ],
  "domains": [],
  "campaigns": null
}
```

For a domain key:

```json
{
  "id": "grant_8c1e4b7a2d9f",
  "name": "Acme receipts",
  "createdAt": 1793456940000,
  "lastSeenAt": 1796048940000,
  "expiresAt": 1803824940000,
  "paused": null,
  "mailboxes": [],
  "domains": [
    {
      "name": "example.com",
      "sending": "ready",
      "from": [
        "receipts@example.com",
        "noreply@example.com"
      ]
    }
  ],
  "campaigns": null
}
```

Answered by [keys.list](https://mailset.app/docs/api/keys#keys.list), [keys.update](https://mailset.app/docs/api/keys#keys.update), [grants.current](https://mailset.app/docs/api/grants#grants.current).

## grants.current

Show what this app key may do: its mailbox or sending domain, and whether it can send.

`POST /v1/grants.current`

Any app key. Or a person: any signed-in person, with an API token.

### Parameters

It takes no input: send an empty object.

### Returns

`data` is the [Key status object](https://mailset.app/docs/api/grants#key-status).

### Request

TypeScript:

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

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

// When the server starts, and once a day.
const status = await mailset.key.check();

if (status.paused) console.warn('Paused:', status.paused);
console.log('Works until', new Date(status.expiresAt));
// A mailbox key sends as its mailbox.
for (const { address, sending } of status.mailboxes)
	if (sending !== 'ready') console.warn(address, sending);
// A domain key sends as the addresses it names.
for (const { name, sending, from } of status.domains) {
	const as = from?.join(', ') ?? 'any address';
	console.log(name, 'sends as', as);
	if (sending !== 'ready') console.warn(name, sending);
}
```

Python:

```python
from datetime import datetime, timezone

from mailset import Mailset

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

# When the server starts, and once a day.
status = mailset.key.check()

if status["paused"]:
    print("Paused:", status["paused"])
ends = status["expires_at"] / 1000
until = datetime.fromtimestamp(ends, timezone.utc)
print("Works until", until)
# A mailbox key sends as its mailbox.
for box in status["mailboxes"]:
    if box["sending"] != "ready":
        print(box["address"], box["sending"])
# A domain key sends as the addresses it names.
for domain in status["domains"]:
    addresses = domain["from"]
    if addresses is None:
        sends_as = "any address"
    else:
        sends_as = ", ".join(addresses)
    print(domain["name"], "sends as", sends_as)
    if domain["sending"] != "ready":
        print(domain["name"], domain["sending"])
```

Go:

```go
import (
	"context"
	"fmt"
	"log"
	"strings"
	"time"

	mailset "mailset.app/go"
)

client, err := mailset.NewClient() // reads MAILSET_KEY
if err != nil {
	log.Fatal(err)
}
ctx := context.Background()

// When the server starts, and once a day.
status, err := client.Key.Check(ctx)
if err != nil {
	log.Fatal(err)
}

if status.Paused != nil {
	log.Println("Paused:", *status.Paused)
}
until := time.UnixMilli(status.ExpiresAt)
fmt.Println("Works until", until)
// A mailbox key sends as its mailbox.
for _, box := range status.Mailboxes {
	if box.Sending != mailset.SendingStateReady {
		log.Println(box.Address, box.Sending)
	}
}
// A domain key sends as the addresses it names.
for _, domain := range status.Domains {
	as := "any address"
	if domain.From != nil {
		as = strings.Join(domain.From, ", ")
	}
	fmt.Println(domain.Name, "sends as", as)
	if domain.Sending != mailset.SendingStateReady {
		log.Println(domain.Name, domain.Sending)
	}
}
```

Ruby:

```ruby
require 'mailset'

mailset = Mailset::Client.new

# When the server starts, and once a day.
status = mailset.key.check

warn "Paused: #{status.paused}" if status.paused
puts "Works until #{Time.at(status.expires_at / 1000)}"
# A mailbox key sends as its mailbox.
status.mailboxes.each do |box|
  next if box.sending == 'ready'

  warn "#{box.address}: #{box.sending}"
end
# A domain key sends as the addresses it names.
status.domains.each do |domain|
  as = domain.from&.join(', ') || 'any address'
  puts "#{domain.name} sends as #{as}"
  next if domain.sending == 'ready'

  warn "#{domain.name}: #{domain.sending}"
end
```

PHP:

```php
<?php

require 'vendor/autoload.php';

use Mailset\Types\SendingState;

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

// When the server starts, and once a day.
$status = $mailset->key->check();

if ($status->paused !== null) {
    error_log("Paused: {$status->paused}");
}
$until = intdiv($status->expiresAt, 1000);
echo 'Works until ', gmdate('c', $until), PHP_EOL;

// A state this SDK doesn't know yet is text.
$text = fn ($s) => is_string($s) ? $s : $s->value;

// A mailbox key sends as its mailbox.
foreach ($status->mailboxes as $box) {
    if ($box->sending !== SendingState::Ready) {
        $state = $text($box->sending);
        error_log("{$box->address}: {$state}");
    }
}
// A domain key sends as the addresses it names.
foreach ($status->domains as $domain) {
    $as = $domain->from === null
        ? 'any address'
        : implode(', ', $domain->from);
    echo "{$domain->name} sends as {$as}", PHP_EOL;
    if ($domain->sending !== SendingState::Ready) {
        $state = $text($domain->sending);
        error_log("{$domain->name}: {$state}");
    }
}
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.GrantDomain;
import app.mailset.model.GrantMailbox;
import app.mailset.model.KeyStatus;
import java.time.Instant;

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

// When the server starts, and once a day.
KeyStatus status = mailset.key().check();

status.paused().ifPresent(why ->
        System.err.println("Paused: " + why));
System.out.println("Works until "
        + Instant.ofEpochMilli(status.expiresAt()));
// A mailbox key sends as its mailbox.
for (GrantMailbox box : status.mailboxes())
    warn(box.address(), box.sending());
// A domain key sends as the addresses it names.
for (GrantDomain domain : status.domains()) {
    String as = domain.from()
            .map(from -> String.join(", ", from))
            .orElse("any address");
    System.out.println(
            domain.name() + " sends as " + as);
    warn(domain.name(), domain.sending());
}
```

Rust:

```rust
use mailset::types::SendingState;
use mailset::Client;

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

// When the server starts, and once a day.
let status = mailset.key().check().await?;

if let Some(paused) = &status.paused {
    eprintln!("Paused: {paused}");
}
println!("Works until {} (ms)", status.expires_at);
// A mailbox key sends as its mailbox.
for b in &status.mailboxes {
    if b.sending != SendingState::Ready {
        eprintln!("{} {}", b.address, b.sending);
    }
}
// A domain key sends as the addresses it names.
for d in &status.domains {
    let from = d.from.as_ref().map(|f| f.join(", "));
    let from = from.unwrap_or("any address".into());
    println!("{} sends as {from}", d.name);
    if d.sending != SendingState::Ready {
        eprintln!("{} {}", d.name, d.sending);
    }
}
```

curl:

```bash
curl https://mailset.app/v1/grants.current \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{}}'
```

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 grants current
```

### Response

```json
{
  "ok": true,
  "data": {
    "id": "grant_3f9a1c0e7b2d",
    "name": "Acme API",
    "createdAt": 1793456940000,
    "lastSeenAt": 1796048940000,
    "expiresAt": 1803824940000,
    "paused": null,
    "mailboxes": [
      {
        "address": "hello@example.com",
        "access": [
          "send"
        ],
        "sendAs": [
          "hello@example.com"
        ],
        "sending": "ready"
      }
    ],
    "domains": [],
    "campaigns": null
  }
}
```

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

---

© 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