# Get a trace

> One trace by its id (32 hex characters): every span, with its parent, kind, timing, status, attributes, resource, events and links, and the log lines written under it.

<div class="g1t-endpoint"><span class="g1t-method" data-method="get">GET</span><code>/workspaces/{workspace}/projects/{project}/observability/traces/{trace_id}</code></div>

Needs a role on the project's repository.

Spans are in the order they started. `404` when the project has no spans of that trace.

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`observability`](/reference/mcp/#observability) with `action` `trace`, and the same inputs
- **Scope:** An access token needs [`observability:read`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace` | string | Yes | The workspace's slug, e.g. "flagon-io". |
| `project` | string | Yes | The project's slug, as in g1t.sh/{workspace}/{project}. |
| `trace_id` | string | Yes | The trace's id, 32 hex characters. |

## Example request

```sh
curl https://api.g1t.sh/workspaces/flagon-io/projects/g1t/observability/traces/4bf92f3577b34da6a3ce929d0e0e4736 \
  -H "Authorization: Bearer $G1T_TOKEN"
```

## Example response

A successful request answers `200` with:

```json
{
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "spans": [
    {
      "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
      "span_id": "00f067aa0ba902b7",
      "parent_span_id": null,
      "name": "GET /:workspace/:repo/pulls/:number",
      "kind": "server",
      "start_us": 1791813807418000,
      "duration_us": 842000,
      "status": "error",
      "status_message": "TypeError",
      "attributes": {
        "http.request.method": "GET",
        "http.response.status_code": 500
      },
      "resource": {
        "service.name": "g1t-web",
        "deployment.environment.name": "production"
      },
      "events": [],
      "links": [],
      "service": "g1t-web",
      "environment": "production",
      "deployment_id": "dpl_01kq9a2c4e6g8j0m2p4r6t8v0x",
      "commit_sha": "7c1e9a4b2d6f80135ac9e2b7d4f6a8c0e1b3d5f7",
      "source": "otlp"
    }
  ],
  "logs": [
    {
      "id": "log_01kq9b7d9f1h3k5m7p9r1t3v5y",
      "time_us": 1791813808251000,
      "severity": "error",
      "severity_number": 17,
      "body": "loading pull request 412 failed: Cannot read properties of undefined (reading 'head')",
      "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
      "span_id": "00f067aa0ba902b7",
      "request_id": "req_01kq9b7d9f1h3k5m7p9r1t3v5x",
      "attributes": {
        "code.function": "loadPull",
        "http.route": "/:workspace/:repo/pulls/:number"
      },
      "service": "g1t-web",
      "environment": "production",
      "deployment_id": "dpl_01kq9a2c4e6g8j0m2p4r6t8v0x",
      "commit_sha": "7c1e9a4b2d6f80135ac9e2b7d4f6a8c0e1b3d5f7",
      "source": "cloudflare"
    }
  ]
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
