# Preview a plan change

`POST /v1/orgs/{org_id}/billing/change/preview`

Requires role owner or higher.

## Authentication

A session token: `Authorization: Bearer <session token>`, or the session cookie in the browser. Requires role `owner` or higher.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `org_id` | path | string | yes |  |

## Request body

`application/json`

```json
{
  "additionalProperties": false,
  "properties": {
    "plan_id": {
      "maxLength": 32,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "plan_id"
  ],
  "type": "object"
}
```

## Responses

### 200

What a plan change does: an upgrade charges now, a downgrade starts at the end of the period.

`application/json`

```json
{
  "additionalProperties": false,
  "description": "What a plan change does: an upgrade charges now, a downgrade starts at the end of the period.",
  "properties": {
    "amount_due": {
      "anyOf": [
        {
          "description": "Upgrade: charged now, in cents, tax included.",
          "type": "integer"
        },
        {
          "type": "null"
        }
      ]
    },
    "currency": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "effective_at": {
      "anyOf": [
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "kind": {
      "anyOf": [
        {
          "enum": [
            "upgrade"
          ],
          "type": "string"
        },
        {
          "enum": [
            "downgrade"
          ],
          "type": "string"
        }
      ]
    }
  },
  "required": [
    "kind",
    "amount_due",
    "currency",
    "effective_at"
  ],
  "type": "object"
}
```

### 401

unauthorized: no valid session, or the email is not verified.

Problem type: [unauthorized](https://docs.dlogify.com/errors/unauthorized.md).

### 403

csrf-origin-rejected: a cookie-authenticated change from an origin outside the web app. forbidden: the action requires the owner role.

Problem type: [csrf-origin-rejected](https://docs.dlogify.com/errors/csrf-origin-rejected.md).

### 404

not-found: the resource does not exist, or the caller is not a member of its organization.

Problem type: [not-found](https://docs.dlogify.com/errors/not-found.md).

### 409

no-subscription: the organization has no subscription.

Problem type: [no-subscription](https://docs.dlogify.com/errors/no-subscription.md).

### 422

plan-change-invalid: the target plan is the current plan, Free, or unknown. validation-failed: the request does not match the schema.

Problem type: [plan-change-invalid](https://docs.dlogify.com/errors/plan-change-invalid.md).

### 429

rate-limited: per-user management request limit.

Problem type: [rate-limited](https://docs.dlogify.com/errors/rate-limited.md).

## Example

```bash
curl -X POST "https://api.dlogify.com/v1/orgs/{org_id}/billing/change/preview" \
  -H "Authorization: Bearer $DLOGIFY_SESSION" \
  -H "Content-Type: application/json" \
  --data-binary @body
```

Source: https://docs.dlogify.com/api/billing/previewPlanChange
