> 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 a restaurant

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

**Partner key alone.** With a test key, creates a sandbox: it is never live, has no ordering page on `{slug}.lettbestilt.no`, and a partner can have up to 20. Live partner keys are not available yet.

The response contains a new restaurant key with full access, in plain text **once**, in `restaurantKey.key`. Store it right away: every call about this restaurant needs it, and it is never shown again.

**`Idempotency-Key` is required** and is scoped per partner for 30 days:

* Same key, same body: `200` with the same restaurant, `restaurantKey: null`, `replayed: true`, a `message`, and the header `Idempotent-Replayed: true`. The restaurant key is not shown again. If you lost it (for example because the first response never arrived), create a new key for the restaurant in the partner portal.
* Same key, different body or environment, or a restaurant that has since been deleted or moved: `409 IDEMPOTENCY_CONFLICT`.

A slug that is already taken gives `409 SLUG_TAKEN` and does not count towards the limit. At most 10 creations per hour per partner key, and 20 per partner. Replays do not count.

Reference: https://docs.lettbestilt.no/api-reference/partner/create-partner-restaurant

## Authentication

- `Authorization` header (bearer token, required) — The partner key, sent as `Authorization: Bearer lbp_test_…`. Created in the partner portal under **Partner key**. It belongs to the partner, not to a restaurant, and only works against `/api/v1/partner`. Server to server only: a request with an `Origin` header is rejected with `403 FORBIDDEN`. A test key sees and creates only sandboxes; live partner keys are not available yet. A revoked key, a restaurant key (`lbs_…`) here, or a suspended or archived partner returns `401 UNAUTHORIZED`; an expired key returns `401 KEY_EXPIRED`.

## Request

### Headers

- `Idempotency-Key` (string, required) — Required. 16–128 URL-safe characters (`a-z`, `A-Z`, `0-9`, `_`, `-`). Use one new key, for example a UUID, per restaurant you want to create.

### Body (application/json)

This endpoint expects a PartnerRestaurantCreate.

- `name` (string, required) — The restaurant's name, 2–80 characters.
- `slug` (string, required) — Lowercase letters, digits and hyphens, 2–32 characters. Becomes `{slug}.lettbestilt.no` and the restaurant's key in `/api/v1`. Stored in lowercase.
- `email` (string, required) — The restaurant's contact email. For a sandbox, use your own address.
- `phone` (string, optional) — Optional phone number.
- `orgNumber` (string, optional) — Optional organization number.
- `pickupEnabled` (boolean, optional, default: true) — Offer pickup. Defaults to `true`.
- `deliveryEnabled` (boolean, optional, default: false) — Offer delivery. Defaults to `false`.

## Response

### 200

Replay of the same `Idempotency-Key`: the same restaurant, `restaurantKey: null`, `replayed: true` and a `message`.

- `data` (PartnerRestaurant, required) — A restaurant as the partner key alone sees it. No contact details, payment status or customer data.
- `restaurantKey` (PartnerNewRestaurantKey, required, nullable) — The new restaurant key with full access, in plain text once (`201`). `null` on a replay (`200`): the key is never shown again. If you lost it, create a new key for the restaurant in the partner portal.
- `replayed` (boolean, optional) — `true` when the response is a replay of the same `Idempotency-Key`.
- `message` (string, optional) — On a replay, why the key is missing and where to create a new one.

### 201

Created. Store `restaurantKey.key` now; it is not shown again.

- `data` (PartnerRestaurant, required) — A restaurant as the partner key alone sees it. No contact details, payment status or customer data.
- `restaurantKey` (PartnerNewRestaurantKey, required, nullable) — The new restaurant key with full access, in plain text once (`201`). `null` on a replay (`200`): the key is never shown again. If you lost it, create a new key for the restaurant in the partner portal.
- `replayed` (boolean, optional) — `true` when the response is a replay of the same `Idempotency-Key`.
- `message` (string, optional) — On a replay, why the key is missing and where to create a new one.

## Errors

### 400 Bad Request Error

`IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing or invalid. `INVALID_JSON`: the body is not valid JSON.

- `error` (ErrorBody, required)

### 401 Unauthorized Error

`UNAUTHORIZED`: missing, invalid or revoked partner key, a restaurant key in `Authorization`, or a suspended or archived partner. `KEY_EXPIRED`: the partner key is past its expiry date.

- `error` (ErrorBody, required)

### 403 Forbidden Error

`FORBIDDEN`: the request has an `Origin` header; the partner API is server to server only.

- `error` (ErrorBody, required)

### 409 Conflict Error

`SLUG_TAKEN`: the slug is in use. `SANDBOX_LIMIT`: the partner already has 20 sandboxes; delete one first. `IDEMPOTENCY_CONFLICT`: see above.

- `error` (ErrorBody, required)

### 422 Unprocessable Entity Error

`VALIDATION_FAILED`: `error.details.issues` lists the fields.

- `error` (ErrorBody, required)

### 429 Too Many Requests Error

`RATE_LIMITED`: more than 120 calls per minute for this partner key, or more than 10 creations per hour per key (20 per partner). See `Retry-After`.

- `error` (ErrorBody, required)

## Types

### PartnerRestaurant

A restaurant as the partner key alone sees it. No contact details, payment status or customer data.

- `slug` (string, required) — The restaurant's identifier everywhere in `/api/v1`.
- `name` (string, required)
- `environment` (enum, required) — `TEST` for a sandbox, `LIVE` for a real restaurant.
  - Allowed values: `TEST`, `LIVE`
- `sandbox` (boolean, required) — `true` for a sandbox.
- `live` (boolean, required) — A real restaurant that has gone live and takes orders. A new real restaurant is not live until its owner has signed and set it live. Always `false` for sandboxes; they accept test orders in `/api/v1` anyway.
- `archived` (boolean, required) — Archived with `DELETE` (real restaurants only). Only LettBestilt can restore it.
- `createdAt` (datetime, required)

### PartnerNewRestaurantKey

A new restaurant key with the plain-text key in `key`, shown once. The same shape on creation and rotation.

- `id` (string, required)
- `name` (string, required)
- `last4` (string, required)
- `environment` (enum, required)
  - Allowed values: `TEST`, `LIVE`
- `scopes` (list of string, required)
- `key` (string, required) — `lbs_test_…` or `lbs_live_…`. Store it now; it is never shown again.

### 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`, `INSUFFICIENT_SCOPE`, `KEY_EXPIRED`, `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`, `PARTNER_AGREEMENT_REQUIRED`, `IDEMPOTENCY_KEY_REQUIRED`, `SLUG_TAKEN`, `SANDBOX_LIMIT`, `RETENTION`, `RESTAURANT_ARCHIVED`, `KEY_NOT_FOUND`, `KEY_IN_USE`, `WEBHOOK_NOT_FOUND`, `WEBHOOK_LIMIT`, `CHANGED`
- `message` (string, required) — A human-readable explanation. Often in Norwegian, and for business rules usually suitable to show the customer.
- `requestId` (string, required) — The same value as the `X-Request-Id` response header. Search for it in the API log in the partner portal, and include it when you contact LettBestilt.
- `details` (any, optional) — Extra data for some codes, for example `issues` for `VALIDATION_FAILED`, the totals for `PRICE_CHANGED` or `requiredScope` for `INSUFFICIENT_SCOPE`.

## Examples

### Partner_createPartnerRestaurant_example

**Request**

```json
{
  "name": "Pizza Roma (test)",
  "slug": "pizzaroma-test",
  "email": "dev@byraet.no",
  "pickupEnabled": true,
  "deliveryEnabled": false
}
```

**Response**

```json
{
  "data": {
    "slug": "string",
    "name": "string",
    "environment": "TEST",
    "sandbox": true,
    "live": true,
    "archived": true,
    "createdAt": "2024-01-15T09:30:00Z"
  },
  "restaurantKey": {
    "id": "string",
    "name": "string",
    "last4": "string",
    "environment": "TEST",
    "scopes": [
      "string"
    ],
    "key": "string"
  },
  "replayed": true,
  "message": "string"
}
```

**SDK Code**

```python Partner_createPartnerRestaurant_example
import requests

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

payload = {
    "name": "Pizza Roma (test)",
    "slug": "pizzaroma-test",
    "email": "dev@byraet.no",
    "pickupEnabled": True,
    "deliveryEnabled": False
}
headers = {
    "Idempotency-Key": "Idempotency-Key",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Partner_createPartnerRestaurant_example
const url = 'https://www.lettbestilt.no/api/v1/partner/restaurants';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'Idempotency-Key',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"name":"Pizza Roma (test)","slug":"pizzaroma-test","email":"dev@byraet.no","pickupEnabled":true,"deliveryEnabled":false}'
};

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

```go Partner_createPartnerRestaurant_example
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}")

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

	req.Header.Add("Idempotency-Key", "Idempotency-Key")
	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 Partner_createPartnerRestaurant_example
