Documentation
AlphaBuild an app
Install a bot on repositories, sign people in with OAuth and receive webhooks. Apps work like GitHub Apps.
The Upstream API is in alpha. Endpoints, fields and limits can change before it's stable. Send feedback to support@coline.app.
An app can work in two ways, and one app can do both:
- Install as a bot. An owner installs your app on their account or organization and picks repositories. The app acts as its own bot, named
{slug}-bot, on just those repositories. - Sign people in. Someone approves your app and it acts as them, with the access they agreed to.
Apps speak GitHub's REST API and webhook format. Code written for a GitHub App with Octokit runs against Upstream once you change the API URL.
Start here
upstream app create my-bot
cd my-bot && npm install && npm run dev
That creates the app, writes a Node project that runs it, and forwards its webhooks to your computer. The app quickstart walks through it. You need CLI 0.8.1 or newer: check with upstream --version, and run upstream update if it's older.
From an agent, a server or CI, add --no-browser. The CLI then creates the app with your sign-in, with no browser step, and upstream app install my-bot --repo api installs it the same way. Code can call POST /v1/apps and POST /v1/user/installations directly.
Octokit and other GitHub-compatible code use https://api.upstream.codes/api/v3, which answers in GitHub's shapes. Upstream's native API is https://api.upstream.codes/v1, which wraps every answer in { "data": … }.
To create an app by hand, open Your apps and choose New app. Choose the most access the app will ever need. People and owners can only grant up to that.
Guides
| Guide | Covers |
|---|---|
| App quickstart | upstream app create to a running Octokit app with local webhooks |
| Install flow and receipts | Install links, state, the setup URL and signed install receipts |
| Authenticate as an app | App JWTs, Octokit, finding installations and installation tokens |
| App keys | Generated keys, your own Ed25519 or P-256 keys, key set URLs and rotation |
| App webhooks | Signatures, the webhook token, relays and upstream webhook forward |
| Device flow | Signing people in from a CLI or agent with a short code |
| App manifests | Creating a configured app from JSON, as on GitHub |
| App directory | Listing an app at upstream.codes/apps and the directory API |
| Provenance | Which person, agent or app made each push and Change Request |
Coming from GitHub Apps
Endpoints, payloads and libraries carry over. Upstream adds these:
| GitHub Apps | Upstream apps | |
|---|---|---|
| Keys for the app JWT | RSA keys GitHub generates | RSA keys Upstream generates, your own RSA, Ed25519 or P-256 public key, or a key set URL you host |
| Setup URL | installation_id, setup_action and state | The same, plus a signed receipt that proves Upstream sent the person |
| Webhook checks | HMAC with a shared secret | HMAC, plus X-Upstream-Webhook-Token, which you verify with public keys |
| Local webhooks | A tunnel or a separate relay service | upstream webhook forward, built in |
| Manifest fields | GitHub's | GitHub's, plus webhook_format, client_type, device_flow_enabled and scopes |
| Listing | GitHub Marketplace | The app directory, with no review step |
Sign people in
Send people to:
https://upstream.codes/login/oauth/authorize
?client_id=CLIENT_ID
&redirect_uri=https://example.com/callback
&scope=repo:read issues:write
&state=RANDOM
&code_challenge=BASE64URL_SHA256_OF_VERIFIER
&code_challenge_method=S256
After they approve, they come back to your callback with code and state. Exchange the code:
curl -X POST https://upstream.codes/login/oauth/access_token \
-H "Accept: application/json" \
-d client_id=CLIENT_ID -d client_secret=CLIENT_SECRET \
-d code=CODE -d redirect_uri=https://example.com/callback \
-d code_verifier=VERIFIER
You get an access token that starts with uou_ and lasts eight hours, and a refresh token that starts with uor_ and rotates each time you use it. Using an old refresh token again revokes the whole chain. Apps without a server, such as CLIs and mobile apps, register as public clients, skip the secret and must use PKCE. Callback URLs must match exactly. scope defaults to user:read, and GitHub scope names such as repo and read:user map to Upstream scopes.
Access tokens work like personal access tokens: the same scopes, the REST API and Git over HTTPS. People can revoke an app at any time in Connected apps.
Programs without a browser use the device flow instead.
Install as a bot
Share your app's install link, https://upstream.codes/apps/{slug}/installations/new. Owners pick a namespace and repositories, then approve. Add ?state= and a setup URL to bring them back to your site afterward. Owners and their agents can also install from the terminal or the API, with no browser: see Install without a browser.
To act as the bot, sign a JWT with your app's key and trade it for an installation token. Octokit does both. See Authenticate as an app.
A bot can open and comment on Issues and Change Requests, review, report checks, publish releases, run Actions and push. It can't change repository settings, delete or transfer repositories, manage webhooks or assign people.
Changing permissions
Removing a permission takes effect right away. Adding one asks every installation's owner to approve it again. Until they do, the installation keeps its current access.
Run CI from your app
An app with the checks:write permission works like a GitHub CI app:
- Subscribe to
check_suite, and tocheck_runto hear about re-runs of single checks. - Each push to a branch of a repository the app is installed on sends
check_suitewith therequestedaction for the pushed commit. Start a build when it arrives. - Report results as check runs on that
head_shawith an installation token. They join your app's check suite for the commit. - When all of your runs on the commit have finished,
check_suitearrives with thecompletedaction and the suite's conclusion.
When someone re-runs your checks, you get check_suite with rerequested for the whole suite, or check_run with rerequested for one run. Report the runs again to answer. People re-run checks from the Checks tab of a Change Request or through the check suites API. Only your app receives requested and rerequested. Repository and organization webhooks get completed.
Subscribe to workflow_job to follow jobs in Upstream Actions as they move through queued, waiting, in_progress and completed.
Apps that use the Upstream payload format get the same events under dotted names, such as check_suite.requested, check.rerequested and workflow_job.in_progress.
In Coline
Apps on upstream.codes and in Coline are the same apps. In Coline, your apps' settings are at /{workspace}/upstream/settings/apps and the directory is at /{workspace}/upstream/apps.