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

# Preview a Salesforce aggregation

> Runs an aggregation (sum, max, latest or first_future of a field on an object linked to Account) on a few sample accounts and returns the value each would get. Calls Salesforce. A preview that Salesforce refuses or cannot answer, for any reason (an expired session or a used-up API limit included), answers is_valid false with a fixed message: Salesforce's reason is not passed on. The object list is a 502 when Salesforce does not answer, and the fields of an object it does not describe are a 404. A 500 on an unexpected failure.



## OpenAPI

````yaml /api/statisfy-api.openapi.json post /v1/integrations/salesforce/preview/aggregation
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/integrations/salesforce/preview/aggregation:
    post:
      tags:
        - integrations
      summary: Preview a Salesforce aggregation
      description: >-
        Runs an aggregation (sum, max, latest or first_future of a field on an
        object linked to Account) on a few sample accounts and returns the value
        each would get. Calls Salesforce. A preview that Salesforce refuses or
        cannot answer, for any reason (an expired session or a used-up API limit
        included), answers is_valid false with a fixed message: Salesforce's
        reason is not passed on. The object list is a 502 when Salesforce does
        not answer, and the fields of an object it does not describe are a 404.
        A 500 on an unexpected failure.
      operationId: integrations_salesforce_preview_aggregation
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                account_field:
                  default: AccountId
                  description: Field linking to Account
                  title: Account Field
                  type: string
                account_filter:
                  anyOf:
                    - type: string
                    - type: 'null'
                  default: null
                  description: >-
                    SOQL WHERE clause for scoping sample accounts (from account
                    filter config)
                  title: Account Filter
                aggregation:
                  default: sum
                  description: Aggregation method
                  enum:
                    - sum
                    - max
                    - latest
                    - first_future
                  title: Aggregation
                  type: string
                field:
                  description: Field to aggregate (e.g., Amount)
                  title: Field
                  type: string
                filter:
                  anyOf:
                    - type: string
                    - type: 'null'
                  default: null
                  description: SOQL WHERE clause filter
                  title: Filter
                limit:
                  default: 5
                  description: Number of sample accounts
                  maximum: 10
                  minimum: 1
                  title: Limit
                  type: integer
                object:
                  description: Salesforce object API name (e.g., Opportunity)
                  title: Object
                  type: string
                order_by:
                  anyOf:
                    - type: string
                    - type: 'null'
                  default: null
                  description: ORDER BY field for 'latest' aggregation
                  title: Order By
              required:
                - object
                - field
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SalesforceAggregationPreview'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    SalesforceAggregationPreview:
      description: The value the aggregation would write on a few sample accounts.
      properties:
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
        is_valid:
          title: Is Valid
          type: boolean
        samples:
          items:
            $ref: '#/components/schemas/AggregationSample'
          title: Samples
          type: array
      required:
        - is_valid
      title: SalesforceAggregationPreview
      type: object
    AggregationSample:
      description: Sample account with aggregation result.
      properties:
        account_id:
          title: Account Id
          type: string
        account_name:
          title: Account Name
          type: string
        computed_value:
          anyOf:
            - type: number
            - type: string
            - type: 'null'
          title: Computed Value
        record_count:
          default: 0
          title: Record Count
          type: integer
      required:
        - account_id
        - account_name
      title: AggregationSample
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.