openapi: 3.1.1
info:
  title: The Contributor Pledge API
  version: v1
  description: Read the pledge and look up active signatures and verified forge identities.
servers:
  - url: /api/v1
security: []
paths:
  /pledge:
    get:
      operationId: getCurrentPledge
      summary: Read the current pledge
      responses:
        '200':
          $ref: '#/components/responses/Pledge'
        '404':
          description: No pledge version has been published.
  /pledge/versions:
    get:
      operationId: listPledgeVersions
      summary: List published pledge versions, newest first
      responses:
        '200':
          description: Each version includes the complete Markdown text, in descending SemVer order.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PledgeVersion'
  /pledge/versions/{version}:
    get:
      operationId: getPledgeVersion
      summary: Read a specific version of the pledge
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
          example: '1.0.0'
      responses:
        '200':
          $ref: '#/components/responses/Pledge'
        '404':
          description: The requested pledge version does not exist.
  /signatories:
    get:
      operationId: listSignatories
      summary: List active signatures, newest first
      parameters:
        - name: page
          in: query
          description: Pages start at 1. The server clamps the page number to the range 1 through 10000000.
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: A page of up to 50 active signatures.
          content:
            application/json:
              schema:
                type: object
                required: [signatories, next_page]
                properties:
                  signatories:
                    type: array
                    maxItems: 50
                    items:
                      $ref: '#/components/schemas/Signature'
                  next_page:
                    type: [integer, 'null']
                    description: The next page number, or null on the last page.
  /signatories/{id}:
    get:
      operationId: getSignatory
      summary: Read a public signature and its verified identities
      parameters:
        - name: id
          in: path
          required: true
          description: The public signature ID.
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: An active signature.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Signature'
        '404':
          description: The signature does not exist or has been withdrawn.
  /lookup:
    get:
      operationId: lookupSignature
      summary: Check whether a forge account has an active signature
      description: Matches the host and case-insensitive username at the last recorded verification. See verified_at on the matching identity.
      parameters:
        - name: profile_url
          in: query
          required: true
          description: HTTPS profile URL on a supported forge instance, with the username as the only path segment.
          schema:
            type: string
            format: uri
          example: https://github.com/octocat
      responses:
        '200':
          description: A match includes the signature. A missing profile or active signature returns signed=false.
          content:
            application/json:
              schema:
                type: object
                required: [signed, signature]
                oneOf:
                  - properties:
                      signed: { type: boolean, const: true }
                      signature:
                        $ref: '#/components/schemas/Signature'
                  - properties:
                      signed: { type: boolean, const: false }
                      signature: { type: 'null' }
              examples:
                unsigned:
                  value: { signed: false, signature: null }
        '422':
          description: The profile URL is missing, malformed or on an unsupported instance.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  responses:
    Pledge:
      description: The pledge version and its complete Markdown text.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PledgeVersion'
  schemas:
    PledgeVersion:
      type: object
      required: [version, text]
      properties:
        version:
          type: string
          description: SemVer identifier for this edition.
          examples: ['1.0.0']
        text:
          type: string
          description: The full pledge as authored in Markdown.
    Signature:
      type: object
      required: [id, pledge_version, signed_at, identities]
      properties:
        id:
          type: string
          format: uuid
        pledge_version:
          type: string
          description: SemVer identifier of the signed edition.
        signed_at:
          type: string
          format: date-time
        identities:
          type: array
          description: Verified forge profiles. A contributor may sign before verifying any profiles.
          items:
            $ref: '#/components/schemas/VerifiedIdentity'
    VerifiedIdentity:
      type: object
      required: [host, username, external_id, profile_url, verified_at]
      properties:
        host:
          type: string
          format: hostname
        username:
          type: string
        external_id:
          type: string
          description: Stable account ID on this forge instance.
        profile_url:
          type: string
          format: uri
        verified_at:
          type: string
          format: date-time
    Error:
      type: object
      required: [error]
      properties:
        error: { type: string }
