# Change the paid plan

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

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

The result of a plan change. The plan itself changes when Stripe's webhook arrives.

`application/json`

```json
{
  "additionalProperties": false,
  "description": "The result of a plan change. The plan itself changes when Stripe's webhook arrives.",
  "properties": {
    "client_secret": {
      "anyOf": [
        {
          "description": "With requires_action: pass to stripe.handleNextAction.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "effective_at": {
      "anyOf": [
        {
          "format": "date-time",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "anyOf": [
        {
          "enum": [
            "applied"
          ],
          "type": "string"
        },
        {
          "enum": [
            "scheduled"
          ],
          "type": "string"
        },
        {
          "enum": [
            "requires_action"
          ],
          "type": "string"
        }
      ]
    }
  },
  "required": [
    "status",
    "client_secret",
    "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; conflict: the subscription is being cancelled.

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" \
  -H "Authorization: Bearer $DLOGIFY_SESSION" \
  -H "Content-Type: application/json" \
  --data-binary @body
```

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