HTTP API

Every endpoint of the Sponsorkit HTTP API (/api/v1), with request and response examples, headers, error codes and rate limits.

On this page

The SDKs are thin clients of this API. You only need it to build an SDK for another language, to verify sessions from a backend without an SDK, or to debug. Everything here is specified normatively in the wire protocol; this page explains it with examples.

Conventions#

  • Base URL: https://api.sponsorkit.io, or your own API origin if you self-host. Every path below is relative to it. The API is served on its own domain and serves nothing but /api/v1/… and /api/oauth/…; the website, including the consent and checkout pages, is a separate static site at https://ffmathy.github.io/sponsorkit (see Browser pages and OAuth endpoints).
  • Format: requests and responses are JSON. Amounts are integers in minor units with an ISO 4217 currency ({ "value": 500, "currency": "USD" } is $5.00). Timestamps are ISO 8601 strings.
  • Authentication: only GET /api/v1/contributions needs it, as Authorization: Bearer sks_…. There are no API keys.
  • Request ID: every response carries a Sponsorkit-Request-Id header. Include it when you report a problem.
  • CORS: /api/v1/* allows any origin (Access-Control-Allow-Origin: *) without credentials. Allowed request headers are Authorization and Content-Type; exposed response headers are Sponsorkit-Session, Sponsorkit-Request-Id and Retry-After. So browsers can call the API directly; the website's own pages call it the same way, cross-origin. The /api/oauth/* endpoints are only reached by top-level browser navigations and send no CORS headers.

Errors#

Errors use RFC 9457 problem details with the content type application/problem+json, plus a stable code:

400 Bad Request
{
  "type": "https://ffmathy.github.io/sponsorkit/docs/reference-http/http-api/#errors",
  "title": "Invalid target",
  "status": 400,
  "code": "invalid_target",
  "detail": "Invalid github account \"-octocat\""
}

Branch on code, not on type, title or detail. type links to this section of the docs (on a self-hosted instance, to its own site), and title and detail are for humans and may change.

CodeStatusMeaning
invalid_request400The request body is not JSON, doesn't have the expected shape, or names a session with a different target set.
invalid_target400A github or open-collective parameter is malformed, or neither was given.
invalid_code400The sign-in code is malformed, expired or tampered with, or the code verifier doesn't match.
session_invalid401The session token is missing, malformed, tampered with, expired or sealed with an unknown key.
rate_limited429Too many requests. Wait for the number of seconds in Retry-After.
not_found404No such endpoint. The API serves no pages or static files, so every path outside /api/ is a 404 too.
internal500, 502Something went wrong on the server (500), or a provider couldn't be reached (502).

Rate limits#

All limits use a 60-second window and are keyed by client IP or by session. A request over a limit gets 429 rate_limited with Retry-After: 60 (the /api/oauth/* endpoints, which browsers navigate to, answer with an HTML page instead).

ScopeLimit
Everything under /api/120 requests per minute per IP
/api/v1/auth/* and /api/oauth/*30 requests per minute per IP
GET /api/v1/contributions60 requests per minute per IP, and 1 per minute per session
GET /api/v1/targets, uncached lookups20 per minute per IP, and 60 per minute in total

The per-session limit is keyed on the session's targets and identities, so a renewed token doesn't reset it. It's shared by everyone using that session: the app and any backend verifying it.

GET /api/v1/targets#

Public metadata about the accounts that receive contributions: whether they exist, their display name and avatar, currency and tiers. The consent and checkout pages use it, and SDKs use it for the dev-time check that your targets exist. No authentication.

Query parameters: github=<login> and/or open-collective=<slug>. At least one is required. Values are trimmed and lowercased.

curl "https://api.sponsorkit.io/api/v1/targets?github=octocat&open-collective=my-project"
200 OK
{
  "targets": [
    {
      "target": "github:octocat",
      "provider": "github",
      "account": "octocat",
      "exists": true,
      "displayName": "The Octocat",
      "avatarUrl": "https://avatars.githubusercontent.com/u/583231?v=4",
      "url": "https://github.com/sponsors/octocat",
      "currency": "USD",
      "frequencies": ["monthly", "one_time"],
      "customAmount": false,
      "tiers": [
        {
          "id": "ST_kwDOAAjq784AAg4z",
          "name": "$5 a month",
          "amount": { "value": 500, "currency": "USD" },
          "frequency": "monthly",
          "url": "https://github.com/sponsors/octocat/sponsorships?tier_id=134707"
        }
      ]
    },
    {
      "target": "open-collective:my-project",
      "provider": "open-collective",
      "account": "my-project",
      "exists": true,
      "displayName": "My Project",
      "avatarUrl": "https://images.opencollective.com/my-project/logo.png",
      "url": "https://opencollective.com/my-project",
      "currency": "EUR",
      "frequencies": ["one_time", "monthly", "yearly"],
      "customAmount": true,
      "tiers": [
        {
          "id": "nb8vq0z4-3plk-7xme-a5rw-9g7ld6yjoe2k",
          "name": "Backer",
          "amount": { "value": 500, "currency": "EUR" },
          "frequency": "monthly",
          "url": null
        }
      ]
    }
  ]
}

Targets are returned in canonical order (sorted by their string form). Details:

  • An account that doesn't exist is still returned, with exists: false. A GitHub account without a Sponsors listing also has exists: false, though displayName and avatarUrl are filled in. An Open Collective account has exists: true only if it can receive contributions, is active and isn't archived.
  • customAmount is always true for an Open Collective account that exists. GitHub doesn't expose its "custom amounts" setting, so it's true only when a published tier allows custom amounts.
  • Tiers: GitHub tier ids are GraphQL node ids. Open Collective tiers with a flexible frequency and tiers that aren't contributions (tickets, products) are left out, and their url is always null.

Caching: successful responses carry Cache-Control: public, max-age=3600 and are also cached by the Worker for an hour.

Errors: 400 invalid_target; 502 internal when a provider couldn't be reached (not cached); 429.

POST /api/v1/auth/token#

Exchanges a sign-in code (skc_…) for a session token. SDKs call it after the consent page has delivered the code. The code is bound to a PKCE challenge, so only the client that started the sign-in, which holds the verifier, can exchange it.

Request body:

FieldTypeMeaning
codestringThe sign-in code from the consent page.
codeVerifierstringThe PKCE verifier, 43–128 characters.
sessionTokenstring, optionalAn existing session, to add this identity to it.
curl https://api.sponsorkit.io/api/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{"code":"skc_…","codeVerifier":"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"}'
200 OK
{
  "sessionToken": "sks_AWkx…",
  "expiresAt": "2027-05-16T18:00:00.000Z",
  "result": {
    "signedIn": true,
    "disabled": false,
    "mock": false,
    "targets": ["github:octocat"],
    "supporter": {
      "id": "sup_q5u2nh7s3lvkx4w3a6c2ybmzr4fo2e3d",
      "identities": [{ "provider": "github", "id": "1234567", "handle": "mona", "needsReconnect": false }]
    },
    "contributions": [],
    "fetchedAt": "2026-11-17T18:00:00.000Z",
    "stale": false,
    "fromCache": false
  }
}

result is the same object GET /api/v1/contributions would return, fetched live, so the app can show something straight away. The session expires 180 days after it was issued (expiresAt), and is renewed while it's used.

Adding an identity: when sessionToken is given, the new identity is added to that session, replacing an existing identity of the same provider (that's how an expired one is reconnected). The response holds a new token with both identities. supporter.id doesn't change, because it's derived from the session's first identity.

Errors:

StatusCodeWhen
400invalid_codeThe code is malformed, expired (60 s, or 10 minutes for paste-back) or tampered with, or the verifier doesn't match.
400invalid_requestThe body isn't valid, or sessionToken belongs to a different target set.
401session_invalidsessionToken is invalid. SDKs then retry once without it, starting a fresh session.
429rate_limitedToo many sign-ins from this IP.

A code can be exchanged more than once within its lifetime. That's harmless, because the verifier never leaves the client, and it lets the SDKs retry after a session_invalid.

GET /api/v1/contributions#

What the signed-in supporter (and the organizations they belong to) has contributed to the session's targets, fetched live from GitHub and Open Collective with the supporter's own provider tokens.

curl https://api.sponsorkit.io/api/v1/contributions \
  -H "Authorization: Bearer sks_AWkx…"
200 OK
{
  "signedIn": true,
  "disabled": false,
  "mock": false,
  "targets": ["github:octocat", "open-collective:my-project"],
  "supporter": {
    "id": "sup_q5u2nh7s3lvkx4w3a6c2ybmzr4fo2e3d",
    "identities": [
      { "provider": "github", "id": "1234567", "handle": "mona", "needsReconnect": false },
      { "provider": "open-collective", "id": "98765", "handle": "mona", "needsReconnect": true }
    ]
  },
  "contributions": [
    {
      "id": "con_github_N2xh0p3dXcU9zb8kYwQe1A",
      "provider": "github",
      "target": "github:octocat",
      "sponsor": { "type": "user", "provider": "github", "id": "1234567", "handle": "mona" },
      "via": "direct",
      "kind": "recurring",
      "frequency": "monthly",
      "status": "active",
      "amount": { "value": 500, "currency": "USD" },
      "tier": { "id": "ST_kwDOAAjq784AAg4z", "name": "$5 a month" },
      "flags": [],
      "private": false,
      "startedAt": "2026-03-02T10:15:00Z",
      "endedAt": null,
      "lastChargedAt": null,
      "nextChargeAt": null,
      "totalContributed": null
    }
  ],
  "fetchedAt": "2026-11-17T18:00:00.000Z",
  "stale": true,
  "fromCache": false,
  "unavailable": ["open-collective"]
}

The shape is the same one every SDK returns from getFinancialContribution(). The fields are described in Contributions and Statuses. From the API, signedIn is always true and disabled, mock and fromCache are always false.

Partial results. If a provider couldn't be queried, the response still succeeds: that provider is listed in unavailable, stale is true, and its contributions are left out. SDKs fill them in from their cache. In the example above, the Open Collective sign-in has expired (needsReconnect: true), which is reported the same way.

Session renewal. When the session is more than 7 days old, the response carries a Sponsorkit-Session: sks_… header with a renewed token (fresh 180-day expiry, sealed with the current key). Clients must replace their stored token with it. A session that's used at least every 180 days therefore never expires.

GitHub amounts. When GitHub hides a sponsorship's tier, amount is { "value": 0, "currency": "USD" } and tier is null.

Errors:

StatusCodeWhen
401session_invalidThe token is missing, malformed, tampered with, expired or sealed with an unknown key.
429rate_limitedMore than one refresh per minute for this session, or 60 per minute from this IP.

Responses carry Cache-Control: no-store.

GET /api/v1/health#

Whether the Worker can reach each provider. No authentication. The answer is cached in the Worker for 30 seconds.

curl https://api.sponsorkit.io/api/v1/health
200 OK
{ "ok": true, "providers": { "github": "ok", "open-collective": "degraded" } }

Each provider is "ok" or "degraded".

Browser pages and OAuth endpoints#

Sign-in and checkout run in the browser, through static pages on the site (https://ffmathy.github.io/sponsorkit) and two endpoints on the API (https://api.sponsorkit.io). SDKs only build the first URL; the rest is navigation. Page URLs always end in /.

WhereURLWhat it does
Site/connect/?targets=…&challenge=…&delivery=…The consent page: shows the targets, who is asking and one button per provider.
APIPOST /api/oauth/:provider/startStarts OAuth with GitHub or Open Collective. The consent page's button submits the sign-in parameters to it as a form.
APIGET /api/oauth/:provider/callbackThe provider's redirect target. Creates the sign-in code and delivers it to the app.
Site/connect/done/Posts the code to the opener (popup flow) or shows it for paste-back.
Site/checkout/?targets=…Signs in if a challenge is given, then picks a provider and redirects to it.

The start endpoint only accepts a form POST whose Origin header is exactly the site's origin (https://ffmathy.github.io), which only the consent page can produce. Links, redirects, typed-in URLs and forms on other sites get an HTML 403 (or 405 for a GET) that links to the consent page, and nothing is started. The short-lived nonce cookie that binds the OAuth state to the browser is set on the API's domain.

delivery is one of web_message (popup), redirect, loopback or paste. The parameters, the delivery rules and the checkout eligibility rules are summarized in Wire protocol and specified in PROTOCOL.md §4.