---
title: "Connect Stripe or GitHub with one key"
method: POST
path: "/api/v1/connect"
---

# Connect Stripe or GitHub with one key

`POST /api/v1/connect`

## Request

- Base URL: `https://anyhook.net`
- URL: `https://anyhook.net/api/v1/connect`
- Auth: HTTP bearer

Registers an app's inbound URL as a webhook at Stripe or GitHub using the provider's own key, saves the signing secret the provider yields, and turns on signature verification at the edge. The provider is read from the key prefix (sk_/rk_ for Stripe, github_pat_/ghp_ for GitHub). The key is used for these calls only and is not stored. Without `app`, a new app is created for the provider (and removed again if the provider refuses the key). Re-running replaces the registration instead of duplicating it. Least privilege: a Stripe restricted key with Webhook Endpoints = Write, or a fine-grained GitHub token with Webhooks = Read and write.

## Request body

- object
  - `key` string, required: Stripe secret or restricted key, or GitHub token. Not stored.
  - `app` string: Slug of an existing app to connect. Omit to create a new app.
  - `target` string: GitHub only: "owner/repo", or an organization name for an org-wide hook. Optional when the token administers exactly one repository.

## Response `200`

Existing app connected

## Other responses

- `201`: New app created and connected. Body: { connected, provider, inboundUrl, app, stripe: { endpointId, livemode, enabledEvents, replaced } | github: { target, hookId, updated }, note }
- `400`: Key not recognised, publishable key, invalid target, or GitHub target required (body lists `candidates`)
- `401`: Unauthorized, or the provider rejected the key (`error: invalid_key`)
- `403`: Read-only AnyHook key, the provider key lacks the webhook permission (`error: missing_permission`), or the plan's app limit is reached (`error: app_limit_reached`)
- `404`: App not found
- `502`: The provider call failed

---

[API](https://skmtc.dev/anyhook/apis/anyhook-api.md) · [All operations](https://skmtc.dev/anyhook/apis/anyhook-api/llms.txt) · [OpenAPI document](https://skmtc.dev/anyhook/apis/anyhook-api/revisions/ddf038fb32fc?raw)
