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
The Billing object
An org’s plan, what it pays for, its balance and what comes next.
Attributes
The org’s plan:
trial,baseorteam.One of
trialbaseteamThe 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.How Base is billed. Null on other plans.
One of
monthyearWhether use past the plan’s allowances draws from the balance.
The subscription’s state:
active,past_dueorcanceled.One of
activepast_duecanceledWhen the trial ends, in ms since the epoch. Null outside a trial.
Whole days left, counted up. Null outside a live trial.
The trial ended, or the subscription was canceled, and nothing replaced it.
What happens after the plan ended. Null while the plan is live, and on a plan arranged with Mailset.
Whether the org may use Mailset’s AI, and why not when it may not.
One of
oncredit_usedoffHow far the org may send.
sending statushas the limits.One of
no_cardtrialpaidThe people who sign in, against what the plan includes.
Show child attributesHide child attributes
Invites nobody has accepted yet. They count once they join.
What the plan includes. Null: no count applies.
Past this an invite is refused (a trial, a plan arranged with Mailset). Null: seats instead.
Seats past the included members, billed on the subscription.
What one more costs, a month or a year (
interval). Null: none is charged.
A plan that would cost less for these members, with what it costs a month.
This month’s use against the plan’s allowances.
Show child attributesHide child attributes
The calendar month in UTC: its first instant and the next month’s.
What this month’s use past the allowances costs so far: drawn, and not yet.
Pay as you go draws it from the balance.
The prepaid balance and auto top-up.
Show child attributesHide child attributes
What the ledger holds.
Usage not drawn yet (today’s, mostly).
What draws see: the ledger less what’s pending, or zero after a failed charge.
A charge failed and hasn’t gone through since.
Credit that expires in the next 30 days.
A card is saved, so auto top-ups can charge it.
Whether card payments are available, so Upgrade, Add credit and Manage billing work.
The org has a paid subscription.
What plans and extra use cost. Null where nothing is charged.
Show child attributesHide child attributes
Members (people who sign in) each plan includes. Mailboxes are unlimited.
Each member past them: a seat on the subscription.
Every plan’s monthly allowances.
What draws from the balance past them.
Top-ups: the least one can be, and the defaults an owner can change.
How far storage may take the balance below zero before it stops drawing.
How long a credit lasts.
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.
The launch offer this org can still subscribe with. Null: none, or it’s used.
When the subscription renews, in ms since the epoch: its period’s end. Null with none.
Default
null.The plan is set to end then, at its period’s end. Null: it renews.
Default
null.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
{
"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
Parameters
It takes no input: send an empty object.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Billing object.
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
{
"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
Parameters
It takes no input: send an empty object.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
Show child attributesHide child attributes
The calendar month in UTC: its first instant and the next month’s.
What this month’s use past the allowances costs so far: drawn, and not yet.
Pay as you go draws it from the balance.
Show child attributesHide child attributes
Members (people who sign in) each plan includes. Mailboxes are unlimited.
Each member past them: a seat on the subscription.
Every plan’s monthly allowances.
What draws from the balance past them.
Top-ups: the least one can be, and the defaults an owner can change.
How far storage may take the balance below zero before it stops drawing.
How long a credit lasts.
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.
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
{
"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
Parameters
The plan:
baseorteam.One of
baseteamDefault
base.Base only: billed once a year.
Default
false.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
The checkout page’s link, to open in a browser.
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
{
"ok": true,
"data": {
"url": "https://hooks.example.com/mailset"
}
}
billing.portal
Owners.
POST/v1/billing.portal
Parameters
Go straight to changing the card.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
The billing portal’s link, to open in a browser.
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
{
"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
Parameters
The plan:
baseorteam.One of
baseteamDefault
base.Base only: billed once a year.
Default
false.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Billing object.
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
{
"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
Parameters
Why the plan is ending, one of the listed reasons.
One of
too_expensivemissing_featuresswitched_serviceunusedcustomer_servicetoo_complexlow_qualityotherAnything to add, up to 1,000 characters.
At most 1,000 characters.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Billing object.
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"
{
"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
Parameters
It takes no input: send an empty object.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Billing object.
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
{
"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
Parameters
onoroff.One of
onoff
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
The org’s billing as it is now.
With no card saved yet: the first top-up’s checkout link. Null otherwise.
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
{
"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
Parameters
It takes no input: send an empty object.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Billing object.
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
{
"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
Parameters
How much credit to add, in whole units of the plan’s currency.
From 1 to 100,000.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is an object with:
The checkout page’s link, to open in a browser.
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
{
"ok": true,
"data": {
"url": "https://hooks.example.com/mailset"
}
}
billing.autotopup
Auto top-up.
POST/v1/billing.autotopup
Parameters
onoroff. Left out: as it is.One of
onoffTop up when the balance falls below this, in whole units.
From 1 to 100,000.
How much each top-up adds, in whole units.
From 1 to 100,000.
The most auto top-ups may charge in a calendar month, in whole units.
From 1 to 100,000.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is the Billing object.
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
{
"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
Parameters
How many lines to return, 1 to 500.
Default
50. From 1 to 500.
Beside input
The org this is about. Needed when the caller is in more than one.
Returns
data is a list of objects, each with:
One of
topupauto_topupaistorageemailsexpiryThe usage or payment it’s for:
ai:<day>,storage:<day>,emails:<day>, or a payment’s id.A credit’s end.
A link to a payment’s invoice PDF or receipt page, once the receipt went.
Default
null.
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
{
"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
}
]
}