Skip to content

Commit

Permalink
chore: Update API usage examples (#10129)
Browse files Browse the repository at this point in the history
Update URLs used in API usage examples to be compatible with all
regions. The un-prefixed URLs only work in the US region or
self-hosted/single-tenant environments.
  • Loading branch information
markstory committed May 23, 2024
1 parent 762f65a commit 6ade42d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions docs/api/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Authentication tokens are passed using an auth header, and are used to authentic
For example, when the documentation says:

```bash
curl -H 'Authorization: Bearer {TOKEN}' https://sentry.io/api/0/projects/
curl -H 'Authorization: Bearer {TOKEN}' https://sentry.io/api/0/organizations/{organization_slug}/projects/
```

If your authentication token is `1a2b3c`, then the command should be:
If your authentication token is `1a2b3c`, and your organization slug is `acme` then the command should be:

```bash
curl -H 'Authorization: Bearer 1a2b3c' https://sentry.io/api/0/projects/
curl -H 'Authorization: Bearer 1a2b3c' https://sentry.io/api/0/organizations/acme/projects/
```

You can create authentication tokens within Sentry by [creating an internal integration](/organization/integrations/integration-platform/#internal-integrations). This is also available for self-hosted Sentry.
Expand All @@ -32,7 +32,7 @@ The endpoints that require a user authentication token are specific to your user
Some API endpoints may allow DSN-based authentication. This is generally very limited and an endpoint will describe if its supported. This works similar to Bearer token authentication, but uses your DSN (Client Key).

```bash
curl -H 'Authorization: DSN {DSN}' https://sentry.io/api/0/projects/
curl -H 'Authorization: DSN {DSN}' https://sentry.io/api/0/{organization_slug}/{project_slug}/user-reports/
```

## API Keys
Expand All @@ -48,7 +48,7 @@ API keys are passed using HTTP Basic auth where the username is your api key, an
As an example, to get information about the project which your key is bound to, you might make a request like so:

```bash
curl -u {API_KEY}: https://sentry.io/api/0/projects/
curl -u {API_KEY}: https://sentry.io/api/0/organizations/{organization_slug}/projects/
```

<Note>
Expand Down
12 changes: 6 additions & 6 deletions docs/api/pagination.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_order: 1
Pagination in the API is handled via the Link header standard:

```bash
curl -i https://sentry.io/api/0/projects/1/groups/
curl -i https://sentry.io/api/0/organizations/acme/projects/1/groups/
```

```http
Expand All @@ -15,9 +15,9 @@ Date: Sat, 14 Feb 2015 18:47:20 GMT
Content-Type: application/json
Content-Language: en
Allow: GET, HEAD, OPTIONS
Link: <https://sentry.io/api/0/projects/1/groups/?&cursor=1420837590:0:1>;
Link: <https://sentry.io/api/0/organizations/acme/projects/1/groups/?&cursor=1420837590:0:1>;
rel="previous"; results="false",
<https://sentry.io/api/0/projects/1/groups/?&cursor=1420837533:0:0>;
<https://sentry.io/api/0/organizations/acme/projects/1/groups/?&cursor=1420837533:0:0>;
rel="next"; results="true"
```

Expand All @@ -32,17 +32,17 @@ https://docs.sentry.io/api/events/list-an-issues-events/
The HTTP request in this example returns 100 events for the issue and has the following link header in the response:

```bash {tabTitle:Http}
<https://sentry.io/api/0/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="false"; cursor="0:0:1", <https://sentry.io/api/0/issues/123456/events/?&cursor=0:100:0>; rel="next"; results="true"; cursor="0:100:0"
<https://sentry.io/api/0/organizations/acme/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="false"; cursor="0:0:1", <https://sentry.io/api/0/organizations/acme/issues/123456/events/?&cursor=0:100:0>; rel="next"; results="true"; cursor="0:100:0"
```

One of the URLs in the link response has `rel=next`, which indicates the next results page. It also has `results=true`, which means that there are more results.

Based on this, the next request is `GET <https://sentry.io/api/0/issues/123456/events/?&cursor=0:100:0>`.
Based on this, the next request is `GET <https://sentry.io/api/0/organizations/acme/issues/123456/events/?&cursor=0:100:0>`.

This request will return the next 100 events for that issue, again, with the following link header:

```bash {tabTitle:Http}
<https://sentry.io/api/0/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="true"; cursor="0:0:1", <https://sentry.io/api/0/issues/123456/events/?&cursor=0:200:0>; rel="next"; results="true"; cursor="0:200:0"
<https://sentry.io/api/0/organizations/acme/issues/123456/events/?&cursor=0:0:1>; rel="previous"; results="true"; cursor="0:0:1", <https://sentry.io/api/0/organizations/acme/issues/123456/events/?&cursor=0:200:0>; rel="next"; results="true"; cursor="0:200:0"
```

The process is repeated until the URL with `rel=next` has the flag `results=false` to indicate the last page.
Expand Down
4 changes: 2 additions & 2 deletions docs/api/requests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ Sentry makes an attempt to stick to appropriate HTTP verbs, but we always priori
Any parameters not included in the URL should be encoded as JSON with a Content-Type of `'application/json'`:

```bash
curl -i https://sentry.io/api/0/projects/1/groups/ \
curl -i https://sentry.io/api/0/organizations/acme/projects/1/groups/ \
-d '{"status": "resolved"}' \
-H 'Content-Type: application/json'
```

Additional parameters are sometimes specified via the querystring, even for `POST`, `PUT`, and `DELETE` requests:

```bash
curl -i https://sentry.io/api/0/projects/1/groups/?status=unresolved \
curl -i https://sentry.io/api/0/organizations/acme/projects/1/groups/?status=unresolved \
-d '{"status": "resolved"}' \
-H 'Content-Type: application/json'
```

0 comments on commit 6ade42d

Please sign in to comment.