Skip to content
Source
Sign inSign up

REST API reference

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. Pass next back as ?cursor=, with the same filters, for the next page.
  • Merges take sha, the headSha from the detail response you reviewed. If the head moved since, the merge is refused with 409.
  • 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 403 on other repositories and on account routes, such as /user.

The main routes

You want toRoute
List or open issuesGET 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 requestsGET or POST /repos/{owner}/{repo}/pulls
CommentPOST /repos/{owner}/{repo}/issues/{n}/comments
Assign people, each with an optional notePOST or PUT /repos/{owner}/{repo}/issues/{n}/assignees
List the people to offer in an assignee pickerGET /repos/{owner}/{repo}/assignees
MergePUT /repos/{owner}/{repo}/pulls/{n}/merge
Make a repository, with optional topicsPOST /repos
Upload an assetPUT /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 timezonePATCH /user or PATCH /orgs/{org}
Upload an imagePUT /user/avatar or PUT /orgs/{org}/avatar
Read or write a profile READMEGET or PUT /user/readme or /orgs/{org}/readme
  • Issue templates: POST .../issues takes template (a file name or a template name) and fields (the values of an issue form, by key). A refusal for a missing field gets 422. See Get complete issues with templates and forms.
  • Topics: topics is a list of up to 10, like ["api", "cli"].
  • Profile README: PUT takes content and baseOid, the headOid of the GET. 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 toRouteWho can
Edit a comment, a review summary or a line commentPATCH .../issues/comments/{id}The author of the comment, the triage role or more
Delete a comment, a review summary or a line commentDELETE .../issues/comments/{id}The author of the comment, the triage role or more
Hide a comment with a reason, or unhide itPOST or DELETE .../issues/comments/{id}/hideThe triage role or more
List the earlier versions of a comment, or of an issue or pull request descriptionGET .../issues/comments/{id}/revisions, GET .../issues/{n}/revisionsEveryone who can read the comment or the item
Delete an earlier versionDELETE .../issues/revisions/{id}The author of the text, repository admins
Lock or unlock a conversationPUT or DELETE .../issues/{n}/lockPeople with write access
List the reactions of an issue or a pull request, add one, or remove yoursGET or POST .../issues/{n}/reactions, DELETE .../issues/{n}/reactions/{content}Readers list them, people who can comment add and remove
The same for a commentGET 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 issuePUT or DELETE .../issues/{n}/pinPeople with write access
Move an issue to another repository of the ownerPOST .../issues/{n}/transferPeople with write access to both
List the branches of an issue, or make oneGET or POST .../issues/{n}/branchesReaders list them, people with write access make one
Delete an issueDELETE .../issues/{n}Repository admins
List the issue templates and the template chooser configGET .../issue-templatesReaders. Only admins get problems
Mark a draft ready, or make it a draft againPUT or DELETE .../pulls/{n}/readyThe author, people with write access
List the people to offer in an assignee pickerGET .../assigneesThe triage role or more
Ask for reviews, or stop askingPOST .../pulls/{n}/reviewersThe triage role or more
Bring the base branch into the head branchPOST .../pulls/{n}/update-branchPeople with write access to the head branch
Commit the suggestions of line comments to the head branch, in one commitPOST .../pulls/{n}/suggestions/applyPeople with write access to the head branch
Merge a pull request by itself when its checks pass, or stop itPUT or DELETE .../pulls/{n}/auto-mergePeople who can merge. The person who turned it on can also stop it
List the merge queuesGET .../pulls/queueReaders
Add a pull request to the merge queue, or take it outPUT or DELETE .../pulls/{n}/queuePeople who can merge. The person who added it can also take it out
Revert a merged pull requestPOST .../pulls/{n}/revertPeople with write access
Read the stack of a pull requestGET .../pulls/{n}/stackReaders
Unlink a pull request from the one below it, link it again, or break its stackPOST .../pulls/{n}/stack/unlink, .../stack/link or .../stack/breakThe author, people with write access
Get the private companion, to push the branch of a private pull requestPOST .../private-remotePeople with write access
Make a private pull request publicPOST .../pulls/{n}/make-publicPeople who can merge
Share a private pull request, read only, with a link or with people. List its shares, or stop onePOST 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 is null while the item is open.

