Billing

Billing

The plan, this month’s use, and the prepaid balance.

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 Billing object
  2. billing.status
  3. billing.usage
  4. billing.upgrade
  5. billing.portal
  6. billing.switch
  7. billing.cancel
  8. billing.resume
  9. billing.payg
  10. billing.balance
  11. billing.topup
  12. billing.autotopup
  13. billing.ledger

The Billing object

An org’s plan, what it pays for, its balance and what comes next.

Attributes

  • planenum

    The org’s plan: trial, base or team.

    One oftrialbaseteam

  • arrangedbooleanoptional

    The plan’s terms were arranged with Mailset, not taken from the price list: no list price applies, and nothing here upgrades, switches or cancels it.

    Default false.

  • intervalnullable enum

    How Base is billed. Null on other plans.

    One ofmonthyear

  • payAsYouGoboolean

    Whether use past the plan’s allowances draws from the balance.

  • statusenum

    The subscription’s state: active, past_due or canceled.

    One ofactivepast_duecanceled

  • trialEndsAtnullable number

    When the trial ends, in ms since the epoch. Null outside a trial.

  • trialDaysLeftnullable number

    Whole days left, counted up. Null outside a live trial.

  • endedboolean

    The trial ended, or the subscription was canceled, and nothing replaced it.

  • afterEndnullable object

    What happens after the plan ended. Null while the plan is live, and on a plan arranged with Mailset.

    Show child attributesHide child attributes
    • sincenumber
    • mailStopsAtnumber

      From here new mail to the org’s addresses is refused.

    • mailStoppedboolean
    • deletesAtnumber

      From here the org’s mailboxes, with their mail and files, are deleted.

    • deletedAtnullable number

      When they were. Null: not yet.

  • mailsetAienum

    Whether the org may use Mailset’s AI, and why not when it may not.

    One ofoncredit_usedoff

  • tierenum

    How far the org may send. sending status has the limits.

    One ofno_cardtrialpaid

  • membersobject

    The people who sign in, against what the plan includes.

    Show child attributesHide child attributes
    • countnumber
    • invitednumber

      Invites nobody has accepted yet. They count once they join.

    • includednullable number

      What the plan includes. Null: no count applies.

    • capnullable number

      Past this an invite is refused (a trial, a plan arranged with Mailset). Null: seats instead.

    • extranumber

      Seats past the included members, billed on the subscription.

    • seatCentsnullable number

      What one more costs, a month or a year (interval). Null: none is charged.

  • cheapernullable object

    A plan that would cost less for these members, with what it costs a month.

    Show child attributesHide child attributes
    • planenum

      One ofbaseteam

    • intervalenum

      One ofmonthyear

    • centsnumber
    • currentCentsnumber
  • usageobject

    This month’s use against the plan’s allowances.

    Show child attributesHide child attributes
    • periodStartnumber

      The calendar month in UTC: its first instant and the next month’s.

    • periodEndnumber
    • aiobject
      Show child attributesHide child attributes
      • priceMicrosnumber

        Mailset’s AI this month at its price list.

      • creditMicrosnullable number

        The month’s AI credit. Null: none limits it (no prices here, or Mailset’s own org).

      • overMicrosnumber
    • storageobject
      Show child attributesHide child attributes
      • bytesnumber

        The latest daily count.

      • includedBytesnullable number

        Null: no prices here, so nothing is included or over.

      • overGbMonthsnumber

        GB-months past what’s included, so far this month.

    • emailsobject
      Show child attributesHide child attributes
      • outsidenumber

        Recipients outside the org’s own domains this month. Incoming and internal mail never count.

      • allowancenullable number
      • overnumber
    • owedMicrosnumber

      What this month’s use past the allowances costs so far: drawn, and not yet.

    • billedboolean

      Pay as you go draws it from the balance.

  • balanceobject

    The prepaid balance and auto top-up.

    Show child attributesHide child attributes
    • microsnumber

      What the ledger holds.

    • pendingMicrosnumber

      Usage not drawn yet (today’s, mostly).

    • availableMicrosnumber

      What draws see: the ledger less what’s pending, or zero after a failed charge.

    • failedboolean

      A charge failed and hasn’t gone through since.

    • retryAtnullable number
    • expiringMicrosnumber

      Credit that expires in the next 30 days.

    • cardSavedboolean

      A card is saved, so auto top-ups can charge it.

    • autoTopupobject
      Show child attributesHide child attributes
      • onboolean
      • thresholdMicrosnumber
      • amountMicrosnumber
      • ceilingMicrosnumber

        The most auto top-ups may charge in a calendar month.

      • usedThisMonthMicrosnumber
  • availableboolean

    Whether card payments are available, so Upgrade, Add credit and Manage billing work.

  • subscribedboolean

    The org has a paid subscription.

  • pricesnullable object

    What plans and extra use cost. Null where nothing is charged.

    Show child attributesHide child attributes
    • currencystring
    • baseMonthlyCentsnumber
    • baseYearlyCentsnumber
    • teamMonthlyCentsnumber
    • teamYearlyCentsnumber
    • baseMembersnumber

      Members (people who sign in) each plan includes. Mailboxes are unlimited.

    • teamMembersnumber
    • trialMembersnumber
    • baseSeatMonthlyCentsnumber

      Each member past them: a seat on the subscription.

    • baseSeatYearlyCentsnumber
    • teamSeatMonthlyCentsnumber
    • teamSeatYearlyCentsnumber
    • storageGbnumber

      Every plan’s monthly allowances.

    • emailAllowancenumber
    • aiCreditCentsnumber
    • emailsPer1000Centsnumber

      What draws from the balance past them.

    • storageGbMonthCentsnumber
    • topupMinCentsnumber

      Top-ups: the least one can be, and the defaults an owner can change.

    • topupThresholdCentsnumber
    • topupAmountCentsnumber
    • topupCeilingCentsnumber
    • overdraftCentsnumber

      How far storage may take the balance below zero before it stops drawing.

    • creditMonthsnumber

      How long a credit lasts.

    • endedReceiveDaysnumber

      After a plan ends unpaid: new mail to the org is refused from this many days on, and its mail and files are deleted at the second.

    • endedDeleteDaysnumber
  • offernullable object

    The launch offer this org can still subscribe with. Null: none, or it’s used.

    Show child attributesHide child attributes
    • codestring
    • namestring
    • percentnumber
    • monthsnumber
    • claimedAtnumber
    • redeemBynumber

      A UTC midnight: Checkout takes the offer off until then.

  • renewsAtnullable numberoptional

    When the subscription renews, in ms since the epoch: its period’s end. Null with none.

    Default null.

  • cancelAtnullable numberoptional

    The plan is set to end then, at its period’s end. Null: it renews.

    Default null.

  • paymentRetryAtnullable numberoptional

    When a failed payment is tried again, in ms since the epoch. Null: none planned.

    Default null.

