API ReferenceREST /api/v1Sign in

Authentication

Customer and staff sessions use Better Auth cookie sessions. The portal and admin send credentials: "include". There is no public API key in v1 for customer routes.

Sign in

POST /api/v1/auth/sign-in/email sets the session cookie. Use the same origin policy as the portal (NEXT_PUBLIC_PORTAL_URL).

Current account

GET /api/v1/me requires customer.read. A 401 means the cookie is missing or expired.

Sign out

POST /api/v1/auth/sign-out clears the session.

Markdown source
---
title: Authentication
nav: Authentication
group: Get started
order: 20
---

# Authentication

Customer and staff sessions use Better Auth cookie sessions. The portal and admin send `credentials: "include"`. There is no public API key in v1 for customer routes.

## Sign in

`POST /api/v1/auth/sign-in/email` sets the session cookie. Use the same origin policy as the portal (`NEXT_PUBLIC_PORTAL_URL`).

```curl
curl -X POST {{API}}/api/v1/auth/sign-in/email \
  -H "Content-Type: application/json" \
  -c cookies.txt \
  -d '{"email":"you@example.com","password":"your-password"}'
```

```node
await fetch(`${api}/api/v1/auth/sign-in/email`, {
  method: "POST",
  credentials: "include",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ email, password }),
});
```

```python
# Use an HTTP client that stores Set-Cookie. Do not log passwords.
```

## Current account

`GET /api/v1/me` requires `customer.read`. A `401` means the cookie is missing or expired.

```curl
curl {{API}}/api/v1/me -b cookies.txt
```

```node
const res = await fetch(`${api}/api/v1/me`, { credentials: "include" });
if (res.status === 401) throw new Error("Sign in");
```

```python
urllib.request.urlopen(urllib.request.Request(f"{api}/api/v1/me"))
```

## Sign out

`POST /api/v1/auth/sign-out` clears the session.

```curl
curl -X POST {{API}}/api/v1/auth/sign-out -b cookies.txt
```

```node
await fetch(`${api}/api/v1/auth/sign-out`, { method: "POST", credentials: "include" });
```

```python
urllib.request.Request(f"{api}/api/v1/auth/sign-out", method="POST")
```