# Create a launch code

> Mint a one-time launch code for one of your users from your backend, for apps whose backend can't sign diner tokens.

Source: https://tamr.link/docs/api/create-launch-code

`POST https://tamr.link/api/v1/sdk/launch-codes`

For a backend that can't sign diner tokens: ask Tamr for a one-time code for one of your users, and your app returns it from its identity provider as a code. A code lasts 5 minutes and works once. `branch` and `locale` are hints; an unknown branch is refused.

## Authentication

**Server API.** Send a secret API key with the **Diner sessions (SDK)** permission (`diner:sdk`) as `Authorization: Bearer <key>`. Secret keys are made in **Settings > API keys** by an owner or admin. Keep them on your server: no browser can call this route.

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `externalUserId` | string | Yes | 1 to 200 characters. |
| `branch` | string | No | An address: lower-case letters, digits and dashes. |
| `locale` | string | No | A language tag, such as `ar` or `en-GB`. |

## Response

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | 1 to 200 characters. |
| `expiresAt` | string (date-time) |  |

## Example

curl:

```bash
curl https://tamr.link/api/v1/sdk/launch-codes \
  -H "Authorization: Bearer $TAMR_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{
  "externalUserId": "user-88213",
  "branch": "achrafieh"
}'
```

Node:

```js
import { createServerClient } from "@tamr/api/server";

const tamr = createServerClient({ secretKey: process.env.TAMR_SECRET_KEY });

const result = await tamr.sdkLaunchCodes({ externalUserId: "user-88213", branch: "achrafieh" });
console.log(result);
```

Python:

```python
import os

import requests

API = "https://tamr.link/api/v1"
headers = {"Authorization": f"Bearer {os.environ['TAMR_SECRET_KEY']}"}

response = requests.post(
    f"{API}/sdk/launch-codes",
    headers=headers,
    json={"externalUserId": "user-88213", "branch": "achrafieh"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

## Example response

```json
{
  "code": "lc_9f2c1b7a4e",
  "expiresAt": "2026-10-23T12:05:00Z"
}
```

## Errors

Every error has the same body; switch on `data.code`. See [Errors and rate limits](https://tamr.link/docs/errors).

| `data.code` | Status | What to do |
| --- | --- | --- |
| `other` | 401 | No secret key, or one Tamr doesn't accept: wrong, revoked, or made by someone who is no longer an owner or admin. |
| `other` | 403 | The key doesn't have the `diner:sdk` permission. |
| `invalid_request` | 400 | A field doesn't match the spec. The message says which. |
| `rate_limited` | 429 | Wait `retryAfter` seconds (also in the `Retry-After` header), then try again. |
| `sdk_disabled` | 403 | The SDK isn't switched on for this restaurant. Ask Tamr. |
