API リファレンス
Overview
このページは Flashcards における AI agents 向けの current external contract を説明します。
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 を create / select する
- published SQL surface へ進む
Published Specs
External agent surface の main spec URLs:
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に送る - Response から
otpSessionTokenを読む - User に最新の8桁メールコードを聞く
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/workspaceswith{"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 は external agents 向けの shared read/write surface です。
これは意図的に制限されており、full PostgreSQL ではありません。
Current command families:
SHOW TABLESDESCRIBE <resource>SELECTINSERTUPDATEDELETE
Current published logical resources:
workspacecardsdecksreview_events
Notes:
- Default
LIMITは100、maximum も100 - Stable pagination が必要なら
ORDER BYを使う - Schema discovery には
SHOW TABLESやDESCRIBE cardsを使う - External contract は post-selection で workspace-scoped になる
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 には human clients と offline-first sync 向けの separate APIs もありますが、external agents の primary contract ではありません:
- Browser flows は CSRF protection と shared-domain cookies を使う
- Offline-first clients は
/v1/workspaces/{workspaceId}/sync/pushと/v1/workspaces/{workspaceId}/sync/pullの sync routes を使う - Sync routes は intentional に external agent OpenAPI surface の外に置かれている