> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pillar8.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkout Optimize

The Checkout Optimize API returns a decision package that ranks available payment methods for a given checkout session.

***

## Endpoint

`POST /api/shopify/checkout-optimize`

***

## Request

### Headers

```text theme={null}
Content-Type: application/json
```

### Body

```text theme={null}
{
  "shop_domain": "example.myshopify.com",
  "cart_value": 85,
  "currency_code": "EUR",
  "country_code": "DE",
  "device_type": "mobile",
  "checkoutToken": "abc123",
  "default_fops": ["card", "paypal", "klarna"],
  "presented_payment_methods": ["card", "paypal", "klarna"]
}
```

### Request Fields

| Field                       | Type   | Description                                     |
| :-------------------------- | :----- | :---------------------------------------------- |
| shop\_domain                | string | Your shop identifier                            |
| cart\_value                 | number | Total transaction amount                        |
| currency\_code              | string | ISO 4217 currency code                          |
| country\_code               | string | ISO 3166-1 country code                         |
| device\_type                | string | `mobile` or `desktop`                           |
| checkoutToken               | string | Unique checkout session identifier              |
| default\_fops               | array  | Payment methods available to the shopper        |
| presented\_payment\_methods | array  | Payment methods currently displayed at checkout |

***

## Response

```text theme={null}
{
  "status": "ok",
  "ab_variant": "optimize",
  "was_optimized": true,
  "shadow_engine": {
    "scored": [
      { "code": "paypal", "score": 0.82 },
      { "code": "card", "score": 0.74 }
    ]
  },
  "gating_passed": true
}
```

### Response Fields

| Field                 | Type    | Description                                                          |
| :-------------------- | :------ | :------------------------------------------------------------------- |
| status                | string  | Request status: `ok` or `error`                                      |
| ab\_variant           | string  | Test group assignment: `control` or `optimize`                       |
| was\_optimized        | boolean | Whether the API applied optimization to this session                 |
| shadow\_engine.scored | array   | Payment methods ranked by conversion likelihood, highest score first |
| gating\_passed        | boolean | Whether to display the optimization advisory to the shopper          |

***

## Security & Privacy

<Note>
  * This API does not process or store payment data
  * No cardholder information is required or transmitted
  * Optimization occurs before payment execution
</Note>

***

## Next Steps

* See **Webhooks** to track checkout outcomes
* See **How It Works** to understand the ranking algorithm
