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

# Create a Data Diff Monitor



## OpenAPI

````yaml /openapi-public.json post /api/v1/monitors/create/diff
openapi: 3.1.0
info:
  contact:
    email: support@datafold.com
    name: API Support
  description: >-
    The Datafold API reference is a guide to our available endpoints and
    authentication methods.

    If you're just getting started with Datafold, we recommend first checking
    out our [documentation](https://docs.datafold.com).


    :::info
      To use the Datafold API, you should first create a Datafold API Key,
      which should be stored as a local environment variable named DATAFOLD_API_KEY.
      This can be set in your Datafold Cloud's Settings under the Account page.
    :::
  title: Datafold API
  version: latest
servers:
  - description: Default server
    url: https://app.datafold.com
security:
  - ApiKeyAuth: []
paths:
  /api/v1/monitors/create/diff:
    post:
      tags:
        - Monitors
      summary: Create a Data Diff Monitor
      operationId: create_monitor_diff_api_v1_monitors_create_diff_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataDiffMonitorSpecPublic'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiPublicCreateMonitorOut'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    DataDiffMonitorSpecPublic:
      properties:
        alert:
          anyOf:
            - $ref: >-
                #/components/schemas/datafold__monitors__schemas__DiffAlertCondition
            - type: 'null'
          description: Condition for triggering alerts based on the data diff.
        datadiff:
          description: Configuration for the data diff.
          discriminator:
            mapping:
              indb:
                $ref: '#/components/schemas/InDbDataDiffConfig'
              inmem:
                $ref: '#/components/schemas/InMemDataDiffConfig'
            propertyName: diff_type
          oneOf:
            - $ref: '#/components/schemas/InDbDataDiffConfig'
            - $ref: '#/components/schemas/InMemDataDiffConfig'
        description:
          anyOf:
            - type: string
            - type: 'null'
          description: The description of the monitor.
          title: Description
        enabled:
          default: true
          description: Indicates whether the monitor is enabled.
          title: Enabled
          type: boolean
        name:
          description: The name of the monitor.
          title: Name
          type: string
        notifications:
          description: Notification configuration for the monitor.
          items:
            discriminator:
              mapping:
                email:
                  $ref: '#/components/schemas/EmailNotification'
                pagerduty:
                  $ref: '#/components/schemas/PagerDutyNotification'
                slack:
                  $ref: '#/components/schemas/SlackNotification'
                teams:
                  $ref: '#/components/schemas/TeamsNotification'
                webhook:
                  $ref: '#/components/schemas/WebhookNotification'
              propertyName: type
            oneOf:
              - $ref: '#/components/schemas/EmailNotification'
              - $ref: '#/components/schemas/PagerDutyNotification'
              - $ref: '#/components/schemas/WebhookNotification'
              - $ref: '#/components/schemas/SlackNotification'
              - $ref: '#/components/schemas/TeamsNotification'
          title: Notifications
          type: array
        owner:
          anyOf:
            - type: string
            - type: 'null'
          description: Email of the monitor owner.
          title: Owner
        schedule:
          anyOf:
            - $ref: '#/components/schemas/IntervalSchedule'
            - $ref: '#/components/schemas/CronSchedule'
            - $ref: '#/components/schemas/NoneSchedule'
          description: The schedule at which the monitor runs.
        tags:
          description: Tags associated with the monitor.
          items:
            type: string
          title: Tags
          type: array
      required:
        - schedule
        - name
        - datadiff
      title: DataDiffMonitorSpecPublic
      type: object
    ApiPublicCreateMonitorOut:
      properties:
        id:
          description: Unique identifier for the monitor.
          title: Id
          type: integer
      required:
        - id
      title: ApiPublicCreateMonitorOut
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    datafold__monitors__schemas__DiffAlertCondition:
      properties:
        different_rows_count:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Threshold for the number of different rows allowed between the
            datasets.
          title: Different Rows Count
        different_rows_percent:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Threshold for the percentage of different rows allowed between the
            datasets.
          title: Different Rows Percent
        match_ratio_min:
          anyOf:
            - maximum: 1
              minimum: 0
              type: number
            - type: 'null'
          description: >-
            Minimum acceptable match ratio (0.0-1.0). Alert when match_ratio <
            match_ratio_min.
          title: Match Ratio Min
      title: Diff Conditions
      type: object
    InDbDataDiffConfig:
      properties:
        column_remapping:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          description: Mapping of columns from one dataset to another for comparison.
          title: Column Remapping
        columns_to_compare:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          description: Optional list of columns to compare between the datasets.
          title: Columns To Compare
        compare_duplicates:
          anyOf:
            - type: boolean
            - type: 'null'
          description: Compare rows with duplicate primary keys. Defaults to true.
          title: Compare Duplicates
        dataset_a:
          anyOf:
            - $ref: '#/components/schemas/InDbTableDataset'
            - $ref: '#/components/schemas/InDbQueryDataset'
          description: The first dataset to compare.
        dataset_b:
          anyOf:
            - $ref: '#/components/schemas/InDbTableDataset'
            - $ref: '#/components/schemas/InDbQueryDataset'
          description: The second dataset to compare.
        ignore_string_case:
          default: false
          description: Indicates whether to ignore case differences in string comparisons.
          title: Ignore String Case
          type: boolean
        materialize_results:
          default: false
          description: Indicates whether to materialize the results of the comparison.
          title: Materialize Results
          type: boolean
        null_equals_empty_string:
          default: false
          description: >-
            Treat NULL and empty string ('') as equal in string comparisons and
            PK joins.
          title: Null Equals Empty String
          type: boolean
        primary_key:
          description: List of columns that make up the primary key for the datasets.
          items:
            type: string
          title: Primary Key
          type: array
        sampling:
          anyOf:
            - $ref: '#/components/schemas/ToleranceBasedSampling'
            - $ref: '#/components/schemas/PercentageSampling'
            - $ref: '#/components/schemas/MaxRowsSampling'
            - type: 'null'
          description: Sampling configuration for the data comparison.
        sort_array_columns:
          anyOf:
            - type: boolean
            - type: 'null'
          description: >-
            Sort array elements before comparison to ignore insertion order
            differences.
          title: Sort Array Columns
        timeseries_dimension_column:
          anyOf:
            - type: string
            - type: 'null'
          description: Column used for time series dimensioning in the comparison.
          title: Timeseries Dimension Column
        tolerance:
          anyOf:
            - $ref: '#/components/schemas/DataDiffToleranceConfig'
            - type: 'null'
          description: Configuration for tolerance.
      required:
        - primary_key
        - dataset_a
        - dataset_b
      title: In-Database
      type: object
    InMemDataDiffConfig:
      properties:
        column_remapping:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          description: Mapping of columns from one dataset to another for comparison.
          title: Column Remapping
        columns_to_compare:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          description: Optional list of columns to compare between the datasets.
          title: Columns To Compare
        compare_duplicates:
          anyOf:
            - type: boolean
            - type: 'null'
          description: Compare rows with duplicate primary keys. Defaults to true.
          title: Compare Duplicates
        dataset_a:
          anyOf:
            - $ref: '#/components/schemas/XdbTableDataset'
            - $ref: '#/components/schemas/XdbQueryDataset'
          description: The first dataset to compare.
          title: Dataset A
        dataset_b:
          anyOf:
            - $ref: '#/components/schemas/XdbTableDataset'
            - $ref: '#/components/schemas/XdbQueryDataset'
          description: The second dataset to compare.
          title: Dataset B
        ignore_string_case:
          default: false
          description: Indicates whether to ignore case differences in string comparisons.
          title: Ignore String Case
          type: boolean
        materialize_results:
          default: false
          description: Indicates whether to materialize the results of the comparison.
          title: Materialize Results
          type: boolean
        materialize_results_to:
          anyOf:
            - type: integer
            - type: 'null'
          description: Identifier for the destination where results should be materialized.
          title: Materialize Results To
        null_equals_empty_string:
          default: false
          description: >-
            Treat NULL and empty string ('') as equal in string comparisons and
            PK joins.
          title: Null Equals Empty String
          type: boolean
        primary_key:
          description: List of columns that make up the primary key for the datasets.
          items:
            type: string
          title: Primary Key
          type: array
        sampling:
          anyOf:
            - $ref: '#/components/schemas/ToleranceBasedSampling'
            - $ref: '#/components/schemas/PercentageSampling'
            - $ref: '#/components/schemas/MaxRowsSampling'
            - type: 'null'
          description: Sampling configuration for the data comparison.
          title: Sampling
        sort_array_columns:
          anyOf:
            - type: boolean
            - type: 'null'
          description: >-
            Sort array elements before comparison to ignore insertion order
            differences.
          title: Sort Array Columns
        tolerance:
          anyOf:
            - $ref: '#/components/schemas/DataDiffToleranceConfig'
            - type: 'null'
          description: Configuration for tolerance.
      required:
        - primary_key
        - dataset_a
        - dataset_b
      title: In-Memory
      type: object
    EmailNotification:
      properties:
        features:
          anyOf:
            - items:
                $ref: '#/components/schemas/DestinationFeatures'
              type: array
            - type: 'null'
          description: A list of features to enable for this notification.
          title: Features
        recipients:
          description: A list of email addresses to receive the notification.
          items:
            type: string
          title: Recipients
          type: array
        type:
          const: email
          default: email
          title: Type
          type: string
      required:
        - recipients
      title: Email
      type: object
    PagerDutyNotification:
      properties:
        features:
          anyOf:
            - items:
                $ref: '#/components/schemas/DestinationFeatures'
              type: array
            - type: 'null'
          description: A list of features to enable for this notification.
          title: Features
        integration:
          description: The identifier for the integration.
          title: Integration
          type: integer
        type:
          const: pagerduty
          default: pagerduty
          title: Type
          type: string
      required:
        - integration
      title: PagerDuty
      type: object
    SlackNotification:
      properties:
        channel:
          description: The channel through which the notification will be sent.
          title: Channel
          type: string
        features:
          anyOf:
            - items:
                $ref: '#/components/schemas/DestinationFeatures'
              type: array
            - type: 'null'
          description: A list of features to enable for this notification.
          title: Features
        integration:
          description: The identifier for the integration.
          title: Integration
          type: integer
        mentions:
          description: A list of mentions to include in the notification.
          items:
            type: string
          title: Mentions
          type: array
        type:
          const: slack
          default: slack
          title: Type
          type: string
      required:
        - integration
        - channel
      title: Slack
      type: object
    TeamsNotification:
      properties:
        channel:
          description: The channel through which the notification will be sent.
          title: Channel
          type: string
        features:
          anyOf:
            - items:
                $ref: '#/components/schemas/DestinationFeatures'
              type: array
            - type: 'null'
          description: A list of features to enable for this notification.
          title: Features
        integration:
          description: The identifier for the integration.
          title: Integration
          type: integer
        mentions:
          description: A list of mentions names to include in the notification.
          items:
            type: string
          title: Mentions
          type: array
        type:
          const: teams
          default: teams
          title: Type
          type: string
      required:
        - integration
        - channel
      title: Teams
      type: object
    WebhookNotification:
      properties:
        features:
          anyOf:
            - items:
                $ref: '#/components/schemas/DestinationFeatures'
              type: array
            - type: 'null'
          description: A list of features to enable for this notification.
          title: Features
        integration:
          description: The identifier for the integration.
          title: Integration
          type: integer
        type:
          const: webhook
          default: webhook
          title: Type
          type: string
      required:
        - integration
      title: Webhook
      type: object
    IntervalSchedule:
      properties:
        interval:
          anyOf:
            - $ref: '#/components/schemas/HourIntervalSchedule'
            - $ref: '#/components/schemas/DayIntervalSchedule'
          description: Specifies the scheduling interval.
      required:
        - interval
      title: Interval
      type: object
    CronSchedule:
      properties:
        cron:
          description: The cron expression that defines the schedule.
          title: Cron
          type: string
        type:
          const: crontab
          default: crontab
          title: Type
          type: string
      required:
        - cron
      title: Cron
      type: object
    NoneSchedule:
      properties:
        type:
          const: none
          default: none
          title: Type
          type: string
      title: None
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
    InDbTableDataset:
      properties:
        connection_id:
          description: The identifier for the data source configuration.
          title: Connection Id
          type: integer
        filter:
          anyOf:
            - type: string
            - type: 'null'
          description: Filter condition for querying the dataset.
          title: Filter
        session_parameters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: Session parameters for the database session.
          title: Session Parameters
        table:
          description: The table in the format 'db.schema.table'.
          title: Table
          type: string
        time_travel_point:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          description: Point in time for querying historical data.
          title: Time Travel Point
      required:
        - connection_id
        - table
      title: Table
      type: object
    InDbQueryDataset:
      properties:
        connection_id:
          description: The identifier for the data source configuration.
          title: Connection Id
          type: integer
        query:
          description: The SQL query to be evaluated.
          title: Query
          type: string
        session_parameters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: Parameters for the database session.
          title: Session Parameters
        time_travel_point:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          description: Point in time for querying historical data.
          title: Time Travel Point
      required:
        - connection_id
        - query
      title: Query
      type: object
    ToleranceBasedSampling:
      properties:
        confidence:
          description: The confidence level for the sampling results.
          title: Confidence
          type: number
        threshold:
          anyOf:
            - type: integer
            - type: 'null'
          description: Threshold for triggering actions based on sampling.
          title: Threshold
        tolerance:
          description: The allowable margin of error for sampling.
          title: Tolerance
          type: number
      required:
        - tolerance
        - confidence
      title: Tolerance
      type: object
    PercentageSampling:
      properties:
        rate:
          description: The sampling rate as a percentage.
          title: Rate
          type: number
        threshold:
          anyOf:
            - type: integer
            - type: 'null'
          description: Threshold for triggering actions based on sampling.
          title: Threshold
      required:
        - rate
      title: Percentage
      type: object
    MaxRowsSampling:
      properties:
        max_rows:
          description: The maximum number of rows to sample.
          title: Max Rows
          type: integer
        threshold:
          anyOf:
            - type: integer
            - type: 'null'
          description: Threshold for triggering actions based on sampling.
          title: Threshold
      required:
        - max_rows
      title: MaxRows
      type: object
    DataDiffToleranceConfig:
      properties:
        datetime:
          anyOf:
            - $ref: '#/components/schemas/DatetimeColumnToleranceConfig'
            - type: 'null'
          description: Configuration for datetime columns tolerance.
        float:
          anyOf:
            - $ref: '#/components/schemas/ColumnToleranceConfig'
            - type: 'null'
          description: Configuration for float columns tolerance.
      title: DataDiffToleranceConfig
      type: object
    XdbTableDataset:
      properties:
        connection_id:
          description: The identifier for the data source configuration.
          title: Connection Id
          type: integer
        filter:
          anyOf:
            - type: string
            - type: 'null'
          description: Filter condition for querying the dataset.
          title: Filter
        materialize:
          default: true
          description: Indicates whether to materialize the dataset.
          title: Materialize
          type: boolean
        session_parameters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: Session parameters for the database session.
          title: Session Parameters
        table:
          description: The table in the format 'db.schema.table'.
          title: Table
          type: string
      required:
        - connection_id
        - table
      title: Table
      type: object
    XdbQueryDataset:
      properties:
        connection_id:
          description: The identifier for the data source configuration.
          title: Connection Id
          type: integer
        materialize:
          default: true
          description: Indicates whether to materialize the dataset.
          title: Materialize
          type: boolean
        query:
          description: The SQL query to be evaluated.
          title: Query
          type: string
        session_parameters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: Parameters for the database session.
          title: Session Parameters
      required:
        - connection_id
        - query
      title: Query
      type: object
    DestinationFeatures:
      enum:
        - attach_csv
        - notify_first_triggered_only
        - disable_recovery_notifications
        - notify_every_run
      title: DestinationFeatures
      type: string
    HourIntervalSchedule:
      properties:
        every:
          const: hour
          title: Every
          type: string
        type:
          const: hourly
          default: hourly
          title: Type
          type: string
      required:
        - every
      title: Hour
      type: object
    DayIntervalSchedule:
      properties:
        every:
          const: day
          title: Every
          type: string
        hour:
          anyOf:
            - type: integer
            - type: 'null'
          description: The hour at which the monitor should trigger. (0 - 23)
          title: Hour
        type:
          const: daily
          default: daily
          title: Type
          type: string
        utc_at:
          anyOf:
            - format: time
              type: string
            - type: 'null'
          description: The UTC time at which the monitor should trigger.
          title: Utc At
      required:
        - every
      title: Day
      type: object
    DatetimeColumnToleranceConfig:
      properties:
        default:
          enum:
            - 1s
            - 0.1s
            - 0.01s
            - 1ms
            - 0.1ms
            - 0.01ms
            - 1us
          title: Default
          type: string
      required:
        - default
      title: DatetimeColumnToleranceConfig
      type: object
    ColumnToleranceConfig:
      properties:
        column_tolerance:
          anyOf:
            - additionalProperties:
                discriminator:
                  mapping:
                    absolute:
                      $ref: '#/components/schemas/AbsoluteColumnTolerance'
                    relative:
                      $ref: '#/components/schemas/RelativeColumnTolerance'
                  propertyName: type
                oneOf:
                  - $ref: '#/components/schemas/RelativeColumnTolerance'
                  - $ref: '#/components/schemas/AbsoluteColumnTolerance'
              type: object
            - type: 'null'
          description: Specific tolerance per column.
          title: Column Tolerance
        default:
          anyOf:
            - discriminator:
                mapping:
                  absolute:
                    $ref: '#/components/schemas/AbsoluteColumnTolerance'
                  relative:
                    $ref: '#/components/schemas/RelativeColumnTolerance'
                propertyName: type
              oneOf:
                - $ref: '#/components/schemas/RelativeColumnTolerance'
                - $ref: '#/components/schemas/AbsoluteColumnTolerance'
            - type: 'null'
          description: Default tolerance applied to all columns.
          title: Default
      title: ColumnToleranceConfig
      type: object
    AbsoluteColumnTolerance:
      properties:
        type:
          const: absolute
          default: absolute
          description: The type of Column Tolerance.
          title: Type
          type: string
        value:
          description: Value of Column Tolerance.
          title: Value
          type: number
      required:
        - value
      title: Absolute
      type: object
    RelativeColumnTolerance:
      properties:
        type:
          const: relative
          default: relative
          description: The type of Column Tolerance.
          title: Type
          type: string
        value:
          anyOf:
            - type: number
            - type: integer
          description: Value of Column Tolerance.
          title: Value
      required:
        - value
      title: Relative
      type: object
  securitySchemes:
    ApiKeyAuth:
      description: Use the 'Authorization' header with the format 'Key <api-key>'
      in: header
      name: Authorization
      type: apiKey

````