pch. Anything they can do, your own tools and agents can do too.
Base URL
https://api.patch.gg/v1 (coming soon). Paths stay the same, and patch.gg/api/v1 keeps working.
The API is described by an OpenAPI 3.1 document at https://patch.gg/api/v1/openapi.json. It’s generated from the API’s code, and the endpoint pages in this reference are built from it, so they always match what’s deployed.
Authentication
Public data, such as projects and their published releases, needs no authentication. Everything else does:API keys
API keys start withpch_ and belong to your account. Create one with POST /tokens while signed in to patch.gg; an API key can’t create other keys. The key is shown once, so store it right away. Keys can expire after a number of days you choose, and you can revoke one at any time with DELETE /tokens/{id}.
A page for managing keys on patch.gg and pch token create are coming soon.
Each key has one or more scopes:
A request whose key lacks a scope gets
403 with the code missing_scope.
Errors
Errors use a 4xx or 5xx status and the same body:code is stable, so branch on it; message is for people and can change. details holds more about the error when there is any, for example which files are missing.
Endpoints add their own codes, such as
project_exists, manifest_invalid, files_missing or version_exists.
Conventions
- JSON in snake_case. Timestamps are RFC 3339 in UTC.
- Addressing. Projects are addressed as
{owner}/{slug}and releases by version. Everything also has a permanentid. - Renames. A request that uses an owner’s old name gets a
308redirect to the new one. Most HTTP clients follow it for you. - Lists take
limit(default 20, at most 100) andcursor, and return{ "data": [...], "next_cursor": "..." }. Passnext_cursorback ascursorfor the next page; it’snullon the last one. - Safe retries.
POST /projectstakes anIdempotency-Keyheader. Retrying with the same key returns the first response instead of creating a second project. - Compatibility. Within
v1, changes are additive only: new endpoints, new optional fields and new error codes. Ignore fields you don’t know.
Publishing a release
This is whatpch publish does, and what any other client needs to do:
1
Validate and hash
Read
patch.json, check it, and hash every file it includes with SHA-256.2
Create a draft
POST /projects/{owner}/{slug}/releases with the manifest, the files as { path, sha256, size }, and optionally a changelog and channel. Patch checks the manifest and creates a draft release.The response has an upload target for each file Patch doesn’t already have. Files Patch already has, from any release, are skipped.3
Upload
Upload each file to its target URL. Files over 100 MB use a multipart upload, with one URL per part; finish each one with
POST /uploads/{id}/complete.4
Submit
POST /projects/{owner}/{slug}/releases/{version}/submit. Patch checks that every upload matches its hash and size, then queues the release for review.version_exists), and published releases never change.