# Billing

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

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

## The Billing object

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

### Attributes

- `plan` (enum): The org’s plan: `trial`, `base` or `team`. One of `trial`, `base`, `team`.
- `arranged` (boolean, optional): 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`.
- `interval` (nullable enum): How Base is billed. Null on other plans. One of `month`, `year`.
- `payAsYouGo` (boolean): Whether use past the plan’s allowances draws from the balance.
- `status` (enum): The subscription’s state: `active`, `past_due` or `canceled`. One of `active`, `past_due`, `canceled`.
- `trialEndsAt` (nullable number): When the trial ends, in ms since the epoch. Null outside a trial.
- `trialDaysLeft` (nullable number): Whole days left, counted up. Null outside a live trial.
- `ended` (boolean): The trial ended, or the subscription was canceled, and nothing replaced it.
- `afterEnd` (nullable object): What happens after the plan ended. Null while the plan is live, and on a plan arranged with Mailset.
  - `since` (number)
  - `mailStopsAt` (number): From here new mail to the org’s addresses is refused.
  - `mailStopped` (boolean)
  - `deletesAt` (number): From here the org’s mailboxes, with their mail and files, are deleted.
  - `deletedAt` (nullable number): When they were. Null: not yet.
- `mailsetAi` (enum): Whether the org may use Mailset’s AI, and why not when it may not. One of `on`, `credit_used`, `off`.
- `tier` (enum): How far the org may send. `sending status` has the limits. One of `no_card`, `trial`, `paid`.
- `members` (object): The people who sign in, against what the plan includes.
  - `count` (number)
  - `invited` (number): Invites nobody has accepted yet. They count once they join.
  - `included` (nullable number): What the plan includes. Null: no count applies.
  - `cap` (nullable number): Past this an invite is refused (a trial, a plan arranged with Mailset). Null: seats instead.
  - `extra` (number): Seats past the included members, billed on the subscription.
  - `seatCents` (nullable number): What one more costs, a month or a year (`interval`). Null: none is charged.
- `cheaper` (nullable object): A plan that would cost less for these members, with what it costs a month.
  - `plan` (enum): One of `base`, `team`.
  - `interval` (enum): One of `month`, `year`.
  - `cents` (number)
  - `currentCents` (number)
- `usage` (object): This month’s use against the plan’s allowances.
  - `periodStart` (number): The calendar month in UTC: its first instant and the next month’s.
  - `periodEnd` (number)
  - `ai` (object)
    - `priceMicros` (number): Mailset’s AI this month at its price list.
    - `creditMicros` (nullable number): The month’s AI credit. Null: none limits it (no prices here, or Mailset’s own org).
    - `overMicros` (number)
  - `storage` (object)
    - `bytes` (number): The latest daily count.
    - `includedBytes` (nullable number): Null: no prices here, so nothing is included or over.
    - `overGbMonths` (number): GB-months past what’s included, so far this month.
  - `emails` (object)
    - `outside` (number): Recipients outside the org’s own domains this month. Incoming and internal mail never count.
    - `allowance` (nullable number)
    - `over` (number)
  - `owedMicros` (number): What this month’s use past the allowances costs so far: drawn, and not yet.
  - `billed` (boolean): Pay as you go draws it from the balance.
- `balance` (object): The prepaid balance and auto top-up.
  - `micros` (number): What the ledger holds.
  - `pendingMicros` (number): Usage not drawn yet (today’s, mostly).
  - `availableMicros` (number): What draws see: the ledger less what’s pending, or zero after a failed charge.
  - `failed` (boolean): A charge failed and hasn’t gone through since.
  - `retryAt` (nullable number)
  - `expiringMicros` (number): Credit that expires in the next 30 days.
  - `cardSaved` (boolean): A card is saved, so auto top-ups can charge it.
  - `autoTopup` (object)
    - `on` (boolean)
    - `thresholdMicros` (number)
    - `amountMicros` (number)
    - `ceilingMicros` (number): The most auto top-ups may charge in a calendar month.
    - `usedThisMonthMicros` (number)
- `available` (boolean): Whether card payments are available, so Upgrade, Add credit and Manage billing work.
- `subscribed` (boolean): The org has a paid subscription.
- `prices` (nullable object): What plans and extra use cost. Null where nothing is charged.
  - `currency` (string)
  - `baseMonthlyCents` (number)
  - `baseYearlyCents` (number)
  - `teamMonthlyCents` (number)
  - `teamYearlyCents` (number)
  - `baseMembers` (number): Members (people who sign in) each plan includes. Mailboxes are unlimited.
  - `teamMembers` (number)
  - `trialMembers` (number)
  - `baseSeatMonthlyCents` (number): Each member past them: a seat on the subscription.
  - `baseSeatYearlyCents` (number)
  - `teamSeatMonthlyCents` (number)
  - `teamSeatYearlyCents` (number)
  - `storageGb` (number): Every plan’s monthly allowances.
  - `emailAllowance` (number)
  - `aiCreditCents` (number)
  - `emailsPer1000Cents` (number): What draws from the balance past them.
  - `storageGbMonthCents` (number)
  - `topupMinCents` (number): Top-ups: the least one can be, and the defaults an owner can change.
  - `topupThresholdCents` (number)
  - `topupAmountCents` (number)
  - `topupCeilingCents` (number)
  - `overdraftCents` (number): How far storage may take the balance below zero before it stops drawing.
  - `creditMonths` (number): How long a credit lasts.
  - `endedReceiveDays` (number): 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.
  - `endedDeleteDays` (number)
- `offer` (nullable object): The launch offer this org can still subscribe with. Null: none, or it’s used.
  - `code` (string)
  - `name` (string)
  - `percent` (number)
  - `months` (number)
  - `claimedAt` (number)
  - `redeemBy` (number): A UTC midnight: Checkout takes the offer off until then.
- `renewsAt` (nullable number, optional): When the subscription renews, in ms since the epoch: its period’s end. Null with none. Default `null`.
- `cancelAt` (nullable number, optional): The plan is set to end then, at its period’s end. Null: it renews. Default `null`.
- `paymentRetryAt` (nullable number, optional): When a failed payment is tried again, in ms since the epoch. Null: none planned. Default `null`.

```json
{
  "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",
  "members": {
    "count": 12,
    "invited": 1,
    "included": 1,
    "cap": 1,
    "extra": 1,
    "seatCents": 1
  },
  "cheaper": {
    "plan": "base",
    "interval": "month",
    "cents": 1,
    "currentCents": 1
  },
  "usage": {
    "periodStart": 1,
    "periodEnd": 1,
    "ai": {
      "priceMicros": 1,
      "creditMicros": 1,
      "overMicros": 1
    },
    "storage": {
      "bytes": 20480,
      "includedBytes": 20480,
      "overGbMonths": 1
    },
    "emails": {
      "outside": 1,
      "allowance": 1,
      "over": 1
    },
    "owedMicros": 1,
    "billed": true
  },
  "balance": {
    "micros": 1,
    "pendingMicros": 1,
    "availableMicros": 1,
    "failed": true,
    "retryAt": 1796048940000,
    "expiringMicros": 1,
    "cardSaved": true,
    "autoTopup": {
      "on": true,
      "thresholdMicros": 1,
      "amountMicros": 1,
      "ceilingMicros": 1,
      "usedThisMonthMicros": 1
    }
  },
  "available": true,
  "subscribed": true,
  "prices": {
    "currency": "text",
    "baseMonthlyCents": 1,
    "baseYearlyCents": 1,
    "teamMonthlyCents": 1,
    "teamYearlyCents": 1,
    "baseMembers": 1,
    "teamMembers": 1,
    "trialMembers": 1,
    "baseSeatMonthlyCents": 1,
    "baseSeatYearlyCents": 1,
    "teamSeatMonthlyCents": 1,
    "teamSeatYearlyCents": 1,
    "storageGb": 1,
    "emailAllowance": 1,
    "aiCreditCents": 1,
    "emailsPer1000Cents": 1,
    "storageGbMonthCents": 1,
    "topupMinCents": 1,
    "topupThresholdCents": 1,
    "topupAmountCents": 1,
    "topupCeilingCents": 1,
    "overdraftCents": 1,
    "creditMonths": 1,
    "endedReceiveDays": 1,
    "endedDeleteDays": 1
  },
  "offer": {
    "code": "482913",
    "name": "Acme API",
    "percent": 1,
    "months": 1,
    "claimedAt": 1796048940000,
    "redeemBy": 1796048940000
  },
  "renewsAt": 1796048940000,
  "cancelAt": 1796048940000,
  "paymentRetryAt": 1796048940000
}
```

Answered by [billing.status](https://mailset.app/docs/api/billing#billing.status), [billing.switch](https://mailset.app/docs/api/billing#billing.switch), [billing.cancel](https://mailset.app/docs/api/billing#billing.cancel), [billing.resume](https://mailset.app/docs/api/billing#billing.resume), [billing.payg](https://mailset.app/docs/api/billing#billing.payg), [billing.balance](https://mailset.app/docs/api/billing#billing.balance), [billing.autotopup](https://mailset.app/docs/api/billing#billing.autotopup).

## billing.status

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

`POST /v1/billing.status`

An admin or owner of the org.

### Parameters

It takes no input: send an empty object.

Beside `input`:

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

### Returns

`data` is the [Billing object](https://mailset.app/docs/api/billing#billing).

### Request

TypeScript:

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

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

const answer = await mailset.billing.status();
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.status()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Billing.Status(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.status
p answer
```

