API Reference
Overview
Эта страница документирует current external contract для AI agents в Flashcards.
Primary discovery entry point:
GET https://api.flashcards-open-source-app.com/v1/
Тот же payload также доступен через GET /v1/agent, но /v1/ — primary public entry point.
Discovery response сообщает agent, как:
- начать email OTP login
- обменять OTP на long-lived API key
- загрузить account context
- создать или выбрать workspace
- перейти к published SQL surface
Published Specs
Основные spec URLs внешнего agent surface:
https://api.flashcards-open-source-app.com/v1/agent/openapi.jsonhttps://api.flashcards-open-source-app.com/v1/agent/swagger.json
Есть и root aliases:
https://api.flashcards-open-source-app.com/v1/openapi.jsonhttps://api.flashcards-open-source-app.com/v1/swagger.json
Auth Bootstrap
Первый OTP stage работает на auth service:
POST https://auth.flashcards-open-source-app.com/api/agent/send-codePOST https://auth.flashcards-open-source-app.com/api/agent/verify-code
Flow:
- Выполните
GET /v1/ - Отправьте user email в
send-code - Прочитайте
otpSessionTokenиз response - Попросите у user последний 8-digit email code
- Вызовите
verify-codeсcode,otpSessionTokenиlabel - Сохраните returned API key вне conversation memory
Suggested environment variable:
export FLASHCARDS_OPEN_SOURCE_API_KEY="fca_ABCDEFGH_0123456789ABCDEFGHJKMNPQRS"
Authenticated requests use:
Authorization: ApiKey <key>
Post-Login Agent Surface
После verification current surface выглядит так:
GET /v1/agent/meGET /v1/agent/workspacesPOST /v1/agent/workspacesPOST /v1/agent/workspaces/{workspaceId}/selectPOST /v1/agent/sql
Typical bootstrap:
GET /v1/agent/meGET /v1/agent/workspaces?limit=100- При необходимости
POST /v1/agent/workspacesс{"name":"Personal"} - При необходимости
POST /v1/agent/workspaces/{workspaceId}/select - Используйте
POST /v1/agent/sql
Workspace selection явный для каждого API key connection. Agents должны следовать returned instructions и docs.openapiUrl, а не строить догадки.
SQL Surface
POST /v1/agent/sql — общий read/write surface для external agents.
Он намеренно ограничен и не является full PostgreSQL.
Current command families:
SHOW TABLESDESCRIBE <resource>SELECTINSERTUPDATEDELETE
Current published logical resources:
workspacecardsdecksreview_events
Notes:
- Default
LIMITравен100, maximum тоже100 - Используйте
ORDER BY, если нужна stable pagination - Для schema discovery используйте
SHOW TABLESилиDESCRIBE cards - External contract после selection ограничен текущим workspace
Example request:
curl -X POST https://api.flashcards-open-source-app.com/v1/agent/sql \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey $FLASHCARDS_OPEN_SOURCE_API_KEY" \
-d '{"sql":"SHOW TABLES"}'
Human And Sync APIs
Flashcards также включает отдельные APIs для human clients и offline-first sync, но это не primary contract для external agents:
- Browser flows используют shared-domain cookies с CSRF protection
- Offline-first clients используют sync routes под
/v1/workspaces/{workspaceId}/sync/pushи/v1/workspaces/{workspaceId}/sync/pull - Sync routes намеренно оставлены вне external agent OpenAPI surface