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

# Create Cart

POST https://api.papertracc.com/v1/store/cart
Content-Type: application/json

Opens a cart for a shopper and returns its token. The cart is anonymous: no customer is attached until checkout. Send `items` to add the first lines in the same call. The body is optional.

For a product whose `request_form` is in `BUY_NOW` mode, send `answers` and `needed_by` with the item. A product sold through order requests returns `422` here; use Create Request instead.

**Keys:** public key or secret key.

Reference: https://api-docs.papertracc.com/storefront/cart/create-cart

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.
- `identity` header (required) — The identity for the active workspace.

## Servers

- `https://api.papertracc.com/v1` (Production, default)
- `https://api.papertracc.com/rc-1` (Release Candidate 1)

## Request

### Headers

- `client-ip` (string, optional) — The shopper's IP address. Read only when the request is signed with a secret key, so a server calling on behalf of many shoppers does not share one rate limit. Ignored for public keys.

### Body (application/json)

This endpoint expects a CreateCartRequest.

- `country` (string, optional) — Market to price the cart for, as a two- or three-letter country code (`NG` or `NGA`). Defaults to the channel's default country. Fixed for the life of the cart.
- `items` (list of CartItemInput, optional) — Lines to add straight away.

## Response

### 201

Successfully created cart

- `status` (boolean, required) — Always `true` on success.
- `message` (string, required) — Human-readable outcome.
- `data` (CartOpened, required)

## Errors

### 400 Bad Request Error

The `channel` header is missing, the body is not valid JSON, or a field failed validation.

- `status` (boolean, required) — Always `false` on a failed request.
- `message` (string, required) — What went wrong, written for the shopper or the developer.
- `error_code` (string, optional) — Present on `402` responses.

### 401 Unauthorized Error

The API key is missing or invalid, the key owner is no longer an active member of the organisation, or the key owner is not a member of the workspace in the `identity` header.

- `status` (boolean, required) — Always `false` on a failed request.
- `message` (string, required) — What went wrong, written for the shopper or the developer.
- `error_code` (string, optional) — Present on `402` responses.

### 402 Payment Required Error

The workspace's subscription plan does not include the Open API.

- `status` (boolean, required) — Always `false` on a failed request.
- `message` (string, required) — What went wrong, written for the shopper or the developer.
- `error_code` (string, optional) — Present on `402` responses.

### 404 Not Found Error

The sales channel, or the record the request names, does not exist or is not published to this channel.

- `status` (boolean, required) — Always `false` on a failed request.
- `message` (string, required) — What went wrong, written for the shopper or the developer.
- `error_code` (string, optional) — Present on `402` responses.

### 422 Unprocessable Entity Error

The request was understood but a rule stopped it. The message says which.

- `status` (boolean, required) — Always `false` on a failed request.
- `message` (string, required) — What went wrong, written for the shopper or the developer.
- `error_code` (string, optional) — Present on `402` responses.

### 429 Too Many Requests Error

Too many attempts from this shopper or on this store. Wait for the time in the message before trying again.

- `status` (boolean, required) — Always `false` on a failed request.
- `message` (string, required) — What went wrong, written for the shopper or the developer.
- `error_code` (string, optional) — Present on `402` responses.

## Types

### CartItemInput

- `variant_id` (string, required) — Variant to add.
- `quantity` (double, optional) — Defaults to `1`. Decimals are accepted for products sold by measure.
- `answers` (list of RequestAnswerInput, optional) — Answers to the product's request form when it is in `BUY_NOW` mode. Pictures cannot be sent here.
- `needed_by` (date, optional) — Required for products with a `BUY_NOW` request form: the date the shopper needs it by, no earlier than the variant's lead time. Refused on a day the merchant is fully booked.

### CartOpened

- `token` (string, required) — Cart token. Returned once. Store it and send it in the `cart-token` header on every later cart request.
- `cart` (Cart, required)

### RequestAnswerInput

An answer to one form question. Send only the field that matches the question's `type`.

- `key` (string, required) — The question's `key`.
- `text` (string, optional) — For `TEXT` and `LONG_TEXT`. Plain text; markup is removed.
- `number` (double, optional) — For `NUMBER`.
- `unit` (enum, optional) — For `MEASUREMENTS`. Defaults to `CM`.
  - Allowed values: `CM`, `IN`
- `choices` (list of string, optional) — For `CHOICE`: option labels. One unless the question allows `multiple`.
- `yes` (boolean, optional) — For `YES_NO`.
- `measurements` (list of MeasurementValueInput, optional) — For `MEASUREMENTS`.
- `files` (list of string, optional) — For `PHOTO`: `id`s from Upload Request Picture. Only on Create Request; a cart line refuses pictures.
- `save_as` (string, optional) — For `MEASUREMENTS` on Create Request: also save these measurements to the signed-in shopper's account under this name.

### Cart

- `currency` (string, required) — ISO 4217 code. Follows the price book of the cart's country.
- `country_code` (string, required, nullable) — Market the cart was opened for, as a three-letter code.
- `lines` (list of CartLine, required)
- `items_count` (integer, required) — Units in the cart. A measured line, such as 1.5 kg, counts as one.
- `subtotal` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `discount_total` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `tax_total` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `total` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `discounts` (list of CartDiscount, required)
- `promotion_code` (string, required, nullable)
- `promotion_issue` (CartIssue, required, nullable) — Why the promotion code on the cart is not applying.
- `updated_at` (datetime, required)