PHP:

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

Java:

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

Rust:

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

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

curl:

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

CLI:

```bash
mailset billing status
```

### Response

```json
{
  "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
    },
    "mailsetAi": "on",
    "tier": "no_card",
    "members": {
      "count": 12,
      "invited": 1,
      "included": 1,
      "cap": 1,
      "extra": 1,
      "seatCents": 1
    },
    "cheaper": {
      "plan": "base",
      "interval": "month",
      "cents": 1,
      "currentCents": 1
    },
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "balance": {
      "micros": 1,
      "pendingMicros": 1,
      "availableMicros": 1,
      "failed": true,
      "retryAt": 1796048940000,
      "expiringMicros": 1,
      "cardSaved": true,
      "autoTopup": {
        "on": true,
        "thresholdMicros": 1,
        "amountMicros": 1,
        "ceilingMicros": 1,
        "usedThisMonthMicros": 1
      }
    },
    "available": true,
    "subscribed": true,
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    },
    "offer": {
      "code": "482913",
      "name": "Acme API",
      "percent": 1,
      "months": 1,
      "claimedAt": 1796048940000,
      "redeemBy": 1796048940000
    },
    "renewsAt": 1796048940000,
    "cancelAt": 1796048940000,
    "paymentRetryAt": 1796048940000
  }
}
```

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

