---
title: "Turn pay as you go on or off"
description: "The switch on Plans & Billing, and the card it needs the first time."
url: "https://openemail.uk/docs/api/billing/pay-as-you-go-switch"
area: "API"
category: "Mailbox"
---

# Turn pay as you go on or off

The switch on Plans & Billing, and the card it needs the first time.

`PATCH /billing/pay-as-you-go`

**Also documents:** `POST /billing/pay-as-you-go/confirm`

## PATCH /billing/pay-as-you-go

The switch on Plans & Billing, and the card it needs the first time.

## Example

Needs `billing:write`. Off takes effect at once, and usage stops at the allowances. On takes effect at once when a card is saved. The first time, `checkoutUrl` is a link where the person adds a card, and pay as you go starts once they have. `theme` and `locale` style the page the link opens.

**curl**

```
curl -X PATCH "$OE/billing/pay-as-you-go" -H "$AUTH" -H 'content-type: application/json' \
  -d '{ "enabled": true, "locale": "de" }'
```

**Response**

```
{
  "object": "pay_as_you_go_switch",
  "enabled": false,
  "suspended": false,
  "activating": false,
  "checkoutUrl": "https://checkout.example.com/c/7Yw2kq9RzX4mB1vN?locale=de"
}
```

> Nothing is paid through the API. The link opens the billing provider’s page, where the person pays, changes the card or cancels, as they do from the app.

> An OAuth access token needs a verification code for this call. Until the app has verified one in the last 60 minutes, the call answers `403` `step_up_required` and changes nothing. An API key is never asked. The Authentication page shows how to ask for a code and verify it.

## After the checkout

Needs `billing:write`. Once the person has added the card, `POST /billing/pay-as-you-go/confirm` checks with the billing provider and records it, as the app does when they come back. `enabled` says whether pay as you go is on now, and calling it again is safe.

**curl**

```
curl -X POST "$OE/billing/pay-as-you-go/confirm" -H "$AUTH"
```

**Response**

```
{ "object": "pay_as_you_go_confirmation", "enabled": true }
```

> `activating: true` from the switch means a card was just saved and pay as you go is being turned on, so read it again in a moment.

> An OAuth access token needs a verification code for this call. Until the app has verified one in the last 60 minutes, the call answers `403` `step_up_required` and changes nothing. An API key is never asked. The Authentication page shows how to ask for a code and verify it.

## Reference

- [`PATCH /billing/pay-as-you-go`](https://openemail.uk/docs/api/reference/billing#patch-billing-pay-as-you-go): full reference
- [`POST /billing/pay-as-you-go/confirm`](https://openemail.uk/docs/api/reference/billing#post-billing-pay-as-you-go-confirm): full reference
