# Authentication

Passkey-based authentication flow (SSE).

## Start a passkey authentication flow (SSE)

> Initiates a passkey-based sign-in. Returns a \`text/event-stream\` (SSE) that emits events until the user authenticates or the 2-minute timeout expires.\
> \*\*Event sequence:\*\*\
> 1\. \`pending\` — contains the \`passkey\` and an \`auth\_url\` to open. 2. \`success\` — contains \`access\_token\` and \`refresh\_token\`.\
> The stream closes automatically after \`success\` or timeout.<br>

````json
{"openapi":"3.1.0","info":{"title":"UI Color Palette API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Passkey-based authentication flow (SSE).\n"}],"servers":[{"url":"https://api-uicp.yelbolt.workers.dev/v1","description":"Production"}],"paths":{"/authenticate":{"get":{"operationId":"authenticate","summary":"Start a passkey authentication flow (SSE)","description":"Initiates a passkey-based sign-in. Returns a `text/event-stream` (SSE) that emits events until the user authenticates or the 2-minute timeout expires.\n**Event sequence:**\n1. `pending` — contains the `passkey` and an `auth_url` to open. 2. `success` — contains `access_token` and `refresh_token`.\nThe stream closes automatically after `success` or timeout.\n","tags":["Authentication"],"responses":{"200":{"description":"SSE stream","content":{"text/event-stream":{"schema":{"type":"string","description":"Each `data:` line is a JSON object. Possible shapes:\n**Pending event:** ```json {\n  \"status\": \"pending\",\n  \"passkey\": \"abc123\",\n  \"auth_url\": \"https://auth.ui-color-palette.com/?passkey=abc123\",\n  \"message\": \"Please authenticate by opening the following URL in your browser: ...\"\n} ```\n**Success event:** ```json {\n  \"status\": \"success\",\n  \"access_token\": \"<supabase-jwt>\",\n  \"refresh_token\": \"<refresh-token>\"\n} ```\n"}}}},"502":{"description":"Failed to reach the passkey service","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"ErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}
````


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ui-color-palette.com/api-reference/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
