<!-- source: https://secondlayer.tools/docs/api-reference#get-subgraph-schema -->

## Get a subgraph's agent schema

`GET /v1/subgraphs/{name}/schema.json`

A compact JSON description of the subgraph for agents and tools: per table, its endpoints, exact row count, columns, the query params and filters it accepts, and example requests.

### Path parameters

| Name | Type | Description |
| --- | --- | --- |
| `name` | string, required | Subgraph name, as deployed (the `name` in its definition). |

### Query parameters

| Name | Type | Description |
| --- | --- | --- |
| `server` | string | Base URL written into the document's endpoints and examples. Defaults to this request's origin, honoring `X-Forwarded-Proto`. |

### Returns

One `SubgraphAgentSchema` object.

### Responses

- `200` The generated agent schema
- `401` This bind requires the instance token, and it was missing or wrong
- `404` No readable subgraph by that name (`SUBGRAPH_NOT_FOUND`). Hosted: another account's private subgraph reads as missing
- `429` Hosted only: rate limited; retry after `Retry-After` seconds. Self-hosted reads are not rate limited

### Example

```bash
curl https://api.secondlayer.tools/v1/subgraphs/{name}/schema.json \
  -H "Authorization: Bearer $SECONDLAYER_API_KEY"
```

```json
{
  "name": "sbtc-token",
  "version": "1.0.0",
  "schemaHash": "fffc99aeb7e11b465bf2b91ff67f3b4fcafc7bfbd447fe4d1d36d3bb4b867c2f",
  "generatedAt": "2026-09-23T15:12:00.000Z",
  "serverUrl": "http://127.0.0.1:3800",
  "sources": {
    "transfers": {
      "type": "ft_transfer",
      "assetIdentifier": "SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token::sbtc-token"
    }
  },
  "tables": {
    "transfers": {
      "endpoint": "http://127.0.0.1:3800/v1/subgraphs/sbtc-token/transfers",
      "countEndpoint": "http://127.0.0.1:3800/v1/subgraphs/sbtc-token/transfers/count",
      "aggregateEndpoint": "http://127.0.0.1:3800/v1/subgraphs/sbtc-token/transfers/aggregate",
      "streamEndpoint": "http://127.0.0.1:3800/v1/subgraphs/sbtc-token/transfers/stream",
      "rowCount": 48138,
      "columns": {
        "sender": {
          "type": "principal"
        },
        "recipient": {
          "type": "principal"
        },
        "amount": {
          "type": "uint"
        },
        "asset_identifier": {
          "type": "text",
          "indexed": true
        },
        "_id": {
          "type": "serial"
        },
        "_block_height": {
          "type": "bigint"
        },
        "_tx_id": {
          "type": "text"
        },
        "_created_at": {
          "type": "timestamp"
        }
      },
      "query": {
        "parameters": [
          "_limit",
          "cursor",
          "_order",
          "_fields"
        ],
        "sortable": [],
        "selectable": [
          "sender",
          "recipient",
          "amount",
          "asset_identifier",
          "_id",
          "_block_height",
          "_tx_id",
          "_created_at"
        ],
        "searchable": [],
        "filters": [
          "sender",
          "sender.neq",
          "sender.like",
          "recipient",
          "recipient.neq",
          "recipient.like",
          "amount",
          "amount.neq",
          "amount.gt",
          "amount.gte",
          "amount.lt",
          "amount.lte",
          "asset_identifier",
          "asset_identifier.neq",
          "asset_identifier.like",
          "_id",
          "_id.neq",
          "_id.gt",
          "_id.gte",
          "_id.lt",
          "_id.lte",
          "_block_height",
          "_block_height.neq",
          "_block_height.gt",
          "_block_height.gte",
          "_block_height.lt",
          "_block_height.lte",
          "_tx_id",
          "_tx_id.neq",
          "_tx_id.like",
          "_created_at",
          "_created_at.neq",
          "_created_at.gt",
          "_created_at.gte",
          "_created_at.lt",
          "_created_at.lte",
          "_created_at.like"
        ]
      },
      "examples": {
        "list": {
          "sender": "SP000000000000000000002Q6VF78",
          "recipient": "SP000000000000000000002Q6VF78",
          "amount": "1000",
          "asset_identifier": "example",
          "_id": 1,
          "_block_height": "1000",
          "_tx_id": "example",
          "_created_at": "2026-01-01T00:00:00.000Z"
        },
        "count": {
          "count": 48138
        },
        "curl": "curl 'http://127.0.0.1:3800/v1/subgraphs/sbtc-token/transfers?_limit=10&_order=desc'"
      }
    }
  }
}
```
