> ## 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 HubSpot aggregation

> Runs an aggregation (sum, max or latest of a property on an object associated with companies) on a few sample companies and returns the value each would get. Calls HubSpot: a 409 when its session expired, a 429 when its API limit is used up, a 500 on an unexpected failure. A filter HubSpot cannot run comes back with is_valid false and HubSpot's reason, scrubbed of anything secret.



## OpenAPI

````yaml /api/statisfy-api.openapi.json post /v1/integrations/hubspot/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/hubspot/preview/aggregation:
    post:
      tags:
        - integrations
      summary: Preview a HubSpot aggregation
      description: >-
        Runs an aggregation (sum, max or latest of a property on an object
        associated with companies) on a few sample companies and returns the
        value each would get. Calls HubSpot: a 409 when its session expired, a
        429 when its API limit is used up, a 500 on an unexpected failure. A
        filter HubSpot cannot run comes back with is_valid false and HubSpot's
        reason, scrubbed of anything secret.
      operationId: integrations_hubspot_preview_aggregation
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                account_filter_groups:
                  anyOf:
                    - items:
                        $ref: '#/components/schemas/HubSpotFilterGroup'
                      type: array
                    - type: 'null'
                  default: null
                  description: >-
                    HubSpot filter groups for scoping sample companies (from
                    account filter config)
                  title: Account Filter Groups
                aggregation:
                  default: sum
                  description: Aggregation method
                  enum:
                    - sum
                    - max
                    - latest
                  title: Aggregation
                  type: string
                field:
                  description: Property to aggregate (e.g., 'amount')
                  title: Field
                  type: string
                filters:
                  anyOf:
                    - items:
                        $ref: '#/components/schemas/HubSpotFilter'
                      type: array
                    - type: 'null'
                  default: null
                  description: >-
                    Additional HubSpot filters (e.g., [{propertyName:
                    'dealstage', operator: 'NEQ', value: 'closedlost'}])
                  title: Filters
                limit:
                  default: 5
                  description: Number of sample companies
                  maximum: 10
                  minimum: 1
                  title: Limit
                  type: integer
                object:
                  description: HubSpot object name (e.g., 'deals')
                  maxLength: 100
                  minLength: 1
                  pattern: ^[A-Za-z0-9_]+$
                  title: Object
                  type: string
                order_by:
                  anyOf:
                    - type: string
                    - type: 'null'
                  default: null
                  description: Property to sort by for 'latest' aggregation
                  title: Order By
              required:
                - object
                - field
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubSpotAggregationPreview'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    HubSpotFilterGroup:
      description: A group of filters (AND logic within group).
      properties:
        filters:
          description: Filters in this group
          items:
            $ref: '#/components/schemas/HubSpotFilter'
          title: Filters
          type: array
      required:
        - filters
      title: HubSpotFilterGroup
      type: object
    HubSpotFilter:
      description: A single HubSpot property filter.
      properties:
        operator:
          $ref: '#/components/schemas/HubSpotOperator'
          description: Filter operator
        propertyName:
          description: HubSpot property name
          title: Propertyname
          type: string
        value:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Filter value (not needed for HAS_PROPERTY)
          title: Value
        values:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          default: null
          description: Filter values for IN/NOT_IN operators
          title: Values
      required:
        - propertyName
        - operator
      title: HubSpotFilter
      type: object
    HubSpotAggregationPreview:
      description: The value the aggregation would write on a few sample companies.
      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: HubSpotAggregationPreview
      type: object
    HubSpotOperator:
      description: HubSpot filter operators.
      enum:
        - EQ
        - NEQ
        - LT
        - LTE
        - GT
        - GTE
        - CONTAINS_TOKEN
        - NOT_CONTAINS_TOKEN
        - HAS_PROPERTY
        - NOT_HAS_PROPERTY
        - IN
        - NOT_IN
      title: HubSpotOperator
      type: string
    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.