Files
crank/docs/api-examples.md
github-ops 9331ee1d89
Deploy / deploy (push) Successful in 37s
CI / Rust Checks (push) Successful in 27m22s
CI / UI Checks (push) Successful in 6s
CI / Deployment Manifests (push) Successful in 3s
CI / Frontend E2E (push) Successful in 20m44s
Complete markdown documentation
2026-06-21 12:49:56 +00:00

3.0 KiB

Практические API-примеры

Здесь собраны минимальные запросы для проверки Crank без веб-интерфейса.

В примерах используется:

https://crank.example.com

Замените адрес на свой.

Вход

curl -i https://crank.example.com/api/auth/login \
  -H 'Content-Type: application/json' \
  --data '{
    "email": "owner@example.com",
    "password": "change-me"
  }'

Сохраните cookie crank_session.

Получить workspace

curl https://crank.example.com/api/admin/workspaces \
  -b 'crank_session=<cookie_value>'

Для стандартной установки workspace id:

ws_default

Получить операции

curl https://crank.example.com/api/admin/workspaces/ws_default/operations \
  -b 'crank_session=<cookie_value>'

После demo seed ожидается операция:

frankfurter_latest_rate

Запустить тест операции

curl https://crank.example.com/api/admin/workspaces/ws_default/operations/<operation_id>/test-runs \
  -b 'crank_session=<cookie_value>' \
  -H 'Content-Type: application/json' \
  --data '{
    "version": 1,
    "input": {
      "base": "USD",
      "quote": "EUR"
    }
  }'

Получить агентов

curl https://crank.example.com/api/admin/workspaces/ws_default/agents \
  -b 'crank_session=<cookie_value>'

После demo seed ожидается агент:

currency-rates

Создать API-ключ агента

curl https://crank.example.com/api/admin/workspaces/ws_default/agents/<agent_id>/platform-api-keys \
  -b 'crank_session=<cookie_value>' \
  -H 'Content-Type: application/json' \
  --data '{
    "name": "Manual MCP test",
    "scopes": ["read", "write"]
  }'

Сохраните поле secret. Оно не будет показано повторно.

Проверить MCP initialize

curl -i https://crank.example.com/mcp/v1/default/currency-rates \
  -H 'Authorization: Bearer <agent_api_key>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
      "protocolVersion": "2025-06-18",
      "capabilities": {},
      "clientInfo": {
        "name": "curl",
        "version": "1.0.0"
      }
    }
  }'

Сохраните MCP-Session-Id из заголовков ответа.

Вызвать инструмент

curl https://crank.example.com/mcp/v1/default/currency-rates \
  -H 'Authorization: Bearer <agent_api_key>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'MCP-Session-Id: <session_id>' \
  --data '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "frankfurter_latest_rate",
      "arguments": {
        "base": "USD",
        "quote": "EUR"
      }
    }
  }'