## billing.usage

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

`POST /v1/billing.usage`

An admin or owner of the org.

### Parameters

It takes no input: send an empty object.

Beside `input`:

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

### Returns

`data` is an object with:

- `usage` (object)
  - `periodStart` (number): The calendar month in UTC: its first instant and the next month’s.
  - `periodEnd` (number)
  - `ai` (object)
    - `priceMicros` (number): Mailset’s AI this month at its price list.
    - `creditMicros` (nullable number): The month’s AI credit. Null: none limits it (no prices here, or Mailset’s own org).
    - `overMicros` (number)
  - `storage` (object)
    - `bytes` (number): The latest daily count.
    - `includedBytes` (nullable number): Null: no prices here, so nothing is included or over.
    - `overGbMonths` (number): GB-months past what’s included, so far this month.
  - `emails` (object)
    - `outside` (number): Recipients outside the org’s own domains this month. Incoming and internal mail never count.
    - `allowance` (nullable number)
    - `over` (number)
  - `owedMicros` (number): What this month’s use past the allowances costs so far: drawn, and not yet.
  - `billed` (boolean): Pay as you go draws it from the balance.
- `prices` (nullable object)
  - `currency` (string)
  - `baseMonthlyCents` (number)
  - `baseYearlyCents` (number)
  - `teamMonthlyCents` (number)
  - `teamYearlyCents` (number)
  - `baseMembers` (number): Members (people who sign in) each plan includes. Mailboxes are unlimited.
  - `teamMembers` (number)
  - `trialMembers` (number)
  - `baseSeatMonthlyCents` (number): Each member past them: a seat on the subscription.
  - `baseSeatYearlyCents` (number)
  - `teamSeatMonthlyCents` (number)
  - `teamSeatYearlyCents` (number)
  - `storageGb` (number): Every plan’s monthly allowances.
  - `emailAllowance` (number)
  - `aiCreditCents` (number)
  - `emailsPer1000Cents` (number): What draws from the balance past them.
  - `storageGbMonthCents` (number)
  - `topupMinCents` (number): Top-ups: the least one can be, and the defaults an owner can change.
  - `topupThresholdCents` (number)
  - `topupAmountCents` (number)
  - `topupCeilingCents` (number)
  - `overdraftCents` (number): How far storage may take the balance below zero before it stops drawing.
  - `creditMonths` (number): How long a credit lasts.
  - `endedReceiveDays` (number): 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.
  - `endedDeleteDays` (number)

