# Getting started

This walk-through signs you up, creates a bot, teaches it two answers and asks it a question. It uses `curl`; any HTTP client works.

Base URL: `https://theunibot.com`

## 1. Create an account

Choose an email address and a password (at least 8 characters).

```bash
curl -X POST https://theunibot.com/api/collections/users/records \
  -H "content-type: application/json" \
  -d '{"email":"you@example.com","password":"a-long-password","passwordConfirm":"a-long-password"}'
```

The response includes your user `id`. You cannot log in with the password until you confirm your email (step 2).

## 2. Confirm with the emailed code

Ask for a one-time code. We email a six-digit code to the address you registered.

```bash
curl -X POST https://theunibot.com/api/collections/users/request-otp \
  -H "content-type: application/json" \
  -d '{"email":"you@example.com"}'
```

The response contains an `otpId`. Exchange it with the code from your inbox for a token:

```bash
curl -X POST https://theunibot.com/api/collections/users/auth-with-otp \
  -H "content-type: application/json" \
  -d '{"otpId":"<otpId>","password":"<six-digit code>"}'
```

The response holds a `token` and your `record`. Your email is now verified.

As a safety measure the password you registered with is cleared when an email is verified this way. Set your password again, using the token you just received:

```bash
curl -X POST https://theunibot.com/v1/account/password \
  -H "authorization: Bearer <token>" -H "content-type: application/json" \
  -d '{"password":"a-long-password","passwordConfirm":"a-long-password"}'
```

The response contains a fresh token (the old one stops working). You can also log in later with your email and password:

```bash
curl -X POST https://theunibot.com/api/collections/users/auth-with-password \
  -H "content-type: application/json" \
  -d '{"identity":"you@example.com","password":"a-long-password"}'
```

## 3. Create a bot

Send the token as a bearer token. `owner` must be your own user id.

```bash
curl -X POST https://theunibot.com/api/collections/bots/records \
  -H "authorization: Bearer <token>" -H "content-type: application/json" \
  -d '{"owner":"<your user id>","name":"Corner Cafe","slug":"corner-cafe","greeting":"Ask me about the cafe.","public":true}'
```

Slugs are 3 to 40 characters of lowercase letters, digits and hyphens, and are unique across Unibot.

## 4. Add answers

```bash
curl -X POST https://theunibot.com/api/collections/answers/records \
  -H "authorization: Bearer <token>" -H "content-type: application/json" \
  -d '{"bot":"<bot id>","question":"What are your opening hours?","answer":"We open 8am to 4pm every day."}'
```

Repeat for each question you want the bot to know.

## 5. Ask the bot

Public bots can be asked without any credentials:

```bash
curl "https://theunibot.com/v1/bots/corner-cafe/ask?q=when+do+you+open"
```

```json
{
  "bot": {"slug": "corner-cafe", "name": "Corner Cafe", "greeting": "Ask me about the cafe."},
  "query": "when do you open",
  "matched": true,
  "answer": {"question": "What are your opening hours?", "answer": "We open 8am to 4pm every day.", "score": 0.5},
  "alternatives": []
}
```

## Try the examples

Two public example bots are ready to ask: `quillfeather-books` and `marrowby-bike-repair`.

```bash
curl "https://theunibot.com/v1/bots/marrowby-bike-repair/ask?q=how+much+is+a+tune-up"
```

## Next

- Do all of this from an AI agent with the [MCP server](/docs/mcp).
- See every endpoint in the [API reference](/docs/api-reference).
