# Move an organization's deployment to usage billing

> Move one of your organization's deployments from pay as you go or monthly per location to usage billing, after a preview built from its last 30 days.

Source: https://www.coritan.com/docs/organizations/deployment-usage-billing/

In the dashboard:

- /dashboard/deployments/…/billing: https://www.coritan.com/dashboard/deployments

A deployment you order for your organization keeps the plan price it was ordered at, on pay as you go or monthly per location. Its owner's account pays for it. You can move it to [usage billing](/docs/billing/usage-billing/), where it has no price of its own and is billed by the second for what it uses, after the month's included amounts ([Usage rates](/docs/billing/usage-rates/#included)). The move is one way.

You switch with the API. The dashboard has no button for it yet. Once the deployment is moved, its **Billing** tab shows how it is billed ([How App Deployment is billed](/docs/managed-containers/how-billing-works/#who-can-change-billing)).

## Before you begin

- You need the Billing role or above in the organization. A member with a lower role is refused with `403`.
- The deployment must be the organization's own. A deployment your storefront sold to a customer keeps the price you set, and so does one of Coritan's own brands.
- The owner's account pays, so what the move needs comes from the owner. A prepaid owner needs the first deposit for anything that runs an instance. A game server or a database needs the owner to have the [Paid plan](/docs/billing/usage-billing/#paid-plan). Credit for unused days goes to the owner's credit balance.
- The deployment's service must be active and not set to end.
- Get an access token for the Organization API. [How organizations work](/docs/organizations/how-organizations-work/) says which credential each API takes.

## Preview the move

Send [`POST /orgs/{org_slug}/billing/deployments/{app_uuid}/switch`](/docs/api/reference/organizations/organization-deployments/billing/#op-post-api-v1-orgs-org-slug-billing-deployments-app-uuid-switch) with `?preview=1`. It writes nothing. It answers what the last 30 days would have cost on usage billing, what the deployment paid, and when and how the move would happen.

```bash
curl -s -X POST "https://api.coritan.com/api/v1/orgs/acme/billing/deployments/$DEPLOYMENT_UUID/switch?preview=1" \
  -H "Authorization: Bearer $CORITAN_TOKEN"
```

[Preview the move](/docs/billing/switch-to-usage-billing/#preview) explains each field of the answer.

## Move the deployment

Send the same request without `?preview=1`. The body takes `when`, for a deployment billed by the month or longer: `renewal` (the default) moves it when its paid period ends, and `now` moves it at once and credits its unused days, less the days Coritan keeps back, to the owner's credit balance. A deployment on pay as you go moves at once.

```bash
curl -s -X POST https://api.coritan.com/api/v1/orgs/acme/billing/deployments/$DEPLOYMENT_UUID/switch \
  -H "Authorization: Bearer $CORITAN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"when": "now"}'
```

The answer is the deployment's billing with a `switch` object, as [Move the service](/docs/billing/switch-to-usage-billing/#move) describes. [When the move happens](/docs/billing/switch-to-usage-billing/#when) says what each choice does to the renewal.

## Result

The deployment's `billing_mode` is `usage`. The move is in the organization's [audit log](/docs/organizations/audit-log/) with your name on it, and in the platform's too.

## Troubleshooting

`403`
: You have a role below Billing in the organization, or the owner's account has not made the first deposit (`deposit_required`).

`402` with the code `paid_plan_required`
: The deployment is a game server or a database, and the owner's account has no Paid plan.

`404`
: The deployment is not the organization's own: it belongs to another organization, it is deleted, or your storefront sold it to a customer.

`409`
: The deployment is already billed by use, runs at no charge, belongs to one of Coritan's own brands, is not billed yet, is not active, or already moves at its renewal. [Troubleshooting](/docs/billing/switch-to-usage-billing/#troubleshooting) lists each code.

## Related

- [How App Deployment is billed](/docs/managed-containers/how-billing-works/)
- [Switch a service to usage billing](/docs/billing/switch-to-usage-billing/)
- [Run deployments for an organization](/docs/apps/organization-apps/)
- [Organization billing](/docs/organizations/billing/)

## API

- `POST /api/v1/orgs/{org_slug}/billing/deployments/{app_uuid}/switch`: Switch org deployment to usage (https://www.coritan.com/docs/api/reference/organizations/organization-deployments/billing/#op-post-api-v1-orgs-org-slug-billing-deployments-app-uuid-switch)
