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

# Sync Reddit Connection Status

> Sync Reddit Connection Status

**CLI:**

```bash theme={null}
puffle composio sync
```

## Overview

Reconciles unsettled `accounts` rows for the caller against the live Reddit connection state. This endpoint does **not** start an OAuth connection. A signed-in human must first open **Senders** in the Puffle dashboard, click **Connect** for Reddit, and complete the provider authorization in the browser.

For each unsettled row this endpoint:

* Reads the connection status from the provider (`ACTIVE` → `connected`, `INITIATED`/`PENDING` → stays `pending`, `REVOKED`/`INACTIVE` → `disconnected`, `FAILED`/`EXPIRED` → `error`).
* When the row flips to `connected`, fetches the Reddit username and avatar (best-effort) and writes them to `display_name`, `profile_url`, and `avatar_url`.
* Idempotent: rows that are already fully settled (connected with a display name) are skipped.

## AI agent notes

<Note>
  **Public API boundary.** `/api/composio/connect` is private, session-oriented integration plumbing and is not a supported public API workflow. An API-key agent must not call or guess that route. Ask the human to begin the connection in the dashboard, then use this endpoint only to observe an already-staged connection.

  **Polling cadence.** After the human confirms that the browser authorization is open, poll every 3–5 seconds for up to 2 minutes. Then stop and ask the human whether authorization completed; do not poll indefinitely. If they are still working and explicitly ask you to continue, poll no more than every 30 seconds for one additional 2-minute window, then stop and require fresh confirmation again.

  **Detecting completion.** The response always returns 200, even when nothing changed. Either:

  * Inspect `synced[]` for an entry with `status: "connected"`, or
  * Re-fetch [`GET /api/senders?type=reddit`](/api-reference/senders/list-senders) and look for a row whose `status` is `connected` and `display_name` is non-null.

  **Disconnected rows.** If the provider reports the connection as missing or revoked, this endpoint writes `status: "disconnected"` to the row. The UI shows it as disconnected; the row sticks around for audit. Remove it from the dashboard if the human wants the disconnected row cleaned up entirely.

  **No-op safety.** Calling this when nothing is pending returns `{ "synced": [] }`. An empty response does not extend the polling budget; follow the cadence and confirmation limits above.

  **Errors.** On `401`, stop and request a valid API key. On a persistent `500`, stop polling and surface the failure; do not attempt to recreate or disconnect the integration through undocumented routes.
</Note>


## OpenAPI

````yaml post /api/composio/sync
openapi: 3.0.3
info:
  title: Puffle API
  version: 1.0.0
  description: >-
    HTTP API for the Puffle GTM platform - Feed and Lead Finder search
    preparation, campaign-backed Outbound execution, Puffle Agent runs, sender
    management, and Unibox reply workflows. Designed for operation by both
    humans and autonomous AI agents. Agents should start at the [Agent
    Playbook](/guides/agent-playbook) which prescribes a workspace-context check
    (`GET /api/context`) and core user journeys with exact call ordering.
  contact:
    name: Puffle Support
    url: https://puffle.ai
servers:
  - url: https://app.puffle.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Campaigns
    description: >-
      Campaign-backed Outbound execution. These endpoints manage draft,
      launching, active, paused, and completed Outbound runs with sequence
      nodes, contacts, and sender accounts.
  - name: Accounts
    description: Signed-in user account, settings, and workspace context endpoints.
  - name: Billing
    description: Billing customer portal and account billing endpoints.
  - name: Senders
    description: >-
      Connected sender accounts, email inboxes, sending domains, DNS
      verification, warmup, and sender capacity.
  - name: Socials
    description: >-
      Read connected LinkedIn and X accounts, review current and archived posts,
      and reconcile publication status. Creating, editing, scheduling,
      publishing, OAuth connection, analytics, and mentions remain
      dashboard-managed workflows and are not part of the public Bearer-token
      API.
paths:
  /api/composio/sync:
    post:
      tags:
        - Senders
      summary: Sync Reddit Connection Status
      description: >-
        Reconcile pending Reddit connections for the caller. This OAuth flow has
        no inbound webhook, so once the user finishes consent in the browser,
        this endpoint must be called to read each pending connection's status,
        flip the matching `accounts` row from `pending` to `connected`, and
        fetch the user's Reddit username and avatar. Safe to call repeatedly;
        rows that are already fully settled are skipped.
      operationId: syncComposioStatus
      parameters: []
      responses:
        '200':
          description: >-
            Returns one entry per unsettled `accounts` row that was inspected.
            An empty `synced` array means nothing was pending. The same shape is
            returned whether or not any rows actually changed status — diff
            against `GET /api/senders?type=reddit` to detect new completions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  synced:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: '`accounts.id` of the row that was reconciled.'
                        status:
                          type: string
                          enum:
                            - pending
                            - connected
                            - disconnected
                            - error
                          description: >-
                            New status after reconciliation. `connected` means
                            the provider reported ACTIVE and, for Reddit, the
                            username was fetched. `pending` is returned when the
                            provider still reports the connection as initiating.
                      required:
                        - id
                        - status
                      additionalProperties: false
                    description: >-
                      One entry per `accounts` row that was inspected. Rows that
                      are already settled (connected with a display name) are
                      not returned.
                required:
                  - synced
                additionalProperties: false
              examples:
                connected:
                  summary: User completed OAuth — row promoted to connected
                  value:
                    synced:
                      - id: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
                        status: connected
                stillPending:
                  summary: User hasn't completed OAuth yet — keep polling
                  value:
                    synced: []
        '401':
          description: Missing or invalid Bearer token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
              examples:
                default:
                  value:
                    error: Unauthorized
        '500':
          description: Database lookup failed or unexpected server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
                additionalProperties: false
              examples:
                syncFailed:
                  summary: Database lookup of pending rows failed
                  value:
                    error: Sync failed
                internal:
                  value:
                    error: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: pk_live_...

````