> ## 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.

# Create Prompt

> Create a new prompt that you can use across your AI applications. Build prompts from one or more components, and use handlebars-style variables like `{{userName}}` for personalization.

**Safe by Default:**
Creating a prompt creates a new version but doesn't activate it. Your production prompts stay unchanged until you explicitly activate the new version (via the UI or when you reference it in the Messages API). This lets you test and prepare new prompts without risk.

**Versioning:**
Every prompt is immutable and versioned with fingerprinting, so you can safely iterate and track changes over time.



## OpenAPI

````yaml https://www.greenflash.ai/api/openapi post /prompts
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:
    post:
      tags:
        - Prompts
      summary: Create Prompt
      description: >-
        Create a new prompt that you can use across your AI applications. Build
        prompts from one or more components, and use handlebars-style variables
        like `{{userName}}` for personalization.


        **Safe by Default:**

        Creating a prompt creates a new version but doesn't activate it. Your
        production prompts stay unchanged until you explicitly activate the new
        version (via the UI or when you reference it in the Messages API). This
        lets you test and prepare new prompts without risk.


        **Versioning:**

        Every prompt is immutable and versioned with fingerprinting, so you can
        safely iterate and track changes over time.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePromptRequest'
            example:
              name: Customer Support Prompt
              description: Standard customer support  prompt
              externalPromptId: support-v1
              components:
                - content: >-
                    You are a helpful assistant for {{productName}}. Greet
                    {{userName}} warmly.
                  type: system
                  source: customer
                  name: Base Instructions
                  isDynamic: false
              tags:
                - support
                - customer-facing
      responses:
        '201':
          description: Prompt created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePromptResponse'
              example:
                promptId: 123e4567-e89b-12d3-a456-426614174000
                versionId: 123e4567-e89b-12d3-a456-426614174001
                componentIds:
                  - 123e4567-e89b-12d3-a456-426614174002
        '400':
          description: Invalid request body
          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 CreatePrompt operations.
        '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 CreatePrompt 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 createPromptResponse = await client.prompts.create({
              components: [
                {
                  content: 'You are a helpful assistant for {{productName}}. Greet {{userName}} warmly.',
                  type: 'system',
                  source: 'customer',
                  name: 'Base Instructions',
                  isDynamic: false,
                },
              ],
              name: 'Customer Support Prompt',
              productId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
              role: 'x',
              description: 'Standard customer support  prompt',
              externalPromptId: 'support-v1',
            });

            console.log(createPromptResponse.componentIds);
        - 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
            )
            create_prompt_response = client.prompts.create(
                components=[{
                    "content": "You are a helpful assistant for {{productName}}. Greet {{userName}} warmly.",
                    "type": "system",
                    "source": "customer",
                    "name": "Base Instructions",
                    "is_dynamic": False,
                }],
                name="Customer Support Prompt",
                product_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                role="x",
                description="Standard customer support  prompt",
                external_prompt_id="support-v1",
            )
            print(create_prompt_response.component_ids)
components:
  schemas:
    CreatePromptRequest:
      type: object
      properties:
        externalPromptId:
          type: string
          description: Your external identifier for the prompt.
        name:
          type: string
          description: Prompt name.
        description:
          type: string
          description: Prompt description.
        productId:
          type: string
          format: uuid
          description: Product this prompt will map to.
        role:
          type: string
          minLength: 1
          description: Role key in the product mapping (e.g. "agent tool").
        source:
          type: string
          enum:
            - customer
            - participant
            - greenflash
            - agent
          default: customer
          description: Prompt source.
        components:
          type: array
          items:
            $ref: '#/components/schemas/ComponentInput'
          minItems: 1
          description: Array of component objects.
      required:
        - name
        - productId
        - role
        - components
    CreatePromptResponse:
      type: object
      properties:
        externalPromptId:
          type: string
          description: The external prompt ID.
        promptId:
          type: string
          format: uuid
          description: The created prompt ID.
        versionId:
          type: string
          format: uuid
          description: >-
            The created version ID. Version is created but not activated
            (activation happens via UI or Messages API).
        componentIds:
          type: array
          items:
            type: string
            format: uuid
          description: The IDs of the created prompt components.
      required:
        - promptId
        - versionId
        - componentIds
    ComponentInput:
      type: object
      properties:
        content:
          type: string
          minLength: 1
          description: The content of the component.
        componentId:
          type: string
          format: uuid
          description: The Greenflash component ID.
        externalComponentId:
          type: string
          description: Your external identifier for the component.
        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: customer, participant, greenflash, or agent.'
        name:
          type: string
          description: Component name.
        isDynamic:
          type: boolean
          description: Whether the component content changes dynamically.
      required:
        - content
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````