Answered by

billing.statusbilling.switchbilling.cancelbilling.resumebilling.paygbilling.balancebilling.autotopup

The Billing object
{
  "plan": "trial",
  "arranged": false,
  "interval": "month",
  "payAsYouGo": true,
  "status": "active",
  "trialEndsAt": 1796048940000,
  "trialDaysLeft": 1,
  "ended": true,
  "afterEnd": {
    "since": 1796048940000,
    "mailStopsAt": 1796048940000,
    "mailStopped": true,
    "deletesAt": 1796048940000,
    "deletedAt": 1796048940000
  },
  "mailsetAi": "on",
  "tier": "no_card",

billing.status

Your org’s plan, members, Mailset AI, the balance and this month’s use.

POST/v1/billing.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 the Billing object.

In the CLIErrors

import { Mailset } from 'mailset';

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

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

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

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

require 'vendor/autoload.php';

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

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

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

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

let answer = mailset.billing().status().await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.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 billing status
Response
{
  "ok": true,
  "data": {
    "plan": "trial",
    "arranged": false,
    "interval": "month",
    "payAsYouGo": true,
    "status": "active",
    "trialEndsAt": 1796048940000,
    "trialDaysLeft": 1,
    "ended": true,
    "afterEnd": {
      "since": 1796048940000,
      "mailStopsAt": 1796048940000,
      "mailStopped": true,
      "deletesAt": 1796048940000,
      "deletedAt": 1796048940000
    },

billing.usage

This month’s outside email, storage and AI against the plan, and what went past it.

POST/v1/billing.usage

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:

  • usageobject
    Show child attributesHide child attributes
    • periodStartnumber

      The calendar month in UTC: its first instant and the next month’s.

    • periodEndnumber
    • aiobject
      Show child attributesHide child attributes
      • priceMicrosnumber

        Mailset’s AI this month at its price list.

      • creditMicrosnullable number

        The month’s AI credit. Null: none limits it (no prices here, or Mailset’s own org).

      • overMicrosnumber
    • storageobject
      Show child attributesHide child attributes
      • bytesnumber

        The latest daily count.

      • includedBytesnullable number

        Null: no prices here, so nothing is included or over.

      • overGbMonthsnumber

        GB-months past what’s included, so far this month.

    • emailsobject
      Show child attributesHide child attributes
      • outsidenumber

        Recipients outside the org’s own domains this month. Incoming and internal mail never count.

      • allowancenullable number
      • overnumber
    • owedMicrosnumber

      What this month’s use past the allowances costs so far: drawn, and not yet.

    • billedboolean

      Pay as you go draws it from the balance.

  • pricesnullable object
    Show child attributesHide child attributes
    • currencystring
    • baseMonthlyCentsnumber
    • baseYearlyCentsnumber
    • teamMonthlyCentsnumber
    • teamYearlyCentsnumber
    • baseMembersnumber

      Members (people who sign in) each plan includes. Mailboxes are unlimited.

    • teamMembersnumber
    • trialMembersnumber
    • baseSeatMonthlyCentsnumber

      Each member past them: a seat on the subscription.

    • baseSeatYearlyCentsnumber
    • teamSeatMonthlyCentsnumber
    • teamSeatYearlyCentsnumber
    • storageGbnumber

      Every plan’s monthly allowances.

    • emailAllowancenumber
    • aiCreditCentsnumber
    • emailsPer1000Centsnumber

      What draws from the balance past them.

    • storageGbMonthCentsnumber
    • topupMinCentsnumber

      Top-ups: the least one can be, and the defaults an owner can change.

    • topupThresholdCentsnumber
    • topupAmountCentsnumber
    • topupCeilingCentsnumber
    • overdraftCentsnumber

      How far storage may take the balance below zero before it stops drawing.

    • creditMonthsnumber

      How long a credit lasts.

    • endedReceiveDaysnumber

      After a plan ends unpaid: new mail to the org is refused from this many days on, and its mail and files are deleted at the second.

    • endedDeleteDaysnumber

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.usage();
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.usage()
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.Billing.Usage(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
require 'mailset'

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

answer = mailset.billing.usage
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->usage();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BillingUsageResult;

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

BillingUsageResult answer = mailset.billing().usage();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.billing().usage().await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.usage \
  -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 billing usage
Response
{
  "ok": true,
  "data": {
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,

billing.upgrade

Open Stripe Checkout for a plan.

POST/v1/billing.upgrade

Owner

Parameters

  • planenumoptional

    The plan: base or team.

    One ofbaseteam

    Default base.

  • yearlybooleanoptional

    Base only: billed once a year.

    Default false.

Beside input

  • orgstringoptional

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

Returns

data is an object with:

  • urlstring

    The checkout page’s link, to open in a browser.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.upgrade({
	plan: "base",
	yearly: true,
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.upgrade(
    {"plan": "base", "yearly": True}
)
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.BillingUpgradeParams{
		Plan:   mailset.PaidPlanBase,
		Yearly: mailset.Bool(true),
	}
	answer, err := client.Billing.Upgrade(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.billing.upgrade(
  plan: 'base',
  yearly: true
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->upgrade([
    'plan' => 'base',
    'yearly' => true,
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BillingUpgradeParams;
import app.mailset.model.BillingUpgradeResult;
import app.mailset.model.PaidPlan;

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

var params = BillingUpgradeParams.builder()
        .plan(PaidPlan.BASE)
        .yearly(true)
        .build();
BillingUpgradeResult answer =
        mailset.billing().upgrade(params);
System.out.println(answer);
use mailset::types::{BillingUpgradeParams, PaidPlan};

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

let answer = mailset
    .billing()
    .upgrade(BillingUpgradeParams {
        plan: Some(PaidPlan::Base),
        yearly: Some(true),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.upgrade \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"plan":"base","yearly":true},"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 billing upgrade --plan base --yearly
Response
{
  "ok": true,
  "data": {
    "url": "https://hooks.example.com/mailset"
  }
}

billing.portal

Owners.

POST/v1/billing.portal

Owner

Parameters

  • cardbooleanoptional

    Go straight to changing the card.

Beside input

  • orgstringoptional

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

Returns

data is an object with:

  • urlstring

    The billing portal’s link, to open in a browser.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.portal({
	card: true,
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.portal({"card": True})
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.BillingPortalParams{
		Card: mailset.Bool(true),
	}
	answer, err := client.Billing.Portal(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.billing.portal(card: true)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->portal(['card' => true]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BillingPortalParams;
import app.mailset.model.BillingPortalResult;

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

var params = BillingPortalParams.builder()
        .card(true)
        .build();
BillingPortalResult answer =
        mailset.billing().portal(params);
System.out.println(answer);
use mailset::types::BillingPortalParams;

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

let answer = mailset
    .billing()
    .portal(BillingPortalParams { card: Some(true) })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.portal \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"card":true},"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 billing portal --card
Response
{
  "ok": true,
  "data": {
    "url": "https://hooks.example.com/mailset"
  }
}

billing.switch

Move a paying org to another plan, seats and all.

POST/v1/billing.switch

Owner

Parameters

  • planenumoptional

    The plan: base or team.

    One ofbaseteam

    Default base.

  • yearlybooleanoptional

    Base only: billed once a year.

    Default false.

Beside input

  • orgstringoptional

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

Returns

data is the Billing object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.switch({
	plan: "team",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.switch({"plan": "team"})
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.BillingSwitchParams{
		Plan: mailset.PaidPlanTeam,
	}
	answer, err := client.Billing.Switch(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.billing.switch(plan: 'team')
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->switch(['plan' => 'team']);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Billing;
import app.mailset.model.BillingSwitchParams;
import app.mailset.model.PaidPlan;

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

var params = BillingSwitchParams.builder()
        .plan(PaidPlan.TEAM)
        .build();
Billing answer = mailset.billing().switchPlan(params);
System.out.println(answer);
use mailset::types::{BillingSwitchParams, PaidPlan};

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

let answer = mailset
    .billing()
    .switch(BillingSwitchParams {
        plan: Some(PaidPlan::Team),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.switch \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"plan":"team"},"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 billing switch team
Response
{
  "ok": true,
  "data": {
    "plan": "trial",
    "arranged": false,
    "interval": "month",
    "payAsYouGo": true,
    "status": "active",
    "trialEndsAt": 1796048940000,
    "trialDaysLeft": 1,
    "ended": true,
    "afterEnd": {
      "since": 1796048940000,
      "mailStopsAt": 1796048940000,
      "mailStopped": true,
      "deletesAt": 1796048940000,
      "deletedAt": 1796048940000
    },

billing.cancel

End the plan when its paid period ends, saying why.

POST/v1/billing.cancel

Owner

Parameters

  • reasonenumrequired

    Why the plan is ending, one of the listed reasons.

    One oftoo_expensivemissing_featuresswitched_serviceunusedcustomer_servicetoo_complexlow_qualityother

  • commentstringoptional

    Anything to add, up to 1,000 characters.

    At most 1,000 characters.

Beside input

  • orgstringoptional

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

Returns

data is the Billing object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.cancel({
	comment: "We only need two mailboxes",
	reason: "too_expensive",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.cancel(
    {
        "comment": "We only need two mailboxes",
        "reason": "too_expensive",
    }
)
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.BillingCancelParams{
		Comment: mailset.String("We only need two mailboxes"),
		Reason:  mailset.CancelReasonTooExpensive,
	}
	answer, err := client.Billing.Cancel(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.billing.cancel(
  comment: 'We only need two mailboxes',
  reason: 'too_expensive'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->cancel([
    'comment' => 'We only need two mailboxes',
    'reason' => 'too_expensive',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Billing;
import app.mailset.model.BillingCancelParams;
import app.mailset.model.CancelReason;

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

var params = BillingCancelParams.builder()
        .comment("We only need two mailboxes")
        .reason(CancelReason.TOO_EXPENSIVE)
        .build();
Billing answer = mailset.billing().cancel(params);
System.out.println(answer);
use mailset::types::{BillingCancelParams, CancelReason};

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

let answer = mailset
    .billing()
    .cancel(BillingCancelParams {
        reason: CancelReason::TooExpensive,
        comment: Some(
            "We only need two mailboxes".into(),
        ),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.cancel \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"comment":"We only need two mailboxes","reason":"too_expensive"},"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 billing cancel too_expensive --comment "We only need two mailboxes"
Response
{
  "ok": true,
  "data": {
    "plan": "trial",
    "arranged": false,
    "interval": "month",
    "payAsYouGo": true,
    "status": "active",
    "trialEndsAt": 1796048940000,
    "trialDaysLeft": 1,
    "ended": true,
    "afterEnd": {
      "since": 1796048940000,
      "mailStopsAt": 1796048940000,
      "mailStopped": true,
      "deletesAt": 1796048940000,
      "deletedAt": 1796048940000
    },

billing.resume

Keep a plan that was set to end, so it renews again.

POST/v1/billing.resume

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 Billing object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.resume();
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.resume()
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.Billing.Resume(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
require 'mailset'

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

answer = mailset.billing.resume
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->resume();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Billing;

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

Billing answer = mailset.billing().resume();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.billing().resume().await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.resume \
  -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 billing resume
Response
{
  "ok": true,
  "data": {
    "plan": "trial",
    "arranged": false,
    "interval": "month",
    "payAsYouGo": true,
    "status": "active",
    "trialEndsAt": 1796048940000,
    "trialDaysLeft": 1,
    "ended": true,
    "afterEnd": {
      "since": 1796048940000,
      "mailStopsAt": 1796048940000,
      "mailStopped": true,
      "deletesAt": 1796048940000,
      "deletedAt": 1796048940000
    },

billing.payg

Turn pay as you go on or off: on|off (with no card yet, it prints the first top-up’s link).

POST/v1/billing.payg

Owner

Parameters

  • stateenumrequired

    on or off.

    One ofonoff

Beside input

  • orgstringoptional

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

Returns

data is an object with:

  • billingBilling object

    The org’s billing as it is now.

  • urlnullable string

    With no card saved yet: the first top-up’s checkout link. Null otherwise.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.payg({
	state: "on",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.payg({"state": "on"})
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.BillingPaygParams{
		State: mailset.BillingPaygParamsStateOn,
	}
	answer, err := client.Billing.Payg(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.billing.payg(state: 'on')
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->payg(['state' => 'on']);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BillingPaygParams;
import app.mailset.model.BillingPaygParamsState;
import app.mailset.model.BillingPaygResult;

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

var params = BillingPaygParams.builder()
        .state(BillingPaygParamsState.ON)
        .build();
BillingPaygResult answer = mailset.billing().payg(params);
System.out.println(answer);
use mailset::types::{
    BillingPaygParams, BillingPaygParamsState,
};

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

let answer = mailset
    .billing()
    .payg(BillingPaygParams {
        state: BillingPaygParamsState::On,
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.payg \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"state":"on"},"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 billing payg on
Response
{
  "ok": true,
  "data": {
    "billing": {
      "plan": "trial",
      "arranged": false,
      "interval": "month",
      "payAsYouGo": true,
      "status": "active",
      "trialEndsAt": 1796048940000,
      "trialDaysLeft": 1,
      "ended": true,
      "afterEnd": {
        "since": 1796048940000,
        "mailStopsAt": 1796048940000,
        "mailStopped": true,
        "deletesAt": 1796048940000,
        "deletedAt": 1796048940000

billing.balance

The prepaid balance, what’s pending, and auto top-up.

POST/v1/billing.balance

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 Billing object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.balance();
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.balance()
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.Billing.Balance(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
require 'mailset'

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

answer = mailset.billing.balance
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->balance();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Billing;

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

Billing answer = mailset.billing().balance();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.billing().balance().await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.balance \
  -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 billing balance
Response
{
  "ok": true,
  "data": {
    "plan": "trial",
    "arranged": false,
    "interval": "month",
    "payAsYouGo": true,
    "status": "active",
    "trialEndsAt": 1796048940000,
    "trialDaysLeft": 1,
    "ended": true,
    "afterEnd": {
      "since": 1796048940000,
      "mailStopsAt": 1796048940000,
      "mailStopped": true,
      "deletesAt": 1796048940000,
      "deletedAt": 1796048940000
    },

billing.topup

Add credit to the balance through Stripe Checkout.

POST/v1/billing.topup

Owner

Parameters

  • amountintegerrequired

    How much credit to add, in whole units of the plan’s currency.

    From 1 to 100,000.

Beside input

  • orgstringoptional

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

Returns

data is an object with:

  • urlstring

    The checkout page’s link, to open in a browser.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.topup({
	amount: 20,
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.topup({"amount": 20})
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.BillingTopupParams{
		Amount: 20,
	}
	answer, err := client.Billing.Topup(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.billing.topup(amount: 20)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->topup(['amount' => 20]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BillingTopupParams;
import app.mailset.model.BillingTopupResult;

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

var params = BillingTopupParams.builder()
        .amount(20L)
        .build();
BillingTopupResult answer =
        mailset.billing().topup(params);
System.out.println(answer);
use mailset::types::BillingTopupParams;

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

let answer = mailset
    .billing()
    .topup(BillingTopupParams { amount: 20 })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.topup \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"amount":"20"},"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 billing topup 20
Response
{
  "ok": true,
  "data": {
    "url": "https://hooks.example.com/mailset"
  }
}

billing.autotopup

Auto top-up.

POST/v1/billing.autotopup

Owner

Parameters

  • stateenumoptional

    on or off. Left out: as it is.

    One ofonoff

  • thresholdintegeroptional

    Top up when the balance falls below this, in whole units.

    From 1 to 100,000.

  • amountintegeroptional

    How much each top-up adds, in whole units.

    From 1 to 100,000.

  • ceilingintegeroptional

    The most auto top-ups may charge in a calendar month, in whole units.

    From 1 to 100,000.

Beside input

  • orgstringoptional

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

Returns

data is the Billing object.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.autotopup({
	threshold: 5,
	amount: 20,
	ceiling: 100,
	state: "on",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.autotopup(
    {
        "threshold": 5,
        "amount": 20,
        "ceiling": 100,
        "state": "on",
    }
)
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.BillingAutotopupParams{
require 'mailset'

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

answer = mailset.billing.autotopup(
  threshold: 5,
  amount: 20,
  ceiling: 100,
  state: 'on'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->autotopup([
    'threshold' => 5,
    'amount' => 20,
    'ceiling' => 100,
    'state' => 'on',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Billing;
import app.mailset.model.BillingAutotopupParams;
import app.mailset.model.BillingPaygParamsState;

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

var params = BillingAutotopupParams.builder()
        .threshold(5L)
        .amount(20L)
        .ceiling(100L)
        .state(BillingPaygParamsState.ON)
        .build();
Billing answer = mailset.billing().autotopup(params);
System.out.println(answer);
use mailset::types::{
    BillingAutotopupParams, BillingPaygParamsState,
};

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

let answer = mailset
    .billing()
    .autotopup(BillingAutotopupParams {
        state: Some(BillingPaygParamsState::On),
        threshold: Some(5),
        amount: Some(20),
        ceiling: Some(100),
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.autotopup \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"threshold":"5","amount":"20","ceiling":"100","state":"on"},"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 billing autotopup on --threshold 5 --amount 20 --ceiling 100
Response
{
  "ok": true,
  "data": {
    "plan": "trial",
    "arranged": false,
    "interval": "month",
    "payAsYouGo": true,
    "status": "active",
    "trialEndsAt": 1796048940000,
    "trialDaysLeft": 1,
    "ended": true,
    "afterEnd": {
      "since": 1796048940000,
      "mailStopsAt": 1796048940000,
      "mailStopped": true,
      "deletesAt": 1796048940000,
      "deletedAt": 1796048940000
    },

billing.ledger

The balance’s credits and debits, newest first.

POST/v1/billing.ledger

Admin or owner

Parameters

  • limitintegeroptional

    How many lines to return, 1 to 500.

    Default 50. From 1 to 500.

Beside input

  • orgstringoptional

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

Returns

data is a list of objects, each with:

  • idstring
  • atnumber
  • kindenum

    One oftopupauto_topupaistorageemailsexpiry

  • microsnumber
  • reasonstring
  • refstring

    The usage or payment it’s for: ai:<day>, storage:<day>, emails:<day>, or a payment’s id.

  • expiresAtnullable number

    A credit’s end.

  • receiptnullable stringoptional

    A link to a payment’s invoice PDF or receipt page, once the receipt went.

    Default null.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.billing.ledger({
	limit: 20,
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.billing.ledger({"limit": 20})
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.BillingLedgerParams{
		Limit: mailset.Int(20),
	}
	answer, err := client.Billing.Ledger(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.billing.ledger(limit: 20)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->billing->ledger(['limit' => 20]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BillingLedgerParams;
import app.mailset.model.LedgerLine;
import java.util.List;

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

var params = BillingLedgerParams.builder()
        .limit(20L)
        .build();
List<LedgerLine> answer =
        mailset.billing().ledger(params);
System.out.println(answer);
use mailset::types::BillingLedgerParams;

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

let answer = mailset
    .billing()
    .ledger(BillingLedgerParams { limit: Some(20) })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/billing.ledger \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"limit":20},"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 billing ledger --limit 20
Response
{
  "ok": true,
  "data": [
    {
      "id": "out_3f9a1c0e7b2d",
      "at": 1796048940000,
      "kind": "topup",
      "micros": 1,
      "reason": "The day’s sending limit is reached.",
      "ref": "text",
      "expiresAt": 1796048940000,
      "receipt": null
    }
  ]
}