跳到內容

API Success Response Policy

本頁內容尚未翻譯。

Error responses use a common ApiError shape, but success responses vary between raw resources, { "ok": true }, and list envelopes.

Do not break existing v1/MCP/SDK contracts. Apply this policy to new endpoints first and migrate app-only endpoints opportunistically.

Use for commands with no returned resource:

{ "ok": true }

Use direct resource objects when the endpoint naturally reads or mutates one resource:

{ "id": "...", "name": "..." }

Use named arrays when the collection name carries meaning:

{ "cards": [], "total": 0 }

Use cursor envelope for paginated lists:

{ "items": [], "nextCursor": null }
  • v1 external contracts require changelog and compatibility review.
  • App-only endpoints can migrate with frontend change in same PR.
  • New routes must document which shape they use.
  • Avoid wrapping every response in a generic envelope until clients agree on it.
  • Serializer tests for v1 resources.
  • Route tests for cursor fields when pagination exists.
  • Snapshot or schema tests for external SDK-facing responses.

Build a7f47a5ca54ddcf7806cd48b81ce1b9827042766