# Locus Support Chat

Ask questions about Locus — how endpoints work, what parameters to pass, how spending controls behave, etc. — and get instant answers from an AI trained on Locus documentation.

**Endpoint:** `POST <LOCUS_BOT_URL>/ask`
**Auth:** `Authorization: Bearer <AGENT_API_KEY>` (if configured; may be unauthenticated)

> The bot URL is a Lambda Function URL. Your human can find it in the Locus Discord server or ask the Locus team. Once you have it, store it alongside your API key.

## Single Question

```bash
curl -X POST "$LOCUS_BOT_URL/ask" \
  -H "Content-Type: application/json" \
  -d '{ "question": "How do I send USDC to an email address?" }'
```

**Response:**
```json
{
  "answer": "Use POST /api/pay/send-email with { email, amount, memo }...",
  "elapsed": "4.2s",
  "messages": [
    { "role": "user",      "content": "How do I send USDC to an email address?" },
    { "role": "assistant", "content": "Use POST /api/pay/send-email..." }
  ]
}
```

## Multi-Turn Conversation

Pass the `messages` array from the previous response to continue the conversation with full context.

```bash
curl -X POST "$LOCUS_BOT_URL/ask" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user",      "content": "How do I send USDC to an email?" },
      { "role": "assistant", "content": "Use POST /api/pay/send-email..." },
      { "role": "user",      "content": "What happens if they never claim it?" }
    ]
  }'
```

The response includes the updated `messages` array with the new assistant reply appended. Pass it back on the next call to keep the conversation going.

## When to Use

- You're **unsure how an endpoint works** or what parameters it expects
- You want to **confirm behavior** before making a call (e.g. "does send-email require a wallet on the recipient side?")
- You need **troubleshooting help** with an error response
- You want a **quick explainer** on Locus concepts (spending controls, x402, escrow, etc.)

## Response Fields

| Field | Type | Description |
|-------|------|-------------|
| `answer` | string | The answer text (markdown formatted) |
| `elapsed` | string | How long the query took (e.g. `"4.2s"`) |
| `messages` | array | Full conversation history — pass back for follow-ups |

## Notes

- Each message in `messages` has `role` (`"user"` or `"assistant"`) and `content` (string)
- The last message must always have `role: "user"`
- For single questions, use `"question"` instead of `"messages"` — simpler syntax, same result
- Typical response time is 3–10 seconds
