AI

AI

Summaries, drafts and sorting, and what runs them.

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

On this page
  1. The AI settings object
  2. ai.status
  3. ai.source
  4. ai.key.set
  5. ai.key.remove
  6. ai.key.check
  7. ai.models
  8. ai.models.set
  9. ai.summarize
  10. ai.replies
  11. ai.draft
  12. ai.triage
  13. ai.safe
  14. ai.search
  15. ai.explain
  16. ai.report

The AI settings object

An org’s AI: what it runs on, a model per feature, and this month.

Attributes

  • sourceenum

    What the org chose to run AI on. mailset: Mailset’s key. own: the org’s own key. off: no AI.

    One ofmailsetownoff

  • usingnullable enum

    What calls go to right now. Null when nothing does.

    One ofmailsetown

  • mailsetAllowedboolean

    Whether the org’s plan lets it use Mailset’s key.

  • configuredboolean

    Whether Mailset’s own key is there to run AI on.

  • bannernullable enum

    What to tell people about the org’s AI right now, if anything.

    One ofno_aicredit_usedkey_failing

  • keynullable object

    The org’s own key. Null: none saved.

    Show child attributesHide child attributes
    • providerenum

      Whose key it is.

      Alwaysanthropic

    • last4string

      The key’s last four characters. The rest is never shown.

    • stateenum

      failing: the provider refused it, and the org’s AI is paused until it’s fixed.

      One ofokfailing

    • failurenullable enum

      Why the key stopped working: invalid, or no_credit left on it. Null while it works.

      One ofinvalidno_credit

    • problemnullable string

      What went wrong and what to do, in words. Null while it works.

    • addedAtnumber

      When the key was saved, in ms since the epoch.

    • checkedAtnumber

      When it was last tried, in ms since the epoch.

    • limitedUntilnullable number

      Until when the provider asked to slow down; null when it hasn’t.

  • providerenum

    Whose models the features pick from.

    Alwaysanthropic

  • featuresarray of objects

    Each AI feature, the model it uses and what a month of it costs.

    Show child attributesHide child attributes
    • jobenum

      The feature’s id.

      One oftriagephishingsummaryrepliesdraftfollowupsearchchat

    • slugstring

      The feature as ai models set names it.

    • namestring

      The feature’s name.

    • aboutstring

      What the feature does, in a sentence.

    • soonboolean

      Held for later: nothing calls it yet.

    • modelstring

      The org’s pick, which runs on its own key.

    • defaultModelstring

      Mailset’s pick for it.

    • inUsenullable string

      What runs right now: the default on Mailset’s key. Null while AI is off.

    • unitsnumber

      Units behind the estimate, over days.

    • usdnumber

      A month of it at the org’s own volume: at Mailset’s price list on Mailset’s key, at the provider’s list prices on the org’s own.

    • optionsarray of objects

      The models it can use.

      Show child attributesHide child attributes
      • modelstring

        The model’s id: what ai models set --model takes.

      • namestring

        The model’s name.

      • usdnumber

        A month of this feature on this model on the org’s own key, at the provider’s list prices.

    • warningnullable string

      Set when the model it uses is a costly one for what it does.

  • daysnumber

    Days of the org’s own volume behind the estimates, at most 30. Zero: none yet.

  • monthobject

    This month so far.

    Show child attributesHide child attributes
    • creditobject

      The month’s AI credit on Mailset’s key, and what was used of it.

      Show child attributesHide child attributes
      • fromstring

        The first day of this month, UTC.

      • usdnullable number

        Null: no credit limits it.

      • usedUsdnumber

        What calls on Mailset’s key were worth this month, at the price list.

      • unitsarray of objects
        Show child attributesHide child attributes
        • jobenum

          One oftriagephishingsummaryrepliesdraftfollowupsearchchat

        • unitsnumber
      • usedWordsstring

        The same in plain words: "about 4,200 sorted emails, 37 drafts".

      • displayenum

        One ofbarearliernone

    • ownobject

      On the org’s own key, at the provider’s list prices. Mailset never bills it.

      Show child attributesHide child attributes
      • callsnumber
      • usdnumber

