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

# Create an order

POST https://www.lettbestilt.no/api/v1/orders
Content-Type: application/json

Creates a takeaway order for pickup or delivery. The server prices every line from its own data and ignores any prices you send. Show the `totals` it returns.

- **Online payment** (`paymentMethod: "STRIPE"`): the response includes `stripeUrl`, SagaPay's hosted payment page. Redirect the customer there. The field name is historical and does not mean Stripe.
- **Cash** (`paymentMethod: "CASH"`): there is no payment link, and the order goes straight to the kitchen.
- **Retries**: send an `Idempotency-Key` header and retry with the same key after a network error. A replay returns the original order instead of creating a new one.
- **Price check**: send `expectedTotal`, the total you showed the customer, to get `409 PRICE_CHANGED` instead of an order at a higher price.

Business rules are checked here as well: opening hours, menu schedules, sold-out products, required add-ons, delivery zones and coupon rules. When one fails, `error.message` explains it in Norwegian and can be shown to the customer.

Table reservations are not orders. `orderType` only accepts `TAKEAWAY`, and `DINE_IN` fails with `422 VALIDATION_FAILED`; use `POST /reservations` instead.

Rate limit: 10 requests per 60 seconds per slug and IP. Walkthrough: [Build an ordering flow](/build-an-ordering-flow).

Reference: https://docs.lettbestilt.no/api-reference/orders/create-order

## Authentication

- `Authorization` header (bearer token, required) — Either this or a trusted browser origin. The restaurant's API key, sent as `Authorization: Bearer lbs_…`. Use it from your server only, never in browser code. Keys are issued per restaurant by LettBestilt.
- `Origin` header (required) — Either this or an API key. No key is needed when the request's `Origin` header is trusted for this restaurant: `https://{slug}.lettbestilt.no`, a verified domain of the restaurant, or a partner origin LettBestilt has bound to the restaurant. Browsers set `Origin` themselves; it is not something you configure. Not accepted by `GET /site-gate`, which requires an API key.

## Request

### Query parameters

- `slug` (string, required) — The restaurant's slug.
- `successUrl` (string, optional) — Where the customer returns after paying. Put `{TOKEN}` in the URL to get the order's `publicToken` back, for example `https://www.pizzaroma.no/order/{TOKEN}`. Must be `https` on a verified domain or on lettbestilt.no; anything else fails with `400 INVALID_SUCCESS_URL`. If you leave it out, the customer returns to `/order/{TOKEN}?payment=success` on the restaurant's domain.
- `cancelUrl` (string, optional) — Where the customer returns if they cancel or the payment fails. Same rules as `successUrl` (`400 INVALID_CANCEL_URL`). If you leave it out, the customer returns to the front page of the restaurant's own domain, or to checkout on `{slug}.lettbestilt.no`.

### Headers

- `Idempotency-Key` (string, optional) — Optional. 16–128 URL-safe characters (`a-z`, `A-Z`, `0-9`, `_`, `-`); a UUID works well. A request with a key that was already used for this restaurant returns that earlier order and its payment link instead of creating a new one. The body of the replay is not compared, so create a new key for every new checkout attempt.

### Body (application/json)

This endpoint expects a CreateOrderRequest.

- `items` (list of OrderItem, required) — The cart, 1–100 lines.
- `fulfillment` (enum, required) — Pickup or delivery. Check `restaurant.capabilities` for what the restaurant offers.
  - Allowed values: `PICKUP`, `DELIVERY`
- `customerName` (string, required) — The customer's name.
- `customerEmail` (string, required) — The order confirmation is sent here.
- `paymentMethod` (enum, required) — `STRIPE` for online payment: the response includes `stripeUrl`, SagaPay's hosted page, where the customer chooses card, Vipps or another enabled method. `CASH` is paid at pickup or delivery. `VIPPS` is only accepted for old direct-Vipps integrations.
  - Allowed values: `STRIPE`, `CASH`, `VIPPS`
- `orderType` (enum, optional, default: TAKEAWAY) — Always `TAKEAWAY` (15 % VAT on food). For table reservations, use `POST /reservations` instead.
  - Allowed values: `TAKEAWAY`
