pr_01m47d15m3e54sn21z27rpy5n9/apps/web/app/docs/api.md

111 lines3,671 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

API and MCP server, Rust identity service, registration, site redesign1# API
2
3The REST API lives at `https://api.g1t.sh`. It exposes the same operations as
4the [MCP server](/docs/agents).
5
6## Authentication
7
8Send an [access token](/settings) as a bearer token:
9
10```sh
11curl https://api.g1t.sh/v1/user \
12 -H "Authorization: Bearer $G1T_TOKEN"
13```
14
15Public data can be read without a token. A token that is not valid is
16rejected with `401` rather than treated as anonymous.
17
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)18## Getting an account and a token
19
20These two calls need no token, so an assistant can set someone up from
21scratch. See [llms.txt](/llms.txt) for the full walkthrough.
22
23| Method | Path | |
24| --- | --- | --- |
25| `POST` | `/v1/register` | Create an account. Body: `username`, `email`, `password`. Sends a confirmation email. |
26| `POST` | `/v1/tokens` | Create an access token. Body: `username`, `password`, `name`. |
27
API and MCP server, Rust identity service, registration, site redesign28## Errors
29
30Errors are JSON with a stable `code` and a human-readable `message`.
31
32```json
33{ "error": { "code": "not_found", "message": "Repository not found." } }
34```
35
36| Status | Code | Meaning |
37| --- | --- | --- |
38| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
39| 403 | `forbidden` | You are signed in but not allowed to do this. |
40| 404 | `not_found` | It does not exist, or you cannot see it. |
41| 409 | `conflict` | The request conflicts with the current state. |
42| 422 | `invalid` | The input is not valid. |
43
44## Repositories
45
46| Method | Path | |
47| --- | --- | --- |
48| `GET` | `/v1/repos?q=` | Repositories you can see. |
49| `POST` | `/v1/repos` | Create one. Body: `name`, `description`, `private`. |
50| `GET` | `/v1/repos/{owner}/{name}` | One repository. |
51| `GET` | `/v1/repos/{owner}/{name}/events?before=` | Its timeline, newest first. |
52
53## Intents
54
55| Method | Path | |
56| --- | --- | --- |
57| `GET` | `/v1/repos/{owner}/{name}/intents?status=` | Intents on a repository. |
58| `POST` | `/v1/repos/{owner}/{name}/intents` | Open one. Body: `title`, `brief`, `checks`. |
59| `GET` | `/v1/repos/{owner}/{name}/intents/{number}` | An intent and its attempts. |
60
61```sh
62curl -X POST https://api.g1t.sh/v1/repos/syntaqx/hello/intents \
63 -H "Authorization: Bearer $G1T_TOKEN" \
64 -H "Content-Type: application/json" \
65 -d '{
66 "title": "Greet the user by name",
67 "brief": "Take a name from the first argument; fall back to world.",
68 "checks": ["cargo build"]
69 }'
70```
71
72## Attempts
73
74| Method | Path | |
75| --- | --- | --- |
76| `POST` | `/v1/intents/{intent_id}/attempts` | Start one. Body: `agent`. |
77| `GET` | `/v1/attempts/{attempt_id}` | An attempt and its intent. |
78| `POST` | `/v1/attempts/{attempt_id}/submit` | Finish. Body: `summary`. |
79| `POST` | `/v1/attempts/{attempt_id}/abandon` | Give up. |
Rust repos service with shipping; pull requests kept in the model80| `POST` | `/v1/attempts/{attempt_id}/ship` | Land it on `main`. Owner only; `409` if `main` has moved. |
API and MCP server, Rust identity service, registration, site redesign81
82Starting an attempt returns the fork's git remote:
83
84```json
85{
86 "attempt": { "id": "att_01…", "number": 1, "status": "working" },
87 "git": { "remote": "https://g1t.sh/attempts/att_01….git" }
88}
89```
90
91## Sessions
92
93| Method | Path | |
94| --- | --- | --- |
95| `GET` | `/v1/attempts/{attempt_id}/session?after=` | Entries after a sequence number. |
96| `POST` | `/v1/attempts/{attempt_id}/session` | Append. Body: `entries`. |
97
98```sh
99curl -X POST https://api.g1t.sh/v1/attempts/$ATTEMPT/session \
100 -H "Authorization: Bearer $G1T_TOKEN" \
101 -H "Content-Type: application/json" \
102 -d '{"entries": [{"kind": "message", "text": "Reading src/main.rs."}]}'
103```
104
105Up to 200 entries can be appended per request.
106
107## Identifiers
108
109Ids are [TypeIDs](https://github.com/jetify-com/typeid): a prefix naming the
110kind of thing, then a UUIDv7 in base32, for example
111`att_01jb2k7x9hfq0b3zj0f5s2m8ra`. They sort by creation time.