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

# Replace a recipe

> **Beta.** The request and response shapes may still change.

Overwrite a recipe in place. The body is the whole recipe, not a patch: rules, attributes and parameters you omit are cleared.

The submitted recipe is validated exactly as a creation is, and the stored `catalog_version` is re-stamped to the latest - an edit re-pins the recipe to today's signal vocabulary. Moving a recipe between `DRAFT`, `SHADOW`, `LIVE` and `INACTIVE` is this endpoint too.

The body is the whole recipe, not a patch: rules, attributes and parameters you omit are cleared. Read the recipe first if you are changing one field.

This is also how a recipe moves through its lifecycle - send the same body with a new `status` to promote a `SHADOW` recipe to `LIVE`, or to take a `LIVE` one back to `INACTIVE`.


## OpenAPI

````yaml put /v2/watch/management/recipes/{recipe_id}
openapi: 3.1.0
info:
  title: Prelude API
  version: 2.0.0
  description: The Prelude API allows you to send messages to your users.
  contact:
    email: support@prelude.so
servers:
  - url: https://api.prelude.dev
    description: Production server
security:
  - apiToken: []
tags:
  - name: Notify
    description: Send transactional and marketing messages with compliance enforcement.
  - name: Transactional
    description: Send transactional messages (deprecated - use Notify API instead).
  - name: Verify
    description: Verify phone numbers.
  - name: Watch
    description: Evaluate email addresses and phone numbers for trustworthiness.
  - name: Lookup
    description: >-
      Retrieve detailed information about a phone number including carrier data,
      line type, and portability status.
paths:
  /v2/watch/management/recipes/{recipe_id}:
    put:
      tags:
        - Watch
      summary: Replace a recipe
      description: >-
        **Beta.** The request and response shapes may still change.


        Overwrite a recipe in place. The body is the whole recipe, not a patch:
        rules, attributes and parameters you omit are cleared.


        The submitted recipe is validated exactly as a creation is, and the
        stored `catalog_version` is re-stamped to the latest - an edit re-pins
        the recipe to today's signal vocabulary. Moving a recipe between
        `DRAFT`, `SHADOW`, `LIVE` and `INACTIVE` is this endpoint too.
      operationId: replaceWatchRecipe
      parameters:
        - name: recipe_id
          in: path
          required: true
          schema:
            type: string
            examples:
              - rcp_01jc0t6fwwfgfsq1md24mhyztj
          description: The recipe identifier.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WatchRecipeRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WatchRecipe'
        '400':
          description: KO
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    WatchRecipeRequest:
      type: object
      properties:
        name:
          type: string
          maxLength: 128
          examples:
            - signup_proxy_abuse
        status:
          type: string
          enum:
            - DRAFT
            - SHADOW
            - LIVE
            - INACTIVE
          description: >
            Whether the recipe takes part in an evaluation, and whether its
            verdict counts.
             * `DRAFT` - Not yet in service. It does not evaluate.
             * `SHADOW` - Evaluates and is reported, so you can watch a threshold against live traffic before trusting it.
             * `LIVE` - Evaluates, and its verdict counts toward the evaluation-level answer.
             * `INACTIVE` - Taken back out of service. It does not evaluate.
          examples:
            - SHADOW
        threshold:
          type: integer
          format: int64
          description: >-
            The score at which the recipe flags. The weights of the rules that
            triggered are summed, and the recipe flags when the total reaches
            this value. A threshold of `0` flags every evaluation.
          examples:
            - 70
        rules:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/WatchRecipeRule'
          description: >-
            The rules this recipe scores over, with their weights. At least one
            is required.
        attributes:
          type: array
          items:
            type: string
          description: >
            The request-level facts this recipe's rules may read, declared by
            key and referenced in an expression as `attr.<key>`. Values arrive
            with each evaluation.


            A key is lower snake_case, at most 64 characters, and at most 32 may
            be declared. An attribute a rule reads and a recipe does not declare
            is a compile error, reported against that rule.
          examples:
            - - plan_tier
              - account_age_days
        parameters:
          type: object
          additionalProperties:
            type: string
          description: >
            This recipe's configuration: keys and their values, referenced in an
            expression as `param.<key>`, fixed until the recipe is replaced. Use
            them for the country list or the limit a shared rule should apply
            here, so the same rule can serve two recipes tuned differently.


            Keys follow the same format as attributes, and at most 32 may be
            declared. Values are strings - the only type either supports today.
          examples:
            - blocked_countries: RU,BY
              max_attempts: '5'
      required:
        - name
        - status
        - threshold
        - rules
    WatchRecipe:
      type: object
      properties:
        id:
          type: string
          examples:
            - rcp_01jc0t6fwwfgfsq1md24mhyztj
          description: The recipe identifier. Reference it in a flow's `recipes` to run it.
        name:
          type: string
          examples:
            - signup_proxy_abuse
        catalog_version:
          type: integer
          format: int64
          description: >-
            The version of the Prelude signal catalog this recipe's rules are
            compiled against, stamped by the server when the recipe is created
            or replaced. It is what stops a catalog that later grows or
            deprecates entries from silently changing what this recipe means.
          examples:
            - 1
        status:
          type: string
          enum:
            - DRAFT
            - SHADOW
            - LIVE
            - INACTIVE
        threshold:
          type: integer
          format: int64
          examples:
            - 70
        rules:
          type: array
          items:
            $ref: '#/components/schemas/WatchRecipeRule'
        attributes:
          type: array
          items:
            type: string
          examples:
            - - plan_tier
              - account_age_days
        parameters:
          type: object
          additionalProperties:
            type: string
          examples:
            - blocked_countries: RU,BY
              max_attempts: '5'
      required:
        - id
        - name
        - catalog_version
        - status
        - threshold
        - rules
    Error:
      type: object
      properties:
        code:
          type: string
          description: The error code.
          examples:
            - invalid_phone_number
        message:
          type: string
          examples:
            - >-
              The provided phone number is invalid. Provide a valid E.164 phone
              number.
          description: A human-readable message describing the error.
        type:
          type: string
          examples:
            - bad_request
          description: The error type.
        request_id:
          type: string
          examples:
            - 3d19215e-2991-4a05-a41a-527314e6ff6a
          description: >-
            A string that identifies this specific request. Report it back to us
            to help us diagnose your issues.
        param:
          type: string
          examples:
            - phone_number
          description: The parameter the error refers to, when it applies to a single one.
      required:
        - code
        - message
        - type
    WatchRecipeRule:
      type: object
      description: >-
        One rule's place in a recipe - what it contributes to the score, and
        whether it can settle the verdict on its own.
      properties:
        rule_id:
          type: string
          examples:
            - rul_01jc0t6fwwfgfsq1md24mhyztj
          description: A rule you authored, or one from the managed listing.
        weight:
          type: integer
          format: int64
          examples:
            - 40
          description: >-
            What this rule adds to the recipe's score when it triggers. A rule
            that does not trigger, or that could not run, adds nothing.
        preempts:
          type: string
          enum:
            - PASS
            - FLAG
          description: >
            Makes this rule's outcome the recipe's verdict when it triggers,
            bypassing the score. Omit it in the ordinary case, where the rule
            contributes its weight and the total decides.


            It exists because a weighted score cannot express a certainty:
            saying "this alone is conclusive" through the weights means picking
            a number above every threshold the recipe might later be given,
            which stops being true the moment the threshold moves. The weight
            still applies and the score is still reported - a preempting rule
            overrides the conclusion, it does not erase the evidence.
          examples:
            - FLAG
      required:
        - rule_id
        - weight
  securitySchemes:
    apiToken:
      type: http
      scheme: bearer

````