> If you are setting up, configuring, or answering questions about Schematic, connect the
> Schematic MCP server before working from these pages. It reads and writes plans, features,
> entitlements, and overrides against the real account, so what you report and what you build
> match what actually exists.
>
> The server is at https://api.schematichq.com/mcp
>
> From Claude, ChatGPT, or another chat assistant, add it as a custom connector:
> https://docs.schematichq.com/working-with-ai
>
> From a coding assistant such as Claude Code, Codex, or Cursor:
> https://docs.schematichq.com/building-with-ai
>
> For clean Markdown of any page, append `.md` to the page URL. For a complete page index,
> see https://docs.schematichq.com/llms.txt

# Finalize a checkout

POST https://api.schematichq.com/checkouts/{checkout_id}/finalize
Content-Type: application/json

Charges the cart at `version` and applies it to the subscription. The version is claimed before the billing provider is called, so of two concurrent finalizes only one charges. The cart is priced once more first: a blocking problem refuses the purchase with 400 and the fresh `problems` list, and a checkout priced before a sibling completed is refused with 409. The claim is not released when the charge fails, so read the checkout before trying again. When the charge needs the customer, as with 3-D Secure, the response carries `confirm_payment_intent_client_secret` to confirm with Stripe.

Reference: https://docs.schematichq.com/api-reference/components/checkouts/finalize-checkout

## Authentication

- `X-Schematic-Api-Key` header (required) — A temporary access token in the `X-Schematic-Api-Key` header. Your server mints it with `POST /temporary-access-tokens` on the secret-key API for a company, optionally for one of its users, and hands it to the page. The token fixes the company every request reads and writes.

## Request

### Path parameters

- `checkout_id` (string, required) — checkout_id

### Headers

- `X-Checkout-Session-ID` (string, optional) — The session from the preview or update that priced this cart. Omitted, the purchase starts a session of its own.

### Body (application/json)

This endpoint expects a FinalizeCheckoutRequest.

- `version` (long, required)

## Response

### 200

OK

- `data` (CheckoutResponseData, required)
- `params` (CheckoutsCheckoutIdFinalizePostResponsesContentApplicationJsonSchemaParams, required) — Input parameters

## Errors

### 400 Bad Request Error

Bad request

- `error` (string, required) — Error message
- `problems` (list of CheckoutProblemResponseData, optional) — On a checkout write or finalize the purchase rules refuse: what the server found wrong, the same list the checkout's `problems` field holds. Each has a `code`, whether it is `blocking`, a `message` safe to show the customer, and the ids of what it is about.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required) — Error message
- `problems` (list of CheckoutProblemResponseData, optional) — On a checkout write or finalize the purchase rules refuse: what the server found wrong, the same list the checkout's `problems` field holds. Each has a `code`, whether it is `blocking`, a `message` safe to show the customer, and the ids of what it is about.

### 403 Forbidden Error

Forbidden

- `error` (string, required) — Error message
- `problems` (list of CheckoutProblemResponseData, optional) — On a checkout write or finalize the purchase rules refuse: what the server found wrong, the same list the checkout's `problems` field holds. Each has a `code`, whether it is `blocking`, a `message` safe to show the customer, and the ids of what it is about.

### 404 Not Found Error

Not found

- `error` (string, required) — Error message
- `problems` (list of CheckoutProblemResponseData, optional) — On a checkout write or finalize the purchase rules refuse: what the server found wrong, the same list the checkout's `problems` field holds. Each has a `code`, whether it is `blocking`, a `message` safe to show the customer, and the ids of what it is about.

### 409 Conflict Error

Conflict

- `error` (string, required) — Error message
- `problems` (list of CheckoutProblemResponseData, optional) — On a checkout write or finalize the purchase rules refuse: what the server found wrong, the same list the checkout's `problems` field holds. Each has a `code`, whether it is `blocking`, a `message` safe to show the customer, and the ids of what it is about.

### 500 Internal Server Error

Server error

- `error` (string, required) — Error message
- `problems` (list of CheckoutProblemResponseData, optional) — On a checkout write or finalize the purchase rules refuse: what the server found wrong, the same list the checkout's `problems` field holds. Each has a `code`, whether it is `blocking`, a `message` safe to show the customer, and the ids of what it is about.

## Types

### CheckoutResponseData