- `customerPhone` (string, optional) — The customer's phone number.
- `deliveryAddress` (string, optional) — The street address for delivery.
- `deliveryCity` (string, optional) — The postal town for delivery.
- `deliveryPostalCode` (string, optional) — Four digits. Used to match postal-code delivery zones (`POSTAL_CODES`).
- `deliveryLat` (double, optional) — Latitude of the delivery address. Required to match radius-based delivery zones (`RADIUS`); postal-code zones only need `deliveryPostalCode`. Get it from `GET /address-search`.
- `deliveryLng` (double, optional) — Longitude of the delivery address. Required to match radius-based delivery zones (`RADIUS`); postal-code zones only need `deliveryPostalCode`.
- `deliveryNotes` (string, optional) — A note for the driver, for example a door code.
- `pickupNotes` (string, optional) — A note for the restaurant about the pickup.
- `requestedPickupAt` (datetime, optional) — Optional. The pickup or delivery time for a pre-order (ISO 8601, UTC). Leave it out for as soon as possible. Opening hours, menu schedules and coupon rules are checked against this time.
- `couponCode` (string, optional) — A coupon code the customer typed. When a code is sent, automatic promotions are not applied.
- `expectedTotal` (integer, optional) — Optional. The total in øre you showed the customer. If the server's total is higher, the order is rejected with `409 PRICE_CHANGED` and nothing is created. A lower total is accepted (the customer pays less than they saw), so an automatic promotion you could not predict never blocks checkout.
- `locale` (enum, optional) — The language of emails to the customer. Defaults to `nb`.
  - Allowed values: `nb`, `en`
- `consentGivenAt` (datetime, optional) — Optional. When the customer gave marketing consent (ISO 8601).
- `marketingOptIn` (boolean, optional) — The customer's consent to marketing, given at checkout.
- `attributionCampaignId` (string, optional) — Campaign attribution: the value of `?lb_campaign=<id>` from a LettBestilt campaign link. Pass it on unchanged at checkout, and the order counts as a conversion for the campaign. Optional metadata: an invalid or unknown ID is dropped silently and never blocks the order.
- `buyerCompanyName` (string, optional) — B2B: the company name on the receipt.
- `buyerOrgNumber` (string, optional) — B2B: Norwegian organization number, exactly 9 digits. Spaces are removed.

## Response

### 200

The order was created, or an earlier order was returned for the same `Idempotency-Key`.

- `orderId` (string, required) — The order's internal ID. Keep it for support requests, but do not put it in URLs.
- `publicToken` (string, required) — Safe to put in URLs and share with the customer. Use it with `GET /orders/{token}`.
- `totals` (OrderTotals, required) — The authoritative totals, calculated by the server. Your own prices are only for display. Show these to the customer before you redirect to payment.
- `stripeUrl` (string, optional) — SagaPay's hosted payment page, for online orders. Redirect the customer here; they choose card, Vipps or another enabled method on the page. The field name is historical and does not say which provider is used.
- `vippsUrl` (string, optional, deprecated) — Only for old direct-Vipps integrations. Use `stripeUrl` for online payment.

## Errors

### 400 Bad Request Error

`MISSING_SLUG`, `INVALID_JSON`, `INVALID_SUCCESS_URL`, `INVALID_CANCEL_URL`, or `BAD_REQUEST`: an invalid `Idempotency-Key`, the restaurant is closed at the requested time, or it does not offer the chosen fulfillment or payment method.

- `error` (ErrorBody, required)

### 401 Unauthorized Error

`UNAUTHORIZED`: missing or invalid API key, and the request does not come from a trusted browser origin.

- `error` (ErrorBody, required)

### 404 Not Found Error

`RESTAURANT_NOT_FOUND`: no live restaurant has this slug.

- `error` (ErrorBody, required)

### 409 Conflict Error

No new order was created, and `publicToken` is never returned. `PRICE_CHANGED`: you sent `expectedTotal` and the server's total is higher; `error.details` is `{ expectedTotal, actualTotal, currency }`. Fetch the menu again, show the new total and let the customer confirm. `PAYMENT_PENDING`: a replay of an `Idempotency-Key` whose order was just created while its payment link is still being made; wait a couple of seconds and retry with the same key. `PAYMENT_INCOMPLETE`: the same, but the order is too old for the first call to still be running, so the payment link was never created (`error.details` is `{ orderId }`); start again with a new key. `IDEMPOTENCY_CONFLICT`: the `Idempotency-Key` was already used by a table reservation. Orders and reservations share one key space per restaurant; create a new key.

- `error` (ErrorBody, required)

### 422 Unprocessable Entity Error

`VALIDATION_FAILED`: the body failed validation (`error.details.issues` lists the fields), or the order breaks a rule, such as a sold-out product, a missing required add-on, an address outside the delivery zones or a coupon that does not apply; `error.message` explains it in Norwegian. `FULFILLMENT_NOT_ALLOWED`: a product can only be picked up or only be delivered, and the order asked for the other; `error.details` is `{ productId, productName, allowedFulfillment, requestedFulfillment }`.

- `error` (ErrorBody, required)

### 429 Too Many Requests Error

`RATE_LIMITED`: more than 10 orders in 60 seconds for this slug and IP. See `Retry-After`.

- `error` (ErrorBody, required)

### 502 Bad Gateway Error

`PAYMENT_PROVIDER_INVALID`: the payment provider returned an unusable payment link.