### MeasurementValueInput

- `label` (string, required)
- `value` (double, required) — Rounded to 2 decimal places.

### CartLine

- `id` (string, required) — Line id. Use it to change the quantity or remove the line.
- `variant_id` (string, required)
- `product_id` (string, required)
- `handle` (string, required) — Product handle.
- `title` (string, required) — Product title.
- `variant_title` (string, required) — Variant title.
- `sku` (string, required) — Stock keeping unit.
- `image` (Image, required, nullable)
- `quantity` (string, required) — Decimal quantity as a string.
- `unit` (string, required) — Unit the quantity is counted in.
- `unit_price` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `compare_at_price` (string, required, nullable)
- `subtotal` (string, required) — Unit price times quantity, before discounts.
- `discount` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `tax` (string, required) — Decimal amount as a string, in the currency shown alongside it.
- `total` (string, required) — What the shopper pays for the line.
- `available` (string, required, nullable) — Stock on hand at the fulfilling location. Informational: whether a shortfall blocks the cart depends on the workspace's stock settings.
- `sell_mode` (enum, required) — How this line will ship. `BACKORDER` only when the cart holds more than is in stock. Show the wait before the shopper checks out, because they pay up front.
  - Allowed values: `STOCK`, `BACKORDER`, `PREORDER`, `MADE_TO_ORDER`
- `lead_time_days` (integer, required, nullable) — Days from the order until it ships (`BACKORDER`) or is ready (`MADE_TO_ORDER`). `null` when the merchant has not set one, and for `STOCK` and `PREORDER`.
- `release_date` (date, required, nullable) — Date a pre-order ships from. Set only when `sell_mode` is `PREORDER`.
- `needed_by` (date, required, nullable) — Date the shopper needs a made-to-order line by. Set only for products with a `BUY_NOW` request form.
- `add_on` (string, required, nullable) — Extra per unit for priced options the shopper chose, already included in `unit_price`.
- `answers` (list of CartLineAnswer, required) — The shopper's answers to the product's request form. Empty for other lines.

### CartDiscount

- `title` (string, required) — Promotion name.
- `code` (string, required, nullable)
- `amount` (string, required) — Decimal amount as a string, in the currency shown alongside it.

### CartIssue

Why the promotion code on the cart is not applying.

- `code` (string, required)
- `reason` (string, required) — Machine-readable reason.
- `message` (string, required) — Explanation that can be shown to the shopper.

### Image

- `id` (string, required)
- `src` (string, required) — Absolute image URL.
- `alt` (string, required) — Alternative text. Falls back to the file name.
- `type` (string, required) — Media type.
- `width` (integer, required) — Width in pixels, `0` when unknown.
- `height` (integer, required) — Height in pixels, `0` when unknown.

### CartLineAnswer

- `label` (string, required) — The question.
- `value` (string, required) — The answer, written out for display.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "status": true,
  "message": "Successfully created cart",
  "data": {
    "token": "string",
    "cart": {
      "currency": "NGN",
      "country_code": "NGA",
      "lines": [
        {
          "id": "string",
          "variant_id": "string",
          "product_id": "string",
          "handle": "silk-scarf",
          "title": "Silk scarf",
          "variant_title": "Blue",
          "sku": "SCARF-BLUE",
          "image": {
            "id": "string",
            "src": "https://cdn.papertracc.com/projects/acme/products/silk-scarf.jpg",
            "alt": "Blue silk scarf",
            "type": "image",
            "width": 1,
            "height": 1
          },
          "quantity": "2",
          "unit": "EACH",
          "unit_price": "25000.00",
          "compare_at_price": "string",
          "subtotal": "50000.00",
          "discount": "0.00",
          "tax": "0.00",
          "total": "50000.00",
          "available": "string",
          "sell_mode": "STOCK",
          "lead_time_days": 14,
          "release_date": "2026-12-12",
          "needed_by": "2026-12-01",
          "add_on": "5000.00",
          "answers": [
            {
              "label": "Fabric",
              "value": "Gold embroidery"
            }
          ]
        }
      ],
      "items_count": 1,
      "subtotal": "50000.00",
      "discount_total": "0.00",
      "tax_total": "0.00",
      "total": "50000.00",
      "discounts": [
        {
          "title": "Launch week",
          "code": "string",
          "amount": "5000.00"
        }
      ],
      "promotion_code": "string",
      "promotion_issue": {
        "code": "string",
        "reason": "string",
        "message": "string"
      },
      "updated_at": "2024-01-15T09:30:00Z"
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.papertracc.com/v1/store/cart"

payload = {}
headers = {
    "channel": "channel",
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.papertracc.com/v1/store/cart';
const options = {
  method: 'POST',
  headers: {
    channel: 'channel',
    Authorization: 'Bearer <apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{}'
};

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.papertracc.com/v1/store/cart"

	payload := strings.NewReader("{}")

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

	req.Header.Add("channel", "channel")
	req.Header.Add("Authorization", "Bearer <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.papertracc.com/v1/store/cart")

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

request = Net::HTTP::Post.new(url)
request["channel"] = 'channel'
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.papertracc.com/v1/store/cart")
  .header("channel", "channel")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.papertracc.com/v1/store/cart', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
    'channel' => 'channel',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.papertracc.com/v1/store/cart");
var request = new RestRequest(Method.POST);
request.AddHeader("channel", "channel");
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "channel": "channel",
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.papertracc.com/v1/store/cart")! 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()
```