> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# CreateCheckoutFromTemplate

# Package: checkout

# Namespace: CheckoutTemplateService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/purchase-flow/checkout/checkout-templates/create-checkout-from-template.md

## Permission Scopes:
Manage eCommerce - all permissions: SCOPE.DC-ECOM-MEGA.MANAGE-ECOM

## Introduction

Creates a new checkout based on the checkout template.

Before using this method, you must have a checkout template available. Create a checkout template with Create Checkout Template.

The customer can be directed to the new checkout using the checkout's `checkoutUrl`.

---

## REST API

### Schema

```
 Method: createCheckoutFromTemplate
 Description: Creates a new checkout based on the checkout template.  Before using this method, you must have a checkout template available. Create a checkout template with Create Checkout Template.  The customer can be directed to the new checkout using the checkout's `checkoutUrl`.
 URL: https://www.wixapis.com/ecom/v1/checkout-templates/{checkoutTemplateId}/create-checkout-from-template
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  siteId
 Method parameters: 
   param name: siteId | type: siteId | description: GUID of the site associated with the checkout template. | required: true | validation: format GUID
 Return type: CreateCheckoutFromTemplateResponse
  - name: checkoutId | type: string | description: GUID of the created checkout.  | validation: format GUID
  - name: checkoutUrl | type: string | description: URL of the created checkout page.  
  - name: purchaseFlowId | type: string | description: Persistent GUID that correlates between the various eCommerce elements: cart, checkout, and order.  | validation: format GUID

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_INVENTORY | Description: One or more items in the checkout template have insufficient inventory.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ITEM_NOT_FOUND_IN_CATALOG | Description: One or more items in the checkout template could not be found in the catalog.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_CREATE_CHECKOUT_FROM_INACTIVE_TEMPLATE | Description: Checkout template is inactive.


```

### Examples

### Create Checkout From Template
```curl
curl -X POST \
  'https://www.wixapis.com/ecom/v1/checkout-templates/d447475f-34ed-4be5-b199-b120c6938c39/create-checkout-from-template' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
    "siteId": "811d8a67-3bd7-46a5-8cd9-843bb77b2a7d"
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.checkoutTemplates.createCheckoutFromTemplate(checkoutTemplateId, siteId)
 Description: Creates a new checkout based on the checkout template.  Before using this method, you must have a checkout template available. Create a checkout template with Create Checkout Template.  The customer can be directed to the new checkout using the checkout's `checkoutUrl`.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  checkoutTemplateId, siteId
 Method parameters: 
   param name: checkoutTemplateId | type: string | description: GUID of the checkout template to use to create a checkout from. | required: true | validation: format GUID
   param name: siteId | type: string | description: GUID of the site associated with the checkout template. | required: true | validation: format GUID
 Return type: PROMISE<CreateCheckoutFromTemplateResponse>
  - name: checkoutId | type: string | description: GUID of the created checkout.  | validation: format GUID
  - name: checkoutUrl | type: string | description: URL of the created checkout page.  
  - name: purchaseFlowId | type: string | description: Persistent GUID that correlates between the various eCommerce elements: cart, checkout, and order.  | validation: format GUID

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_INVENTORY | Description: One or more items in the checkout template have insufficient inventory.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: ITEM_NOT_FOUND_IN_CATALOG | Description: One or more items in the checkout template could not be found in the catalog.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_CREATE_CHECKOUT_FROM_INACTIVE_TEMPLATE | Description: Checkout template is inactive.


```

### Examples

### createCheckoutFromTemplate
```javascript
import { checkoutTemplates } from '@wix/ecom';

async function createCheckoutFromTemplate(checkoutTemplateId,siteId) {
  const response = await checkoutTemplates.createCheckoutFromTemplate(checkoutTemplateId,siteId);
};
```

### createCheckoutFromTemplate (with elevated permissions)
```javascript
import { checkoutTemplates } from '@wix/ecom';
import { auth } from '@wix/essentials';

async function myCreateCheckoutFromTemplateMethod(checkoutTemplateId,siteId) {
  const elevatedCreateCheckoutFromTemplate = auth.elevate(checkoutTemplates.createCheckoutFromTemplate);
  const response = await elevatedCreateCheckoutFromTemplate(checkoutTemplateId,siteId);
}
```

### createCheckoutFromTemplate (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { checkoutTemplates } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { checkoutTemplates },
  // Include the auth strategy and host as relevant
});


async function createCheckoutFromTemplate(checkoutTemplateId,siteId) {
  const response = await myWixClient.checkoutTemplates.createCheckoutFromTemplate(checkoutTemplateId,siteId);
};
```

---