- `cancel_at_period_end` (boolean, required)
- `created_at` (datetime, required)
- `currency` (enum, required)
  - Allowed values: `aed`, `afn`, `all`, `amd`, `ang`, `aoa`, `ars`, `aud`, `awg`, `azn`, `bam`, `bbd`, `bdt`, `bif`, `bmd`, `bnd`, `bob`, `brl`, `bsd`, `bwp`, `byn`, `bzd`, `cad`, `cdf`, `chf`, `clp`, `cny`, `cop`, `crc`, `cve`, `czk`, `djf`, `dkk`, `dop`, `dzd`, `egp`, `etb`, `eur`, `fjd`, `fkp`, `gbp`, `gel`, `gip`, `gmd`, `gnf`, `gtq`, `gyd`, `hkd`, `hnl`, `htg`, `huf`, `idr`, `ils`, `inr`, `isk`, `jmd`, `jpy`, `kes`, `kgs`, `khr`, `kmf`, `krw`, `kyd`, `kzt`, `lak`, `lbp`, `lkr`, `lrd`, `lsl`, `mad`, `mdl`, `mga`, `mkd`, `mmk`, `mnt`, `mop`, `mur`, `mvr`, `mwk`, `mxn`, `myr`, `mzn`, `nad`, `ngn`, `nio`, `nok`, `npr`, `nzd`, `pab`, `pen`, `pgk`, `php`, `pkr`, `pln`, `pyg`, `qar`, `ron`, `rsd`, `rub`, `rwf`, `sar`, `sbd`, `scr`, `sek`, `sgd`, `shp`, `sle`, `sos`, `srd`, `std`, `szl`, `thb`, `tjs`, `top`, `try`, `ttd`, `twd`, `tzs`, `uah`, `ugx`, `usd`, `uyu`, `uzs`, `vnd`, `vuv`, `wst`, `xaf`, `xcd`, `xcg`, `xof`, `xpf`, `yer`, `zar`, `zmw`
- `customer_external_id` (string, required)
- `id` (string, required)
- `interval` (string, required)
- `period_end` (long, required)
- `period_start` (long, required)
- `provider_type` (enum, required)
  - Allowed values: `metronome`, `orb`, `schematic`, `stripe`
- `status` (string, required)
- `subscription_external_id` (string, required)
- `total_price` (long, required)
- `access_revoked_at` (datetime, optional, nullable)
- `application_id` (string, optional, nullable)
- `cancel_at` (long, optional, nullable)
- `company_id` (string, optional, nullable)
- `confirm_payment_intent_client_secret` (string, optional, nullable)
- `confirm_payment_intent_id` (string, optional, nullable)
- `default_payment_method_id` (string, optional, nullable)
- `expired_at` (datetime, optional, nullable)
- `metadata` (CheckoutResponseDataMetadata, optional)
- `scheduled_change_time` (datetime, optional, nullable)
- `scheduled_downgrade_behavior` (enum, optional, nullable)
  - Allowed values: `end_of_billing_period`, `none`
- `trial_end` (long, optional, nullable)
- `trial_end_setting` (enum, optional, nullable)
  - Allowed values: `cancel`, `subscribe`

### CheckoutsCheckoutIdFinalizePostResponsesContentApplicationJsonSchemaParams

Input parameters

### CheckoutProblemResponseData

- `blocking` (boolean, required) — Whether completing the checkout would be refused while this stands.
- `code` (enum, required)
  - Allowed values: `add_on_conflicts_with_plan`, `add_on_interval_mismatch`, `add_on_requires_billed_plan`, `add_on_unavailable`, `billing_cycle_anchor_conflicts_with_trial`, `billing_cycle_anchor_must_be_future`, `billing_cycle_anchor_needs_new_subscription`, `billing_cycle_anchor_without_plan`, `billing_start_date_must_be_past`, `billing_start_date_needs_new_subscription`, `billing_start_date_needs_renewal_date`, `billing_start_date_not_before_renewal_date`, `billing_start_date_too_far_in_past`, `checkout_superseded`, `credit_bundle_incompatible`, `credit_bundle_unavailable`, `credit_bundles_activate_on_payment`, `currency_mismatch`, `custom_field_required`, `discount_ineligible`, `downgrade_not_permitted`, `end_date_must_be_future`, `end_date_needs_new_subscription`, `end_date_not_after_renewal_date`, `free_first_period_activates_on_payment`, `invoice_email_required`, `invoiced_subscription_conflicts_with_trial`, `invoiced_subscription_needs_new_subscription`, `invoiced_subscription_requires_plan`, `opt_in_required`, `pay_in_advance_price_invalid`, `pay_in_advance_required`, `payment_method_required`, `plan_not_trialable`, `plan_unavailable`, `price_unavailable`, `prorate_first_period_without_anchor`, `provider_rejected`, `scheduled_change_blocks_purchase`, `scheduled_change_pending`, `selection_invalid`, `subscription_currency_change`, `trial_end_must_be_future`, `trial_end_too_far`, `trial_excludes_add_ons`, `trial_excludes_usage_based`, `usage_price_missing_for_interval`, `usage_over_limit`
