CLI and APIs
REST API reference
You build a tool on the forge, and you need the route for a task: its path, who can call it, and what it answers. The REST API is at /api/v1: it speaks JSON, takes a token in the Authorization header, and has the same features as MCP and the src CLI.
34 min read
New to the API? Send your first request with a token and curl. For a token that the person approves in the browser, ask the person for a token. /llms.txt lists every route, with its fields.
How the API answers
- Errors come back as
{ "error": "<text>" }with the HTTP status. - Lists come back as
{ "items": [...], "next": "<cursor>" }, 100 at a time, newest first. Passnextback as?cursor=, with the same filters, for the next page. - Merges take
sha, theheadShafrom the detail response you reviewed. If the head moved since, the merge is refused with409. - Limits: a title is at most 256 characters, and a body or a comment at most 65,536. A longer one gets
422. - Freshness: a read always shows the writes before it. See Read your own change at once for the indexes that can be a moment behind.
For tokens:
- Refused tokens: a token that is unknown, revoked or expired gets
401. It is never treated as anonymous. - Tokens limited to repositories get
403on other repositories and on account routes, such as/user.
The main routes
| You want to | Route |
|---|---|
| List or open issues | GET or POST /repos/{owner}/{repo}/issues |
| List the issue templates, to open an issue from one (how) | GET /repos/{owner}/{repo}/issue-templates |
| Report a bug in a package to its repository (how) | POST /upstream-issues |
| List or open pull requests | GET or POST /repos/{owner}/{repo}/pulls |
| Comment | POST /repos/{owner}/{repo}/issues/{n}/comments |
| Assign people, each with an optional note | POST or PUT /repos/{owner}/{repo}/issues/{n}/assignees |
| List the people to offer in an assignee picker | GET /repos/{owner}/{repo}/assignees |
| Merge | PUT /repos/{owner}/{repo}/pulls/{n}/merge |
Make a repository, with optional topics | POST /repos |
| Upload an asset | PUT /repos/{owner}/{repo}/assets/files/{path} |
| Publish a plan, a report or a page as an artifact (how) | GET or POST /repos/{owner}/{repo}/artifact-pages, or /accounts/{owner}/artifact-pages for a profile |
| Read or save the agent memories of a repository (how) | GET /repos/{owner}/{repo}/memories, PUT /repos/{owner}/{repo}/memories/{name} |
Change the profile of your account or of an organization, like timezone | PATCH /user or PATCH /orgs/{org} |
| Upload an image | PUT /user/avatar or PUT /orgs/{org}/avatar |
| Read or write a profile README | GET or PUT /user/readme or /orgs/{org}/readme |
- Issue templates:
POST .../issuestakestemplate(a file name or a template name) andfields(the values of an issue form, by key). A refusal for a missing field gets422. See Get complete issues with templates and forms. - Topics:
topicsis a list of up to 10, like["api", "cli"]. - Profile README:
PUTtakescontentandbaseOid, theheadOidof theGET. Your profile and image has the details. - Attachments: a bot that cannot write to the repository can still upload an image or a video for a comment. See Upload an attachment from a bot.
Issue and pull request routes
A path that starts with ... is under /repos/{owner}/{repo}. Issues and pull requests share their numbers.
| You want to | Route | Who can |
|---|---|---|
| Edit a comment, a review summary or a line comment | PATCH .../issues/comments/{id} | The author of the comment, the triage role or more |
| Delete a comment, a review summary or a line comment | DELETE .../issues/comments/{id} | The author of the comment, the triage role or more |
| Hide a comment with a reason, or unhide it | POST or DELETE .../issues/comments/{id}/hide | The triage role or more |
| List the earlier versions of a comment, or of an issue or pull request description | GET .../issues/comments/{id}/revisions, GET .../issues/{n}/revisions | Everyone who can read the comment or the item |
| Delete an earlier version | DELETE .../issues/revisions/{id} | The author of the text, repository admins |
| Lock or unlock a conversation | PUT or DELETE .../issues/{n}/lock | People with write access |
| List the reactions of an issue or a pull request, add one, or remove yours | GET or POST .../issues/{n}/reactions, DELETE .../issues/{n}/reactions/{content} | Readers list them, people who can comment add and remove |
| The same for a comment | GET or POST .../issues/comments/{id}/reactions, DELETE .../issues/comments/{id}/reactions/{content} | Readers list them, people who can comment add and remove |
| Pin or unpin an issue | PUT or DELETE .../issues/{n}/pin | People with write access |
| Move an issue to another repository of the owner | POST .../issues/{n}/transfer | People with write access to both |
| List the branches of an issue, or make one | GET or POST .../issues/{n}/branches | Readers list them, people with write access make one |
| Delete an issue | DELETE .../issues/{n} | Repository admins |
| List the issue templates and the template chooser config | GET .../issue-templates | Readers. Only admins get problems |
| Mark a draft ready, or make it a draft again | PUT or DELETE .../pulls/{n}/ready | The author, people with write access |
| List the people to offer in an assignee picker | GET .../assignees | The triage role or more |
| Ask for reviews, or stop asking | POST .../pulls/{n}/reviewers | The triage role or more |
| Bring the base branch into the head branch | POST .../pulls/{n}/update-branch | People with write access to the head branch |
| Commit the suggestions of line comments to the head branch, in one commit | POST .../pulls/{n}/suggestions/apply | People with write access to the head branch |
| Merge a pull request by itself when its checks pass, or stop it | PUT or DELETE .../pulls/{n}/auto-merge | People who can merge. The person who turned it on can also stop it |
| List the merge queues | GET .../pulls/queue | Readers |
| Add a pull request to the merge queue, or take it out | PUT or DELETE .../pulls/{n}/queue | People who can merge. The person who added it can also take it out |
| Revert a merged pull request | POST .../pulls/{n}/revert | People with write access |
| Read the stack of a pull request | GET .../pulls/{n}/stack | Readers |
| Unlink a pull request from the one below it, link it again, or break its stack | POST .../pulls/{n}/stack/unlink, .../stack/link or .../stack/break | The author, people with write access |
| Get the private companion, to push the branch of a private pull request | POST .../private-remote | People with write access |
| Make a private pull request public | POST .../pulls/{n}/make-public | People who can merge |
| Share a private pull request, read only, with a link or with people. List its shares, or stop one | POST or GET .../pulls/{n}/shares, DELETE .../pulls/{n}/shares/{id} | People with write access. Never an agent or a job |
Build a list of issues or pull requests
A list page needs the age, the last change and the branches of each row, with no read of each item. Each row of GET .../issues and GET .../pulls has these times, in milliseconds since 1970:
createdAt: when the item was opened.updatedAt: when the item last changed.closedAt: when the item was closed or merged. It isnullwhile the item is open.
Each row of GET .../pulls also has its branches:
base: the base branch, likemain.head: the head branch, orowner:branchfor a fork.headSha: the head commit.
head and headSha are null when the head is hidden: a public pull request from a fork that is private now. The MCP tools list_issues and list_pull_requests give the same rows.
Show the timeline of an item
GET .../issues/{n} (MCP get_issue) reads an issue or a pull request. It has createdAt, updatedAt and closedAt, as a list row has. Its timeline holds the comments and the events, 100 at a time.
Each event has event, actor, agent, by and at. Some events also name what changed:
event | Extra field |
|---|---|
labeled, unlabeled | labels: the label names |
assigned, unassigned | assignees: the usernames |
review_requested, review_request_removed | reviewer: the username, or null when it is not known |
Other events have no extra field.
Fill an assignee picker
GET .../assignees (MCP list_assignees, src repo assignees) gives the people that the web assignee picker shows. You need the triage role or more. The answer is a list of up to 50 people, each { "username": "ana", "displayName": "Ana" }, sorted by username. displayName can be empty. The list has:
- The owner of a personal repository.
- The members of the organization that owns the repository. A private member shows only when you are a member of that organization.
- The collaborators of the repository.
You can also assign a person who is not in this list, by username, when they can read the item. See Assign people to issues and pull requests.
Read a pull request without loading its diff
GET .../pulls/{n} returns metadata and stored comparison facts. It does not compute a diff or check whether the pull request can merge. baseSha and headSha name the known commits. After a merge, mergeCommitSha, mergedAt (milliseconds) and mergedBy (a username) name the merge. They are null before it. mergeable, changedFiles, changedLines and tooLarge are null when facts are missing or stale. Facts must match both commits. An oversized comparison has unknown file and line counts. No commit count, separate addition or deletion counts, or conflict paths are stored.
Stored fork and GitHub heads can lag. Closed and merged pull requests use recorded commits; missing recorded IDs stay null. A stored clean result never grants permission to merge.
Read details only when you need them. These routes require the same pulls:read access as the summary:
| Route | Data |
|---|---|
GET .../pulls/{n}/files | files: paths, status, additions, deletions, binary and truncation flags, plus available old/new paths, object IDs, modes and sizes |
GET .../pulls/{n}/commits | commits: PR-only commits, with commitsTruncated when the newest 250 do not cover the full list |
GET .../pulls/{n}/diff | patch: the unified diff, with truncated when content is cut |
Each detail response has the actual baseSha, headSha and mergeBaseSha, plus available, unavailable and tooLarge. Missing refs, missing historical IDs or a hidden fork give available: false. A size refusal also gives available: false and a reason in tooLarge. The requested data is then null, not an empty successful result. File and patch responses also have truncated; each file keeps its own flag. Partial line counts are not exact totals.
A diff stops at its limits, so one read never blocks the repository for long. A file is truncated when a side is over 512 KB, or when it changes in more than 2,000 lines. An added or a deleted file has no line limit. The diff stops after 20,000 lines, or after 8 MiB of files read: the files after that point are truncated too, with no line counts and no sizes. A merged or closed pull request compares the two commits that it recorded, which never change. After the first read, its files, commits and diff come from a cache.
Use the headSha from the detail response you reviewed as the merge request's sha. If you combine detail responses, check that both base and head SHAs match. The merge still checks current policy, branch rules, conflicts and the head SHA.
Update your installed src CLI before using this response format. Older binaries expect files, commits and patch in the summary and can show false empty results. The updated CLI reads details only when requested. It fails clearly for unavailable results, and warns on stderr for truncated ones.
Comments, reactions and locks
- Edit a comment: the body is
{"body": "New text"}. The comment id is theidin the timeline ofGET .../issues/{n}. An empty body gets422, except for a review summary. See Edit the title, the description and comments. - Delete and hide a comment:
DELETE .../issues/comments/{id}answers{ "ok": true, "notice": null }. On a repository that syncs with GitHub,noticesays when GitHub keeps the comment. The hide body is{"reason": "off_topic"}. A reason isspam,abuse,off_topic,outdated,duplicateorresolved. See Hide or delete a comment. - Earlier versions: each version is
{ id, body, editor, createdAt }, newest first, at most 50. See Delete an earlier version. - Reactions: the
POSTbody is{"content": "+1"}. The names are the names of GitHub:+1,-1,laugh,hooray,confused,heart,rocketandeyes. Another name gets400. The comment id is theidin the timeline ofGET .../issues/{n}. - Reaction answers:
POSTanswers201andDELETEanswers200, each with{ number, reactions }: every emoji of the issue or the comment, its count,meand up to 10byusernames.GETgives each emoji with its count and the usernames of up to 100 people. - Suggestions: the body is
{"commentIds": [31, 32], "message": "Apply the review suggestions"}, withmessageoptional. The answer is{"sha": "<the new commit>"}. When the forge refuses a suggestion, it commits none and answers422with the reason. See Suggest a change in a review. - Lock: the body is
{"reason": "too_heated"}, or empty for no reason. A reason isoff_topic,too_heated,resolvedorspam.
Drafts, reviewers and private pull requests
- Drafts and reviewers:
POST .../pullsalso takes"draft": trueand"reviewers": ["ana"]. Nobody can merge a draft. - Private pull requests: push the branch to the
cloneUrlofPOST .../private-remote, then sendPOST .../pullswith"private": true. Only people with write access, and the author, see the pull request. See Work on a change in private.
Share a private pull request
Send POST .../pulls/{n}/shares to show one private pull request of a public repository to a person outside the team, read only. The answer is 201.
- A link: the body is
{"kind": "link", "days": 7}.daysis 1, 7 or 30. The answer is{"kind": "link", "level", "id", "token", "label", "expiresAt", "url"}. Only this answer has thetokenand theurl. - A label: add
"label": "Ana's review"to a link, so that you can find it in the list later. It has at most 100 characters. The forge trims it, and a blank label is none. You cannot change it later. - People: the body is
{"kind": "people", "users": ["ana", "ben"]}, with up to 50 usernames. The answer is{"kind": "people", "level", "people": [{"id", "userId", "username"}]}. Each person gets a notification. - Level: add
"level": "everything"to also show the CI logs, the artifacts and the agent run logs of the pull request. The default is"page". The run logs of the agents that read the intent of the pull request stay hidden. - List:
GET .../pulls/{n}/sharesanswers{"links": [...], "people": [...]}, newest first. Each share has itsleveland itsstate:live,expiredorrevoked. Each link has itslabel,nullwhen it has none. A link never shows its token again. - Stop:
DELETE .../pulls/{n}/shares/{id}answers{"revoked": true}.
The forge refuses:
- A public pull request, with
422: "This pull request is public: only a private pull request can be shared". - A pull request of a private repository, with
422: "Only a private pull request of a public repository can be shared". - A username with no account, with
422: "No account named ana". - A
labelthat is not text, is longer than 100 characters, or comes with"kind": "people", with400: "labelis text", "labelis at most 100 characters" or "labelworks only for a link". - A caller with no write access, an agent session token or a job token, with
403.
A share link works only in a browser. REST refuses its tsv_ token. A person that you named reads the pull request over REST with their own token. See Share a private pull request.
Moves, merges and stacks
- Transfer: the body is
{"repo": "acme/docs"}. After the move,GET .../issues/{n}at the old place answers301with the new place. - Merge when ready: the
PUTbody is optional:{"merge_method": "squash", "commit_title": "Fix the crash (#7)", "commit_message": ""}.merge_methodismerge(the default),squashorrebase. The answer hasautoMerge:enabledBy,methodandenabledAt, ornullwhen it is off. See Merge when ready. - Merge queue: the
PUTbody is the body of merge when ready.GET .../pulls/queue?base=mainlists the queue of one base branch. The answer ofPUTandDELETEhasmergeQueue:addedBy,method,addedAt,base,positionandphase, ornullwhen the pull request is not in the queue. See Merge pull requests one at a time with the merge queue. - Update branch:
{"rebase": true}rebases in place of a merge. Withsha, a head that moved is refused. A conflict gets409. - Stacks:
PUT .../pulls/{n}/mergealso lands the linked pull requests below{n}, bottom first, and its answer lists them inlanded. See Split a change into a stack.
See Lock, pin, move and delete issues and Drafts, reviews and updates of pull requests.
Repository routes
A path that starts with ... is under /repos/{owner}/{repo}.
| You want to | Route | Who can |
|---|---|---|
| Change the description, default branch or crawler blocking | PATCH /repos/{owner}/{repo} | The maintain role or more, admin for blockCrawlers |
| Rename a repository | POST .../rename | Repository admins |
| Archive or unarchive a repository | PUT or DELETE .../archive | Repository admins |
| Delete a repository | DELETE /repos/{owner}/{repo} | Repository admins, people only |
| Sync a fork from its parent | POST .../sync | People with write access to the fork, people only |
| List, add or delete autolinks | GET or POST .../autolinks, GET or DELETE .../autolinks/{id} | Repository admins |
| List or add webhooks | GET or POST .../hooks | Repository admins |
| Read, change or delete a webhook | GET, PATCH or DELETE .../hooks/{id} | Repository admins |
| Send a ping to a webhook | POST .../hooks/{id}/pings | Repository admins |
| Make a new secret for a webhook | POST .../hooks/{id}/secret | Repository admins |
| List the newest deliveries of a webhook | GET .../hooks/{id}/deliveries, with ?limit= up to 100 (50 by default) | Repository admins |
| Send a delivery of a webhook again | POST .../hooks/{id}/deliveries/{delivery}/attempts | Repository admins |
| Follow the changes of items, checks, pushes, CI runs or a CI job's log, live | GET .../events (Server-Sent Events) | Readers |
| Wait for the next change of items, checks, pushes, CI runs or a CI job's log | GET .../events/wait | Readers |
| List, set or delete expert entries | GET .../experts, PUT or DELETE .../experts/{username} | Readers list them. The triage role or more sets your own entry, admins set anyone's. |
| Read the CODEOWNERS file of the default branch: its path, rules and errors | GET .../codeowners | Readers |
| Read only the errors of the CODEOWNERS file, in the fields of GitHub | GET .../codeowners/errors | Readers |
| List the templates for a new repository | GET /gitignore/templates, GET /licenses | Everyone |
| Start an upload of a push in parts | POST .../git/uploads | Write access. Not a job token |
| Send a part of an upload | PUT .../git/uploads/{id}/parts/{n} | The caller that started the upload |
| Finish an upload: the pack lands, and the refs move | POST .../git/uploads/{id}/finish | The caller that started the upload |
| Delete an upload | DELETE .../git/uploads/{id} | The caller that started the upload |
Repositories and monorepos
- Archived: every write to an archived repository gets
403, except the settings of its admins. - Delete: a repository with forks gets
422. Delete the forks first. - New repository:
POST /repostakesgitignore(a template name) andlicense(a license key). Its first commit has the files. - New monorepo:
POST /reposalso takesmembers, at most 50:[{"member": "acme/web"}, {"member": "acme/billing", "folder": "pay"}].folderis optional, and is the name of the repository by default. A bad member makes no repository, and the error names it. See Make a monorepo. - The answer with members: it also has
members(each withowner,name,folder,visibility,defaultBranchandcloneUrl) andmemberErrors.memberErrorslists each member that changed after the check and was not added, as[{"member": "acme/docs", "error": "..."}]. The repository and the other members stay.
See Rename, archive or delete a repository.
Webhooks
POST .../hookstakes{"url", "events", "active", "secret"}.eventsis a list ofpush,issues,pull_request,issue_comment,pull_request_reviewandci_run. When you leave them out,activeistrueandsecretis new.- It answers
201with{"hook", "secret"}. The secret shows only there, and in the answer{"secret"}ofPOST .../hooks/{id}/secret. PATCH .../hooks/{id}takesurl,eventsoractive, and keeps the fields that you leave out.DELETEanswers{"deleted": true}. A ping and a redelivery answer{"deliveryId"}.- The lists of webhooks and deliveries are plain arrays, not pages. A delivery never holds the secret or the signature.
- A bad URL, an unknown event, a 21st webhook, or a ping to a webhook that is off gets
422. An unknown webhook or delivery gets404. See Webhook events and payloads for what the forge sends.
Wait for changes
Neither route needs a public server. See Wait for changes over REST for the query, the events and a loop.
GET .../eventsis a live stream (Server-Sent Events). SendAccept: text/event-stream, or you get406. Each event is one frame, with its cursor asid. The forge ends the stream after 60 seconds: open the next one withLast-Event-IDset to the last id.GET .../events/waitis a long poll: the forge answers when a change comes, or aftertimeoutseconds. It answers{ events, cursor, reset }.scope=job&job=<job id>gives thelogevents of one CI job, on both routes.
Upload of a push in parts
The git/uploads routes take a push that is too large for one request, as a full pack (not thin). src repo push uses them: see Push a large repository. MCP has no upload, because a tool call cannot carry a pack.
Upload a large push in parts has the body and the answer of each route.
Search routes
A path that starts with ... is under /repos/{owner}/{repo}.
| You want to | Route |
|---|---|
| Filter the issues or the pull requests of a repository | GET .../issues or GET .../pulls, with author=, assignee=, mention= and label= |
| Search issues and pull requests across repositories | GET /search/issues?q= |
| List your issues and pull requests across repositories | GET /user/items?role=assigned, author, review-requested or mentioned |
| Read your home feed: reviews that wait for you, new comments on your items, and what the people you follow did | GET /user/feed |
| Find repositories | GET /search/repos?q= |
| Search the code of a repository or an owner | GET /search/code?q= |
| Search the commit messages and authors of a repository or an owner | GET /search/commits?q= |
| List your organizations | GET /user/orgs |
The filters of a repository list:
- A person filter takes a username, or
@mefor you. GET .../pullsalso takeshead=,draft=trueorfalse, andreviewRequested=.GET .../issuesandGET .../pullsalso takequery=, which searches the title and the description.#12or12also finds the items whose number starts with 12: 12, 120 and more.unseen=truekeeps only the items that are new to you. Each listed item hasnew(trueorfalse) andassignees(usernames).GET .../issues/{n}andGET .../pulls/{n}mark the item as seen. See See what is new since your last visit.
The searches and the feed:
GET /search/issuestakeskind=issueorpull,label=,draft=,author=,assignee=,mention=andreviewRequested=.GET /search/reposgives only the repositories that you can read. It leaves out forks, unless you addincludeForks=include.GET /search/codeandGET /search/commitstake GitHub's query syntax inq, which must name a repository (repo:owner/name) or an owner (owner:), andpageandper_page.GET /search/commitsalso takessort=author-dateorcommitter-date, andorder. See Search code and commits.GET /user/feedgives{ waiting, comments, following }. Each item ofcommentshaslastComment, and each entry offollowinghas its weburl. An agent token gets an emptyfollowing. See Catch up on your home page.
Community routes
The Community tab of a repository is read only over REST. People post, vote, answer and run the roadmap on the web. A path that starts with ... is under /repos/{owner}/{repo}.
| You want to | Route |
|---|---|
| List the feature requests | GET .../discussions?category=request |
| List the questions | GET .../discussions?category=question |
| Read one post, with its replies | GET .../discussions/{n} |
| Read the roadmap | GET .../roadmap |
- Feature requests:
sort=top(the default),neworactive.state=open,accepted,declined,duplicateorshippedkeeps one state. - Questions:
filter=unanswered,answeredorall(the default).sort=new(the default) oractive. - Paging: a list gives 50 posts and
next. Passnextback ascursor. A post gives 100 replies andnext. Passnextback asafter. - Community off: each route answers
404.
CI routes
The CI reference lists every CI route. These paths are under /repos/{owner}/{repo}:
| You want to | Route | Who can |
|---|---|---|
| Read or change the CI variables | GET /ci/variables, GET, PUT or DELETE /ci/variables/{name} | People with write access read them, admins change them |
| List the workflows, or turn one on or off | GET /ci/workflows, PUT or DELETE /ci/workflows/{workflow}/enabled | Readers list them, admins turn them on or off |
| Delete a run that ended | DELETE /ci/runs/{id} | Repository admins. A run of a pull request gets 422. |
| Read or change the branch rules, with their review rules | GET /ci/rules, PUT or DELETE /ci/rules/{pattern} | Readers list them, admins change them |
| Read or change the tag rules | GET /tag-rules, PUT or DELETE /tag-rules/{pattern}, with the pattern URL-encoded | Readers list them, admins change them |
| List the agent jobs | GET /jobs?kind=agent | Everyone who can read the jobs |
While billing is on, POST /jobs answers 402 when the owner of the repository has no container time left. Its error says why.
Why a job did not pass or has not started
endReason: each job ofGET /ci/runs/{id}has it. It says in words why the job did not pass: its error, its time limit, who cancelled it, or how many findings it reported. It isnullfor a job that passed, was skipped, waits or runs, and when nothing says why.waitReason: each job ofGET /ci/runs/{id}has it too. It isneeds,slotsorauthor-dayfor a job of an active run that waits, elsenull.- A run that never started: when the forge cannot start a push or a pull request run, the run fails with no jobs. Its
warningssay why, and what to do. InGET /ci/runs, such a run hasplanErrorswith the same texts. - The required checks: each check of
GET /pulls/{n}/checkshasjobId, the job that its reason is about, ornull. - Billing: a job of paid CI (private CI, or paid public CI) that billing refused failed with
jobIdnull. Itssummarysays why. See When nothing is left.
See When something on your pull request fails.
App routes
For people and agents, these routes manage the apps of a repository:
| You want to | Route | Who can |
|---|---|---|
| List the app installs that cover a repository | GET /repos/{owner}/{repo}/apps | Everyone who can read the repository |
| Take the repository out of an install that picked it | DELETE /repos/{owner}/{repo}/apps/{install} | Repository admins |
| List the app installs of an account, with their repositories | GET /app-installs?owner={name} | The owner of the account, a person only |
| Uninstall an app from its account | DELETE /app-installs/{install} | The owner of the account, a person only |
| Click a webhook button of the card of an app | POST /repos/{owner}/{repo}/pulls/{n}/app-cards/{slug}/buttons/{button}/click | People who can read the pull request |
GET /repos/{owner}/{repo}/appsanswers a list, not a page: each install withinstallId,app(slugandname),repos(allorpicked),actionsandevents.GET /app-installs?owner={name}answers the same fields, withreposasallor a list ofidandname.- The server of an app calls other routes with its app secret or its install token: tokens, setup codes, deliveries and its card. They are in Build an app and Cards and statuses.
- Registering, installing and deleting an app, and connecting it to more repositories, are on the web only, because each needs a person to agree.
Factory and ban routes
These routes run the software factory and bans. A path that starts with ... is under /repos/{owner}/{repo}, or under /orgs/{org} for an organization.
Note
Settings, keys, custom agents and bans are for people only. They refuse an agent session token.
Settings and keys
| You want to | Route | Who can |
|---|---|---|
| Read or change the factory settings | GET or PUT .../factory/settings | Repository admins, organization owners |
| List the model keys | GET .../factory/keys | Repository admins, organization owners |
| Save or delete a model key | PUT or DELETE .../factory/keys/{provider} | Repository admins, organization owners |
A settings PUT takes only the fields that you change. null clears a field, so the organization value or the default holds again. This body turns on the review and its fixes:
{"agents": {"review": {"enabled": true, "steps": {"fix": true}}}}
- Agents:
agentstakes the agent ids:audit,spam,review,keep-green,summary,triage,assign,issue-fix,deps,architectureandci-cache. Every agent is off by default. The switches of an agent are insteps. See Models, keys and triggers. - Spend cap:
monthlySpendCapUsdsets a monthly spend cap in dollars, on an organization only. While billing is off for the organization, it is at most the maximum of the forge. While billing is on, it can be up to 100,000 dollars. See The monthly spend cap. - Spend: the
GETanswer hasspend, withspentMicros(this UTC month, in millionths of a dollar) andcapUsd, the cap that holds. While billing is on for the owner,spendalso hasbilling, withaiLeftMicros(what billing leaves for forge-paid AI this period, in millionths of a dollar at 1.5 times the cost to the forge) andurl(the path of the Billing page of the owner, ornullon a repository of another person, whose Billing page is for that person only).capUsdis then the lower of two caps: the cap that a site admin gave the account, and the cap of the organization. It isnullwhen neither is set. - Chats:
prChatandarchChatset the PR chat and the architecture chat, each withenabledandmodel, for example{"archChat": {"enabled": false}}. The two chats are web only: no route asks them a question. - Keys:
PUT .../factory/keys/{provider}takes{"key": "<key>"}. No route gives a key back.GETlists the providers and the time that each key was set.
Custom agents
| You want to | Route | Who can |
|---|---|---|
| List the custom agents | GET /repos/{owner}/{repo}/factory/agents | Repository admins |
| See the custom agents that loaded, and the errors of the files | GET /repos/{owner}/{repo}/factory/agents/status | Repository admins |
| Save or delete a custom agent | PUT or DELETE /repos/{owner}/{repo}/factory/agents/{name} | Repository admins |
- Save: a
PUTtakes{"script": "<file>"}, a TypeScript file that default-exportsdefineFactory(...). Each agent is{ agent: defineAgent(...), on, trigger }, with an optionalmodeland an optionalbudget({ maxTokens, maxCostCents }) that stops the run at that limit. See Custom agents. - Status:
GET .../factory/agents/statusgivessource(vaultorrepo-file), theagentsthat loaded (name, factory, file and events), anderrors, one line for each error with its file. It can take a few seconds when the files changed.
Runs and activity
| You want to | Route | Who can |
|---|---|---|
| List the runs on an issue or a pull request | GET /repos/{owner}/{repo}/issues/{n}/factory | Everyone who can read the item |
| See what runs on an issue or a pull request now | GET /repos/{owner}/{repo}/issues/{n}/activity, or .../pulls/{n}/activity | Everyone who can read the item |
| See what runs on every item now | GET /repos/{owner}/{repo}/activity | Everyone who can read the repository |
| List the newest runs of the repository | GET /repos/{owner}/{repo}/factory/runs | People with write access |
| Read one run, its verdicts and its log | GET /repos/{owner}/{repo}/factory/runs/{id} | People with write access |
- One item now:
screening, and therunsthat arequeuedorrunning, each withrunId,agent,step,status,createdAtandstartedAt. See See what runs on an item. - Every item now: the
runsthat arequeuedorrunning, each with thenumberof its item,agent,stepandstatus. Alsoheld, the countsscreeningandquarantined(0 for people who are not maintainers). - Newest runs: the runs of every item and of the default branch, each with its
number(nullfor the branch).?limit=goes up to 500, 50 by default. Each run hasagent(the agent id) andstep(the step id, for examplefixer). - Run filters:
?agent=keeps the runs of one agent (all its steps) or of one step.?status=keeps the runs with one status:queued,running,succeeded,failed,skippedorcancelled. Any other status gets 400. See Factory runs. - Run logs come one page at a time. Pass
nextfrom the log back as?cursor=.
Architecture, impact and dependencies
| You want to | Route | Who can |
|---|---|---|
| Read the architecture of the repository | GET /repos/{owner}/{repo}/architecture | Everyone who can read the code |
| Make the architecture now | POST /repos/{owner}/{repo}/architecture | People with write access |
| Read the impact of a pull request | GET /repos/{owner}/{repo}/pulls/{n}/impact | Everyone who can read the pull request |
| Read the dependencies, the update groups and the rules of the dependency agent | GET /repos/{owner}/{repo}/factory/dependencies | Everyone who can read the code |
| Check the dependencies now | POST /repos/{owner}/{repo}/factory/dependencies/check | People with write access |
| Set or remove the rule of a dependency | PUT or DELETE /repos/{owner}/{repo}/factory/dependencies/rules/{name} | People with write access |
- Architecture:
GET .../architecturegivesrecord(the overview, the packages and the diagrams, ornullbefore the first run), thecommitthat it describes,at,runId,running,enabled,canGenerateandskills.skillsholds the skill folders of each package, by package name, each withname,pathanddescription. - The record: each package of
recordcan haveusage(markdown) andwhenToUse(short lines). Each diagram hasnodesandedges, ormermaidin an older view. - Make it now:
POST .../architecturestarts a run on the tip of the default branch:201with{"runId": "..."}, or200with{"skipped": "<why>"}. See Read the architecture of a repository. - Impact:
GET .../pulls/{n}/impactgives the head commit (headOid), theassessmentof that head, therecord(architectureandpublicApi, each only when it applies),runningandenabled. See Read the Impact tab.
The dependency routes:
GET .../factory/dependenciesgivesenabled(the agent that fixes failing update pull requests),autoUpdate,settings, the newestplan(ornullbefore the first check), thegroups, therules,dueAt(the next check, in ms) andrunning.POST .../factory/dependencies/checkbuilds a new plan and starts no run:200with{"checked": {"commit": "<sha>", "groups": 2}}, or{"skipped": "<why>"}.POST .../factory/dependencies/updatetakes{"group": "minor-patch"}, or{}for every group, and opens or updates the pull requests:201with{"started": ["<run id>"]}, or200with{"skipped": "<why>"}.- A rule
PUTtakes{"kind": "ignore"},{"kind": "no-major"}or{"kind": "ignore-version", "version": "4.17.20"}. A scoped name keeps its/, as in.../rules/@types/node.
See Keep dependencies up to date.
Bans
| You want to | Route | Who can |
|---|---|---|
| List the bans | GET .../bans | Repository admins, organization owners |
| Ban an account, or lift its ban | PUT or DELETE .../bans/{username} | Repository admins, organization owners |
| Read the spam signals of an account | GET /repos/{owner}/{repo}/bans/{username}/signals | Repository admins |
| List the suggested bans | GET .../bans/suggestions | Repository admins, organization owners |
| Ban the account of a suggested ban, or dismiss it | POST .../bans/suggestions/{id}/accept or .../dismiss | Repository admins, organization owners |
- Suggested bans:
GET .../bans/suggestionsgives the open ones. Each has itsid, the account, the item that the spam agent closed (repoandnumber), thereasonsand thesignals. Add?status=bannedor?status=dismissedfor the decided ones. - Accept and dismiss:
acceptbans the account with the reason spam. Afterdismiss, the spam agent suggests the same ban again only after 30 days, or with hard proof. - Appeals: a banned person appeals on the web only. No route opens or decides an appeal.
Skill routes
Find and read skills. Public skills need no token.
| You want to | Route |
|---|---|
| Search the marketplace | GET /skills?q= |
| List the skills of an owner | GET /skills?owner= |
| List trending, popular skills or tags | GET /skills/trending, GET /skills/popular, GET /skills/tags |
| List rising skills: new skills that people install and star now | GET /skills/rising |
| Read a skill with its files | GET /skills/{address} |
| List the versions, or compare two | GET /skills/versions?address=, GET /skills/diff?address=&from=&to= |
- Rising lists the skills that are 7 days old or newer. Trending lists the older skills.
- Both rank skills by the stars and installs of the last 7 days.
- Add
?days=(at most 90) to change the 7 days, and?tag=to keep one tag.
Change your own skills (people only):
| You want to | Route |
|---|---|
| Create a skill | POST /skills |
| Change its files | PATCH /skills/{owner}/{name}/files |
| Rename it, or change its visibility | POST /skills/{owner}/{name}/rename, PUT /skills/{owner}/{name}/visibility |
| Make, list or revoke share links | POST /skills/{owner}/{name}/shares, GET /skills/shares?address=, DELETE /skills/{owner}/{name}/shares/{id} |
| Delete it | DELETE /skills/{owner}/{name} |
Skills in a repository:
| You want to | Route |
|---|---|
| List them, with their state | GET /repos/{owner}/{repo}/skills |
| Add one | POST /repos/{owner}/{repo}/skills |
| Update or remove one | PATCH or DELETE /repos/{owner}/{repo}/skills/{name} |
| Get suggestions | GET /repos/{owner}/{repo}/skills/suggestions |
| Count an install that you made yourself | POST /skills/installs |
A share link of a private skill goes in ?share= or in a share field, never in the Authorization header. See Agent skills for the addresses.
Billing routes
These routes read the billing of an account: its plan, the money of its current period, and what it used in this UTC month. They also give a person a link to pay, or to manage the billing, in Polar. Plans and billing explains the plans, and See what your account uses says what counts.
| You want to | Route | Who can |
|---|---|---|
| Read the billing of your own account | GET /user/billing | You, as a person |
| Read the billing of an organization | GET /orgs/{org}/billing | The owners of the organization |
| Get a link to buy a plan or credits | POST /user/billing/checkout or POST /orgs/{org}/billing/checkout | You as a person, or the owners of the organization |
| Get a link to the billing portal | POST /user/billing/portal or POST /orgs/{org}/billing/portal | You as a person, or the owners of the organization |
The answer of GET has these fields:
| Field | What it holds |
|---|---|
account | kind (user or org) and name |
enabled | true while billing is on for the account: billing is on for the site, or a site admin turned it on early for the account. It is false while billing is off for the site and not on early for the account, or when a site admin made the account exempt. Then the money fields show what the period costs, and nothing is charged. |
plan, seats, period | The plan (free, pro, team or enterprise), its seats, and the start and end of the current period in milliseconds. The end is not in the period. |
included, used, left | What the plan includes, what the period used and what is left, each as ciMilli and aiMicros |
creditsBalance, charge, creditsUsed, overage, overageEnabled, limitMicros, debt | The credits before the charge of the period, and the cost of the usage over the plan. Credits pay first, then overage up to limitMicros while overageEnabled is true. debt is what nothing paid. |
settings | The billing settings of the account: plan, complimentary, exempt, early (billing is on for the account before the site), and the overageEnabled and spendLimitMicros that an owner set. Then what Polar has: interval (month or year), cancelAtPeriodEnd, periodEnd, hasPolarCustomer and hasSubscription. |
publicCi | The free public CI of the period, in milli-minutes: usedMilli (what the period used) and freeMilli (20,000 CI minutes). Only small jobs of public repositories are free. |
usage | period (the month, YYYY-MM), lines (one for each UTC day, item and privacy) and totals |
- Units: CI minutes are in milli-minutes (1,000 is 1 CI minute). Money is in micro-dollars (1,000,000 is 1 dollar).
- An organization: a member who is not an owner gets
403. Anyone else gets404. - Refused tokens: agent, job and app tokens get
403. So does a token limited to repositories. - Overage: no route turns on overage or sets the monthly spending limit. See Turn on overage.
Links to pay and to manage billing
A script or an agent cannot pay. It gets a link and gives it to the person, who opens it in a browser. Polar, the payment provider, asks for the card there.
- Checkout: the body is
{"plan": "pro"}or{"credits": 25}. A plan isprofor a person, andteamorenterprisefor an organization. Add"interval": "year"for a yearly plan:monthis the default. A credit pack is10,25or100dollars. A Team or Enterprise checkout starts with the seats of the organization. - Portal: no body. In the portal, the person changes the card, reads the invoices, and cancels or resumes the plan. The link signs the person in for 1 hour, so get a new one each time.
- Answer: both routes answer
{"url": "<the link>"}. After the payment, Polar sends the person back to the Billing page, and the account gets its plan or its credits. - Refusals: a body with both
planandcredits, or with neither, gets400. A purchase that the account cannot make gets422, anderrorsays why. For example, billing is not on for the account yet, or the account has a plan already. The portal of an account that bought nothing yet gets422too. - Plan changes: no route changes a plan. The person changes it on the Billing page.
Account approval
New accounts need approval before the routes that need a login work. Existing accounts keep their access. See Get approved and invite someone for approval, invite codes, the waitlist and their REST routes.