### Request

TypeScript:

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

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

const answer = await mailset.billing.usage();
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.usage()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Billing.Usage(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.usage
p answer
```

PHP:

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

Java:

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

Rust:

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

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

curl:

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

CLI:

```bash
mailset billing usage
```

### Response

```json
{
  "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,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    }
  }
}
```

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

## billing.upgrade

Open Stripe Checkout for a plan.

`POST /v1/billing.upgrade`

An owner of the org.

### Parameters

- `plan` (enum, optional): The plan: `base` or `team`. One of `base`, `team`. Default `base`.
- `yearly` (boolean, optional): Base only: billed once a year. Default `false`.

Beside `input`:

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

### Returns

`data` is an object with:

- `url` (string): The checkout page’s link, to open in a browser.

### Request

TypeScript:

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

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.upgrade(
    {"plan": "base", "yearly": True}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingUpgradeParams{
		Plan:   mailset.PaidPlanBase,
		Yearly: mailset.Bool(true),
	}
	answer, err := client.Billing.Upgrade(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.upgrade(
  plan: 'base',
  yearly: true
)
p answer
```

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing upgrade --plan base --yearly
```

### Response

```json
{
  "ok": true,
  "data": {
    "url": "https://hooks.example.com/mailset"
  }
}
```

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

## billing.portal

Owners.

`POST /v1/billing.portal`

An owner of the org.

### Parameters

- `card` (boolean, optional): Go straight to changing the card.

Beside `input`:

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

### Returns

`data` is an object with:

- `url` (string): The billing portal’s link, to open in a browser.

### Request

TypeScript:

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

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.portal({"card": True})
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingPortalParams{
		Card: mailset.Bool(true),
	}
	answer, err := client.Billing.Portal(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.portal(card: true)
p answer
```

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing portal --card
```

### Response

```json
{
  "ok": true,
  "data": {
    "url": "https://hooks.example.com/mailset"
  }
}
```

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

## billing.switch

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

`POST /v1/billing.switch`

An owner of the org.

### Parameters

- `plan` (enum, optional): The plan: `base` or `team`. One of `base`, `team`. Default `base`.
- `yearly` (boolean, optional): Base only: billed once a year. Default `false`.

Beside `input`:

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

### Returns

`data` is the [Billing object](https://mailset.app/docs/api/billing#billing).

### Request

TypeScript:

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

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.switch({"plan": "team"})
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingSwitchParams{
		Plan: mailset.PaidPlanTeam,
	}
	answer, err := client.Billing.Switch(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.switch(plan: 'team')
p answer
```

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing switch team
```

### Response

```json
{
  "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
    },
    "mailsetAi": "on",
    "tier": "no_card",
    "members": {
      "count": 12,
      "invited": 1,
      "included": 1,
      "cap": 1,
      "extra": 1,
      "seatCents": 1
    },
    "cheaper": {
      "plan": "base",
      "interval": "month",
      "cents": 1,
      "currentCents": 1
    },
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "balance": {
      "micros": 1,
      "pendingMicros": 1,
      "availableMicros": 1,
      "failed": true,
      "retryAt": 1796048940000,
      "expiringMicros": 1,
      "cardSaved": true,
      "autoTopup": {
        "on": true,
        "thresholdMicros": 1,
        "amountMicros": 1,
        "ceilingMicros": 1,
        "usedThisMonthMicros": 1
      }
    },
    "available": true,
    "subscribed": true,
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    },
    "offer": {
      "code": "482913",
      "name": "Acme API",
      "percent": 1,
      "months": 1,
      "claimedAt": 1796048940000,
      "redeemBy": 1796048940000
    },
    "renewsAt": 1796048940000,
    "cancelAt": 1796048940000,
    "paymentRetryAt": 1796048940000
  }
}
```

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

## billing.cancel

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

`POST /v1/billing.cancel`

An owner of the org.

### Parameters

- `reason` (enum, required): Why the plan is ending, one of the listed reasons. One of `too_expensive`, `missing_features`, `switched_service`, `unused`, `customer_service`, `too_complex`, `low_quality`, `other`.
- `comment` (string, optional): Anything to add, up to 1,000 characters. At most 1,000 characters.

Beside `input`:

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

### Returns

`data` is the [Billing object](https://mailset.app/docs/api/billing#billing).

### Request

TypeScript:

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

Python:

```python
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)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.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)
}
```

Ruby:

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

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing cancel too_expensive --comment "We only need two mailboxes"
```