Each row of GET .../pulls also has its branches:

  • base: the base branch, like main.
  • head: the head branch, or owner:branch for 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:

eventExtra field
labeled, unlabeledlabels: the label names
assigned, unassignedassignees: the usernames
review_requested, review_request_removedreviewer: 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:

RouteData
GET .../pulls/{n}/filesfiles: paths, status, additions, deletions, binary and truncation flags, plus available old/new paths, object IDs, modes and sizes
GET .../pulls/{n}/commitscommits: PR-only commits, with commitsTruncated when the newest 250 do not cover the full list
GET .../pulls/{n}/diffpatch: 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 the id in the timeline of GET .../issues/{n}. An empty body gets 422, 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, notice says when GitHub keeps the comment. The hide body is {"reason": "off_topic"}. A reason is spam, abuse, off_topic, outdated, duplicate or resolved. 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 POST body is {"content": "+1"}. The names are the names of GitHub: +1, -1, laugh, hooray, confused, heart, rocket and eyes. Another name gets 400. The comment id is the id in the timeline of GET .../issues/{n}.
  • Reaction answers: POST answers 201 and DELETE answers 200, each with { number, reactions }: every emoji of the issue or the comment, its count, me and up to 10 by usernames. GET gives 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"}, with message optional. The answer is {"sha": "<the new commit>"}. When the forge refuses a suggestion, it commits none and answers 422 with the reason. See Suggest a change in a review.
  • Lock: the body is {"reason": "too_heated"}, or empty for no reason. A reason is off_topic, too_heated, resolved or spam.

Drafts, reviewers and private pull requests

  • Drafts and reviewers: POST .../pulls also takes "draft": true and "reviewers": ["ana"]. Nobody can merge a draft.
  • Private pull requests: push the branch to the cloneUrl of POST .../private-remote, then send POST .../pulls with "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}. days is 1, 7 or 30. The answer is {"kind": "link", "level", "id", "token", "label", "expiresAt", "url"}. Only this answer has the token and the url.
  • 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}/shares answers {"links": [...], "people": [...]}, newest first. Each share has its level and its state: live, expired or revoked. Each link has its label, null when 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 label that is not text, is longer than 100 characters, or comes with "kind": "people", with 400: "label is text", "label is at most 100 characters" or "label works 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 answers 301 with the new place.
  • Merge when ready: the PUT body is optional: {"merge_method": "squash", "commit_title": "Fix the crash (#7)", "commit_message": ""}. merge_method is merge (the default), squash or rebase. The answer has autoMerge: enabledBy, method and enabledAt, or null when it is off. See Merge when ready.
  • Merge queue: the PUT body is the body of merge when ready. GET .../pulls/queue?base=main lists the queue of one base branch. The answer of PUT and DELETE has mergeQueue: addedBy, method, addedAt, base, position and phase, or null when 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. With sha, a head that moved is refused. A conflict gets 409.
  • Stacks: PUT .../pulls/{n}/merge also lands the linked pull requests below {n}, bottom first, and its answer lists them in landed. 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 toRouteWho can
