Document API Endpoint
SentryOfficialPublished by Sentry
- Skill
- Tool integration
- Software development
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to maintaining and updating API documentation for Sentry endpoints. It focuses on ensuring that OpenAPI specifications accurately reflect runtime behavior by aligning @extend_schema decorators and TypedDict definitions with actual API responses. The workflow covers the full lifecycle of endpoint documentation, including migrating legacy JSON-based documentation to code-based schemas, handling type drift, and promoting experimental endpoints to public status.
What it does
- Configures @extend_schema decorators for class and method-level API documentation.
- Defines and enforces TypedDict structures to ensure accurate response typing.
- Identifies and corrects type drift between declared schemas and actual runtime outputs.
- Migrates legacy static JSON API documentation to dynamic code-based schemas.
- Guides the promotion of private or experimental endpoints to public status.
- Provides validation steps to verify documentation against live endpoint behavior.
When to use it
- When adding or updating OpenAPI documentation for a Sentry API endpoint.
- When fixing discrepancies between the declared API schema and the actual response.
- When promoting an internal or experimental endpoint to a public-facing status.
- When refactoring legacy API documentation files into the current codebase structure.
Advantages
- Ensures API documentation remains synchronized with evolving backend code.
- Reduces type errors by enforcing canonical TypedDict usage across the codebase.
- Provides a clear, repeatable process for public API promotion.
- Eliminates reliance on outdated legacy JSON documentation files.
Usage examples
- “Document the new project settings endpoint.”
- The agent will apply the appropriate @extend_schema decorators, define the required TypedDicts, and ensure the endpoint is correctly tagged and owned.
- “Fix the type drift on the issues list endpoint.”
- The agent will compare the current schema against the live endpoint response, identify mismatches, and update the TypedDicts to match the actual runtime data.
- “Promote the experimental profiling endpoint to public.”
- The agent will update the publish status, assign the correct API owner, remove it from the allowlist, and ensure the documentation reflects the public status.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/getsentry/document-api-endpoint/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip document-api-endpoint.zip -d .agents/skills
Documentation by Sentry
Document & Type a Sentry API Endpoint
Add or fix OpenAPI docs for a Sentry endpoint with drf-spectacular. Full reference is at https://develop.sentry.dev/backend/api/public/, the most useful section to you will be https://develop.sentry.dev/backend/api/public/#5-method-decorator. This skill captures the non-obvious lessons on top of it. Most of the work is making the declared schema match what the endpoint actually returns. Before documenting, identify which endpoint class serves the route and what it does; the MCP tool that calls it is usually the fastest way to confirm its behavior. Promoting a PRIVATE/EXPERIMENTAL endpoint to PUBLIC is one application (see below).
Workflow
Class-level
@extend_schema(tags=[...])— use the closest existingOPENAPI_TAGSentry.Method-level
@extend_schema(operation_id=..., parameters=[...], responses={...}, examples=...).Reuse
src/sentry/apidocs/parameters.pyandexamples/*.py; ensureowner = ApiOwner.<TEAM>is set.If a legacy
api-docs/paths/**/*.jsoncovers the path, remove it (see lesson 4).Validate, then verify against the live endpoint (lesson 1).
Lessons
1. Carefully compare what the code does vs declared types
Ideally, hit the live endpoint with a real token and diff the keys and types against your TypedDict. Serializers are sometimes inaccurate. Look out for counts coming back as floats instead of integers, IDs declared int emitted as strings, nested types declaring the wrong number of fields. Correct the declared type to match runtime.
curl -s -H "Authorization: Bearer $TOKEN" "https://us.sentry.io/api/0/<endpoint>" | jq 'keys'2. Reuse the canonical response type
Match the codebase's XxxResponseOptional(TypedDict, total=False) mixin (main class declares required fields). Nullable-vs-absent: T | None = key always present, value may be null; NotRequired[T] = key only set under a condition (e.g. an expand query param). Reuse the existing canonical type instead of re-declaring a second or third copy in a *_types.py. If there's no clean canonical type to reuse (e.g. a payload proxied from another service like vroom/profiling), type it dict[str, Any] rather than inventing a new mirror, and confirm the shape from the owning service's repo, not just the serializer.
3. Infer the type. Avoid cast and # type: ignore
When a serializer returns a base type plus extra fields, refactor the producing code so the response type is inferred rather than forced.
4. Legacy doc migration is all-or-nothing per path
Delete the api-docs/paths/**/*.json file AND its $ref in api-docs/openapi.json. drf-spectacular's APPEND_PATHS does not merge HTTP methods, so once any method on a path uses @extend_schema, all legacy methods on that path vanish — migrate every method on the path in one commit.
Promoting to PUBLIC
Do the workflow above, then on the concrete endpoint only (leave siblings PRIVATE):
Bump
publish_status[<METHOD>]→PUBLICand setowner = ApiOwner.<TEAM>.Remove the method from
API_OWNERSHIP_ALLOWLIST_DONT_MODIFYin the same change as the flip.If the endpoint is redundant or being renamed, delete or deprecate the old version in its own change first, then stack the publish on top.
Note in the PR if scopes widen (
event:read→event:{admin,read,write}) — that's drf-spectacular regenerating frompermission_classes, documentation-only.
The change reaches the @sentry/api SDK / MCP only after sentry-api-schema regenerates downstream.
Validate
make build-api-docs
pnpm run validate-api-examples
.venv/bin/pytest -q --reuse-db tests/apidocs/endpoints/<area>/test_<name>.py
.venv/bin/prek run -q --files <changed paths>Files
- ATTRIBUTION.mdAdded by AutoGineer866 B
- LICENSELicence file added by AutoGineer10.5 KiB
- SKILL.md4.4 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs network access, Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Sentry
- Publisher
- Sentry (Official)
- Source
- getsentry/skills · skills/document-api-endpoint · commit e94f222
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Sentry or Sentry.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download document-api-endpoint.zip