> ## 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.

# Generate a Deal Brief

Gated by the `ai.deal_brief` config feature flag — a `403` names the flag when disabled.

Follows the same async placeholder pattern as [Generate a Competitive Brief](/api-reference/deals/generate-competitive-intelligence) — writes a placeholder, kicks off a background job, and returns `202` immediately.

### 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`.

### Flow

1. **Already generating** (`deals.latest_brief.model_used == "deal_brief_generating"`) → `202 {accepted: true, already_running: true, message}`.
2. **Otherwise** → deletes any stuck placeholder `deal_briefs` rows, inserts a new placeholder row + placeholder `deals.latest_brief`, schedules a background job, returns `202 {accepted: true, already_running: false, id, latest_brief: <placeholder>, message}` immediately.

Unlike competitive-intelligence generation, there's no `force` flag or "return existing if already generated" short-circuit — every call (when not already running) starts a fresh generation.

The background job calls an LLM (Anthropic) to produce a structured executive brief grounded in the deal's contacts, activities, health factors, and open tasks, then PATCHes both the `deal_briefs` row and `deals.latest_brief`. A failure persists an error brief instead (`model_used: "deal_brief_error"`).

### Payload shape (once complete, in `latest_brief` / via Get a Deal)

`{summary, summary_evidence: [{ref_type, ref_id, excerpt}], stakeholders: [{name, role, sentiment, last_contact_summary, risk_flag, recommended_action, evidence}], risks: [{title, description, severity, mitigation, evidence}], opportunities: [{title, description, impact, action, evidence}], strategy, next_actions: [{action, priority, owner, due_timing}], forecast_assessment: {confidence, reasoning, adjusted_close_date, adjusted_value}, model_used, brief_type}`

Poll [Get a Deal](/api-reference/deals/get-deal) and read `.brief` until `model_used` is no longer `"deal_brief_generating"`.

### Errors

| Status | Cause                             |
| ------ | --------------------------------- |
| `400`  | No active organization.           |
| `403`  | `ai.deal_brief` feature disabled. |
| `404`  | Deal not found.                   |


## OpenAPI

````yaml POST /deals/{deal_id}/brief
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:
  /deals/{deal_id}/brief:
    post:
      tags:
        - Deals
      summary: Generate Brief
      operationId: generate_brief_deals__deal_id__brief_post
      parameters:
        - name: deal_id
          in: path
          required: true
          schema:
            type: string
            description: The deal's id.
            title: Deal Id
          description: The deal's id.
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/BriefRequest'
                - type: 'null'
              title: Body
      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:
    BriefRequest:
      properties:
        brief_type:
          type: string
          title: Brief Type
          description: 'Brief style: `standard`, `board_ready`, or `qbr`.'
          default: standard
      type: object
      title: BriefRequest
    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

````