### Response

```json
{
  "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
    },
    "mailsetAi": "on",
    "tier": "no_card",
    "members": {
      "count": 12,
      "invited": 1,
      "included": 1,
      "cap": 1,
      "extra": 1,
      "seatCents": 1
    },
    "cheaper": {
      "plan": "base",
      "interval": "month",
      "cents": 1,
      "currentCents": 1
    },
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "balance": {
      "micros": 1,
      "pendingMicros": 1,
      "availableMicros": 1,
      "failed": true,
      "retryAt": 1796048940000,
      "expiringMicros": 1,
      "cardSaved": true,
      "autoTopup": {
        "on": true,
        "thresholdMicros": 1,
        "amountMicros": 1,
        "ceilingMicros": 1,
        "usedThisMonthMicros": 1
      }
    },
    "available": true,
    "subscribed": true,
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    },
    "offer": {
      "code": "482913",
      "name": "Acme API",
      "percent": 1,
      "months": 1,
      "claimedAt": 1796048940000,
      "redeemBy": 1796048940000
    },
    "renewsAt": 1796048940000,
    "cancelAt": 1796048940000,
    "paymentRetryAt": 1796048940000
  }
}
```

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

## billing.resume

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

`POST /v1/billing.resume`

An owner of the org.

### Parameters

It takes no input: send an empty object.

Beside `input`:

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

### Returns