require 'uri'
require 'net/http'

url = URI("https://www.lettbestilt.no/api/v1/partner/restaurants")

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

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'Idempotency-Key'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}"

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

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

HttpResponse<String> response = Unirest.post("https://www.lettbestilt.no/api/v1/partner/restaurants")
  .header("Idempotency-Key", "Idempotency-Key")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.lettbestilt.no/api/v1/partner/restaurants', [
  'body' => '{
  "name": "Pizza Roma (test)",
  "slug": "pizzaroma-test",
  "email": "dev@byraet.no",
  "pickupEnabled": true,
  "deliveryEnabled": false
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'Idempotency-Key',
  ],
]);

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

```csharp Partner_createPartnerRestaurant_example
using RestSharp;

var client = new RestClient("https://www.lettbestilt.no/api/v1/partner/restaurants");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "Idempotency-Key");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Partner_createPartnerRestaurant_example
import Foundation

let headers = [
  "Idempotency-Key": "Idempotency-Key",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Pizza Roma (test)",
  "slug": "pizzaroma-test",
  "email": "dev@byraet.no",
  "pickupEnabled": true,
  "deliveryEnabled": false
] as [String : Any]

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

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

### Partner_createPartnerRestaurant_example

**Request**

```json
{
  "name": "Pizza Roma (test)",
  "slug": "pizzaroma-test",
  "email": "dev@byraet.no",
  "pickupEnabled": true,
  "deliveryEnabled": false
}
```

**Response**

```json
{
  "data": {
    "slug": "pizzaroma-test",
    "name": "Pizza Roma (test)",
    "environment": "TEST",
    "sandbox": true,
    "live": false,
    "archived": false,
    "createdAt": "2026-10-16T08:12:00.000Z"
  },
  "restaurantKey": {
    "id": "cm2key0001abcdefghijklmn",
    "name": "Opprettet via partner-API",
    "last4": "x9Qa",
    "environment": "TEST",
    "scopes": [
      "*"
    ],
    "key": "lbs_test_cm2key0001abcdefghijklmn_q8Vt2mWkRb7LpZ3nDc5HsYf1JuE9aT0oGi4Nw6Kx9Qa"
  },
  "message": "Lagre restaurantnøkkelen nå. Den vises ikke igjen."
}
```

**SDK Code**

```python Partner_createPartnerRestaurant_example
import requests

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

payload = {
    "name": "Pizza Roma (test)",
    "slug": "pizzaroma-test",
    "email": "dev@byraet.no",
    "pickupEnabled": True,
    "deliveryEnabled": False
}
headers = {
    "Idempotency-Key": "Idempotency-Key",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Partner_createPartnerRestaurant_example
const url = 'https://www.lettbestilt.no/api/v1/partner/restaurants';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'Idempotency-Key',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"name":"Pizza Roma (test)","slug":"pizzaroma-test","email":"dev@byraet.no","pickupEnabled":true,"deliveryEnabled":false}'
};

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

```go Partner_createPartnerRestaurant_example
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}")

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

	req.Header.Add("Idempotency-Key", "Idempotency-Key")
	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 Partner_createPartnerRestaurant_example
require 'uri'
require 'net/http'

url = URI("https://www.lettbestilt.no/api/v1/partner/restaurants")

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

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'Idempotency-Key'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}"

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

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

HttpResponse<String> response = Unirest.post("https://www.lettbestilt.no/api/v1/partner/restaurants")
  .header("Idempotency-Key", "Idempotency-Key")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.lettbestilt.no/api/v1/partner/restaurants', [
  'body' => '{
  "name": "Pizza Roma (test)",
  "slug": "pizzaroma-test",
  "email": "dev@byraet.no",
  "pickupEnabled": true,
  "deliveryEnabled": false
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'Idempotency-Key',
  ],
]);

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

```csharp Partner_createPartnerRestaurant_example
using RestSharp;

var client = new RestClient("https://www.lettbestilt.no/api/v1/partner/restaurants");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "Idempotency-Key");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Pizza Roma (test)\",\n  \"slug\": \"pizzaroma-test\",\n  \"email\": \"dev@byraet.no\",\n  \"pickupEnabled\": true,\n  \"deliveryEnabled\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Partner_createPartnerRestaurant_example
import Foundation

let headers = [
  "Idempotency-Key": "Idempotency-Key",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Pizza Roma (test)",
  "slug": "pizzaroma-test",
  "email": "dev@byraet.no",
  "pickupEnabled": true,
  "deliveryEnabled": false
] as [String : Any]

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

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