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

# Créer une veille publicitaire

> Enregistrez une recherche quotidienne d'un annonceur dans une bibliothèque publicitaire et démarrez sa première exécution.



## OpenAPI

````yaml POST /v1/ad-watches
openapi: 3.1.0
info:
  title: querying.ai
  description: >-
    One API for every AI answer engine. Every task is asynchronous: submit, then
    collect the result via webhook or polling.
  version: 1.0.0
servers:
  - url: https://api.querying.ai
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/ad-watches:
    post:
      tags:
        - Ad watches
      summary: Create an ad watch
      description: >-
        Save a daily search of one advertiser or keyword in an ad library and
        schedule its first run, which starts within about a minute. The first
        run is the baseline: it records the ads running now and sends no events;
        ads that appear in later runs are new. Creating a watch spends no
        credits. Each run is billed at the ADS search price, 0.5 credits for
        every 30 ads the run returns, and estimatedCreditsPerRun is the upper
        bound for maxAds. An account holds 5 watches, or 200 on a contract
        account. webhookUrl turns on signed events and needs an API key. A key
        restricted to some engines needs ADS (403 KEY_SCOPE_DENIED otherwise).
      operationId: createAdWatch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAdWatchRequest'
      responses:
        '201':
          description: Ad watch created and scheduled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdWatchResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/KeyScopeDenied'
        '409':
          $ref: '#/components/responses/AdWatchLimit'
components:
  schemas:
    CreateAdWatchRequest:
      type: object
      required:
        - name
        - platform
        - search
      properties:
        name:
          type: string
        platform:
          $ref: '#/components/schemas/AdWatchPlatform'
        search:
          $ref: '#/components/schemas/AdWatchSearch'
        maxAds:
          type: integer
          minimum: 1
          maximum: 1000
          default: 200
          description: >-
            The most ads one run reads. A library that lists fewer ends the run
            earlier.
        intervalHours:
          type: integer
          const: 24
          default: 24
        stopAfterRuns:
          type: integer
          minimum: 1
          maximum: 10
          default: 2
        archiveMedia:
          type: boolean
          default: true
        webhookUrl:
          type: string
          format: uri
          description: >-
            An HTTPS URL on a public host that receives events. Set it with an
            API key: deliveries are signed with the key that sets it.
      examples:
        - name: Northwind on Meta
          platform: meta_ad_library
          search:
            pageId: '123456789012345'
            country: US
          maxAds: 200
          stopAfterRuns: 2
          webhookUrl: https://hooks.example.com/querying/ad-watches
    AdWatchResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            watch:
              $ref: '#/components/schemas/AdWatch'
          required:
            - watch
    AdWatchPlatform:
      type: string
      enum:
        - meta_ad_library
        - google_ads_transparency
        - linkedin_ad_library
        - tiktok_ad_library
      description: >-
        The ad library a watch reads. tiktok_creative_center is a ranked sample
        of top ads and is rejected with 400 VALIDATION_ERROR.
    AdWatchSearch:
      type: object
      additionalProperties: true
      description: >-
        The ADS search fields of the watch platform, such as pageId, pageIds,
        advertiserId, advertiserIds, domain, query, advertiserName, payer,
        country, mediaType, publisherPlatforms and startDate, and details: true
        to read each ad's detail. The watch sets action, limit and cursor
        itself, and sets activeStatus to active on Meta and TikTok. Fixed for
        the life of the watch.
      examples:
        - pageId: '123456789012345'
          country: US
    AdWatch:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        platform:
          $ref: '#/components/schemas/AdWatchPlatform'
        search:
          $ref: '#/components/schemas/AdWatchSearch'
        maxAds:
          type: integer
          minimum: 1
          maximum: 1000
        intervalHours:
          type: integer
          const: 24
          description: Hours between runs. 24 is the only value.
        stopAfterRuns:
          type: integer
          minimum: 1
          maximum: 10
          description: >-
            Meta and LinkedIn: consecutive COMPLETE runs that must miss an ad
            before it counts as stopped.
        archiveMedia:
          type: boolean
        enabled:
          type: boolean
        disabledReason:
          type:
            - string
            - 'null'
          description: >-
            Why the watch was disabled, for example after five failed runs in a
            row.
        webhookUrl:
          type:
            - string
            - 'null'
        nextRunAt:
          type:
            - string
            - 'null'
          format: date-time
        lastRunAt:
          type:
            - string
            - 'null'
          format: date-time
        lastRunStatus:
          type:
            - string
            - 'null'
          enum:
            - RUNNING
            - COMPLETE
            - PARTIAL
            - SUSPECT
            - FAILED
            - null
        runCount:
          type: integer
        activeAdCount:
          type: integer
        stoppedAdCount:
          type: integer
        estimatedCreditsPerRun:
          type: number
          description: >-
            Upper bound for a full run of maxAds: 0.5 credits for every 30 ads,
            plus 0.5 for every 5 ads read in detail when search.details is true.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          const: false
        error:
          $ref: '#/components/schemas/ErrorDetail'
    ErrorDetail:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Stable, safe to branch on. See the Errors guide for the full list.
        message:
          type: string
          description: For humans. May change.
        details:
          description: >-
            Context for the error. An array of `{field, message}` on most
            `VALIDATION_ERROR`s; an object elsewhere (for example `{id}` on
            `RESOURCE_NOT_FOUND`, `retryAfterSec` on 429 and 503 codes). Omitted
            when there is nothing to add.
          oneOf:
            - type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
            - type: object
              additionalProperties: true
        timestamp:
          type: string
          format: date-time
  responses:
    ValidationError:
      description: >-
        The request is malformed: bad JSON, unrecognised `taskType`, or neither
        `payload.prompt` nor `payload.query` present. `details` names the
        offending field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingPrompt:
              summary: Neither prompt nor query supplied
              value:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: Request validation failed
                  details:
                    - field: payload.prompt
                      message: payload.prompt or payload.query is required
                  timestamp: '2026-07-09T04:12:00.000Z'
            badTaskType:
              summary: Unrecognised taskType
              value:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: Request validation failed
                  details:
                    - field: taskType
                      message: '''NOPE'' is not recognized'
                  timestamp: '2026-07-09T04:12:00.000Z'
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: MISSING_API_KEY
              message: Missing or invalid API key
              timestamp: '2026-07-09T04:12:00.000Z'
    KeyScopeDenied:
      description: >-
        The key is restricted to some engines (allowedTaskTypes) and the monitor
        schedules an engine outside that list. The scope that applies to POST
        /v1/async/task also applies to monitors, or a schedule would be a way
        around it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: KEY_SCOPE_DENIED
              message: This key is not allowed to use engine GEMINI
              timestamp: '2026-09-22T04:12:00.000Z'
    AdWatchLimit:
      description: >-
        The account already holds the maximum number of ad watches: 5, or 200 on
        a contract account. Delete one before creating another.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: AD_WATCH_LIMIT
              message: Max 5 ad watches. Delete one first.
              timestamp: '2026-11-23T09:00:00.000Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key, sent as `Authorization: Bearer <key>`.'

````

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