- `error` (ErrorBody, required)

### 503 Service Unavailable Error

`INTERNAL_ERROR`: the payment provider did not respond. The order was saved without a payment link. Start again with a new `Idempotency-Key`, or offer cash.

- `error` (ErrorBody, required)

## Types

### OrderItem

- `productId` (string, required) — A product ID from the menu.
- `quantity` (integer, required) — Number of units, 1–99.
- `variantId` (string, optional) — The chosen variant, if the product has variants.
- `addonIds` (list of string, optional) — The chosen add-ons. At most 50.
- `notes` (string, optional) — A note for the kitchen about this line.
- `comboSelections` (list of ComboSelection, optional) — Required when `productId` refers to a combo product (`isCombo: true`). Total entries per `slotId` must satisfy that slot's `minQty`/`maxQty`. Server re-prices and validates.

### OrderTotals

The authoritative totals, calculated by the server. Your own prices are only for display. Show these to the customer before you redirect to payment.

- `subtotal` (integer, required) — The sum of all lines including add-ons, in øre.
- `deliveryFee` (integer, required) — The delivery fee in øre (0 for pickup).
- `discount` (integer, required) — The applied coupon or automatic promotion, in øre.
- `total` (integer, required) — `subtotal + deliveryFee − discount`, in øre.
- `currency` (string, required) — The restaurant's currency, for example "NOK".

### ErrorBody

- `code` (enum, required) — A machine-readable error code.
  - Allowed values: `MISSING_SLUG`, `MISSING_TOKEN`, `INVALID_JSON`, `INVALID_SUCCESS_URL`, `INVALID_CANCEL_URL`, `VALIDATION_FAILED`, `RESTAURANT_NOT_FOUND`, `ORDER_NOT_FOUND`, `RATE_LIMITED`, `BAD_REQUEST`, `UNAUTHORIZED`, `FORBIDDEN`, `POPUP_NOT_AVAILABLE`, `PRICE_CHANGED`, `PAYMENT_INCOMPLETE`, `PAYMENT_PENDING`, `PAYMENT_PROVIDER_INVALID`, `FULFILLMENT_NOT_ALLOWED`, `IDEMPOTENCY_CONFLICT`, `DINE_IN_DISABLED`, `PARTY_TOO_LARGE`, `TOO_EARLY`, `INTERNAL_ERROR`
- `message` (string, required) — A human-readable explanation. Often in Norwegian, and for business rules usually suitable to show the customer.
- `details` (any, optional) — Extra data for some codes, for example `issues` for `VALIDATION_FAILED` or the totals for `PRICE_CHANGED`.

### ComboSelection

One chosen product for one combo slot. Submit one entry per pick — for `maxQty: 2`, send two entries with the same `slotId`.

- `slotId` (string, required)
- `productId` (string, required)
- `variantId` (string, optional)
- `addonIds` (list of string, optional)

## Examples

**Request**

```json
{
  "items": [
    {
      "productId": "cm1pza0001margherita",
      "quantity": 2,
      "variantId": "cm1pza0002medium",
      "addonIds": [
        "cm1pza0003extracheese"
      ],
      "notes": "Godt stekt"
    }
  ],
  "fulfillment": "PICKUP",
  "customerName": "Kari Nordmann",
  "customerEmail": "kari@example.com",
  "paymentMethod": "STRIPE",
  "customerPhone": "+4799999999",
  "expectedTotal": 33800,
  "locale": "nb"
}
```

**Response**

```json
{
  "orderId": "cm2ord0001abcdefghijklmn",
  "publicToken": "cm2tok0001abcdefghijklmn",
  "totals": {
    "subtotal": 33800,
    "deliveryFee": 0,
    "discount": 0,
    "total": 33800,
    "currency": "NOK"
  },
  "stripeUrl": "https://pay.example.com/checkout/abc123"
}
```

**SDK Code**

```python Orders_createOrder_example
import requests

url = "https://www.lettbestilt.no/api/v1/orders"

querystring = {"slug":"slug"}

payload = {
    "items": [
        {
            "productId": "cm1pza0001margherita",
            "quantity": 2,
            "variantId": "cm1pza0002medium",
            "addonIds": ["cm1pza0003extracheese"],
            "notes": "Godt stekt"
        }
    ],
    "fulfillment": "PICKUP",
    "customerName": "Kari Nordmann",
    "customerEmail": "kari@example.com",
    "paymentMethod": "STRIPE",
    "customerPhone": "+4799999999",
    "expectedTotal": 33800,
    "locale": "nb"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Orders_createOrder_example
const url = 'https://www.lettbestilt.no/api/v1/orders?slug=slug';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"items":[{"productId":"cm1pza0001margherita","quantity":2,"variantId":"cm1pza0002medium","addonIds":["cm1pza0003extracheese"],"notes":"Godt stekt"}],"fulfillment":"PICKUP","customerName":"Kari Nordmann","customerEmail":"kari@example.com","paymentMethod":"STRIPE","customerPhone":"+4799999999","expectedTotal":33800,"locale":"nb"}'
};

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

```go Orders_createOrder_example
package main

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