`data` is the [Billing object](https://mailset.app/docs/api/billing#billing).

### Request

TypeScript:

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

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

const answer = await mailset.billing.resume();
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.resume()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Billing.Resume(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.resume
p answer
```

PHP:

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

Java:

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

Rust:

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

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

curl:

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

CLI:

```bash
mailset billing resume
```

### Response

```json
{
  "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
    },
    "mailsetAi": "on",
    "tier": "no_card",
    "members": {
      "count": 12,
      "invited": 1,
      "included": 1,
      "cap": 1,
      "extra": 1,
      "seatCents": 1
    },
    "cheaper": {
      "plan": "base",
      "interval": "month",
      "cents": 1,
      "currentCents": 1
    },
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "balance": {
      "micros": 1,
      "pendingMicros": 1,
      "availableMicros": 1,
      "failed": true,
      "retryAt": 1796048940000,
      "expiringMicros": 1,
      "cardSaved": true,
      "autoTopup": {
        "on": true,
        "thresholdMicros": 1,
        "amountMicros": 1,
        "ceilingMicros": 1,
        "usedThisMonthMicros": 1
      }
    },
    "available": true,
    "subscribed": true,
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    },
    "offer": {
      "code": "482913",
      "name": "Acme API",
      "percent": 1,
      "months": 1,
      "claimedAt": 1796048940000,
      "redeemBy": 1796048940000
    },
    "renewsAt": 1796048940000,
    "cancelAt": 1796048940000,
    "paymentRetryAt": 1796048940000
  }
}
```

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

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

An owner of the org.

### Parameters

- `state` (enum, required): `on` or `off`. One of `on`, `off`.

Beside `input`:

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

### Returns

`data` is an object with:

- `billing` ([Billing](https://mailset.app/docs/api/billing#billing) object): The org’s billing as it is now.
- `url` (nullable string): With no card saved yet: the first top-up’s checkout link. Null otherwise.

### Request

TypeScript:

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

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.payg({"state": "on"})
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingPaygParams{
		State: mailset.BillingPaygParamsStateOn,
	}
	answer, err := client.Billing.Payg(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.payg(state: 'on')
p answer
```

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing payg on
```

### Response

```json
{
  "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
      },
      "mailsetAi": "on",
      "tier": "no_card",
      "members": {
        "count": 12,
        "invited": 1,
        "included": 1,
        "cap": 1,
        "extra": 1,
        "seatCents": 1
      },
      "cheaper": {
        "plan": "base",
        "interval": "month",
        "cents": 1,
        "currentCents": 1
      },
      "usage": {
        "periodStart": 1,
        "periodEnd": 1,
        "ai": {
          "priceMicros": 1,
          "creditMicros": 1,
          "overMicros": 1
        },
        "storage": {
          "bytes": 20480,
          "includedBytes": 20480,
          "overGbMonths": 1
        },
        "emails": {
          "outside": 1,
          "allowance": 1,
          "over": 1
        },
        "owedMicros": 1,
        "billed": true
      },
      "balance": {
        "micros": 1,
        "pendingMicros": 1,
        "availableMicros": 1,
        "failed": true,
        "retryAt": 1796048940000,
        "expiringMicros": 1,
        "cardSaved": true,
        "autoTopup": {
          "on": true,
          "thresholdMicros": 1,
          "amountMicros": 1,
          "ceilingMicros": 1,
          "usedThisMonthMicros": 1
        }
      },
      "available": true,
      "subscribed": true,
      "prices": {
        "currency": "text",
        "baseMonthlyCents": 1,
        "baseYearlyCents": 1,
        "teamMonthlyCents": 1,
        "teamYearlyCents": 1,
        "baseMembers": 1,
        "teamMembers": 1,
        "trialMembers": 1,
        "baseSeatMonthlyCents": 1,
        "baseSeatYearlyCents": 1,
        "teamSeatMonthlyCents": 1,
        "teamSeatYearlyCents": 1,
        "storageGb": 1,
        "emailAllowance": 1,
        "aiCreditCents": 1,
        "emailsPer1000Cents": 1,
        "storageGbMonthCents": 1,
        "topupMinCents": 1,
        "topupThresholdCents": 1,
        "topupAmountCents": 1,
        "topupCeilingCents": 1,
        "overdraftCents": 1,
        "creditMonths": 1,
        "endedReceiveDays": 1,
        "endedDeleteDays": 1
      },
      "offer": {
        "code": "482913",
        "name": "Acme API",
        "percent": 1,
        "months": 1,
        "claimedAt": 1796048940000,
        "redeemBy": 1796048940000
      },
      "renewsAt": 1796048940000,
      "cancelAt": 1796048940000,
      "paymentRetryAt": 1796048940000
    },
    "url": "https://hooks.example.com/mailset"
  }
}
```

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

## billing.balance

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

`POST /v1/billing.balance`

An admin or owner of the org.

### Parameters

It takes no input: send an empty object.

Beside `input`:

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

### Returns

`data` is the [Billing object](https://mailset.app/docs/api/billing#billing).

### Request

TypeScript:

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

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

const answer = await mailset.billing.balance();
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.balance()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Billing.Balance(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.balance
p answer
```

