Designing a New API

Here are some considerations to make when designing new Sentry APIs.

URL Patterns

The API's URL is what developers use to call the endpoint so itโ€™s important that it is meaningful and clear.

Don't Exceed 3-level Nesting

Nested resources format like api/0/organizations/{org}/projects/ is recommended over api/0/projects/ for readability because it gives user an understanding of resource hierarchy. However, nesting can make URLs too long and hard to use. Sentry uses 3-level nesting as a hybrid solution.

Here are some possible urls for values with this resource hierarchy: organization -> project -> tag -> value

  • ๐Ÿ‘ /projects/{organization_slug}/{project_slug}/tags/{tag_id}/values
  • ๐Ÿ‘Ž /organizations/{organization_slug}/projects/{project_slug}/tags/{tag_id}/values/
  • ๐Ÿ‘Ž /values/

In the above example we flattened projects. The table below shows the existing flattened collections which works out with our existing APIs.

First collection in URLWhen to useParentIdentifierExample
organizationsWhen the resource cannot be attached to any other collection below parent like ProjectN/A - always comes as first collection{organization_slug}Create a New Team
teamsWhen the resource is under a specific team in the hierarchyorganizations{organization_slug}/ {team_slug}Retreive Team Stats
projectsWhen the resource is under a specific project in the hierarchy but not under an issueorganizations{organization_slug}/ {project_slug}Create a New Client Key
issuesWhen the resource is under a specific issue in the hierarchyprojects{issue_id}List an Issue's Events
sentry-app-installationsWhen the resource is mapped to a specific integrationorganizations{integration_slug}Delete an External Issue
You can edit this page on GitHub.