# Create a plan payment link

- **OpenAPI Version:** `3.2.0`
- **API Version:** `3.1.0`
- **Contact:** Syndai <https://syndai.ai>

## Contents

**Operations**

- [POST /api/v1/external/coding/purchases/subscription-checkout](#scalar-operation-post-apiv1externalcodingpurchasessubscription-checkout)

**Schemas**

- [SubscriptionCheckoutRequest](#scalar-schema-subscriptioncheckoutrequest)
- [CheckoutLinkResponse](#scalar-schema-checkoutlinkresponse)
- [ProblemDetail](#scalar-schema-problemdetail)
- [ExternalErrorCode](#scalar-schema-externalerrorcode)

<a id="scalar-context-global-servers"></a>

## Servers

- **URL:** `https://api.syndai.ai`

<a id="scalar-context-global-authentication"></a>

## Authentication

- **CustomerApiKey**: HTTP bearer (`API Key`)

  Customer API key sent as a bearer token

## Tags

### Billing

The workspace's plan, balance and prices: read current-period usage, credit packs, plans and the live subscription, and create a payment link for a pack or a first plan. Nothing is charged until a person pays on that link; changing plan, the card and cancelling stay on the Billing page (403 `HUMAN_APPROVAL_REQUIRED`).

## Operations

<a id="scalar-operation-post-apiv1externalcodingpurchasessubscription-checkout"></a>

### Create a plan payment link

- **Method:** `POST`
- **Path:** `/api/v1/external/coding/purchases/subscription-checkout`
- **Operation ID:** `createPlanCheckout`
- **Tags:** Billing

A payment link for the workspace's first paid plan (`plan_code` from `GET /purchases/tiers`, `interval` month or year, `country` the ISO alpha-2 billing country that picks the price band). Nothing is charged until a person pays on `checkout_url`. A workspace already on a paid plan is refused: changing plan charges the saved card, so a person does it on the Billing page. Needs `coding:billing:checkout`.

**Servers:** [Inherited servers](#scalar-context-global-servers)

**Authentication:** [Global authentication](#scalar-context-global-authentication)

#### Query parameters

- **`customer_id`**: `string | null`, format: `uuid`

#### Request body

**Required:** `true`

**Content type:** `application/json`

[SubscriptionCheckoutRequest](#scalar-schema-subscriptioncheckoutrequest)

<a id="scalar-example-1"></a>

**Generated example:**

```json
{
  "country": "",
  "interval": "month",
  "plan_code": ""
}
```

#### Responses

##### 201 Document created, URL follows

**Content type:** `application/json`

[CheckoutLinkResponse](#scalar-schema-checkoutlinkresponse)

<a id="scalar-example-2"></a>

**Generated example:**

```json
{
  "checkout_url": "",
  "expires_at": ""
}
```

##### 400, 401, 403, 404, 409, 502, 503

- `400` Bad request syntax or unsupported method; or PLAN\_UNKNOWN: plan\_code is not a self-serve plan
- `401` Invalid or missing customer API key
- `403` Insufficient scope or forbidden customer access
- `404` Resource not found
- `409` ALREADY\_SUBSCRIBED (change plan on the Billing page), PLAN\_CHECKOUT\_PENDING (retry), PLAN\_CHECKOUT\_OPEN (checkout\_url names the open one) or BILLING\_DISPUTE\_HOLD
- `502` BILLING\_PROVIDER\_UNAVAILABLE or BILLING\_CHECKOUT\_URL\_MISSING; retry
- `503` PRICES\_UPDATING: prices are updating; retry in a minute

**Content type:** `application/problem+json`

[ProblemDetail](#scalar-schema-problemdetail)

RFC 7807 problem detail returned for public CaaS errors.

<a id="scalar-example-3"></a>

**Generated example:**

```json
{
  "code": "BUDGET_EXHAUSTED",
  "detail": null,
  "existing_run_id": null,
  "instance": null,
  "status": 1,
  "title": "",
  "type": "about:blank",
  "additionalProperty": "anything"
}
```

##### 429 Rate limit exceeded

**Headers:**

- **`Retry-After`**

  Seconds to wait before retrying the request

  `integer`

**Content type:** `application/problem+json`

[ProblemDetail](#scalar-schema-problemdetail)

RFC 7807 problem detail returned for public CaaS errors.

[Generated example](#scalar-example-3)

##### default Unexpected error

**Content type:** `application/problem+json`

[ProblemDetail](#scalar-schema-problemdetail)

<a id="scalar-example-4"></a>

**Generated example:**

```json
null
```

## Schemas

<a id="scalar-schema-subscriptioncheckoutrequest"></a>

### SubscriptionCheckoutRequest

**Type:** `object`

- **`country` (required)**: `string`, pattern: `^[A-Z]{2}$`
- **`interval` (required)**: `string`, possible values: `"month", "year"`
- **`plan_code` (required)**: `string`

<a id="scalar-example-5"></a>

**Generated example:**

```json
{
  "country": "",
  "interval": "month",
  "plan_code": ""
}
```

<a id="scalar-schema-checkoutlinkresponse"></a>

### CheckoutLinkResponse

**Type:** `object`

- **`checkout_url` (required)**: `string`
- **`expires_at`**: `string | null`, format: `date-time`

<a id="scalar-example-6"></a>

**Generated example:**

```json
{
  "checkout_url": "",
  "expires_at": ""
}
```

<a id="scalar-schema-problemdetail"></a>

### ProblemDetail

**Type:** `object`

RFC 7807 problem detail returned for public CaaS errors.

- **`code` (required)**: `string`, possible values: `"BUDGET_EXHAUSTED", "QUOTA_EXCEEDED", "RUN_CONCURRENCY_LIMIT", "CUSTOMER_DISABLED", "REPO_NOT_BOUND", "IDEMPOTENCY_REPLAY", "CONFLICT", "MISSION_BUSY_RETRY", "HITL_REQUEST_CONFLICT", "HITL_REQUEST_SETTLED", "RUN_TERMINATED_BEFORE_RESPONSE", "INVALID_POLICY", "INVALID_SCOPE", "RATE_LIMITED", "INSTALLATION_INCOMPLETE", "SUBSCRIPTION_USAGE_UNAVAILABLE", "INVALID_TOKEN", "ROLE_REQUIRED", "PLAN_UPGRADE_REQUIRED", "EMAIL_MISMATCH", "EXPIRED_TOKEN", "NOT_FOUND", "OVERSCOPE_ACK_REQUIRED", "VERIFY_FAILED", "PUBLISH_IN_FLIGHT", "PUBLISH_UNSUPPORTED_REPO", "PUBLICATION_NOT_LIVE", "NO_APP_DATA", "FEATURE_REQUESTS_NEEDS_MEMBERS", "EMPTY_UPDATE", "BAD_CURSOR", "HUMAN_APPROVAL_REQUIRED", "PROTECTED_PATHS_MANAGED_ONLY", "RUN_IN_FLIGHT", "TEXT_EDIT_REFUSED", "CLI_UPGRADE_REQUIRED", "PRODUCTION_STEP_UP_REQUIRED", "PRICES_UPDATING", "GITHUB_UNAVAILABLE", "PUBLISH_NOT_SET_UP", "PUBLISH_TAG_EXISTS", "PUBLISH_VERSION_EXISTS", "VERSION_NOT_DEPLOYED", "DATA_REFUSED", "INTERNAL_ERROR"`

  Stable error codes surfaced to public CaaS clients.
- **`status` (required)**: `integer`
- **`title` (required)**: `string`
- **`detail`**: `string | null`, default: `null`
- **`existing_run_id`**: `string | null`, default: `null`
- **`instance`**: `string | null`, default: `null`
- **`type`**: `string`, default: `"about:blank"`

<a id="scalar-example-7"></a>

**Generated example:**

```json
{
  "code": "BUDGET_EXHAUSTED",
  "detail": null,
  "existing_run_id": null,
  "instance": null,
  "status": 1,
  "title": "",
  "type": "about:blank",
  "additionalProperty": "anything"
}
```

<a id="scalar-schema-externalerrorcode"></a>

### ExternalErrorCode

**Type:** `string`, possible values: `"BUDGET_EXHAUSTED", "QUOTA_EXCEEDED", "RUN_CONCURRENCY_LIMIT", "CUSTOMER_DISABLED", "REPO_NOT_BOUND", "IDEMPOTENCY_REPLAY", "CONFLICT", "MISSION_BUSY_RETRY", "HITL_REQUEST_CONFLICT", "HITL_REQUEST_SETTLED", "RUN_TERMINATED_BEFORE_RESPONSE", "INVALID_POLICY", "INVALID_SCOPE", "RATE_LIMITED", "INSTALLATION_INCOMPLETE", "SUBSCRIPTION_USAGE_UNAVAILABLE", "INVALID_TOKEN", "ROLE_REQUIRED", "PLAN_UPGRADE_REQUIRED", "EMAIL_MISMATCH", "EXPIRED_TOKEN", "NOT_FOUND", "OVERSCOPE_ACK_REQUIRED", "VERIFY_FAILED", "PUBLISH_IN_FLIGHT", "PUBLISH_UNSUPPORTED_REPO", "PUBLICATION_NOT_LIVE", "NO_APP_DATA", "FEATURE_REQUESTS_NEEDS_MEMBERS", "EMPTY_UPDATE", "BAD_CURSOR", "HUMAN_APPROVAL_REQUIRED", "PROTECTED_PATHS_MANAGED_ONLY", "RUN_IN_FLIGHT", "TEXT_EDIT_REFUSED", "CLI_UPGRADE_REQUIRED", "PRODUCTION_STEP_UP_REQUIRED", "PRICES_UPDATING", "GITHUB_UNAVAILABLE", "PUBLISH_NOT_SET_UP", "PUBLISH_TAG_EXISTS", "PUBLISH_VERSION_EXISTS", "VERSION_NOT_DEPLOYED", "DATA_REFUSED", "INTERNAL_ERROR"`

Stable error codes surfaced to public CaaS clients.
