> 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.

# Sign up for the newsletter

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

Adds the customer to the restaurant's newsletter and returns the welcome coupon. Signing up again with the same email is safe: it returns the welcome coupon again and keeps the address subscribed.

The newsletter popup must be enabled in the restaurant's dashboard and linked to an active coupon. Otherwise the response is `404 POPUP_NOT_AVAILABLE` and nothing is stored. Check `restaurant.newsletterPopup` in `GET /restaurant` before you show a signup form; it also holds the popup's texts.

Rate limits: 5 requests per 60 seconds per IP, and 200 per hour per restaurant.

Reference: https://docs.lettbestilt.no/api-reference/coupons-and-newsletter/sign-up-for-newsletter

## 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.

### Body (application/json)

This endpoint expects an object.

- `email` (string, required)
- `name` (string, optional)

## Response

### 200

The customer is subscribed. Show the welcome coupon.

- `couponCode` (string, optional) — The welcome code. Show it to the customer.
- `discountType` (enum, optional) — The kind of discount the code gives.
  - Allowed values: `PERCENT`, `FIXED`, `FREE_DELIVERY`
- `discountValue` (integer, optional) — `PERCENT`: percent. `FIXED`: øre.
- `successMessage` (string, optional) — The restaurant's thank-you text. Replace `{{code}}` and `{{discount}}` before you show it.

## Errors

### 400 Bad Request Error

`MISSING_SLUG` or `INVALID_JSON`.

- `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`, or `POPUP_NOT_AVAILABLE` when the popup is turned off or has no active coupon.

- `error` (ErrorBody, required)

### 422 Unprocessable Entity Error

`VALIDATION_FAILED`: the body failed validation.

- `error` (ErrorBody, required)

### 429 Too Many Requests Error

`RATE_LIMITED`: too many signups from this IP or for this restaurant.

- `error` (ErrorBody, required)

## Types

### 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`.

## Examples

**Request**

```json
{
  "email": "kari@example.com",
  "name": "Kari"
}
```

**Response**

```json
{
  "couponCode": "VELKOMMEN",
  "discountType": "PERCENT",
  "discountValue": 10,
  "successMessage": "Takk! Bruk koden {{code}} for {{discount}} rabatt."
}
```

**SDK Code**

```python Coupons and newsletter_signUpForNewsletter_example
import requests

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

querystring = {"slug":"slug"}

payload = {
    "email": "kari@example.com",
    "name": "Kari"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Coupons and newsletter_signUpForNewsletter_example
const url = 'https://www.lettbestilt.no/api/v1/newsletter/signup?slug=slug';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"email":"kari@example.com","name":"Kari"}'
};

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

```go Coupons and newsletter_signUpForNewsletter_example
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"email\": \"kari@example.com\",\n  \"name\": \"Kari\"\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 Coupons and newsletter_signUpForNewsletter_example
require 'uri'
require 'net/http'

url = URI("https://www.lettbestilt.no/api/v1/newsletter/signup?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  \"email\": \"kari@example.com\",\n  \"name\": \"Kari\"\n}"

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

```java Coupons and newsletter_signUpForNewsletter_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://www.lettbestilt.no/api/v1/newsletter/signup?slug=slug")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"email\": \"kari@example.com\",\n  \"name\": \"Kari\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.lettbestilt.no/api/v1/newsletter/signup?slug=slug', [
  'body' => '{
  "email": "kari@example.com",
  "name": "Kari"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Coupons and newsletter_signUpForNewsletter_example
using RestSharp;

var client = new RestClient("https://www.lettbestilt.no/api/v1/newsletter/signup?slug=slug");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"email\": \"kari@example.com\",\n  \"name\": \"Kari\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Coupons and newsletter_signUpForNewsletter_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "email": "kari@example.com",
  "name": "Kari"
] as [String : Any]

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

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