# Start a subscription checkout

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

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

A Stripe Checkout Session for a first subscription.

`application/json`

```json
{
  "additionalProperties": false,
  "description": "A Stripe Checkout Session for a first subscription.",
  "properties": {
    "client_secret": {
      "description": "Initializes Stripe.js Checkout (ui_mode elements). Never log it.",
      "type": "string"
    },
    "offer": {
      "anyOf": [
        {
          "enum": [
            "applied"
          ],
          "type": "string"
        },
        {
          "enum": [
            "not_eligible"
          ],
          "type": "string"
        },
        {
          "enum": [
            "none"
          ],
          "type": "string"
        }
      ],
      "description": "applied: the public offer is on the session and no other code is accepted. not_eligible: a public offer is running but does not apply to this organization (it paid before); no code is accepted. none: no public offer for this plan; the customer may enter a promotion code."
    }
  },
  "required": [
    "client_secret",
    "offer"
  ],
  "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

subscription-exists: the organization already has a live subscription.

Problem type: [subscription-exists](https://docs.dlogify.com/errors/subscription-exists.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/checkout" \
  -H "Authorization: Bearer $DLOGIFY_SESSION" \
  -H "Content-Type: application/json" \
  --data-binary @body
```

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