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

# Update Prompt

> Update a prompt with new content or properties. Your production prompt stays safe—updates create new versions without affecting what's currently active.

**How it Works:**
- **Updating components:** Creates a new immutable version with fingerprinting. The new version is created but NOT activated, so you can test before going live.
- **Updating only properties (name/description):** Updates the prompt in-place without creating a new version.

**Version Safety:**
Old versions always point to their original prompts, preserving your message history and allowing you to roll back if needed.



## OpenAPI

````yaml https://www.greenflash.ai/api/openapi put /prompts/{id}
openapi: 3.1.0
info:
  title: Greenflash API Reference
  version: 1.0.0
  description: >-
    Greenflash endpoints for capturing interactions, managing prompts, and
    identifying users.
servers:
  - url: https://www.greenflash.ai/api/v1
    description: Greenflash API v1
security: []
tags:
  - name: Interactions
    description: Capture interactions between users and AI
  - name: Business Events
    description: Capture business events
  - name: Analytics
    description: Understand chat and agentic interactions analyses
  - name: Inbox
    description: Review flagged conversations
  - name: Segments
    description: Manage user segments
  - name: Prompts
    description: Manage prompts
  - name: Chat
    description: Stream chat and agentic conversations
  - name: Models
    description: Manage AI models
  - name: Products
    description: Manage products
  - name: Users
    description: Manage users
  - name: Organizations
    description: Manage organizations
paths:
  /prompts/{id}:
    put:
      tags:
        - Prompts
      summary: Update Prompt
      description: >-
        Update a prompt with new content or properties. Your production prompt
        stays safe—updates create new versions without affecting what's
        currently active.


        **How it Works:**

        - **Updating components:** Creates a new immutable version with
        fingerprinting. The new version is created but NOT activated, so you can
        test before going live.

        - **Updating only properties (name/description):** Updates the prompt
        in-place without creating a new version.


        **Version Safety:**

        Old versions always point to their original prompts, preserving your
        message history and allowing you to roll back if needed.
      parameters:
        - schema:
            type: string
            format: uuid
            description: The prompt ID to update
          required: true
          description: The prompt ID to update
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePromptRequest'
            example:
              name: Updated Customer Support Prompt
              description: Updated description
              components:
                - content: >-
                    You are a helpful assistant for {{productName}}. Always be
                    polite to {{userName}}.
                  type: system
                  source: customer
                  name: Base Instructions V2
      responses:
        '200':
          description: Prompt updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdatePromptResponse'
              example:
                promptId: 123e4567-e89b-12d3-a456-426614174004
                versionId: 123e4567-e89b-12d3-a456-426614174005
        '404':
          description: Prompt not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for UpdatePrompt operations.
              example:
                success: false
                error: Prompt not found
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Whether the API call was successful (false for errors).
                  error:
                    type: string
                    description: Error message describing what went wrong.
                description: Error response for UpdatePrompt operations.
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Greenflash from 'greenflash';


            const client = new Greenflash({
              apiKey: process.env['GREENFLASH_API_KEY'], // This is the default and can be omitted
            });


            const updatePromptResponse = await
            client.prompts.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
              components: [
                {
                  content: 'You are a helpful assistant for {{productName}}. Always be polite to {{userName}}.',
                  type: 'system',
                  source: 'customer',
                  name: 'Base Instructions V2',
                },
              ],
              description: 'Updated description',
              name: 'Updated Customer Support Prompt',
            });


            console.log(updatePromptResponse.promptId);
        - lang: Python
          source: |-
            import os
            from greenflash import Greenflash

            client = Greenflash(
                api_key=os.environ.get("GREENFLASH_API_KEY"),  # This is the default and can be omitted
            )
            update_prompt_response = client.prompts.update(
                id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                components=[{
                    "content": "You are a helpful assistant for {{productName}}. Always be polite to {{userName}}.",
                    "type": "system",
                    "source": "customer",
                    "name": "Base Instructions V2",
                }],
                description="Updated description",
                name="Updated Customer Support Prompt",
            )
            print(update_prompt_response.prompt_id)
components:
  schemas:
    UpdatePromptRequest:
      type: object
      properties:
        name:
          type: string
          description: Updated prompt name.
        description:
          type: string
          description: Updated prompt description.
        role:
          type: string
          description: Role key in the product mapping.
        source:
          type: string
          enum:
            - customer
            - participant
            - greenflash
            - agent
          default: customer
          description: Prompt source.
        components:
          type: array
          items:
            $ref: '#/components/schemas/ComponentUpdate'
          description: >-
            Updated components (if provided, creates new immutable prompt and
            version).
    UpdatePromptResponse:
      type: object
      properties:
        externalPromptId:
          type: string
          description: The external prompt ID.
        promptId:
          type: string
          format: uuid
          description: The updated prompt ID.
        versionId:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            The version ID. Version is created/updated but not activated
            (activation happens via UI). Null if only prompt metadata was
            updated without components.
      required:
        - promptId
        - versionId
    ComponentUpdate:
      type: object
      properties:
        content:
          type: string
          minLength: 1
          description: Updated component content.
        componentId:
          type: string
          format: uuid
          description: The Greenflash component ID.
        externalComponentId:
          type: string
          description: External component identifier.
        type:
          type: string
          enum:
            - system
            - user
            - tool
            - guardrail
            - rag
            - agent
            - other
          default: system
          description: >-
            Component type: system, user, tool, guardrail, rag, agent, or a
            custom type (other).
        source:
          type: string
          enum:
            - customer
            - participant
            - greenflash
            - agent
          default: customer
          description: Component source.
        name:
          type: string
          description: Component name.
        isDynamic:
          type: boolean
          description: Dynamic flag.
      required:
        - content
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````