Repositories
Get repository contents
What a repository holds at a path, at ref (a branch, tag or commit; the default branch when left out).
/repos/{owner}/{name}/contentsA file: its text (null for a binary file or one too large to show; at most 200,000 characters, the rest cut with a note), size in bytes and html_url. A directory (or the root, with no path): its entries (each name, path and type: dir, file, symlink or submodule) and its README’s text when it has one. Read the root first to find README, CONTRIBUTING, package.json, Cargo.toml or a workflow under .g1t/workflows, then the files you need.
A file’s text, or with no path (or a directory’s) the entries and README. ref is a branch, tag or commit; the default branch when left out.
- Authentication: Required. Send an access token as
Authorization: Bearer. - MCP tool:
repositorywithactioncontents, and the same inputs - Scope: An access token needs
code:read.
Path parameters
Section titled “Path parameters”| Name | Type | Required | Description |
|---|---|---|---|
owner |
string | Yes | The workspace that owns the repository. |
name |
string | Yes | The repository’s name. |
Query parameters
Section titled “Query parameters”| Name | Type | Required | Description |
|---|---|---|---|
path |
string | No | A file or directory, such as README.md or src/lib; the root when left out. |
ref |
string | No | A branch, tag or commit; the default branch when left out. |
Example request
Section titled “Example request”curl "https://api.g1t.sh/repos/flagon-io/g1t/contents?path=CONTRIBUTING.md" \ -H "Authorization: Bearer $G1T_TOKEN"Example response
Section titled “Example response”A successful request answers 200 with:
{ "type": "file", "repo": "flagon-io/g1t", "ref": "main", "path": "CONTRIBUTING.md", "size": 412, "binary": false, "text": "# Contributing\n\nRun the tests before you push:\n\n```sh\ncargo test --workspace\nnpm test --workspaces --if-present\n```\n", "html_url": "https://g1t.sh/flagon-io/g1t/blob/main/CONTRIBUTING.md"}Errors
Section titled “Errors”A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See 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. |