> For the complete documentation index, see [llms.txt](https://wiki.crosswatch.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.crosswatch.app/crosswatch/advanced-and-api/api-reference/api-foundations.md).

# API foundations

Use these endpoints to verify an instance and establish an authenticated session.

### Base URL

CrossWatch serves its API from the instance URL. Routes are not versioned.

```
http://localhost:8787
https://crosswatch.example.com
```

Use HTTPS outside a trusted network.

### Authentication

CrossWatch uses the HTTP-only `cw_auth` session cookie. Most `/api/*` routes require it when application authentication is enabled.

| Method | Endpoint                      | Purpose                                   |
| ------ | ----------------------------- | ----------------------------------------- |
| `GET`  | `/api/health`                 | Return liveness and readiness.            |
| `GET`  | `/healthz`                    | Container health alias.                   |
| `GET`  | `/api/app-auth/status`        | Return authentication and session status. |
| `POST` | `/api/app-auth/login`         | Create a local session.                   |
| `POST` | `/api/app-auth/logout`        | End the current session.                  |
| `POST` | `/api/app-auth/logout-all`    | End every session.                        |
| `POST` | `/api/app-auth/logout-others` | End all other sessions.                   |
| `POST` | `/api/app-auth/credentials`   | Configure local credentials.              |

```bash
curl -sS -c cookies.txt \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"replace-me","remember_me":true}' \
  "$BASE_URL/api/app-auth/login"
```

### Common responses

Check both the HTTP status and response body. Some operational endpoints return `200` with `ok: false`.

```json
{"ok": true}
```

FastAPI validation failures return a `detail` array. Webhook behavior differs and is documented separately.

### Runtime schema

| Method | Endpoint             | Purpose                             |
| ------ | -------------------- | ----------------------------------- |
| `GET`  | `/openapi.json`      | Download the live OpenAPI schema.   |
| `GET`  | `/docs`              | Open interactive API documentation. |
| `GET`  | `/redoc`             | Open ReDoc API documentation.       |
| `GET`  | `/api/version`       | Return the application version.     |
| `GET`  | `/api/version/check` | Check the configured update source. |
| `GET`  | `/api/update`        | Return update information.          |

The runtime schema reflects registered routes. It can omit field details for dictionary-backed request bodies.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://wiki.crosswatch.app/crosswatch/advanced-and-api/api-reference/api-foundations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
