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

# Refresh Account Health

Recomputes the account's health score from scratch and stores a new snapshot. This is a **rule-based calculation, not an AI call** — it scores 9 fixed factors (pipeline health, communication recency, contact breadth, contact engagement spread, meeting cadence, deal pipeline value, deal win rate, task follow-through, new-deal recency) against data pulled live from `deals`, `activities`, `contacts`, and open `tasks` for this account, starting from a base of 50 and clamping the result to `0`–`100`.

`trend` compares the new score to the account's snapshot from \~30 days ago (falling back to the oldest available snapshot if the account has less than 30 days of history): `improving` if the score rose by more than 3 points, `declining` if it fell by more than 3, otherwise `stable`. On an account's first-ever refresh (no prior snapshot at all), `trend` is always `stable`.

As a side effect, this also writes the new score onto `accounts.health_score` (the denormalized column returned by [List Accounts](/api-reference/accounts/list-accounts) and [Update an Account](/api-reference/accounts/update-account)) — but that write is best-effort: if it fails, the refresh still returns `200` with the freshly computed score, it just doesn't get reflected on the account row.

### Auth

Requires a CRM manage [scope](/authentication#scopes) and an active organization on the token. Any `*:manage` scope qualifies — in practice `contacts:manage`, `deals:manage`, `companies:manage`, or `activities:manage`.

### Response

| Field                   | Type                    | Description                                                                                                                                                                                            |
| ----------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `score`                 | `integer`               | New health score, `0`–`100`.                                                                                                                                                                           |
| `trend`                 | `string`                | `improving`, `declining`, or `stable`.                                                                                                                                                                 |
| `factors`               | array of factor objects | The 9 factors that produced `score`. See below.                                                                                                                                                        |
| `factors[].factor_name` | `string`                | e.g. `pipeline_health`, `communication_recency`, `contact_breadth`, `contact_engagement_spread`, `meeting_cadence`, `deal_pipeline_value`, `deal_win_rate`, `task_follow_through`, `new_deal_recency`. |
| `factors[].score`       | `integer`               | This factor's signed contribution to the score (can be negative).                                                                                                                                      |
| `factors[].max_score`   | `integer`               | The most this factor could have contributed.                                                                                                                                                           |
| `factors[].status`      | `string`                | `good` if `score > 5`, `critical` if `score <= -5`, otherwise `neutral`.                                                                                                                               |
| `factors[].evidence`    | `string`                | Human-readable reason, e.g. `"Last activity 3d ago"`.                                                                                                                                                  |
| `snapshot_id`           | `string` (uuid)         | Id of the row inserted into the health-history table.                                                                                                                                                  |


## OpenAPI

````yaml POST /accounts/{account_id}/health/refresh
openapi: 3.1.0
info:
  title: anycrm-api
  version: 0.0.1
servers: []
security: []
tags:
  - name: Customer Intelligence
    description: >-
      Company research and ICP-fit scoring — create a research run, track its
      progress, and read back scored companies as leads.
  - name: Outreach
    description: >-
      The cold-email management console — domains, mailboxes, and campaigns — as
      a thin control plane over the SalesForge stack.
  - name: AnyCard
    description: >-
      Authenticated CRUD for AnyCard, the org's digital business-card /
      lead-capture product.
  - name: AnyCard Events
    description: >-
      Event-attribution analytics for AnyCard — which captured leads converted,
      broken down by source, owner, and deal.
  - name: AnyCard Share Links
    description: >-
      Unauthenticated endpoints reached by anyone who scans a QR code or opens a
      shared AnyCard link.
  - name: AI
    description: >-
      A streaming (SSE) AI chat endpoint with account-commit actions it can take
      on the caller's behalf.
  - name: Analytics Assistant
    description: >-
      The natural-language analytics assistant — a guarded text-to-SQL loop
      (SSE) that answers ad-hoc questions over the org's CRM data as a
      least-privilege, read-only database role.
  - name: Account Readiness
    description: >-
      Account Readiness Profiles — AI-scored signals on whether an account is
      ready for outreach or expansion, computed via a Temporal workflow.
  - name: Integrations
    description: >-
      Pipedream Connect — issuing connect tokens and managing the org's
      connected third-party accounts.
  - name: Feedback
    description: >-
      User-submitted platform feedback (bug reports, feature requests) — global,
      not scoped to one organization.
  - name: Public Media
    description: >-
      Unauthenticated image reads for publicly-embeddable assets (card photos,
      inline email images) — allowlisted by key shape; everything else in the
      storage bucket stays private.
  - name: Service Health
    description: Service liveness.
paths:
  /accounts/{account_id}/health/refresh:
    post:
      tags:
        - Accounts
      summary: Refresh Account Health
      operationId: refresh_account_health_accounts__account_id__health_refresh_post
      parameters:
        - name: account_id
          in: path
          required: true
          schema:
            type: string
            description: The account's id.
            title: Account Id
          description: The account's id.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````