> This page is for Entria API Reference.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.navipartner.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.navipartner.com/_mcp/server.

# Create a new cart

POST https://api.entria.app/api/cart

Starts a new, empty cart and returns its id. Keep that id for the rest of the shopper's session: every other cart endpoint is scoped to it, and it cannot be recovered from anything else. The response also includes `checkoutUrl`, the hosted page you send the shopper to when they are ready to pay.

Reference: https://docs.navipartner.com/entria-api/entria-api-reference/cart/post-create-cart

## Request

### Query parameters

- `locale` (string, optional) — BCP 47 locale for the cart contents (e.g. da-DK, en-US). Defaults to the store's configured locale.
- `codes` (string, optional) — Comma-separated discount codes to attach at creation, for campaign deep links (`?codes=SOMMER25,VIP`). An empty cart qualifies for nothing, so they land in `cart.pendingDiscountCodes` and apply on their own once a qualifying line is added. Lenient by design and unlike POST /api/cart/discounts: no per-code verdict is returned, blank or over-long codes and anything past the tenth are dropped, unknown codes are dropped, and if the store cannot apply codes yet the cart is still created without them. Send the codes again via POST /api/cart/discounts to learn why one did not apply.

### Headers

- `x-entria` (string, required) — Identifies which store this request is for. Required on every store-scoped route. It is not authentication and not a secret — it grants no privileges and is safe to send from a browser. You receive the value once your Entria backend has been created and configured. Missing header returns 400; an unknown store returns 404.

## Response

### 200

The newly created cart, including its id and checkoutUrl.

- `cart` (Cart, required)

## Errors

### 401 Unauthorized Error

The account Bearer is ours but cannot be honoured: expired, not yet valid, minted for another store, or its claims no longer fit (`code: ACCOUNT_TOKEN_INVALID`). Log the shopper in again. Any other Bearer, such as a client token, is ignored.

- `error` (string, required)
- `code` (string, optional)
- `details` (list of ErrorResponseDetailsItems, optional) — Per-field validation failures; present when code is VALIDATION_ERROR.
- `success` (boolean, optional, deprecated) — Deprecated. Use code === VALIDATION_ERROR.
- `errors` (list of any, optional, deprecated) — Deprecated. Raw zod issues; use details instead.

### 404 Not Found Error

The `x-entria` store handle is not a known store.

- `error` (string, required)
- `code` (string, optional)
- `details` (list of ErrorResponseDetailsItems, optional) — Per-field validation failures; present when code is VALIDATION_ERROR.
- `success` (boolean, optional, deprecated) — Deprecated. Use code === VALIDATION_ERROR.
- `errors` (list of any, optional, deprecated) — Deprecated. Raw zod issues; use details instead.

## Types

### Cart

- `id` (string, required)
- `checkoutUrl` (string, required)
- `currencyCode` (string, required)
- `locale` (string, required)
- `email` (string, required, nullable)
- `createdAt` (string, required)
- `updatedAt` (string, required)
- `total` (double, required)
- `subtotal` (double, required)
- `taxTotal` (double, required)
- `customerId` (string, required, nullable)
- `shippingAddressCountry` (string, required, nullable)
- `metadata` (CartMetadata, required)
- `countries` (list of CartCountry, required)
- `items` (list of CartItem, required)
- `reservationToken` (string, optional)
- `reservationExpiration` (string, optional)
- `discountTotal` (double, optional)
- `discountSubtotal` (double, optional)
- `discountTaxTotal` (double, optional)
- `discounts` (list of CartDiscount, optional)
- `pendingDiscountCodes` (list of string, optional)

### ErrorResponseDetailsItems

- `path` (string, required)
- `message` (string, required)

### CartMetadata

- `reservation_token` (string, optional)
- `reservation_expiration` (string, optional)
- `opportunity_number` (string, optional)
- `checkout_url` (string, optional)
- `account_key` (string, optional) — Present once an account token has bound the cart (on create, `PATCH /api/cart`, `/api/cart/identity` or `/api/cart/lines`): from then on every call on it needs that account’s token. A keyed hash, not personal data, but the same for one member on every cart.

### CartCountry

- `iso2` (string, required)
- `displayName` (string, required)

### CartItem

- `id` (string, required)
- `productType` (string, required)
- `thumbnail` (string, required, nullable)
- `description` (string, required, nullable)
- `metadata` (CartItemMetadata, required)
- `createdAt` (string, required)
- `updatedAt` (string, required)
- `title` (string, required)
- `quantity` (double, required)
- `price` (double, required)
- `basePrice` (double, required)
- `requiresShipping` (boolean, required)
- `taxLines` (list of CartItemTaxLine, required)
- `discountAllocations` (list of CartDiscountAllocation, optional)

### CartDiscount

- `promotionId` (string, required)
- `amount` (double, required)
- `code` (string, optional)
- `source` (enum, optional)
  - Allowed values: `CODE`, `AUTOMATIC`
- `removable` (boolean, optional)

### CartItemMetadata

- `date` (string, optional)
- `endTime` (string, optional)
- `startTime` (string, optional)
- `price` (double, optional)
- `isCustomPrice` (boolean, optional)
- `admissionCode` (string, optional)
- `scheduleNumber` (double, optional)
- `scheduleSelection` (enum, optional)
  - Allowed values: `userSelectedSchedule`, `nextAvailableSchedule`
