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

# Reconcile claimed GitHub changes

> Applies an atomic plan to current unlaunched campaigns. Source generations, leases, content hashes, and coverage are checked on the server. Approval remains unchanged. This operation cannot launch or schedule campaigns. Available in Galinum Cloud.



## OpenAPI

````yaml /openapi.json post /api/v1/github/refs/{refId}/reconcile
openapi: 3.1.0
info:
  title: Galinum API
  version: '2026-08-22'
  description: >-
    Galinum's HTTP API. SDK endpoints power the browser SDK. Management
    endpoints use a project secret. The scoped hosted-agent credential writes
    only through lease-fenced evaluation and GitHub source endpoints.
    Managed-only operations return 501 on the self-host server.
servers:
  - url: https://galinum.com
    description: Production
security:
  - publishableKey: []
paths:
  /api/v1/github/refs/{refId}/reconcile:
    post:
      tags:
        - GitHub sources
      summary: Reconcile claimed GitHub changes
      description: >-
        Applies an atomic plan to current unlaunched campaigns. Source
        generations, leases, content hashes, and coverage are checked on the
        server. Approval remains unchanged. This operation cannot launch or
        schedule campaigns. Available in Galinum Cloud.
      operationId: reconcileGithubRef
      parameters:
        - name: refId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 128
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GithubReconcilePlan'
      responses:
        '200':
          description: The successful source-work result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubReconcileResult'
        '400':
          description: Invalid source request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubSourceError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: The source policy or lease refuses this action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubSourceError'
        '404':
          description: The source ref is not available in this project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubSourceError'
        '409':
          description: The work, coverage, or current campaign conflicts with this request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubSourceError'
        '413':
          $ref: '#/components/responses/TooLarge'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: Source evidence is unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubSourceError'
      security:
        - secretKey: []
        - hostedAgentKey: []