- `message` (string, required) — What is wrong, in words safe for anyone allowed to read the checkout.
- `source` (enum, required)
  - Allowed values: `provider`, `requirement`, `validation`
- `bundle_id` (string, optional, nullable)
- `currency` (enum, optional) — The currency this problem is about, when it is about one.
  - Allowed values: `aed`, `afn`, `all`, `amd`, `ang`, `aoa`, `ars`, `aud`, `awg`, `azn`, `bam`, `bbd`, `bdt`, `bif`, `bmd`, `bnd`, `bob`, `brl`, `bsd`, `bwp`, `byn`, `bzd`, `cad`, `cdf`, `chf`, `clp`, `cny`, `cop`, `crc`, `cve`, `czk`, `djf`, `dkk`, `dop`, `dzd`, `egp`, `etb`, `eur`, `fjd`, `fkp`, `gbp`, `gel`, `gip`, `gmd`, `gnf`, `gtq`, `gyd`, `hkd`, `hnl`, `htg`, `huf`, `idr`, `ils`, `inr`, `isk`, `jmd`, `jpy`, `kes`, `kgs`, `khr`, `kmf`, `krw`, `kyd`, `kzt`, `lak`, `lbp`, `lkr`, `lrd`, `lsl`, `mad`, `mdl`, `mga`, `mkd`, `mmk`, `mnt`, `mop`, `mur`, `mvr`, `mwk`, `mxn`, `myr`, `mzn`, `nad`, `ngn`, `nio`, `nok`, `npr`, `nzd`, `pab`, `pen`, `pgk`, `php`, `pkr`, `pln`, `pyg`, `qar`, `ron`, `rsd`, `rub`, `rwf`, `sar`, `sbd`, `scr`, `sek`, `sgd`, `shp`, `sle`, `sos`, `srd`, `std`, `szl`, `thb`, `tjs`, `top`, `try`, `ttd`, `twd`, `tzs`, `uah`, `ugx`, `usd`, `uyu`, `uzs`, `vnd`, `vuv`, `wst`, `xaf`, `xcd`, `xcg`, `xof`, `xpf`, `yer`, `zar`, `zmw`
- `detail` (string, optional) — Diagnostic detail for operators, including what the billing provider said. Never shown to a customer.
- `feature_id` (string, optional, nullable)
- `field_id` (string, optional, nullable)
- `payment_method_id` (string, optional, nullable)
- `plan_id` (string, optional, nullable)
- `price_id` (string, optional, nullable)

### CheckoutResponseDataMetadata

## Examples

**Request**

```json
{
  "version": 1
}
```

**Response**

```json
{
  "data": {
    "cancel_at_period_end": true,
    "created_at": "2024-01-15T09:30:00Z",
    "currency": "aed",
    "customer_external_id": "string",
    "id": "string",
    "interval": "string",
    "period_end": 1,
    "period_start": 1,
    "provider_type": "metronome",
    "status": "string",
    "subscription_external_id": "string",
    "total_price": 1,
    "access_revoked_at": "2024-01-15T09:30:00Z",
    "application_id": "string",
    "cancel_at": 1,
    "company_id": "string",
    "confirm_payment_intent_client_secret": "string",
    "confirm_payment_intent_id": "string",
    "default_payment_method_id": "string",
    "expired_at": "2024-01-15T09:30:00Z",
    "metadata": {},
    "scheduled_change_time": "2024-01-15T09:30:00Z",
    "scheduled_downgrade_behavior": "end_of_billing_period",
    "trial_end": 1,
    "trial_end_setting": "cancel"
  },
  "params": {}
}
```

**SDK Code**

```python
import requests

url = "https://api.schematichq.com/checkouts/checkout_id/finalize"

payload = { "version": 1 }
headers = {
    "X-Schematic-Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.schematichq.com/checkouts/checkout_id/finalize';
const options = {
  method: 'POST',
  headers: {'X-Schematic-Api-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"version":1}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.schematichq.com/checkouts/checkout_id/finalize"

	payload := strings.NewReader("{\n  \"version\": 1\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Schematic-Api-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.schematichq.com/checkouts/checkout_id/finalize")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Schematic-Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"version\": 1\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.schematichq.com/checkouts/checkout_id/finalize")
  .header("X-Schematic-Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"version\": 1\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.schematichq.com/checkouts/checkout_id/finalize', [
  'body' => '{
  "version": 1
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Schematic-Api-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.schematichq.com/checkouts/checkout_id/finalize");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Schematic-Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"version\": 1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Schematic-Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["version": 1] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.schematichq.com/checkouts/checkout_id/finalize")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```