func main() {

	url := "https://www.lettbestilt.no/api/v1/orders?slug=slug"

	payload := strings.NewReader("{\n  \"items\": [\n    {\n      \"productId\": \"cm1pza0001margherita\",\n      \"quantity\": 2,\n      \"variantId\": \"cm1pza0002medium\",\n      \"addonIds\": [\n        \"cm1pza0003extracheese\"\n      ],\n      \"notes\": \"Godt stekt\"\n    }\n  ],\n  \"fulfillment\": \"PICKUP\",\n  \"customerName\": \"Kari Nordmann\",\n  \"customerEmail\": \"kari@example.com\",\n  \"paymentMethod\": \"STRIPE\",\n  \"customerPhone\": \"+4799999999\",\n  \"expectedTotal\": 33800,\n  \"locale\": \"nb\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Orders_createOrder_example
require 'uri'
require 'net/http'

url = URI("https://www.lettbestilt.no/api/v1/orders?slug=slug")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"items\": [\n    {\n      \"productId\": \"cm1pza0001margherita\",\n      \"quantity\": 2,\n      \"variantId\": \"cm1pza0002medium\",\n      \"addonIds\": [\n        \"cm1pza0003extracheese\"\n      ],\n      \"notes\": \"Godt stekt\"\n    }\n  ],\n  \"fulfillment\": \"PICKUP\",\n  \"customerName\": \"Kari Nordmann\",\n  \"customerEmail\": \"kari@example.com\",\n  \"paymentMethod\": \"STRIPE\",\n  \"customerPhone\": \"+4799999999\",\n  \"expectedTotal\": 33800,\n  \"locale\": \"nb\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://www.lettbestilt.no/api/v1/orders?slug=slug")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"items\": [\n    {\n      \"productId\": \"cm1pza0001margherita\",\n      \"quantity\": 2,\n      \"variantId\": \"cm1pza0002medium\",\n      \"addonIds\": [\n        \"cm1pza0003extracheese\"\n      ],\n      \"notes\": \"Godt stekt\"\n    }\n  ],\n  \"fulfillment\": \"PICKUP\",\n  \"customerName\": \"Kari Nordmann\",\n  \"customerEmail\": \"kari@example.com\",\n  \"paymentMethod\": \"STRIPE\",\n  \"customerPhone\": \"+4799999999\",\n  \"expectedTotal\": 33800,\n  \"locale\": \"nb\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.lettbestilt.no/api/v1/orders?slug=slug', [
  'body' => '{
  "items": [
    {
      "productId": "cm1pza0001margherita",
      "quantity": 2,
      "variantId": "cm1pza0002medium",
      "addonIds": [
        "cm1pza0003extracheese"
      ],
      "notes": "Godt stekt"
    }
  ],
  "fulfillment": "PICKUP",
  "customerName": "Kari Nordmann",
  "customerEmail": "kari@example.com",
  "paymentMethod": "STRIPE",
  "customerPhone": "+4799999999",
  "expectedTotal": 33800,
  "locale": "nb"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Orders_createOrder_example
using RestSharp;

var client = new RestClient("https://www.lettbestilt.no/api/v1/orders?slug=slug");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"items\": [\n    {\n      \"productId\": \"cm1pza0001margherita\",\n      \"quantity\": 2,\n      \"variantId\": \"cm1pza0002medium\",\n      \"addonIds\": [\n        \"cm1pza0003extracheese\"\n      ],\n      \"notes\": \"Godt stekt\"\n    }\n  ],\n  \"fulfillment\": \"PICKUP\",\n  \"customerName\": \"Kari Nordmann\",\n  \"customerEmail\": \"kari@example.com\",\n  \"paymentMethod\": \"STRIPE\",\n  \"customerPhone\": \"+4799999999\",\n  \"expectedTotal\": 33800,\n  \"locale\": \"nb\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Orders_createOrder_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "items": [
    [
      "productId": "cm1pza0001margherita",
      "quantity": 2,
      "variantId": "cm1pza0002medium",
      "addonIds": ["cm1pza0003extracheese"],
      "notes": "Godt stekt"
    ]
  ],
  "fulfillment": "PICKUP",
  "customerName": "Kari Nordmann",
  "customerEmail": "kari@example.com",
  "paymentMethod": "STRIPE",
  "customerPhone": "+4799999999",
  "expectedTotal": 33800,
  "locale": "nb"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://www.lettbestilt.no/api/v1/orders?slug=slug")! 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()
```