components:
  schemas:
    GithubReconcilePlan:
      type: object
      properties:
        leaseToken:
          type: string
          minLength: 1
          maxLength: 256
        sourceGeneration:
          type: integer
          minimum: 0
          maximum: 9007199254740991
        fromSha:
          anyOf:
            - type: string
              pattern: ^[a-f0-9]{40}$
            - type: 'null'
        toSha:
          type: string
          pattern: ^[a-f0-9]{40}$
        rationale:
          type: string
          minLength: 1
          maxLength: 4000
        ops:
          minItems: 1
          maxItems: 50
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  op:
                    type: string
                    const: create
                  shas:
                    minItems: 1
                    maxItems: 500
                    type: array
                    items:
                      type: string
                      pattern: ^[a-f0-9]{40}$
                  campaign:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 80
                      channel:
                        type: string
                        enum:
                          - web_inapp
                          - email
                      message:
                        type: object
                        properties:
                          title:
                            type: string
                            maxLength: 16384
                          body:
                            type: string
                            maxLength: 16384
                          subject:
                            type: string
                            maxLength: 16384
                          previewText:
                            type: string
                            maxLength: 16384
                          presentation:
                            type: string
                            maxLength: 30
                          cta:
                            type: object
                            properties:
                              label:
                                type: string
                                minLength: 1
                                maxLength: 16384
                              url:
                                type: string
                                minLength: 1
                                maxLength: 16384
                            required:
                              - label
                            additionalProperties: false
                          media:
                            type: object
                            properties:
                              url:
                                type: string
                                minLength: 1
                                maxLength: 16384
                              alt:
                                type: string
                                minLength: 1
                                maxLength: 16384
                              decorative:
                                type: boolean
                            required:
                              - url
                            additionalProperties: false
                        additionalProperties: false
                      variants:
                        minItems: 1
                        maxItems: 10
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                              minLength: 1
                              maxLength: 16384
                            message:
                              type: object
                              properties:
                                title:
                                  type: string
                                  maxLength: 16384
                                body:
                                  type: string
                                  maxLength: 16384
                                subject:
                                  type: string
                                  maxLength: 16384
                                previewText:
                                  type: string
                                  maxLength: 16384
                                presentation:
                                  type: string
                                  maxLength: 30
                                cta:
                                  type: object
                                  properties:
                                    label:
                                      type: string
                                      minLength: 1
                                      maxLength: 16384
                                    url:
                                      type: string
                                      minLength: 1
                                      maxLength: 16384
                                  required:
                                    - label
                                  additionalProperties: false
                                media:
                                  type: object
                                  properties:
                                    url:
                                      type: string
                                      minLength: 1
                                      maxLength: 16384
                                    alt:
                                      type: string
                                      minLength: 1
                                      maxLength: 16384
                                    decorative:
                                      type: boolean
                                  required:
                                    - url
                                  additionalProperties: false
                              additionalProperties: false
                            weight:
                              type: integer
                              minimum: 0
                              maximum: 100
                            isControl:
                              type: boolean
                          required:
                            - message
                          additionalProperties: false
                      audience:
                        $ref: '#/components/schemas/CampaignAudienceInput'
                      pages:
                        anyOf:
                          - maxItems: 100
                            type: array
                            items:
                              type: string
                              maxLength: 1024
                          - type: 'null'
                    required:
                      - name
                      - channel
                    additionalProperties: false
                    oneOf:
                      - required:
                          - message
                        not:
                          required:
                            - variants
                      - required:
                          - variants
                        not:
                          required:
                            - message
                required:
                  - op
                  - shas
                  - campaign
                additionalProperties: false
              - type: object
                properties:
                  op:
                    type: string
                    const: revise
                  shas:
                    minItems: 1
                    maxItems: 500
                    type: array
                    items:
                      type: string
                      pattern: ^[a-f0-9]{40}$
                  campaignId:
                    type: string
                    minLength: 1
                    maxLength: 128
                  baseContentHash:
                    type: string
                    pattern: ^[a-f0-9]{64}$
                  patch:
                    type: object
                    properties:
                      name:
                        type: object
                        properties:
                          before:
                            type: string
                            minLength: 1
                            maxLength: 80
                          after:
                            type: string
                            minLength: 1
                            maxLength: 80
                        required:
                          - before
                          - after
                        additionalProperties: false
                      variants:
                        minItems: 1
                        maxItems: 10
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              minLength: 1
                              maxLength: 128
                            edits:
                              minItems: 1
                              maxItems: 20
                              type: array
                              items:
                                type: object
                                properties:
                                  field:
                                    type: string
                                    enum:
                                      - title
                                      - body
                                      - subject
                                      - previewText
                                      - cta.label
                                      - cta.url
                                      - cta.destination.kind
                                      - cta.destination.url
                                  before:
                                    type: string
                                    minLength: 1
                                    maxLength: 16384
                                  after:
                                    type: string
                                    maxLength: 16384
                                required:
                                  - field
                                  - before
                                  - after
                                additionalProperties: false
                          required:
                            - id
                            - edits
                          additionalProperties: false
                    additionalProperties: false
                required:
                  - op
                  - shas
                  - campaignId
                  - baseContentHash
                  - patch
                additionalProperties: false
              - type: object
                properties:
                  op:
                    type: string
                    const: withdraw
                  campaignId:
                    type: string
                    minLength: 1
                    maxLength: 128
                  baseContentHash:
                    type: string
                    pattern: ^[a-f0-9]{64}$
                  patch:
                    type: object
                    properties:
                      name:
                        type: object
                        properties:
                          before:
                            type: string
                            minLength: 1
                            maxLength: 80
                          after:
                            type: string
                            minLength: 1
                            maxLength: 80
                        required:
                          - before
                          - after
                        additionalProperties: false
                      variants:
                        minItems: 1
                        maxItems: 10
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              minLength: 1
                              maxLength: 128
                            edits:
                              minItems: 1
                              maxItems: 20
                              type: array
                              items:
                                type: object
                                properties:
                                  field:
                                    type: string
                                    enum:
                                      - title
                                      - body
                                      - subject
                                      - previewText
                                      - cta.label
                                      - cta.url
                                      - cta.destination.kind
                                      - cta.destination.url
                                  before:
                                    type: string
                                    minLength: 1
                                    maxLength: 16384
                                  after:
                                    type: string
                                    maxLength: 16384
                                required:
                                  - field
                                  - before
                                  - after
                                additionalProperties: false
                          required:
                            - id
                            - edits
                          additionalProperties: false
                    additionalProperties: false
                required:
                  - op
                  - campaignId
                  - baseContentHash
                  - patch
                additionalProperties: false
              - type: object
                properties:
                  op:
                    type: string
                    const: skip
                  shas:
                    minItems: 1
                    maxItems: 500
                    type: array
                    items:
                      type: string
                      pattern: ^[a-f0-9]{40}$
                  reason:
                    type: string
                    minLength: 1
                    maxLength: 2000
                required:
                  - op
                  - shas
                  - reason
                additionalProperties: false
      required:
        - leaseToken
        - sourceGeneration
        - fromSha
        - toSha
        - rationale
        - ops
      additionalProperties: false
    GithubReconcileResult:
      type: object
      additionalProperties: false
      required:
        - ok
        - campaigns
        - reconciledSha
        - replayed
      properties:
        ok:
          const: true
        campaigns:
          type: array
          items:
            type: object
            additionalProperties: false
            required:
              - campaignId
              - created
            properties:
              campaignId:
                type: string
              created:
                type: boolean
        reconciledSha:
          type: string
          pattern: ^[a-f0-9]{40}$
        replayed:
          type: boolean
    GithubSourceError:
      type: object
      additionalProperties: false
      required:
        - ok
        - status
        - error
      properties:
        ok:
          const: false
        status:
          type: integer
          enum:
            - 400
            - 403
            - 404
            - 409
            - 503
        error:
          type: string
        retryAfterMs:
          type: integer
          minimum: 0
    CampaignAudienceInput:
      oneOf:
        - type: 'null'
          description: Everyone.
        - type: object
          required:
            - kind
          additionalProperties: false
          properties:
            kind:
              const: all
            reason:
              type: string
              maxLength: 500
          description: Everyone.
        - type: object
          required:
            - kind
            - expression
          additionalProperties: false
          properties:
            kind:
              const: expression
            expression:
              $ref: '#/components/schemas/AudienceExpression'
            reason:
              type: string
              maxLength: 500
              description: >-
                Concise note on why this audience was chosen or revised; stored
                on the immutable audience version.
          description: >-
            Inline audience: validated, canonicalized, and stored as an
            immutable audience version the campaign pins.
        - type: object
          required:
            - kind
            - segment
          additionalProperties: false
          properties:
            kind:
              const: segment
            segment:
              type: string
              description: Segment id (seg_…) or machine key.
            version:
              type: integer
              minimum: 1
              description: >-
                Pin a specific immutable version; omitted = the segment's
                current version, resolved atomically at write time.
          description: >-
            Pin a saved segment's audience version. Archived segments are
            refused (409). A `reason` is rejected here — the pinned version
            carries its own revision reason.
      description: >-
        Canonical audience union. `null` or `{ "kind": "all" }` targets
        everyone. `{ "kind": "expression", "expression": { … }, "reason": "…" }`
        authors an inline audience stored as an immutable audience version. `{
        "kind": "segment", "segment": "id-or-key", "version": n? }` pins a saved
        segment version (omitted version = current, resolved atomically;
        archived segments are refused). Check expressions first with POST
        /api/v1/audiences/check. Mutually exclusive with the deprecated
        `targeting` field.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable description of what went wrong.
    AudienceExpression:
      type: object
      required:
        - version
        - root
      properties:
        version:
          type: integer
          enum:
            - 1
          description: Audience expression schema version.
        root:
          $ref: '#/components/schemas/AudienceNode'
      additionalProperties: false
      description: >-
        Versioned, strictly validated audience rule. Example: `{ "version": 1,
        "root": { "kind": "all", "children": [ { "kind": "field", "field": {
        "kind": "trait", "key": "plan" }, "op": "eq", "value": "free" }, {
        "kind": "not", "child": { "kind": "event", "event": "used_csv_export" }
        } ] } }`
      example:
        version: 1
        root:
          kind: all
          children:
            - kind: field
              field:
                kind: trait
                key: plan
              op: eq
              value: free
            - kind: not
              child:
                kind: event
                event: used_csv_export
    AudienceNode:
      oneOf:
        - type: object
          required:
            - kind
            - children
          additionalProperties: false
          properties:
            kind:
              const: all
            children:
              type: array
              minItems: 1
              maxItems: 16
              items:
                $ref: '#/components/schemas/AudienceNode'
          description: Every child must match.
        - type: object
          required:
            - kind
            - children
          additionalProperties: false
          properties:
            kind:
              const: any
            children:
              type: array
              minItems: 1
              maxItems: 16
              items:
                $ref: '#/components/schemas/AudienceNode'
          description: At least one child must match.
        - type: object
          required:
            - kind
            - child
          additionalProperties: false
          properties:
            kind:
              const: not
            child:
              $ref: '#/components/schemas/AudienceNode'
          description: Negates one child condition.
        - type: object
          required:
            - kind
            - field
            - op
          additionalProperties: false
          properties:
            kind:
              const: field
            field:
              $ref: '#/components/schemas/AudienceFieldRef'
            op:
              type: string
              enum:
                - eq
                - neq
                - in
                - not_in
                - contains
                - starts_with
                - ends_with
                - gt
                - gte
                - lt
                - lte
                - exists
                - not_exists
                - before
                - after
                - within_last
                - not_within_last
            value:
              description: >-
                Required for every operator except exists/not_exists (which
                reject it). Typed per operator: eq/neq take a
                string/number/boolean; in/not_in a non-empty array (≤ 50) of all
                strings or all numbers; contains/starts_with/ends_with a string;
                gt/gte/lt/lte a number; before/after an ISO-8601 date-time with
                explicit offset; within_last/not_within_last an AudienceWindow.
          description: >-
            Compares a user trait or lifecycle field. Comparisons are strict —
            no type coercion; a value comparison on an absent or
            type-incompatible field does not match (use exists/not_exists for
            absence). Lifecycle fields accept only datetime and existence
            operators.
        - type: object
          required:
            - kind
            - event
          additionalProperties: false
          properties:
            kind:
              const: event
            event:
              type: string
              maxLength: 80
            count:
              type: object
              required:
                - op
                - value
              additionalProperties: false
              properties:
                op:
                  type: string
                  enum:
                    - eq
                    - neq
                    - gt
                    - gte
                    - lt
                    - lte
                value:
                  type: integer
                  minimum: 0
                  maximum: 10000
              description: >-
                Occurrence-count comparison; defaults to at-least-once ({ op:
                gte, value: 1 }).
            window:
              $ref: '#/components/schemas/AudienceWindow'
            where:
              type: array
              minItems: 1
              maxItems: 8
              items:
                $ref: '#/components/schemas/AudienceNode'
              description: field nodes on event_property references, ANDed per occurrence.
          description: >-
            Evaluates occurrences of one event, optionally within a relative
            window and filtered by event-property conditions.
      description: >-
        One audience expression node, discriminated by `kind`. Overall limits:
        nesting depth ≤ 8, total nodes ≤ 64. Unknown kinds, unknown operators,
        unknown keys, and empty groups are rejected with structured diagnostics.
    AudienceFieldRef:
      oneOf:
        - type: object
          required:
            - kind
            - key
          properties:
            kind:
              const: trait
            key:
              type: string
              maxLength: 128
              description: Literal top-level trait key.
          additionalProperties: false
        - type: object
          required:
            - kind
            - field
          properties:
            kind:
              const: user
            field:
              type: string
              enum:
                - firstSeenAt
                - lastSeenAt
              description: Lifecycle field (datetime).
          additionalProperties: false
        - type: object
          required:
            - kind
            - key
          properties:
            kind:
              const: event_property
            key:
              type: string
              maxLength: 128
              description: >-
                Literal top-level event property key. Only valid inside an event
                node's where conditions.
          additionalProperties: false
      description: Structured, unambiguous field reference.
    AudienceWindow:
      type: object
      required:
        - amount
        - unit
      properties:
        amount:
          type: integer
          minimum: 1
        unit:
          type: string
          enum:
            - minutes
            - hours
            - days
      additionalProperties: false
      description: >-
        Relative time window measured back from the evaluation instant
        (evaluatedAt).
  responses:
    Unauthorized:
      description: >-
        Missing or invalid API key. SDK endpoints take the publishable key;
        management endpoints (campaigns, media, users, events, goals, agent
        runs) take the secret key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unauthorized
    TooLarge:
      description: Request body exceeds the endpoint's size limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Invalid request
    RateLimited:
      description: >-
        Rate limit exceeded, counted per project (SDK endpoints: 120
        requests/minute or 2,000/hour per endpoint; management endpoints:
        60/minute or 1,000/hour per resource group — all campaign operations
        share one budget, as do goal operations and user reads). Retry after the
        `Retry-After` header.
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Too many requests
  securitySchemes:
    publishableKey:
      type: http
      scheme: bearer
      description: >-
        Your project's publishable key (`pk_pub_…`). Safe to expose in the
        browser — it identifies the project and is rate-limited, not secret.
    secretKey:
      type: http
      scheme: bearer
      description: >-
        Your project's secret key (`pk_…`, without the `pub` segment).
        Server-side only — never ship it to a browser. Get it from Settings →
        Projects in the dashboard.
    hostedAgentKey:
      type: http
      scheme: bearer
      description: >-
        Galinum's scoped hosted-agent key (pk_agent_...). It can read required
        project state, including launch policy and campaign activation, and use
        fenced evaluation or GitHub source operations. Ordinary campaign,
        status, goal, segment, media, launch-policy, and campaign-activation
        writes return 403. Reads grant no approval or deployment configuration
        authority.

````

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