Documentation

Getting started with PatchWork

Quick start

Get PatchWork running in three steps:

  1. Connect Slack — Authorise PatchWork in your Slack workspace and choose a channel for alerts.
  2. Add GitHub — Install the PatchWork GitHub App on the repositories you want to receive fix PRs for.
  3. Drop in the snippet — Add a single POST call to your error handler. That's it.

Ingestion endpoint

POST https://api.patchwork.dev/ingest

Send error data from your application to PatchWork. Requires an API key passed in the x-api-key header.

Request body

FieldTypeRequiredDescription
errorstringYesThe error message
stackstringYesFull stack trace
envstringNoEnvironment name (e.g. production)
userstringNoAnonymised user identifier
routestringNoRequest path or route name
metaobjectNoArbitrary key-value metadata

Example — Node.js / Express

// In your existing error handler
app.use(async (err, req, res, next) => {

  await fetch("https://api.patchwork.dev/ingest", {
    method: "POST",
    headers: { "x-api-key": process.env.PATCHWORK_KEY },
    body: JSON.stringify({
      error: err.message,
      stack: err.stack,
      env: process.env.NODE_ENV,
      user: req.user?.id,
      route: req.path,
    })
  });

  res.status(500).json({ error: "Something went wrong" });
});

Example — Python / Django

import requests, traceback

class PatchWorkMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        try:
            return self.get_response(request)
        except Exception as e:
            requests.post(
                "https://api.patchwork.dev/ingest",
                headers={"x-api-key": settings.PATCHWORK_KEY},
                json={
                    "error": str(e),
                    "stack": traceback.format_exc(),
                    "env": settings.ENVIRONMENT,
                    "route": request.path,
                }
            )
            raise

Response

StatusBodyMeaning
202{"accepted": true}Error queued for processing
401{"error": "Invalid API key"}Missing or invalid x-api-key
422{"error": "Missing field: error"}Required field not provided
429{"error": "Rate limit exceeded"}Too many requests — back off and retry

Slack integration

Once connected, PatchWork posts structured error alerts to your chosen channel. Each alert includes the error type, file location, occurrence count, and affected users.

Click Analyse with AI on any alert to trigger a root-cause analysis. PatchWork will respond in-thread with the likely cause and a suggested fix.

Click Push fix to GitHub to create a pull request with the suggested changes. The PR is created on a new branch and assigned to your team for review.

GitHub integration

PatchWork uses the GitHub App model. Install it on the repositories you want to receive fixes for. The app requests only the permissions it needs:

Rate limits

The ingestion endpoint is rate-limited per API key:

If you exceed the limit, you'll receive a 429 response. Implement exponential backoff in your error handler to handle this gracefully.

Support

Need help? Reach us at support@patchwork.dev. Team plan users get priority response within 4 hours.