> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wanderersguide.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Reconcile current Patreon memberships

> Internal scheduler endpoint for creator-side v2 verification. Requires a Supabase JWT and a short-lived scheduler signature or manual recovery capability.



## OpenAPI

````yaml POST /sync-patreon-memberships
openapi: 3.1.0
info:
  title: Wanderer's Guide API
  description: >-
    Public HTTP API for Wanderer's Guide, the Pathfinder 2e character builder.
    Every endpoint is a Supabase Edge Function reached via `POST
    /functions/v1/<name>`. All responses follow the
    [JSend](https://github.com/omniti-labs/jsend) convention: `{ status:
    'success' | 'fail' | 'error', data?, message? }`.
  version: 1.0.0
  contact:
    name: Wanderer's Guide Discord
    url: https://discord.com/invite/FxsFZVvedr
  license:
    name: MIT
    url: https://github.com/wanderers-guide/wanderers-guide/blob/main/LICENSE
servers:
  - url: https://api.wanderersguide.app/functions/v1
    description: Production
  - url: '{supabaseUrl}/functions/v1'
    description: Self-hosted Supabase
    variables:
      supabaseUrl:
        default: http://127.0.0.1:54321
        description: Base URL of your Supabase instance, including scheme and port.
security:
  - apiKeyAuth: []
tags:
  - name: Content
    description: 'Pathfinder 2e content: spells, items, feats, ancestries, classes, etc.'
  - name: Characters
    description: Player characters.
  - name: Campaigns
    description: Campaigns and encounters.
  - name: GM
    description: 'Game-master tools: group management, access codes.'
  - name: Users
    description: Public user profiles, account management, Patreon integration.
  - name: Search
    description: Full-text and advanced search across content.
  - name: Files
    description: User-uploaded portrait and background images.
  - name: Integrations
    description: Vector DB and Discord webhooks.
paths:
  /sync-patreon-memberships:
    post:
      tags:
        - Integrations
      summary: Reconcile current Patreon memberships (internal scheduler)
      description: >-
        Internal service endpoint. Requires a valid Supabase gateway JWT
        (callers use the public anon JWT) AND either the paired
        X-WG-Patreon-Signature/X-WG-Patreon-Timestamp headers from Supabase Cron
        or the X-WG-Patreon-Sync manual recovery capability. WG API keys alone
        are not accepted. The body is unused; send {}. Reads every page of the
        fixed WG campaign, refreshes the creator grant when necessary, and
        atomically publishes current entitlement observations. Does not charge
        patrons or replace personal connections. A failed/incomplete scan
        preserves the previous snapshot. Response contains only aggregate
        counts.
      operationId: syncPatreonMemberships
      requestBody:
        required: false
        description: >-
          Unused; scheduler sends an empty JSON object. No account identifiers
          or credentials are accepted in the body.
        content:
          application/json:
            schema: {}
      responses:
        '200':
          description: Complete campaign reconciliation published.
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - data
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  data:
                    type: object
                    required:
                      - members
                      - pages
                    properties:
                      members:
                        type: integer
                        minimum: 0
                      pages:
                        type: integer
                        minimum: 1
        '401':
          description: Supabase gateway JWT missing or rejected.
        '403':
          description: >-
            Missing/invalid manual capability or timestamped signature, or
            missing server configuration. No creator credential is acquired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '405':
          description: Only POST is supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendFail'
        '503':
          description: >-
            Reconciliation unavailable or busy; existing customer connections
            preserved. code=PATREON_SYNC_UNAVAILABLE. Inspect
            scheduler/integration state; do not replay an ambiguous OAuth
            exchange.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JSendError'
      security:
        - bearerAuth: []
          patreonSyncCapability: []
        - bearerAuth: []
          patreonSyncSignature: []
          patreonSyncTimestamp: []
components:
  schemas:
    JSendFail:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          enum:
            - fail
        data:
          type: object
          properties:
            message:
              type: string
    JSendError:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
        data: {}
        code:
          type: integer
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key (UUID, 36 chars)
      description: >-
        API key created in your Wanderer's Guide account settings. Send as
        `Authorization: Bearer <key>`. Used for direct API access from external
        tools and scripts.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Supabase JWT
      description: >-
        Supabase Auth JWT issued to the signed-in user. Used by the Wanderer's
        Guide web app. Subject to the same row-level security policies as the
        user's database access.
    patreonSyncCapability:
      type: apiKey
      in: header
      name: X-WG-Patreon-Sync
      description: >-
        Manual recovery capability, distinct from a WG API key or Patreon token.
        Provision its SHA-256 digest as PATREON_SYNC_SECRET_SHA256. Never expose
        the value to web clients.
    patreonSyncSignature:
      type: apiKey
      in: header
      name: X-WG-Patreon-Signature
      description: >-
        Internal Supabase Cron HMAC-SHA256 signature of POST

        sync-patreon-memberships

        <unix_seconds>, using the hex-decoded PATREON_SCHEDULER_KEY. The signing
        key stays in Vault and edge secrets; it never enters the HTTP queue.
        Requires the timestamp header and gateway JWT.
    patreonSyncTimestamp:
      type: apiKey
      in: header
      name: X-WG-Patreon-Timestamp
      description: >-
        Unix seconds signed with the fixed operation. Accepted for at most five
        minutes, with at most 30 seconds of future clock skew. Both signed
        headers are required; malformed signed requests cannot fall back to
        manual capability authentication.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.