Change the description, default branch or crawler blockingPATCH /repos/{owner}/{repo}The maintain role or more, admin for blockCrawlers
Rename a repositoryPOST .../renameRepository admins
Archive or unarchive a repositoryPUT or DELETE .../archiveRepository admins
Delete a repositoryDELETE /repos/{owner}/{repo}Repository admins, people only
Sync a fork from its parentPOST .../syncPeople with write access to the fork, people only
List, add or delete autolinksGET or POST .../autolinks, GET or DELETE .../autolinks/{id}Repository admins
List or add webhooksGET or POST .../hooksRepository admins
Read, change or delete a webhookGET, PATCH or DELETE .../hooks/{id}Repository admins
Send a ping to a webhookPOST .../hooks/{id}/pingsRepository admins
Make a new secret for a webhookPOST .../hooks/{id}/secretRepository admins
List the newest deliveries of a webhookGET .../hooks/{id}/deliveries, with ?limit= up to 100 (50 by default)Repository admins
Send a delivery of a webhook againPOST .../hooks/{id}/deliveries/{delivery}/attemptsRepository admins
Follow the changes of items, checks, pushes, CI runs or a CI job's log, liveGET .../events (Server-Sent Events)Readers
Wait for the next change of items, checks, pushes, CI runs or a CI job's logGET .../events/waitReaders
List, set or delete expert entriesGET .../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 errorsGET .../codeownersReaders
Read only the errors of the CODEOWNERS file, in the fields of GitHubGET .../codeowners/errorsReaders
List the templates for a new repositoryGET /gitignore/templates, GET /licensesEveryone
Start an upload of a push in partsPOST .../git/uploadsWrite access. Not a job token
Send a part of an uploadPUT .../git/uploads/{id}/parts/{n}The caller that started the upload
Finish an upload: the pack lands, and the refs movePOST .../git/uploads/{id}/finishThe caller that started the upload
Delete an uploadDELETE .../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 /repos takes gitignore (a template name) and license (a license key). Its first commit has the files.
  • New monorepo: POST /repos also takes members, at most 50: [{"member": "acme/web"}, {"member": "acme/billing", "folder": "pay"}]. folder is 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 with owner, name, folder, visibility, defaultBranch and cloneUrl) and memberErrors. memberErrors lists 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 .../hooks takes {"url", "events", "active", "secret"}. events is a list of push, issues, pull_request, issue_comment, pull_request_review and ci_run. When you leave them out, active is true and secret is new.
  • It answers 201 with {"hook", "secret"}. The secret shows only there, and in the answer {"secret"} of POST .../hooks/{id}/secret.
  • PATCH .../hooks/{id} takes url, events or active, and keeps the fields that you leave out. DELETE answers {"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 gets 404. 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 .../events is a live stream (Server-Sent Events). Send Accept: text/event-stream, or you get 406. Each event is one frame, with its cursor as id. The forge ends the stream after 60 seconds: open the next one with Last-Event-ID set to the last id.
  • GET .../events/wait is a long poll: the forge answers when a change comes, or after timeout seconds. It answers { events, cursor, reset }.
  • scope=job&job=<job id> gives the log events 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 toRoute
Filter the issues or the pull requests of a repositoryGET .../issues or GET .../pulls, with author=, assignee=, mention= and label=
Search issues and pull requests across repositoriesGET /search/issues?q=
List your issues and pull requests across repositoriesGET /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 didGET /user/feed
Find repositoriesGET /search/repos?q=
Search the code of a repository or an ownerGET /search/code?q=
Search the commit messages and authors of a repository or an ownerGET /search/commits?q=
List your organizationsGET /user/orgs

The filters of a repository list:

  • A person filter takes a username, or @me for you.
  • GET .../pulls also takes head=, draft=true or false, and reviewRequested=.
  • GET .../issues and GET .../pulls also take query=, which searches the title and the description. #12 or 12 also finds the items whose number starts with 12: 12, 120 and more.
  • unseen=true keeps only the items that are new to you. Each listed item has new (true or false) and assignees (usernames). GET .../issues/{n} and GET .../pulls/{n} mark the item as seen. See See what is new since your last visit.

The searches and the feed:

  • GET /search/issues takes kind=issue or pull, label=, draft=, author=, assignee=, mention= and reviewRequested=.
  • GET /search/repos gives only the repositories that you can read. It leaves out forks, unless you add includeForks=include.
  • GET /search/code and GET /search/commits take GitHub's query syntax in q, which must name a repository (repo:owner/name) or an owner (owner:), and page and per_page. GET /search/commits also takes sort=author-date or committer-date, and order. See Search code and commits.
  • GET /user/feed gives { waiting, comments, following }. Each item of comments has lastComment, and each entry of following has its web url. An agent token gets an empty following. 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 toRoute
List the feature requestsGET .../discussions?category=request
List the questionsGET .../discussions?category=question
Read one post, with its repliesGET .../discussions/{n}
Read the roadmapGET .../roadmap
  • Feature requests: sort=top (the default), new or active. state=open, accepted, declined, duplicate or shipped keeps one state.
  • Questions: filter=unanswered, answered or all (the default). sort=new (the default) or active.
  • Paging: a list gives 50 posts and next. Pass next back as cursor. A post gives 100 replies and next. Pass next back as after.
  • Community off: each route answers 404.

CI routes

The CI reference lists every CI route. These paths are under /repos/{owner}/{repo}:

You want toRouteWho can
Read or change the CI variablesGET /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 offGET /ci/workflows, PUT or DELETE /ci/workflows/{workflow}/enabledReaders list them, admins turn them on or off
Delete a run that endedDELETE /ci/runs/{id}Repository admins. A run of a pull request gets 422.
Read or change the branch rules, with their review rulesGET /ci/rules, PUT or DELETE /ci/rules/{pattern}Readers list them, admins change them
Read or change the tag rulesGET /tag-rules, PUT or DELETE /tag-rules/{pattern}, with the pattern URL-encodedReaders list them, admins change them
List the agent jobsGET /jobs?kind=agentEveryone 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 of GET /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 is null for a job that passed, was skipped, waits or runs, and when nothing says why.
  • waitReason: each job of GET /ci/runs/{id} has it too. It is needs, slots or author-day for a job of an active run that waits, else null.
  • A run that never started: when the forge cannot start a push or a pull request run, the run fails with no jobs. Its warnings say why, and what to do. In GET /ci/runs, such a run has planErrors with the same texts.
  • The required checks: each check of GET /pulls/{n}/checks has jobId, the job that its reason is about, or null.
  • Billing: a job of paid CI (private CI, or paid public CI) that billing refused failed with jobId null. Its summary says 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 toRouteWho can
List the app installs that cover a repositoryGET /repos/{owner}/{repo}/appsEveryone who can read the repository
Take the repository out of an install that picked itDELETE /repos/{owner}/{repo}/apps/{install}Repository admins
List the app installs of an account, with their repositoriesGET /app-installs?owner={name}The owner of the account, a person only
Uninstall an app from its accountDELETE /app-installs/{install}The owner of the account, a person only
Click a webhook button of the card of an appPOST /repos/{owner}/{repo}/pulls/{n}/app-cards/{slug}/buttons/{button}/clickPeople who can read the pull request
  • GET /repos/{owner}/{repo}/apps answers a list, not a page: each install with installId, app (slug and name), repos (all or picked), actions and events.
  • GET /app-installs?owner={name} answers the same fields, with repos as all or a list of id and name.
  • 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 toRouteWho can
Read or change the factory settingsGET or PUT .../factory/settingsRepository admins, organization owners
List the model keysGET .../factory/keysRepository admins, organization owners
Save or delete a model keyPUT 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: agents takes the agent ids: audit, spam, review, keep-green, summary, triage, assign, issue-fix, deps, architecture and ci-cache. Every agent is off by default. The switches of an agent are in steps. See Models, keys and triggers.
  • Spend cap: monthlySpendCapUsd sets 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 GET answer has spend, with spentMicros (this UTC month, in millionths of a dollar) and capUsd, the cap that holds. While billing is on for the owner, spend also has billing, with aiLeftMicros (what billing leaves for forge-paid AI this period, in millionths of a dollar at 1.5 times the cost to the forge) and url (the path of the Billing page of the owner, or null on a repository of another person, whose Billing page is for that person only). capUsd is then the lower of two caps: the cap that a site admin gave the account, and the cap of the organization. It is null when neither is set.
  • Chats: prChat and archChat set the PR chat and the architecture chat, each with enabled and model, 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. GET lists the providers and the time that each key was set.

Custom agents

You want toRouteWho can
List the custom agentsGET /repos/{owner}/{repo}/factory/agentsRepository admins
See the custom agents that loaded, and the errors of the filesGET /repos/{owner}/{repo}/factory/agents/statusRepository admins
Save or delete a custom agentPUT or DELETE /repos/{owner}/{repo}/factory/agents/{name}Repository admins
  • Save: a PUT takes {"script": "<file>"}, a TypeScript file that default-exports defineFactory(...). Each agent is { agent: defineAgent(...), on, trigger }, with an optional model and an optional budget ({ maxTokens, maxCostCents }) that stops the run at that limit. See Custom agents.
  • Status: GET .../factory/agents/status gives source (vault or repo-file), the agents that loaded (name, factory, file and events), and errors, one line for each error with its file. It can take a few seconds when the files changed.

Runs and activity

You want toRouteWho can
List the runs on an issue or a pull requestGET /repos/{owner}/{repo}/issues/{n}/factoryEveryone who can read the item
See what runs on an issue or a pull request nowGET /repos/{owner}/{repo}/issues/{n}/activity, or .../pulls/{n}/activityEveryone who can read the item
See what runs on every item nowGET /repos/{owner}/{repo}/activityEveryone who can read the repository
List the newest runs of the repositoryGET /repos/{owner}/{repo}/factory/runsPeople with write access
Read one run, its verdicts and its logGET /repos/{owner}/{repo}/factory/runs/{id}People with write access
  • One item now: screening, and the runs that are queued or running, each with runId, agent, step, status, createdAt and startedAt. See See what runs on an item.
  • Every item now: the runs that are queued or running, each with the number of its item, agent, step and status. Also held, the counts screening and quarantined (0 for people who are not maintainers).
  • Newest runs: the runs of every item and of the default branch, each with its number (null for the branch). ?limit= goes up to 500, 50 by default. Each run has agent (the agent id) and step (the step id, for example fixer).
  • 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, skipped or cancelled. Any other status gets 400. See Factory runs.
  • Run logs come one page at a time. Pass next from the log back as ?cursor=.

Architecture, impact and dependencies

You want toRouteWho can
Read the architecture of the repositoryGET /repos/{owner}/{repo}/architectureEveryone who can read the code
Make the architecture nowPOST /repos/{owner}/{repo}/architecturePeople with write access
Read the impact of a pull requestGET /repos/{owner}/{repo}/pulls/{n}/impactEveryone who can read the pull request
Read the dependencies, the update groups and the rules of the dependency agentGET /repos/{owner}/{repo}/factory/dependenciesEveryone who can read the code
Check the dependencies nowPOST /repos/{owner}/{repo}/factory/dependencies/checkPeople with write access
Set or remove the rule of a dependencyPUT or DELETE /repos/{owner}/{repo}/factory/dependencies/rules/{name}People with write access
  • Architecture: GET .../architecture gives record (the overview, the packages and the diagrams, or null before the first run), the commit that it describes, at, runId, running, enabled, canGenerate and skills. skills holds the skill folders of each package, by package name, each with name, path and description.
  • The record: each package of record can have usage (markdown) and whenToUse (short lines). Each diagram has nodes and edges, or mermaid in an older view.
  • Make it now: POST .../architecture starts a run on the tip of the default branch: 201 with {"runId": "..."}, or 200 with {"skipped": "<why>"}. See Read the architecture of a repository.
  • Impact: GET .../pulls/{n}/impact gives the head commit (headOid), the assessment of that head, the record (architecture and publicApi, each only when it applies), running and enabled. See Read the Impact tab.

The dependency routes:

  • GET .../factory/dependencies gives enabled (the agent that fixes failing update pull requests), autoUpdate, settings, the newest plan (or null before the first check), the groups, the rules, dueAt (the next check, in ms) and running.
  • POST .../factory/dependencies/check builds a new plan and starts no run: 200 with {"checked": {"commit": "<sha>", "groups": 2}}, or {"skipped": "<why>"}.
  • POST .../factory/dependencies/update takes {"group": "minor-patch"}, or {} for every group, and opens or updates the pull requests: 201 with {"started": ["<run id>"]}, or 200 with {"skipped": "<why>"}.
  • A rule PUT takes {"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 toRouteWho can
List the bansGET .../bansRepository admins, organization owners
Ban an account, or lift its banPUT or DELETE .../bans/{username}Repository admins, organization owners
Read the spam signals of an accountGET /repos/{owner}/{repo}/bans/{username}/signalsRepository admins
List the suggested bansGET .../bans/suggestionsRepository admins, organization owners
Ban the account of a suggested ban, or dismiss itPOST .../bans/suggestions/{id}/accept or .../dismissRepository admins, organization owners
  • Suggested bans: GET .../bans/suggestions gives the open ones. Each has its id, the account, the item that the spam agent closed (repo and number), the reasons and the signals. Add ?status=banned or ?status=dismissed for the decided ones.
  • Accept and dismiss: accept bans the account with the reason spam. After dismiss, 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 toRoute
Search the marketplaceGET /skills?q=
List the skills of an ownerGET /skills?owner=
List trending, popular skills or tagsGET /skills/trending, GET /skills/popular, GET /skills/tags
List rising skills: new skills that people install and star nowGET /skills/rising
Read a skill with its filesGET /skills/{address}
List the versions, or compare twoGET /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 toRoute
Create a skillPOST /skills
Change its filesPATCH /skills/{owner}/{name}/files
Rename it, or change its visibilityPOST /skills/{owner}/{name}/rename, PUT /skills/{owner}/{name}/visibility
Make, list or revoke share linksPOST /skills/{owner}/{name}/shares, GET /skills/shares?address=, DELETE /skills/{owner}/{name}/shares/{id}
Delete itDELETE /skills/{owner}/{name}

Skills in a repository:

You want toRoute
List them, with their stateGET /repos/{owner}/{repo}/skills
Add onePOST /repos/{owner}/{repo}/skills
Update or remove onePATCH or DELETE /repos/{owner}/{repo}/skills/{name}
Get suggestionsGET /repos/{owner}/{repo}/skills/suggestions
Count an install that you made yourselfPOST /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 toRouteWho can
Read the billing of your own accountGET /user/billingYou, as a person
Read the billing of an organizationGET /orgs/{org}/billingThe owners of the organization
Get a link to buy a plan or creditsPOST /user/billing/checkout or POST /orgs/{org}/billing/checkoutYou as a person, or the owners of the organization
Get a link to the billing portalPOST /user/billing/portal or POST /orgs/{org}/billing/portalYou as a person, or the owners of the organization

The answer of GET has these fields:

FieldWhat it holds
accountkind (user or org) and name
enabledtrue 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, periodThe 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, leftWhat the plan includes, what the period used and what is left, each as ciMilli and aiMicros
creditsBalance, charge, creditsUsed, overage, overageEnabled, limitMicros, debtThe 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.
settingsThe 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.
publicCiThe 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.
usageperiod (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 gets 404.
  • 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.

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 is pro for a person, and team or enterprise for an organization. Add "interval": "year" for a yearly plan: month is the default. A credit pack is 10, 25 or 100 dollars. 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 plan and credits, or with neither, gets 400. A purchase that the account cannot make gets 422, and error says 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 gets 422 too.
  • 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.