PHP:

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

Java:

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

Rust:

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

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

curl:

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

CLI:

```bash
mailset billing balance
```

### Response

```json
{
  "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
    },
    "mailsetAi": "on",
    "tier": "no_card",
    "members": {
      "count": 12,
      "invited": 1,
      "included": 1,
      "cap": 1,
      "extra": 1,
      "seatCents": 1
    },
    "cheaper": {
      "plan": "base",
      "interval": "month",
      "cents": 1,
      "currentCents": 1
    },
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "balance": {
      "micros": 1,
      "pendingMicros": 1,
      "availableMicros": 1,
      "failed": true,
      "retryAt": 1796048940000,
      "expiringMicros": 1,
      "cardSaved": true,
      "autoTopup": {
        "on": true,
        "thresholdMicros": 1,
        "amountMicros": 1,
        "ceilingMicros": 1,
        "usedThisMonthMicros": 1
      }
    },
    "available": true,
    "subscribed": true,
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    },
    "offer": {
      "code": "482913",
      "name": "Acme API",
      "percent": 1,
      "months": 1,
      "claimedAt": 1796048940000,
      "redeemBy": 1796048940000
    },
    "renewsAt": 1796048940000,
    "cancelAt": 1796048940000,
    "paymentRetryAt": 1796048940000
  }
}
```

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

## billing.topup

Add credit to the balance through Stripe Checkout.

`POST /v1/billing.topup`

An owner of the org.

### Parameters

- `amount` (integer, required): How much credit to add, in whole units of the plan’s currency. From 1 to 100,000.

Beside `input`:

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

### Returns

`data` is an object with:

- `url` (string): The checkout page’s link, to open in a browser.

### Request

