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

# Preview an entity notification

> Builds a sample notification from a `track` and `fields` you have not saved yet, so a create
form can show or deliver the exact envelope before the watch exists.

The sample record is generated by walking the dataset's own enrich model, so every trackable
field is present in the exact production shape and the sample never drifts from the schema. Its
values are a fixed, public demo profile rather than a real subject of yours. It is signed
exactly as a real delivery is, so a receiver that verifies here verifies production, and
`metadata.watch_id` is `0` because no watch exists yet.

Same guarantees as the saved-watch test: no run, no snapshot, no credit, nothing persisted.




## OpenAPI

````yaml /openapi-specs/2025-11-01/watch.yaml post /watch/{dataset}/test
openapi: 3.0.3
info:
  title: Watch API
  version: '2025-11-01'
  description: >
    The Watch API turns a Crustdata query into a recurring feed. A watch runs on
    your schedule and

    delivers only what is new or what changed since its previous run, to a
    webhook, Slack, Google Chat,

    or email.


    There are two kinds of watch, and the kind decides the URL:


    - **Discovery watches** (`/watch/{dataset}/search`) re-run a *search filter*
    and deliver records that
      newly match it. Use one to find people, companies, jobs, or social posts you do not know yet.
      Available for `person`, `company`, `job`, and `social_post`.
    - **Entity watches** (`/watch/{dataset}`) monitor a *list you supply* and
    deliver a notification when
      a tracked field on one of those records changes. Use one to follow a known set. Available for
      `person` and `company`.

    Both kinds share the same `config`, `notifications`, and run-history
    surfaces, and both start with a

    free baseline run: a discovery watch delivers a sample of up to 5 current
    matches, an entity watch

    records each subject's starting values and never fires. Every request needs
    an `Authorization` Bearer

    API key and the `x-api-version: 2025-11-01` header.


    **Credits.** Every watch is priced by its SLA, how fresh the data behind a
    notification is kept,

    written as `config.refresh_frequency_days`. At the 30-day default a
    discovery watch is charged per

    new record delivered: 0.5 for a person, 2 for a company, 0.5 for a job, 2
    for a social post. At a

    1-day SLA it is charged 150 per new record on every dataset, because each
    run searches live rather

    than reading the index; a discovery watch asks for that SLA with
    `config.is_realtime: true` and the

    create response echoes `config.refresh_frequency_days: 1`. An entity watch
    is charged per

    notification at the same SLA scale: 5 credits at the 30-day default, 10 at
    14 days, 20 at 7 days,

    50 at 3 days, 150 at 1 day. A run that finds nothing costs nothing, and the
    baseline run is free

    for both kinds.


    **Rate limit.** Watch-management requests are limited to 10 requests per
    minute, counted per

    endpoint: exhausting `/watch/company/search` leaves `/watch/company`,
    `/watch/person/search`,

    and `/watch/job/search` with a full allowance. Every response carries
    `X-RateLimit-Limit`,

    `X-RateLimit-Remaining`, and `X-RateLimit-Reset`, the seconds until the
    window rolls over.


    **Access.** Creating a watch is open to any authenticated API customer, and
    the 10-requests-per-minute

    limit is what bounds abuse. What is gated is the data underneath: a create
    is rejected with `403` when

    the key is not entitled to the dataset, or when `fields` or `track` name
    field groups the key may not

    receive. Contact info@crustdata.com to request access.
servers:
  - url: https://api.crustdata.com
    description: Production API server
security:
  - bearerAuth: []
tags:
  - name: Watch APIs
    description: Recurring feeds over the Crustdata datasets
  - name: Discovery Watches
    description: Watches that re-run a search filter and deliver newly matching records
  - name: Entity Watches
    description: >-
      Watches that monitor a supplied list of people or companies for field
      changes
  - name: Watch Runs
    description: Run history and per-run delivery detail, shared by both watch kinds
