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

# Generate deal AI field

> Generate the values of a deal AI field on a set of deals, asynchronously. Target the deals with `dealIds` or with the `viewId` of a deal view. By default only the deals without a value are processed; set `mode` to `Recompute` to regenerate every value. A generation covers at most 333 deals: larger generations are rejected, never truncated. Set `estimateOnly` to get `totalCount` and `estimatedCredits` without starting the generation; an estimate fails whenever the real generation would. Follow the generation with `GET /v1/deals/fields/generations/{generationId}`.

Generates the values of a deal AI field on a list of deals or on the deals of a view, asynchronously. By default only the deals without a value are processed. Set `estimateOnly` to get the deal count and `estimatedCredits` without starting the generation. See [Generations](/api-reference/ai_fields#generations).


## OpenAPI

````yaml POST /v1/deals/fields/{fieldId}/generations
openapi: 3.1.0
info:
  title: Claap API
  description: Development documentation
  version: 0.0.0
servers:
  - url: https://api.claap.io/
security:
  - ApiKey: []
paths:
  /v1/deals/fields/{fieldId}/generations:
    post:
      description: >-
        Generate the values of a deal AI field on a set of deals,
        asynchronously. Target the deals with `dealIds` or with the `viewId` of
        a deal view. By default only the deals without a value are processed;
        set `mode` to `Recompute` to regenerate every value. A generation covers
        at most 333 deals: larger generations are rejected, never truncated. Set
        `estimateOnly` to get `totalCount` and `estimatedCredits` without
        starting the generation; an estimate fails whenever the real generation
        would. Follow the generation with `GET
        /v1/deals/fields/generations/{generationId}`.
      operationId: postV1DealsAiFieldsByAiFieldIdGenerations
      parameters:
        - in: path
          name: fieldId
          schema:
            type: string
            description: Deal AI field identifier
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                creatorEmail:
                  type: string
                  format: email
                  description: >-
                    Email address of the generation author. It must belong to an
                    active workspace member.
                dealIds:
                  type: array
                  items:
                    type: string
                  minItems: 1
                  maxItems: 333
                  description: >-
                    Generate the field on these deals, at most 333 identifiers:
                    use `viewId` for larger sets. Exactly one of `dealIds` and
                    `viewId` is required.
                viewId:
                  type: string
                  description: >-
                    Generate the field on the deals of this view instead of
                    listing their identifiers. Use `GET /v1/deals/views` to
                    discover views.
                mode:
                  type: string
                  enum:
                    - FillMissing
                    - Recompute
                  default: FillMissing
                  description: >-
                    `FillMissing` only generates the deals without a value,
                    `Recompute` regenerates every deal.
                estimateOnly:
                  type: boolean
                  default: false
                  description: >-
                    Return `totalCount` and `estimatedCredits` without starting
                    the generation.
              required:
                - creatorEmail
            examples:
              dealIds:
                summary: By deal ids
                value:
                  creatorEmail: jsmith@example.com
                  dealIds:
                    - Deal#6f1c2b9e-4a7d-4e3b-9c5f-2d8a1e7b3c40
                    - Deal#b2e8d4a1-7c3f-4f9a-8e6d-1a5c9b3f7e22
                  mode: FillMissing
                  estimateOnly: false
              viewId:
                summary: By view, estimate only
                value:
                  creatorEmail: jsmith@example.com
                  viewId: Hq7Tn2Wc9Rk4
                  mode: Recompute
                  estimateOnly: true
      responses:
        '200':
          description: Deal AI field generation was successfully started
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    $ref: '#/components/schemas/AiFieldGenerationStart'
                required:
                  - result
              example:
                result:
                  estimatedCredits: 6
                  generationId: CreateDealsInsightsOp#Wd4Kp8Zr2Mx6Qt1Hs9Fb3
                  totalCount: 2
        '400':
          description: >-
            `creatorEmail` does not belong to an active workspace member, both
            or none of `dealIds` and `viewId` are set, `dealIds` has more than
            333 items, the field is archived or manual (it has no prompt), or
            the generation covers more than 333 deals
        '403':
          description: >-
            The workspace plan does not include AI fields, or the creator is a
            Guest
        '404':
          description: Deal AI field or view was not found
components:
  schemas:
    AiFieldGenerationStart:
      type: object
      properties:
        estimatedCredits:
          type: integer
          description: The estimated AI credit cost of the generation.
        generationId:
          type: string
          description: >-
            Generation identifier, used to follow and cancel the generation.
            Omitted when `estimateOnly` is set and when no record needs to be
            processed.
        totalCount:
          type: integer
          description: The number of records the generation processes.
      required:
        - estimatedCredits
        - totalCount
      description: The outcome of an AI field generation request.
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-Claap-Key

````

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