TypeScript:

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

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.topup({"amount": 20})
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingTopupParams{
		Amount: 20,
	}
	answer, err := client.Billing.Topup(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.topup(amount: 20)
p answer
```

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing topup 20
```

### Response

```json
{
  "ok": true,
  "data": {
    "url": "https://hooks.example.com/mailset"
  }
}
```

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

## billing.autotopup

Auto top-up.

`POST /v1/billing.autotopup`

An owner of the org.

### Parameters

- `state` (enum, optional): `on` or `off`. Left out: as it is. One of `on`, `off`.
- `threshold` (integer, optional): Top up when the balance falls below this, in whole units. From 1 to 100,000.
- `amount` (integer, optional): How much each top-up adds, in whole units. From 1 to 100,000.
- `ceiling` (integer, optional): The most auto top-ups may charge in a calendar month, in whole units. From 1 to 100,000.

Beside `input`:

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

### Returns

`data` is the [Billing object](https://mailset.app/docs/api/billing#billing).

### Request

TypeScript:

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

Python:

```python
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)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingAutotopupParams{
		Threshold: mailset.Int(5),
		Amount:    mailset.Int(20),
		Ceiling:   mailset.Int(100),
		State:     mailset.BillingPaygParamsStateOn,
	}
	answer, err := client.Billing.Autotopup(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

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

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing autotopup on --threshold 5 --amount 20 --ceiling 100
```

### Response

```json
{
  "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
    },
    "mailsetAi": "on",
    "tier": "no_card",
    "members": {
      "count": 12,
      "invited": 1,
      "included": 1,
      "cap": 1,
      "extra": 1,
      "seatCents": 1
    },
    "cheaper": {
      "plan": "base",
      "interval": "month",
      "cents": 1,
      "currentCents": 1
    },
    "usage": {
      "periodStart": 1,
      "periodEnd": 1,
      "ai": {
        "priceMicros": 1,
        "creditMicros": 1,
        "overMicros": 1
      },
      "storage": {
        "bytes": 20480,
        "includedBytes": 20480,
        "overGbMonths": 1
      },
      "emails": {
        "outside": 1,
        "allowance": 1,
        "over": 1
      },
      "owedMicros": 1,
      "billed": true
    },
    "balance": {
      "micros": 1,
      "pendingMicros": 1,
      "availableMicros": 1,
      "failed": true,
      "retryAt": 1796048940000,
      "expiringMicros": 1,
      "cardSaved": true,
      "autoTopup": {
        "on": true,
        "thresholdMicros": 1,
        "amountMicros": 1,
        "ceilingMicros": 1,
        "usedThisMonthMicros": 1
      }
    },
    "available": true,
    "subscribed": true,
    "prices": {
      "currency": "text",
      "baseMonthlyCents": 1,
      "baseYearlyCents": 1,
      "teamMonthlyCents": 1,
      "teamYearlyCents": 1,
      "baseMembers": 1,
      "teamMembers": 1,
      "trialMembers": 1,
      "baseSeatMonthlyCents": 1,
      "baseSeatYearlyCents": 1,
      "teamSeatMonthlyCents": 1,
      "teamSeatYearlyCents": 1,
      "storageGb": 1,
      "emailAllowance": 1,
      "aiCreditCents": 1,
      "emailsPer1000Cents": 1,
      "storageGbMonthCents": 1,
      "topupMinCents": 1,
      "topupThresholdCents": 1,
      "topupAmountCents": 1,
      "topupCeilingCents": 1,
      "overdraftCents": 1,
      "creditMonths": 1,
      "endedReceiveDays": 1,
      "endedDeleteDays": 1
    },
    "offer": {
      "code": "482913",
      "name": "Acme API",
      "percent": 1,
      "months": 1,
      "claimedAt": 1796048940000,
      "redeemBy": 1796048940000
    },
    "renewsAt": 1796048940000,
    "cancelAt": 1796048940000,
    "paymentRetryAt": 1796048940000
  }
}
```

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

## billing.ledger

The balance’s credits and debits, newest first.

`POST /v1/billing.ledger`

An admin or owner of the org.

### Parameters

- `limit` (integer, optional): How many lines to return, 1 to 500. Default `50`. From 1 to 500.

Beside `input`:

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

### Returns

`data` is a list of objects, each with:

- `id` (string)
- `at` (number)
- `kind` (enum): One of `topup`, `auto_topup`, `ai`, `storage`, `emails`, `expiry`.
- `micros` (number)
- `reason` (string)
- `ref` (string): The usage or payment it’s for: `ai:<day>`, `storage:<day>`, `emails:<day>`, or a payment’s id.
- `expiresAt` (nullable number): A credit’s end.
- `receipt` (nullable string, optional): A link to a payment’s invoice PDF or receipt page, once the receipt went. Default `null`.

### Request

TypeScript:

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

Python:

```python
from mailset import Mailset

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

answer = mailset.billing.ledger({"limit": 20})
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.BillingLedgerParams{
		Limit: mailset.Int(20),
	}
	answer, err := client.Billing.Ledger(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.billing.ledger(limit: 20)
p answer
```

PHP:

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

Java:

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

Rust:

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

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

CLI:

```bash
mailset billing ledger --limit 20
```

### Response

```json
{
  "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
    }
  ]
}
```

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

---

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