- `productId` (string, optional)
- `externalId` (string, optional)
- `basePrice` (double, optional)
- `activationDate` (string, optional)
- `expirationDate` (string, optional)
- `birthdate` (string, optional)
- `subscription` (boolean, optional)
- `discounts` (list of string, optional)
- `reservationLineId` (string, optional)
- `voucherAmount` (double, optional)
- `membershipLegalText` (string, optional)
- `members` (CartItemMetadataMembers, optional)
- `member` (CartItemMetadataMember, optional)
- `children` (list of CartItemChildMetadata, optional)
- `parentProductId` (string, optional)

### CartItemTaxLine

- `code` (string, required)
- `rate` (double, required)

### CartDiscountAllocation

- `promotionId` (string, required)
- `amount` (double, required)
- `code` (string, optional)

### CartItemMetadataMembers

- `member_first_name` (string, required)
- `member_email` (string, required)

### CartItemMetadataMember

- `firstName` (string, optional)
- `lastName` (string, optional)
- `email` (string, optional)
- `phoneNo` (string, optional)
- `address` (string, optional)
- `city` (string, optional)
- `postCode` (string, optional)
- `country` (string, optional)
- `birthday` (string, optional)

### CartItemChildMetadata

- `productId` (string, optional)
- `externalId` (string, optional)
- `quantity` (double, optional)
- `date` (string, optional)
- `startTime` (string, optional)
- `endTime` (string, optional)
- `scheduleNumber` (double, optional)
- `scheduleSelection` (enum, optional)
  - Allowed values: `userSelectedSchedule`, `nextAvailableSchedule`
- `admissionCode` (string, optional)
- `price` (double, optional)
- `basePrice` (double, optional)
- `discounts` (list of string, optional)
- `voucherAmount` (double, optional)
- `taxRate` (double, optional)
- `total` (double, optional)
- `title` (string, optional)
- `reservationLineId` (string, optional)

## Examples

**Response**

```json
{
  "cart": {
    "id": "string",
    "checkoutUrl": "string",
    "currencyCode": "string",
    "locale": "string",
    "email": "string",
    "createdAt": "string",
    "updatedAt": "string",
    "total": 1.1,
    "subtotal": 1.1,
    "taxTotal": 1.1,
    "customerId": "string",
    "shippingAddressCountry": "string",
    "metadata": {
      "reservation_token": "string",
      "reservation_expiration": "string",
      "opportunity_number": "string",
      "checkout_url": "string",
      "account_key": "string"
    },
    "countries": [
      {
        "iso2": "string",
        "displayName": "string"
      }
    ],
    "items": [
      {
        "id": "string",
        "productType": "string",
        "thumbnail": "string",
        "description": "string",
        "metadata": {
          "date": "string",
          "endTime": "string",
          "startTime": "string",
          "price": 1.1,
          "isCustomPrice": true,
          "admissionCode": "string",
          "scheduleNumber": 1.1,
          "scheduleSelection": "userSelectedSchedule",
          "productId": "string",
          "externalId": "string",
          "basePrice": 1.1,
          "activationDate": "string",
          "expirationDate": "string",
          "birthdate": "string",
          "subscription": true,
          "discounts": [
            "string"
          ],
          "reservationLineId": "string",
          "voucherAmount": 1.1,
          "membershipLegalText": "string",
          "members": {
            "member_first_name": "string",
            "member_email": "string"
          },
          "member": {
            "firstName": "string",
            "lastName": "string",
            "email": "string",
            "phoneNo": "string",
            "address": "string",
            "city": "string",
            "postCode": "string",
            "country": "string",
            "birthday": "string"
          },
          "children": [
            {
              "productId": "string",
              "externalId": "string",
              "quantity": 1.1,
              "date": "string",
              "startTime": "string",
              "endTime": "string",
              "scheduleNumber": 1.1,
              "scheduleSelection": "userSelectedSchedule",
              "admissionCode": "string",
              "price": 1.1,
              "basePrice": 1.1,
              "discounts": [
                "string"
              ],
              "voucherAmount": 1.1,
              "taxRate": 1.1,
              "total": 1.1,
              "title": "string",
              "reservationLineId": "string"
            }
          ],
          "parentProductId": "string"
        },
        "createdAt": "string",
        "updatedAt": "string",
        "title": "string",
        "quantity": 1.1,
        "price": 1.1,
        "basePrice": 1.1,
        "requiresShipping": true,
        "taxLines": [
          {
            "code": "string",
            "rate": 1.1
          }
        ],
        "discountAllocations": [
          {
            "promotionId": "string",
            "amount": 1.1,
            "code": "string"
          }
        ]
      }
    ],
    "reservationToken": "string",
    "reservationExpiration": "string",
    "discountTotal": 1.1,
    "discountSubtotal": 1.1,
    "discountTaxTotal": 1.1,
    "discounts": [
      {
        "promotionId": "string",
        "amount": 1.1,
        "code": "string",
        "source": "CODE",
        "removable": true
      }
    ],
    "pendingDiscountCodes": [
      "string"
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.entria.app/api/cart"

headers = {"x-entria": "x-entria"}

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

print(response.json())
```

```javascript
const url = 'https://api.entria.app/api/cart';
const options = {method: 'POST', headers: {'x-entria': 'x-entria'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.entria.app/api/cart"

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

	req.Header.Add("x-entria", "x-entria")

	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.entria.app/api/cart")

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

request = Net::HTTP::Post.new(url)
request["x-entria"] = 'x-entria'

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.entria.app/api/cart")
  .header("x-entria", "x-entria")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.entria.app/api/cart', [
  'headers' => [
    'x-entria' => 'x-entria',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.entria.app/api/cart");
var request = new RestRequest(Method.POST);
request.AddHeader("x-entria", "x-entria");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["x-entria": "x-entria"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.entria.app/api/cart")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```