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

# Email an Activity Report

> Queue the activity report and email it to the caller.

Gated on manage rather than read: this sends outbound mail on the org's
behalf and packages every rep's numbers into files that leave the app.
Viewing the Reports tab stays open to anyone with CRM read.

<Note>New to reports? See the [Reports guide](/concepts/reports) for what a report is and why generation is asynchronous.</Note>

This endpoint sends outbound email on the org's behalf and packages every rep's activity numbers into files that leave the system, so it's gated like a management action rather than a plain read.

Rendering the activity report needs WeasyPrint, which only the render-worker Docker image installs — the API image doesn't — so this endpoint never renders anything itself. It queues an `ActivityReportWorkflow` on the Temporal `CX_REPORTS_TASK_QUEUE` and returns as soon as the workflow is accepted; the workflow does the fetch → render → email work asynchronously and lands the result in the caller's inbox. Because the render dependencies are only installed in the render-worker image, this endpoint can `503` in any deployment where that workflow's imports aren't available — that's an environment gap, not a request error.

<Note>**The recipient is never a request field.** The email address and display name are resolved server-side from the caller's own identity (`token.sub` → Logto user lookup) — there's no `to`/`email` field you can set on the body. Accepting an arbitrary address here would turn this into a way to mail an org's entire activity history to anyone, off-org. If the caller's Logto profile has no email address, the request fails with `400` rather than silently dropping the send.</Note>

The report window is always sent as explicit bounds rather than a relative phrase — this endpoint doesn't interpret vocabulary like "this week" itself, so the caller resolves that into literal `date_from`/`date_to` plus pre-rendered display labels before sending the request.

### Auth

Requires a CRM manage [scope](/authentication#scopes) (any `*:manage`, e.g. `deals:manage`) and an active organization on the token. Gated on manage rather than read because it mails every rep's numbers out of the app; viewing the same data in the Reports tab only needs CRM read.

### Response

`202 Accepted` — the workflow was queued; delivery itself happens asynchronously.

| Field         | Type             | Description                                                                                           |
| ------------- | ---------------- | ----------------------------------------------------------------------------------------------------- |
| `status`      | `string`         | Always `"queued"` on a `202`.                                                                         |
| `workflow_id` | `string`         | The Temporal workflow id (`activity-report-<org_id>-<request_id>`), useful for correlating with logs. |
| `email`       | `string`         | The resolved recipient address (the caller's own).                                                    |
| `name`        | `string \| null` | The recipient's display name from Logto, if set.                                                      |

### Errors

| Status                    | Cause                                                                                                                                                           |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400 Bad Request`         | No active organization on the token, or the caller's Logto profile has no email address.                                                                        |
| `403 Forbidden`           | Token lacks a CRM manage scope.                                                                                                                                 |
| `502 Bad Gateway`         | Starting the Temporal workflow failed for a reason other than missing imports.                                                                                  |
| `503 Service Unavailable` | The report-rendering workflow's imports aren't installed in this deployment (API image vs. render-worker image) — report rendering isn't available here at all. |


## OpenAPI

````yaml POST /reports/activity/email
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:
  /reports/activity/email:
    post:
      tags:
        - Reports
      summary: Email Activity Report
      description: |-
        Queue the activity report and email it to the caller.

        Gated on manage rather than read: this sends outbound mail on the org's
        behalf and packages every rep's numbers into files that leave the app.
        Viewing the Reports tab stays open to anyone with CRM read.
      operationId: email_activity_report_reports_activity_email_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActivityReportBody'
        required: true
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Email Activity Report Reports Activity Email Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ActivityReportBody:
      properties:
        date_from:
          anyOf:
            - type: string
            - type: 'null'
          title: Date From
          description: >-
            Inclusive start of the report window (ISO date/datetime). Must be an
            explicit bound; relative phrases are not interpreted.
        date_to:
          anyOf:
            - type: string
            - type: 'null'
          title: Date To
          description: >-
            Inclusive end of the report window (ISO date/datetime). Must be an
            explicit bound; relative phrases are not interpreted.
        period_long:
          type: string
          title: Period Long
          description: >-
            Long display label for the window, e.g. "Last 7 days · 4 - 10 Aug
            2026", rendered in the generated report's header.
          default: ''
        period_short:
          type: string
          title: Period Short
          description: >-
            Shorter display label for the same window, rendered where the report
            layout is narrow.
          default: ''
        compare_long:
          type: string
          title: Compare Long
          description: >-
            Display label for the comparison period shown alongside the main
            window, if any.
          default: ''
        types:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Types
          description: >-
            Activity types to include (e.g. "call", "email"); omit or null for
            every type.
        owner_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Owner Ids
          description: Logto user ids to scope the report to; omit or null for every rep.
        formats:
          items:
            type: string
          type: array
          title: Formats
          description: >-
            Row-export attachment formats to generate; only "xlsx" and "csv" are
            honored, anything else is silently dropped.
        row_conditions:
          items:
            type: string
          type: array
          title: Row Conditions
          description: >-
            Raw PostgREST filter expressions applied to the row-level export,
            mirroring whatever feed filters (search/source/linkage) the caller
            had applied.
      type: object
      title: ActivityReportBody
      description: >-
        The report window is sent as explicit bounds, never a relative phrase.


        This endpoint does not interpret date vocabulary like "this week" — the

        caller resolves it into literal ``date_from``/``date_to`` plus the
        display

        labels it wants rendered, so the report reads exactly as the caller
        intended

        rather than re-deriving the window from a second definition that could
        drift.
    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

````