Answered by

ai.sourceai.key.setai.key.removeai.key.checkai.modelsai.models.set

The AI settings object
{
  "source": "mailset",
  "using": "mailset",
  "mailsetAllowed": true,
  "configured": true,
  "banner": "no_ai",
  "key": {
    "provider": "anthropic",
    "last4": "text",
    "state": "ok",
    "failure": "invalid",
    "problem": "text",
    "addedAt": 1796048940000,
    "checkedAt": 1796048940000,
    "limitedUntil": 1796048940000
  },
  "provider": "anthropic",
  "features": [

ai.status

Show what runs AI in each of your orgs, anything that stopped it, and this month’s AI credit.

POST/v1/ai.status

API token

Parameters

It takes no input: send an empty object.

Returns

data is an object with:

  • configuredboolean

    Whether Mailset’s own key is there to run AI on.

  • limitsobject

    What each org may spend a day on Mailset’s key.

    Show child attributesHide child attributes
    • callsnumber
    • usdnumber
  • todayarray of objects

    Today on Mailset’s key, per org.

    Show child attributesHide child attributes
    • orgstring
    • callsnumber
    • usdnumber
  • bannernullable enum

    The most pressing banner among this person’s orgs: a failing key first.

    One ofno_aicredit_usedkey_failing

  • orgsarray of objects

    Each org you’re in, and what runs its AI.

    Show child attributesHide child attributes
    • idstring

      The org’s id.

    • namestring

      The org’s name.

    • roleenum

      One ofowneradminmember

    • sourceenum

      What the org chose to run AI on. mailset: Mailset’s key. own: the org’s own key. off: no AI.

      One ofmailsetownoff

    • usingnullable enum

      What calls go to right now; null when nothing does.

      One ofmailsetown

    • mailsetAllowedboolean

      Mailset’s key is open to this org.

    • bannernullable enum

      What to tell people about the org’s AI right now, if anything.

      One ofno_aicredit_usedkey_failing

    • keynullable object

      The org’s own key. Owners and admins only.

      Show child attributesHide child attributes
      • providerenum

        Whose key it is.

        Alwaysanthropic

      • last4string

        The key’s last four characters. The rest is never shown.

      • stateenum

        failing: the provider refused it, and the org’s AI is paused until it’s fixed.

        One ofokfailing

      • failurenullable enum

        Why the key stopped working: invalid, or no_credit left on it. Null while it works.

        One ofinvalidno_credit

      • problemnullable string

        What went wrong and what to do, in words. Null while it works.

      • addedAtnumber

        When the key was saved, in ms since the epoch.

      • checkedAtnumber

        When it was last tried, in ms since the epoch.

      • limitedUntilnullable number

        Until when the provider asked to slow down; null when it hasn’t.

    • creditnullable object

      The month’s AI credit. Owners and admins only.

      Show child attributesHide child attributes
      • fromstring

        The first day of this month, UTC.

      • usdnullable number

        Null: no credit limits it.

      • usedUsdnumber

        What calls on Mailset’s key were worth this month, at the price list.

      • unitsarray of objects
        Show child attributesHide child attributes
        • jobenum

          One oftriagephishingsummaryrepliesdraftfollowupsearchchat

        • unitsnumber
      • usedWordsstring

        The same in plain words: "about 4,200 sorted emails, 37 drafts".

      • displayenum

        One ofbarearliernone

    • ownnullable object

      This month on the org’s own key, at the provider’s list prices. Owners and admins only.

      Show child attributesHide child attributes
      • callsnumber
      • usdnumber

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.status();
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.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.AI.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.ai.status
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->status();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiStatus;

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

AiStatus answer = mailset.ai().status();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.ai().status().await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.status \
  -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 shows how.

mailset ai status
Response
{
  "ok": true,
  "data": {
    "configured": true,
    "limits": {
      "calls": 1,
      "usd": 1
    },
    "today": [
      {
        "org": "text",
        "calls": 1,
        "usd": 1
      }
    ],
    "banner": "no_ai",
    "orgs": [
      {

ai.source

Run the org’s AI on Mailset’s key (mailset), its own key (own), or not at all (off).

POST/v1/ai.source

Admin or owner

Parameters

  • sourceenumrequired

    mailset: Mailset’s key. own: the org’s own key. off: no AI.

    One ofmailsetownoff

Beside input

  • orgstringoptional

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

Returns

data is the AI settings object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.source({
	source: "own",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.source({"source": "own"})
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.AISourceParams{
		Source: mailset.AISourceOwn,
	}
	answer, err := client.AI.Source(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.ai.source(source: 'own')
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->source(['source' => 'own']);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiSettings;
import app.mailset.model.AiSource;
import app.mailset.model.AiSourceParams;

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

var params = AiSourceParams.builder()
        .source(AiSource.OWN)
        .build();
AiSettings answer = mailset.ai().source(params);
System.out.println(answer);
use mailset::types::{AiSource, AiSourceParams};

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

let answer = mailset
    .ai()
    .source(AiSourceParams {
        source: AiSource::Own,
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.source \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"source":"own"},"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 ai source own
Response
{
  "ok": true,
  "data": {
    "source": "mailset",
    "using": "mailset",
    "mailsetAllowed": true,
    "configured": true,
    "banner": "no_ai",
    "key": {
      "provider": "anthropic",
      "last4": "text",
      "state": "ok",
      "failure": "invalid",
      "problem": "text",
      "addedAt": 1796048940000,
      "checkedAt": 1796048940000,
      "limitedUntil": 1796048940000
    },

ai.key.set

Check and keep the org’s own AI key, and run its AI on it. The CLI reads the key from stdin or a hidden prompt.

POST/v1/ai.key.set

Admin or ownerPasskey

Parameters

  • providerenumrequired

    Whose key it is: anthropic.

    Alwaysanthropic

  • keystringrequired

    The key itself. The CLI reads it from stdin or a hidden prompt, never from a flag.

    At most 400 characters.

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 the AI settings object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.key.set({
	provider: "anthropic",
	key: "<key>",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.key.set(
    {"provider": "anthropic", "key": "<key>"}
)
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.AIKeySetParams{
		Provider: mailset.AIProviderAnthropic,
		Key:      "<key>",
	}
	answer, err := client.AI.Key.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.ai.key.set(
  provider: 'anthropic',
  key: '<key>'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->key->set([
    'provider' => 'anthropic',
    'key' => '<key>',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiKeySetParams;
import app.mailset.model.AiProvider;
import app.mailset.model.AiSettings;

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

var params = AiKeySetParams.builder()
        .provider(AiProvider.ANTHROPIC)
        .key("<key>")
        .build();
AiSettings answer = mailset.ai().key().set(params);
System.out.println(answer);
use mailset::types::{AiKeySetParams, AiProvider};

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

let answer = mailset
    .ai()
    .key()
    .set(AiKeySetParams {
        provider: AiProvider::Anthropic,
        key: "<key>".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.key.set \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"provider":"anthropic","key":"<key>"},"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 ai key set anthropic
Response
{
  "ok": true,
  "data": {
    "source": "mailset",
    "using": "mailset",
    "mailsetAllowed": true,
    "configured": true,
    "banner": "no_ai",
    "key": {
      "provider": "anthropic",
      "last4": "text",
      "state": "ok",
      "failure": "invalid",
      "problem": "text",
      "addedAt": 1796048940000,
      "checkedAt": 1796048940000,
      "limitedUntil": 1796048940000
    },

ai.key.remove

Remove the org’s own AI key.

POST/v1/ai.key.remove

Admin or ownerPasskey

Parameters

  • providerenumoptional

    Whose key it is: anthropic.

    Alwaysanthropic

    Default anthropic.

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 the AI settings object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.key.remove({
	provider: "anthropic",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.key.remove({"provider": "anthropic"})
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.AIKeyRemoveParams{
		Provider: mailset.AIProviderAnthropic,
	}
	answer, err := client.AI.Key.Remove(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.ai.key.remove(provider: 'anthropic')
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->key->remove([
    'provider' => 'anthropic',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiKeyRemoveParams;
import app.mailset.model.AiProvider;
import app.mailset.model.AiSettings;

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

var params = AiKeyRemoveParams.builder()
        .provider(AiProvider.ANTHROPIC)
        .build();
AiSettings answer = mailset.ai().key().remove(params);
System.out.println(answer);
use mailset::types::{AiKeyRemoveParams, AiProvider};

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

let answer = mailset
    .ai()
    .key()
    .remove(AiKeyRemoveParams {
        provider: Some(AiProvider::Anthropic),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.key.remove \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"provider":"anthropic"},"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 ai key remove anthropic
Response
{
  "ok": true,
  "data": {
    "source": "mailset",
    "using": "mailset",
    "mailsetAllowed": true,
    "configured": true,
    "banner": "no_ai",
    "key": {
      "provider": "anthropic",
      "last4": "text",
      "state": "ok",
      "failure": "invalid",
      "problem": "text",
      "addedAt": 1796048940000,
      "checkedAt": 1796048940000,
      "limitedUntil": 1796048940000
    },

ai.key.check

Try the org’s own AI key again: one that works resumes its AI, one that doesn’t pauses it.

POST/v1/ai.key.check

Admin or owner

Parameters

  • providerenumoptional

    Whose key it is: anthropic.

    Alwaysanthropic

    Default anthropic.

Beside input

  • orgstringoptional

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

Returns

data is the AI settings object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.key.check({
	provider: "anthropic",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.key.check({"provider": "anthropic"})
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.AIKeyCheckParams{
		Provider: mailset.AIProviderAnthropic,
	}
	answer, err := client.AI.Key.Check(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.ai.key.check(provider: 'anthropic')
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->key->check([
    'provider' => 'anthropic',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiKeyCheckParams;
import app.mailset.model.AiProvider;
import app.mailset.model.AiSettings;

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

var params = AiKeyCheckParams.builder()
        .provider(AiProvider.ANTHROPIC)
        .build();
AiSettings answer = mailset.ai().key().check(params);
System.out.println(answer);
use mailset::types::{AiKeyCheckParams, AiProvider};

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

let answer = mailset
    .ai()
    .key()
    .check(AiKeyCheckParams {
        provider: Some(AiProvider::Anthropic),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.key.check \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"provider":"anthropic"},"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 ai key check anthropic
Response
{
  "ok": true,
  "data": {
    "source": "mailset",
    "using": "mailset",
    "mailsetAllowed": true,
    "configured": true,
    "banner": "no_ai",
    "key": {
      "provider": "anthropic",
      "last4": "text",
      "state": "ok",
      "failure": "invalid",
      "problem": "text",
      "addedAt": 1796048940000,
      "checkedAt": 1796048940000,
      "limitedUntil": 1796048940000
    },

ai.models

Show the model each AI feature uses, a month of each at your volume, and this month’s credit.

POST/v1/ai.models

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 the AI settings object.

In the CLIErrors

import { Mailset } from 'mailset';

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

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

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

answer = mailset.ai.models.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.AI.Models.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.ai.models.get
p answer
<?php

require 'vendor/autoload.php';

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

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

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

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

let answer = mailset.ai().models().get().await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.models \
  -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 ai models
Response
{
  "ok": true,
  "data": {
    "source": "mailset",
    "using": "mailset",
    "mailsetAllowed": true,
    "configured": true,
    "banner": "no_ai",
    "key": {
      "provider": "anthropic",
      "last4": "text",
      "state": "ok",
      "failure": "invalid",
      "problem": "text",
      "addedAt": 1796048940000,
      "checkedAt": 1796048940000,
      "limitedUntil": 1796048940000
    },

ai.models.set

Pick the model one AI feature uses on the org’s own key (model default goes back to Mailset’s pick).

POST/v1/ai.models.set

Admin or owner

Parameters

  • featurestringrequired

    The feature: sorting, phishing, summaries, replies, drafts, followups, ask or chat.

    At most 40 characters.

  • modelstringrequired

    The model’s id, from ai models, or default for Mailset’s pick.

    At most 100 characters.

Beside input

  • orgstringoptional

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

Returns

data is the AI settings object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.models.set({
	model: "claude-haiku-5-5",
	feature: "summaries",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.models.set(
    {"model": "claude-haiku-5-5", "feature": "summaries"}
)
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.AIModelsSetParams{
		Model:   "claude-haiku-5-5",
		Feature: "summaries",
	}
	answer, err := client.AI.Models.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.ai.models.set(
  model: 'claude-haiku-5-5',
  feature: 'summaries'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->models->set([
    'model' => 'claude-haiku-5-5',
    'feature' => 'summaries',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiModelsSetParams;
import app.mailset.model.AiSettings;

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

var params = AiModelsSetParams.builder()
        .model("claude-haiku-5-5")
        .feature("summaries")
        .build();
AiSettings answer = mailset.ai().models().set(params);
System.out.println(answer);
use mailset::types::AiModelsSetParams;

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

let answer = mailset
    .ai()
    .models()
    .set(AiModelsSetParams {
        feature: "summaries".into(),
        model: "claude-haiku-5-5".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.models.set \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"model":"claude-haiku-5-5","feature":"summaries"},"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 ai models set summaries --model claude-haiku-5-5
Response
{
  "ok": true,
  "data": {
    "source": "mailset",
    "using": "mailset",
    "mailsetAllowed": true,
    "configured": true,
    "banner": "no_ai",
    "key": {
      "provider": "anthropic",
      "last4": "text",
      "state": "ok",
      "failure": "invalid",
      "problem": "text",
      "addedAt": 1796048940000,
      "checkedAt": 1796048940000,
      "limitedUntil": 1796048940000
    },

ai.summarize

Summarize a conversation.

POST/v1/ai.summarize

API token

Parameters

  • idstringrequired

    The conversation’s id.

Returns

data is an object with:

  • textnullable string
  • reasonnullable enum

    One ofoffno_ainot_configuredcredit_usedkey_failingrate_limitedlimitfailed

  • meterobjectoptional
    Show child attributesHide child attributes
    • idnullable string

      The chat message’s own record; null for every other job.

    • modelstring
    • sourceenum

      Whose key paid: an org’s own key is worth nothing to Mailset.

      One ofmailsetown

    • tokensobject
      Show child attributesHide child attributes
      • inputnumber
      • outputnumber
      • cacheReadnumber
      • cacheWritenumber
    • usdnumber

      At Mailset’s price list on its key; zero on the org’s own.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.summarize({
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.summarize(
    {"id": "t_5d2c8a1f9e3b47c6a0d1e2f3"}
)
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.AISummarizeParams{
		ID: "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.AI.Summarize(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.ai.summarize(
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->summarize([
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiSummarizeParams;
import app.mailset.model.AiSummary;

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

var params = AiSummarizeParams.builder()
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
AiSummary answer = mailset.ai().summarize(params);
System.out.println(answer);
use mailset::types::AiSummarizeParams;

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

let answer = mailset
    .ai()
    .summarize(AiSummarizeParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.summarize \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'

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 ai summarize t_5d2c8a1f9e3b47c6a0d1e2f3
Response
{
  "ok": true,
  "data": {
    "text": "text",
    "reason": "off",
    "meter": {
      "id": "out_3f9a1c0e7b2d",
      "model": "text",
      "source": "mailset",
      "tokens": {
        "input": 1,
        "output": 1,
        "cacheRead": 1,
        "cacheWrite": 1
      },
      "usd": 1
    }
  }
}

ai.replies

Suggest short replies to a conversation. Nothing is sent.

POST/v1/ai.replies

API token

Parameters

  • idstringrequired

    The conversation’s id.

Returns

data is an object with:

  • repliesarray of strings
  • reasonnullable enum

    One ofoffno_ainot_configuredcredit_usedkey_failingrate_limitedlimitfailed

  • meterobjectoptional
    Show child attributesHide child attributes
    • idnullable string

      The chat message’s own record; null for every other job.

    • modelstring
    • sourceenum

      Whose key paid: an org’s own key is worth nothing to Mailset.

      One ofmailsetown

    • tokensobject
      Show child attributesHide child attributes
      • inputnumber
      • outputnumber
      • cacheReadnumber
      • cacheWritenumber
    • usdnumber

      At Mailset’s price list on its key; zero on the org’s own.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.replies({
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.replies(
    {"id": "t_5d2c8a1f9e3b47c6a0d1e2f3"}
)
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.AIRepliesParams{
		ID: "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.AI.Replies(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.ai.replies(
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->replies([
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiReplies;
import app.mailset.model.AiRepliesParams;

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

var params = AiRepliesParams.builder()
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
AiReplies answer = mailset.ai().replies(params);
System.out.println(answer);
use mailset::types::AiRepliesParams;

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

let answer = mailset
    .ai()
    .replies(AiRepliesParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.replies \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'

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 ai replies t_5d2c8a1f9e3b47c6a0d1e2f3
Response
{
  "ok": true,
  "data": {
    "replies": [
      "text"
    ],
    "reason": "off",
    "meter": {
      "id": "out_3f9a1c0e7b2d",
      "model": "text",
      "source": "mailset",
      "tokens": {
        "input": 1,
        "output": 1,
        "cacheRead": 1,
        "cacheWrite": 1
      },
      "usd": 1
    }
  }
}

ai.draft

Write a draft reply to a conversation. Nothing is sent.

POST/v1/ai.draft

API token

Parameters

  • idstringrequired

    The conversation’s id.

  • instructionsstringoptional

    What you want the reply to do, in your own words.

    At most 2,000 characters.

Returns

data is an object with:

  • textnullable string
  • reasonnullable enum

    One ofoffno_ainot_configuredcredit_usedkey_failingrate_limitedlimitfailed

  • meterobjectoptional
    Show child attributesHide child attributes
    • idnullable string

      The chat message’s own record; null for every other job.

    • modelstring
    • sourceenum

      Whose key paid: an org’s own key is worth nothing to Mailset.

      One ofmailsetown

    • tokensobject
      Show child attributesHide child attributes
      • inputnumber
      • outputnumber
      • cacheReadnumber
      • cacheWritenumber
    • usdnumber

      At Mailset’s price list on its key; zero on the org’s own.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.draft({
	instructions: "Say yes, and ask to move it to Thursday",
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.draft(
    {
        "instructions": (
            "Say yes, and ask to move it to Thursday"
        ),
        "id": "t_5d2c8a1f9e3b47c6a0d1e2f3",
    }
)
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.AIDraftParams{
require 'mailset'

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

answer = mailset.ai.draft(
  instructions: 'Say yes, and ask to move it to Thursday',
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->draft([
    'instructions' =>
        'Say yes, and ask to move it to Thursday',
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiDraft;
import app.mailset.model.AiDraftParams;

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

var params = AiDraftParams.builder()
        .instructions(
                "Say yes, and ask to move it to Thursday")
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
AiDraft answer = mailset.ai().draft(params);
System.out.println(answer);
use mailset::types::AiDraftParams;

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

let answer = mailset
    .ai()
    .draft(AiDraftParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
        instructions: Some(
            "Say yes, and ask to move it to Thursday"
                .into(),
        ),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.draft \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"instructions":"Say yes, and ask to move it to Thursday","id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'

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 ai draft t_5d2c8a1f9e3b47c6a0d1e2f3 --instructions "Say yes, and ask to move it to Thursday"
Response
{
  "ok": true,
  "data": {
    "text": "text",
    "reason": "off",
    "meter": {
      "id": "out_3f9a1c0e7b2d",
      "model": "text",
      "source": "mailset",
      "tokens": {
        "input": 1,
        "output": 1,
        "cacheRead": 1,
        "cacheWrite": 1
      },
      "usd": 1
    }
  }
}

ai.triage

Sort a conversation and check it for phishing, now.

POST/v1/ai.triage

API token

Parameters

  • idstringrequired

    The conversation’s id.

Returns

data is an object with:

  • tabenum

    One ofprimaryupdatesnewsletterspromotions

  • needsReplyboolean
  • phishingnullable object
    Show child attributesHide child attributes
    • domainstring

      The domain the mail really came from.

    • imitatesnullable string

      The domain or name it passes itself off as. Null when it imitates nobody known.

    • failednullable string

      The check it failed, such as DMARC. Null when none did.

    • reasonenumoptional

      What it does that looks like fraud: a lookalike domain, a payment ask, a request for credentials, or a risky attachment.

      One oflookalikepaymentcredentialsattachment

  • reasonnullable enum

    One ofoffno_ainot_configuredcredit_usedkey_failingrate_limitedlimitfailed

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.triage({
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.triage(
    {"id": "t_5d2c8a1f9e3b47c6a0d1e2f3"}
)
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.AITriageParams{
		ID: "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.AI.Triage(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.ai.triage(
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->triage([
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiTriageParams;
import app.mailset.model.AiVerdict;

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

var params = AiTriageParams.builder()
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
AiVerdict answer = mailset.ai().triage(params);
System.out.println(answer);
use mailset::types::AiTriageParams;

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

let answer = mailset
    .ai()
    .triage(AiTriageParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.triage \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'

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 ai triage t_5d2c8a1f9e3b47c6a0d1e2f3
Response
{
  "ok": true,
  "data": {
    "tab": "primary",
    "needsReply": true,
    "phishing": {
      "domain": "example.com",
      "imitates": "text",
      "failed": "text",
      "reason": "lookalike"
    },
    "reason": "off"
  }
}

ai.safe

Take a phishing warning off a conversation.

POST/v1/ai.safe

API token

Parameters

  • idstringrequired

    The conversation’s id.

Returns

data is an object with:

  • safeboolean

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.safe({
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.safe(
    {"id": "t_5d2c8a1f9e3b47c6a0d1e2f3"}
)
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.AISafeParams{
		ID: "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.AI.Safe(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.ai.safe(id: 't_5d2c8a1f9e3b47c6a0d1e2f3')
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->safe([
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiSafeParams;
import app.mailset.model.AiSafeResult;

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

var params = AiSafeParams.builder()
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
AiSafeResult answer = mailset.ai().safe(params);
System.out.println(answer);
use mailset::types::AiSafeParams;

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

let answer = mailset
    .ai()
    .safe(AiSafeParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.safe \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'

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 ai safe t_5d2c8a1f9e3b47c6a0d1e2f3
Response
{
  "ok": true,
  "data": {
    "safe": true
  }
}

ai.search

Turn a question into search operators.

POST/v1/ai.search

API token

Parameters

  • questionstringrequired

    What you’re looking for, in your own words. Up to 500 characters.

    At most 500 characters.

Returns

data is an object with:

  • querynullable string

    The question as search operators, or null to search the words as typed.

  • reasonnullable enum

    One ofoffno_ainot_configuredcredit_usedkey_failingrate_limitedlimitfailed

  • meterobjectoptional
    Show child attributesHide child attributes
    • idnullable string

      The chat message’s own record; null for every other job.

    • modelstring
    • sourceenum

      Whose key paid: an org’s own key is worth nothing to Mailset.

      One ofmailsetown

    • tokensobject
      Show child attributesHide child attributes
      • inputnumber
      • outputnumber
      • cacheReadnumber
      • cacheWritenumber
    • usdnumber

      At Mailset’s price list on its key; zero on the org’s own.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.search({
	question: "invoices from Stripe since March",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.search(
    {"question": "invoices from Stripe since March"}
)
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.AISearchParams{
		Question: "invoices from Stripe since March",
	}
	answer, err := client.AI.Search(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.ai.search(
  question: 'invoices from Stripe since March'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->search([
    'question' => 'invoices from Stripe since March',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiSearch;
import app.mailset.model.AiSearchParams;

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

var params = AiSearchParams.builder()
        .question("invoices from Stripe since March")
        .build();
AiSearch answer = mailset.ai().search(params);
System.out.println(answer);
use mailset::types::AiSearchParams;

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

let answer = mailset
    .ai()
    .search(AiSearchParams {
        question: "invoices from Stripe since March"
            .into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.search \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"question":"invoices from Stripe since March"}}'

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 ai search "invoices from Stripe since March"
Response
{
  "ok": true,
  "data": {
    "query": "text",
    "reason": "off",
    "meter": {
      "id": "out_3f9a1c0e7b2d",
      "model": "text",
      "source": "mailset",
      "tokens": {
        "input": 1,
        "output": 1,
        "cacheRead": 1,
        "cacheWrite": 1
      },
      "usd": 1
    }
  }
}

ai.explain

Say why a conversation is in its tab.

POST/v1/ai.explain

API token

Parameters

  • idstringrequired

    The conversation’s id.

Returns

data is an object with:

  • tabenum

    One ofprimaryupdatesnewsletterspromotions

  • decidedBystring

    In words: your choice, headers, cached, sender pattern, shared sender, model.

  • whynullable string

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.explain({
	id: "t_5d2c8a1f9e3b47c6a0d1e2f3",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.explain(
    {"id": "t_5d2c8a1f9e3b47c6a0d1e2f3"}
)
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.AIExplainParams{
		ID: "t_5d2c8a1f9e3b47c6a0d1e2f3",
	}
	answer, err := client.AI.Explain(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.ai.explain(
  id: 't_5d2c8a1f9e3b47c6a0d1e2f3'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->explain([
    'id' => 't_5d2c8a1f9e3b47c6a0d1e2f3',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiExplainParams;
import app.mailset.model.TabExplained;

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

var params = AiExplainParams.builder()
        .id("t_5d2c8a1f9e3b47c6a0d1e2f3")
        .build();
TabExplained answer = mailset.ai().explain(params);
System.out.println(answer);
use mailset::types::AiExplainParams;

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

let answer = mailset
    .ai()
    .explain(AiExplainParams {
        id: "t_5d2c8a1f9e3b47c6a0d1e2f3".into(),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.explain \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"id":"t_5d2c8a1f9e3b47c6a0d1e2f3"}}'

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 ai explain t_5d2c8a1f9e3b47c6a0d1e2f3
Response
{
  "ok": true,
  "data": {
    "tab": "primary",
    "decidedBy": "text",
    "why": "text"
  }
}

ai.report

Show what sorted your mail and how much reached a model.

POST/v1/ai.report

API token

Parameters

It takes no input: send an empty object.

Returns

data is an object with:

  • byLayerarray of objects

    Conversations in your mailboxes by what placed them.

    Show child attributesHide child attributes
    • layerstring
    • threadsnumber
  • threadsnumber
  • reachedModelnumber

    Conversations a model actually had to read to place.

  • modelSharenumber
  • callsnumber

    Model calls paid for, and answers reused instead, in your orgs.

  • hitsnumber
  • callsAvoidednumber
  • usdnumber

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.ai.report();
console.log(answer);
from mailset import Mailset

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

answer = mailset.ai.report()
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.AI.Report(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
require 'mailset'

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

answer = mailset.ai.report
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->ai->report();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.AiReport;

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

AiReport answer = mailset.ai().report();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.ai().report().await?;
println!("{answer:?}");
curl https://mailset.app/v1/ai.report \
  -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 shows how.

mailset ai report
Response
{
  "ok": true,
  "data": {
    "byLayer": [
      {
        "layer": "text",
        "threads": 1
      }
    ],
    "threads": 1,
    "reachedModel": 1,
    "modelShare": 1,
    "calls": 1,
    "hits": 1,
    "callsAvoided": 1,
    "usd": 1
  }
}