paths:
  /watch/{dataset}/test:
    post:
      tags:
        - Watch APIs
        - Entity Watches
      summary: Preview a notification before creating an entity watch
      description: >
        Builds a sample notification from a `track` and `fields` you have not
        saved yet, so a create

        form can show or deliver the exact envelope before the watch exists.


        The sample record is generated by walking the dataset's own enrich
        model, so every trackable

        field is present in the exact production shape and the sample never
        drifts from the schema. Its

        values are a fixed, public demo profile rather than a real subject of
        yours. It is signed

        exactly as a real delivery is, so a receiver that verifies here verifies
        production, and

        `metadata.watch_id` is `0` because no watch exists yet.


        Same guarantees as the saved-watch test: no run, no snapshot, no credit,
        nothing persisted.
      operationId: previewEntityWatchNotification
      parameters:
        - $ref: '#/components/parameters/EntityDatasetPath'
        - $ref: '#/components/parameters/ApiVersion'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EntityTestPreviewRequest'
            examples:
              preview_only:
                summary: Build the envelope without delivering it
                value:
                  track:
                    field: experience.employment_details.current
                    type: added
                  fields:
                    - basic_profile
                    - experience
                  deliver: false
              deliver_to_endpoint:
                summary: Deliver three samples to a URL you control
                value:
                  track:
                    field: basic_profile.current_title
                    type: changed
                  notification_endpoint: https://your-server.example.com/webhook
                  count: 3
      responses:
        '200':
          description: The sample was built, and delivered when `deliver` was not `false`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestSendResponse'
        '400':
          description: >-
            A body field failed validation, or the endpoint override is not a
            safe public URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WatcherErrorResponse'
              example:
                error:
                  type: invalid_request
                  message: fields must be a list of non-empty field-path strings.
                  metadata: []
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            The key is not entitled to this dataset, or `track` or `fields` name
            field groups it may not receive.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WatcherErrorResponse'
              example:
                error:
                  type: permission_error
                  message: 'Access denied to fields: contact'
                  metadata: []
        '404':
          description: >
            The dataset segment is not `person` or `company`. There is no job
            entity watch, so

            `/watch/job` does not match a route at all and the router answers a
            plain HTML `404`

            with no JSON body. Use `/watch/job/search` for jobs.
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    EntityDatasetPath:
      name: dataset
      in: path
      required: true
      description: >
        The dataset the watch is built on. Entity watches support `person` and
        `company`; there is no

        job entity watch, and `job` returns `404` here. Use `/watch/job/search`
        for jobs.
      schema:
        type: string
        enum:
          - person
          - company
        example: person
    ApiVersion:
      name: x-api-version
      in: header
      required: true
      schema:
        type: string
        enum:
          - '2025-11-01'
        default: '2025-11-01'
        example: '2025-11-01'
      description: >
        API version to use. `2025-11-01` is the only accepted value. Send it on
        every call: it is

        enforced today on `POST /watch/{dataset}/search`, where a missing or
        unrecognized value returns

        `400`, and the other watch routes accept a request without it rather
        than relying on that.
  schemas:
    EntityTestPreviewRequest:
      type: object
      description: >
        An in-progress entity watch config to build a sample from. Carries the
        same `track` and `fields`

        a create request would, but nothing is saved.
      properties:
        track:
          description: The track tree to build the sample `changes` array from.
          oneOf:
            - $ref: '#/components/schemas/TrackCondition'
            - $ref: '#/components/schemas/TrackConditionGroup'
        fields:
          type: array
          items:
            type: string
          description: >-
            Field groups to project the sample `record` to. Entitlement-checked
            like a create.
          example:
            - basic_profile
            - experience
        notification_endpoint:
          type: string
          format: uri
          description: >-
            Public URL to deliver the sample to. Required when `deliver` is not
            `false`, since there is no saved watch to fall back on.
          example: https://your-server.example.com/webhook
        count:
          type: integer
          minimum: 1
          maximum: 25
          default: 1
          example: 1
        deliver:
          type: boolean
          default: true
          description: Set `false` to get the envelope back without sending anything.
          example: false
    TestSendResponse:
      type: object
      description: >-
        The result of a test send, carrying what each channel answered and the
        exact envelope that was delivered.
      properties:
        delivered:
          type: array
          description: >-
            One entry per channel the test was sent to. Empty when `deliver` was
            `false`.
          items:
            $ref: '#/components/schemas/DeliveryAttempt'
        envelope:
          $ref: '#/components/schemas/NotificationEnvelope'
    WatcherErrorResponse:
      type: object
      description: >
        Every watcher failure, whatever the status code. `type` is the
        machine-readable code,

        `message` is the sentence you can show a user, and `metadata` carries
        per-problem detail.


        Validation collects every failure in one pass, so a body with three
        problems answers once

        with three `metadata` entries and a `message` that joins them. Each
        validation entry is a

        `{field, type, message}` triple: `field` is the request path that
        failed, indexed into

        filter and track trees; `type` is drawn from the vocabulary the search
        and enrich APIs use

        (`missing`, `enum`, `greater_than_equal`, `less_than_equal`,
        `string_type`, `int_type`,

        `bool_type`, `list_type`, `dict_type`, `too_long`, `date_parsing`,
        `extra_forbidden`,

        `invalid`) plus `unknown_field` and `unsupported`, which only watcher
        emits.


        A limit that names no request field, such as the tracking cap, carries
        an empty `metadata`.

        Three responses put something other than a triple in it: `Invalid
        fields: ...` carries

        `available_fields`, `Access denied to fields: ...` carries
        `denied_fields` and

        `permitted_fields`, and a test send that was never attempted carries the
        `delivered` and

        `envelope` it had built. Check for the keys you expect before iterating.
      required:
        - error
      example:
        error:
          type: not_found
          message: Watch not found
          metadata: []
      properties:
        error:
          type: object
          required:
            - type
            - message
            - metadata
          properties:
            type:
              type: string
              description: Machine-readable error type.
              enum:
                - invalid_request
                - unauthorized
                - permission_error
                - not_found
                - rate_limit_error
                - internal_error
              example: not_found
            message:
              type: string
              description: >
                Human-readable description. On a validation failure this is
                every entry's

                message joined in order.
              example: Watch not found
            metadata:
              type: array
              description: >-
                One entry per problem, empty when the failure names no request
                field.
              items:
                type: object
                additionalProperties: true
                properties:
                  field:
                    type: string
                    description: The request path that failed.
                    example: config.trigger.every_hours
                  type:
                    type: string
                    description: The failure code for this one problem.
                    example: greater_than_equal
                  message:
                    type: string
                    description: The sentence for this one problem.
                    example: config.trigger.every_hours must be an integer >= 1.
              example:
                - field: config.trigger.every_hours
                  type: greater_than_equal
                  message: config.trigger.every_hours must be an integer >= 1.
    TrackCondition:
      type: object
      description: >
        One `track` leaf: the change on one field that fires a notification. The
        operator must match the

        field's shape, so `changed` needs a scalar path and `added` needs an
        array path. Mixing them

        returns `400`. An `added` leaf may carry `keys` to say which fields
        identify an element of the

        array.
      required:
        - field
        - type
      properties:
        field:
          type: string
          description: >
            Dot-path into the record, addressing the same structure the
            dataset's enrich endpoint

            returns: the fields of `POST /person/enrich` or `POST
            /company/enrich` are the fields a

            watch can track, and there is no separate list. An array path takes
            `added`; a field

            inside an array's items, or any single value, takes `changed`,
            `increased`/`decreased`

            or a comparison. A field that identifies an array item cannot take
            `changed`, since a

            new value there is a new item, and arrays can be tracked at most two
            levels deep.
          example: experience.employment_details.current
        type:
          type: string
          enum:
            - changed
            - added
            - increased
            - decreased
            - '='
            - '!='
            - '>'
            - <
            - '=>'
            - '=<'
          description: >
            `changed` fires when a scalar becomes different from the last
            snapshot. `added` fires

            when a new element appears in an array. `increased` and `decreased`
            fire when a number

            moves up or down from the last snapshot, for example
            `headcount.total` growing; they take

            no `value` and are refused on a field that is not a number. The
            comparison operators fire

            when the comparison flips from false to true, for example
            `professional_network.connections`

            crossing 500.
          example: added
        keys:
          type: array
          minItems: 1
          items:
            oneOf:
              - type: string
              - type: array
                items:
                  type: string
          description: >
            Which fields identify an element of the array, in place of the
            identity the dataset gives

            it. Valid only with `added`: on any other operator the create
            returns `400` with

            `track: 'keys' is only valid with 'added', not '<type>'`. A string
            entry is one field; a

            nested entry is a composite of several fields. Entries are matched
            as a union, so an

            element is already known when any one entry matches, and the loosest
            entry therefore

            wins: give a fallback entry the same fields as the entry it backs
            up. An entry cannot

            identify an element when any field in that entry is null. The fields
            must belong to the

            array's own elements and your key must be entitled to each one, so
            `keys` on an array of

            plain strings returns `400`. A watch remembers every identity it has
            seen on the array,

            so an element that leaves and returns does not fire again. An empty
            list or a bare

            string returns `400` with

            `track: '<path>': 'keys' must be a non-empty list of fields or field
            groups`.
          example:
            - crustdata_company_id
            - name
        value:
          description: >-
            The threshold to compare against. Required for the comparison
            operators, omitted for `changed`, `added`, `increased` and
            `decreased`.
          example: 500
    TrackConditionGroup:
      type: object
      description: >
        A group of track conditions. An `or` group fires if any child fires. An
        `and` group fires only

        when all conditions hold and at least one just became true. Groups nest.
      required:
        - op
        - conditions
      properties:
        op:
          type: string
          enum:
            - and
            - or
          example: or
        conditions:
          type: array
          minItems: 1
          items:
            oneOf:
              - $ref: '#/components/schemas/TrackCondition'
              - $ref: '#/components/schemas/TrackConditionGroup'
    DeliveryAttempt:
      type: object
      description: The outcome of one channel's delivery attempt.
      properties:
        type:
          type: string
          description: The channel type the attempt used.
          example: webhook
        endpoint:
          type: string
          description: Where it was delivered.
          example: https://your-server.example.com/webhook
        http_status:
          type: integer
          nullable: true
          description: >-
            Status your receiver answered with. `null` if the request never
            completed.
          example: 200
        ok:
          type: boolean
          description: True when `http_status` was 2xx.
          example: true
        response:
          type: string
          description: Your receiver's response body, truncated to 500 characters.
          example: '{"received": true}'
    NotificationEnvelope:
      type: object
      description: >
        The body POSTed to each webhook channel, and the same body a test send
        returns under `envelope`.


        The two watch kinds shape `results` differently. A discovery watch keys
        results by membership

        polarity, so records arrive under `results.added`, each one the raw
        dataset record. An entity

        watch delivers a flat list, one object per fired subject, each with its
        own `changes` and

        `record`.


        A watch whose `config.payload_delivery_type` is `link` omits `results`
        entirely and carries the

        records' location in `metadata.payload_delivery` instead. Branch on

        `metadata.payload_delivery.type` rather than on the presence of
        `results`: the field is present

        on every delivery, and a `link` watch falls back to an inline body when
        the file cannot be

        written.
      properties:
        metadata:
          type: object
          properties:
            watch_id:
              type: integer
              example: 46936
            kind:
              type: string
              enum:
                - discovery
                - entity
              example: entity
            dataset:
              type: string
              enum:
                - person
                - company
                - job
              example: person
            api_version:
              type: string
              example: '2025-11-01'
            run_id:
              type: integer
              example: 64200
            notification_id:
              type: string
              description: >-
                Unique id for this delivery, echoed in the
                `x-crustdata-event-id` header. Key your receiver's deduplication
                on it.
              example: ntf_64200
            delivered_at:
              type: string
              format: date-time
              example: '2026-07-16T03:20:00.351849+00:00'
            test:
              type: boolean
              description: >-
                Present and `true` only on a test send. Absent on a real
                delivery.
              example: true
            summary:
              type: object
              description: >
                The run's counts. `records_matched` ships only on an entity
                watch and `records_stale` only

                on a discovery watch, so read `metadata.kind` before you read
                either one. A key that does

                not apply to the watch kind is left out rather than sent as
                `null`.
              properties:
                delivered:
                  type: integer
                  description: Records in this envelope.
                  example: 1
                total_count:
                  type: integer
                  description: >
                    New records the run found, before the cap. On a discovery
                    watch, the new matches.

                    On an entity watch, the entities that changed, and on its
                    first run every subject

                    Crustdata resolved. It exceeds `delivered` when the cap cut
                    the run short.
                  example: 1
                records_searched:
                  type: integer
                  description: >
                    What the run started from. On a discovery watch, everything
                    the query returned

                    before the new-record check and the cap. On an entity watch,
                    the identifiers you

                    listed in `entities`.
                  example: 2
                max_results_per_run:
                  type: integer
                  example: 100
                truncated:
                  type: boolean
                  description: True when `total_count` exceeded `delivered`.
                  example: false
                records_matched:
                  type: integer
                  description: >
                    Entity watches only. Identifiers that resolved to a record
                    Crustdata holds. A gap

                    between this and `records_searched` is the part of your list
                    that matches nothing,

                    which a run would otherwise pass over in silence. Left out
                    on a discovery watch.
                  example: 1
                records_stale:
                  type: integer
                  description: >
                    Discovery watches only. Matches an earlier run already
                    handled, so

                    `records_searched` minus `records_stale` is `total_count`.
                    On a job or post watch

                    it counts the records posted before the last run. Left out
                    on an entity watch.
                  example: 150
            payload_delivery:
              $ref: '#/components/schemas/PayloadDelivery'
            chunk:
              type: object
              description: >
                Present only when an inline run was too large for one request
                and was split.

                Each request then carries its own `notification_id` of
                `ntf_{run_id}_{index}`.

                Absent on a single-request run and on every `link` delivery.
              properties:
                index:
                  type: integer
                  description: Zero-based position of this request in the run's sequence.
                  example: 0
        results:
          description: >
            The payload. An object keyed by polarity for a discovery watch, a
            flat array for an

            entity watch. Absent entirely when `metadata.payload_delivery.type`
            is `link`.
          oneOf:
            - $ref: '#/components/schemas/DiscoveryResults'
            - $ref: '#/components/schemas/EntityResults'
    PayloadDelivery:
      type: object
      description: >
        Where the records of this delivery actually travelled. Present on every
        notification and on

        every run summary, so read `type` before reaching for `url`.


        An `inline` delivery carries `{"type": "inline"}` and nothing else, and
        its records sit in the

        body under `results`. A `link` delivery carries the whole block and no
        records: fetch `url`

        with a plain `GET` and no `authorization` header, since the pre-signed
        S3 URL carries its own

        authentication in the query string.


        The file is NDJSON, one complete JSON object per line with no wrapping
        array, so you can stream

        it without holding the run in memory. Each line is the record the inline
        body would have

        carried: the raw dataset record for a discovery watch, without the
        `added` wrapper, and the

        same `{changes, record}` object for an entity watch.


        A watch set to `link` still reports `inline` here when the file could
        not be written. The

        delivery then carries its records in the body as usual, so an outage
        costs the link and not the

        notification.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - inline
            - link
          description: Where the records of this delivery travelled.
          example: link
        url:
          type: string
          format: uri
          description: >
            Pre-signed S3 URL for the run's file. Present only when `type` is
            `link`. Fetch it when

            the notification arrives rather than storing it: the signature stops
            working at

            `expires_at`.
          example: >-
            https://crustdata-batch-api-data.s3.amazonaws.com/watcher/watch=46849/run=64200/records.ndjson?...&X-Amz-Expires=432000
        format:
          type: string
          enum:
            - ndjson
          description: Format of the linked file. Present only when `type` is `link`.
          example: ndjson
        bytes:
          type: integer
          description: Size of the linked file. Present only when `type` is `link`.
          example: 4823901
        expires_at:
          type: string
          format: date-time
          description: >
            When `url` stops working, five days after it was issued. Present
            only when `type` is

            `link`. Reading the run again from the run-summary endpoint issues a
            fresh link over

            the same records.
          example: '2026-09-01T03:20:00.000000+00:00'
    DiscoveryResults:
      type: object
      description: >-
        Discovery payload. Records that newly matched the filter arrive under
        `added`.
      properties:
        added:
          type: array
          description: >
            The newly matching records, each in the dataset's own record shape
            projected to the

            watch's `fields`. A person or company record is the enrich shape; a
            job record carries

            `job_details`, `company`, `location`, and `metadata`.
          items:
            type: object
            additionalProperties: true
          example:
            - job_details:
                title: Backend Engineer, Vehicle Software
                url: https://www.example-jobs.com/postings/4448814407
                category: Engineering
                workplace_type: On-site
                number_of_openings: 1
              company:
                basic_info:
                  name: Tesla
                  primary_domain: tesla.com
              location:
                raw: Palo Alto, California, United States
                country: United States
              metadata:
                date_added: '2026-08-04T05:32:47'
    EntityResults:
      type: array
      description: Entity payload. One object per subject that fired on this run.
      items:
        type: object
        properties:
          changes:
            type: array
            description: >-
              Exactly what moved. Reported whatever `fields` says, so a change
              is always legible even with the default projection.
            items:
              $ref: '#/components/schemas/RecordChange'
          record:
            type: object
            additionalProperties: true
            description: >
              The subject's current data, projected to the watch's `fields`, in
              the same shape the

              dataset's enrich endpoint returns. The subject's identity travels
              inside the record

              as `crustdata_person_id` or `crustdata_company_id`.
    RecordChange:
      type: object
      description: >
        One field-level change. A `changed` scalar reports `from` and `to`. An
        `added` array reports

        `new_elements`. On a comparison operator, `value` carries the threshold
        that was crossed.
      properties:
        field:
          type: string
          example: experience.employment_details.current
        type:
          type: string
          enum:
            - changed
            - added
          example: added
        from:
          nullable: true
          description: Previous value, on a `changed` scalar.
        to:
          nullable: true
          description: New value, on a `changed` scalar.
        value:
          nullable: true
          description: >-
            The threshold target for a comparison operator, `null` for a plain
            `changed`.
        new_elements:
          type: array
          description: The elements that appeared, on an `added` array.
          items:
            type: object
            additionalProperties: true
  responses:
    Unauthorized:
      description: >
        The API key is missing or not valid. Both failures answer with the same
        body, so the

        response does not tell you which of the two happened.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WatcherErrorResponse'
          example:
            error:
              type: unauthorized
              message: Invalid API key in request.
              metadata: []
    RateLimited:
      description: >
        Too many watch requests. The per-endpoint limit is 10 requests per
        minute per API key, which is

        what bounds bursty create and update loops. Steady use is unaffected.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WatcherErrorResponse'
          example:
            error:
              type: rate_limit_error
              message: >-
                Rate limit exceeded for this endpoint. Please write to
                gtm@crustdata.co.
              metadata: []
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key passed as a Bearer token in the Authorization header.

````

## Related topics

- [Create an entity watch](https://docs.crustdata.com/api-reference/watch-apis/create-an-entity-watch.md)
- [Company Entity Watcher](https://docs.crustdata.com/watcher-docs/company/entity.md)
- [Person Entity Watcher](https://docs.crustdata.com/watcher-docs/person/entity.md)
- [Update an entity watch](https://docs.crustdata.com/api-reference/watch-apis/edit-the-watched-list-pause-or-reconfigure-an-entity-watch.md)
- [Get an entity watch](https://docs.crustdata.com/api-reference/watch-apis/get-one-entity-watch.md)
