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

# Reconcile Pipedrive deals in a stage against Reply.io sequence enrollments.

> Reconcile Pipedrive deals in a stage against Reply.io sequence enrollments.

    For each open deal in `stage_id` (default 20 = "Nurture (Drip Campaign)"):
      1. Read `campaign_type` custom field → map to Reply.io sequence_id
      2. Pull primary email from deal.person_id
      3. Check whether that email is enrolled in the mapped sequence
      4. Records where the email is missing in Reply are flagged as "gaps"

    `apply=False` (default) → dry-run report, no mutations.
    `apply=True` → for each gap: move the deal to `new_stage_id` (default 1 =
       "New"). If `enqueue=True` (default), ALSO enqueue the contact into
       reply_bulk_enroll_enqueue so the next 60s flush re-enrolls it via the
       v3 bulk pipeline. Set `enqueue=False` to do PD-only cleanup (useful
       when target sequences are paused/draft and you don't want to push
       contacts into them yet).

    Skipped silently: deals with campaign_type=fallout (no sequence mapping),
    deals without a primary email, deals without campaign_type set.

    Returns a per-sequence breakdown + the full gap list (deal_id, email,
    person_id, campaign_type, sequence_id). When apply=True, also includes
    per-sequence actions taken (deals_moved, enqueue_results).



## OpenAPI

````yaml /openapi/private/specs/mcp/sagescreen.yml post /tools/reply_pipedrive_reconcile
openapi: 3.1.0
info:
  title: SageScreen — MCP Tool Catalog
  description: >-
    Agent-callable tools exposed by the SageScreen MCP server at
    `https://mcp.sagescreen.net`.


    These are the same tools served over the Model Context Protocol; this
    reference documents their **REST** surface (`POST /tools/{name}`, body = the
    tool's arguments), which is what the playground below invokes. The live,
    machine-readable catalog is `GET /tools/list`.


    **This page is generated deterministically** from the server's tool registry
    (`apps/docs/scripts/generate_mcp_spec.py`), not hand-written and not
    AI-generated — it cannot drift from the shipped tools.


    All calls authenticate with the `X-Service-Token` header (or `?token=`).
  version: 1.0.0
servers:
  - url: https://mcp.sagescreen.net
    description: Production MCP server
security:
  - serviceToken: []
  - tokenQuery: []
tags:
  - name: Agents
  - name: Contact Push
  - name: Image Generation
  - name: Other
  - name: Productlane
  - name: Reply.io
  - name: Sequences
  - name: Spaces
  - name: WordPress
paths:
  /tools/reply_pipedrive_reconcile:
    post:
      tags:
        - Reply.io
      summary: >-
        Reconcile Pipedrive deals in a stage against Reply.io sequence
        enrollments.
      description: >-
        Reconcile Pipedrive deals in a stage against Reply.io sequence
        enrollments.

            For each open deal in `stage_id` (default 20 = "Nurture (Drip Campaign)"):
              1. Read `campaign_type` custom field → map to Reply.io sequence_id
              2. Pull primary email from deal.person_id
              3. Check whether that email is enrolled in the mapped sequence
              4. Records where the email is missing in Reply are flagged as "gaps"

            `apply=False` (default) → dry-run report, no mutations.
            `apply=True` → for each gap: move the deal to `new_stage_id` (default 1 =
               "New"). If `enqueue=True` (default), ALSO enqueue the contact into
               reply_bulk_enroll_enqueue so the next 60s flush re-enrolls it via the
               v3 bulk pipeline. Set `enqueue=False` to do PD-only cleanup (useful
               when target sequences are paused/draft and you don't want to push
               contacts into them yet).

            Skipped silently: deals with campaign_type=fallout (no sequence mapping),
            deals without a primary email, deals without campaign_type set.

            Returns a per-sequence breakdown + the full gap list (deal_id, email,
            person_id, campaign_type, sequence_id). When apply=True, also includes
            per-sequence actions taken (deals_moved, enqueue_results).
      operationId: reply_pipedrive_reconcile
      requestBody:
        required: false
        content:
          application/json:
            schema:
              properties:
                stage_id:
                  anyOf:
                    - type: integer
                    - type: 'null'
                  default: null
                  title: Stage Id
                apply:
                  anyOf:
                    - type: boolean
                    - type: 'null'
                  default: false
                  title: Apply
                new_stage_id:
                  anyOf:
                    - type: integer
                    - type: 'null'
                  default: null
                  title: New Stage Id
                enqueue:
                  anyOf:
                    - type: boolean
                    - type: 'null'
                  default: true
                  title: Enqueue
              type: object
      responses:
        '200':
          description: >-
            Tool result. The shape is tool-specific; most tools return a JSON
            object, some a `{"result": ...}` envelope.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Bad arguments (unknown kwargs, malformed JSON body).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Unknown tool name.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Tool raised an error during execution.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
        detail:
          type: string
          description: Optional additional context.
      required:
        - error
  responses:
    Unauthorized:
      description: Missing or invalid service token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Unauthorized
  securitySchemes:
    serviceToken:
      type: apiKey
      in: header
      name: X-Service-Token
    tokenQuery:
      type: apiKey
      in: query
      name: token

````