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

# Prompt erstellen

> Erstelle einen neuen Prompt in deinem Workspace

Erstellt einen Prompt in deinem Workspace. Der User, der den API Key erstellt hat, wird Besitzer des Prompts und kann ihn in der Prompt Library verwalten.

## Basis-URL

```
https://api.langdock.com/prompts/v1
```

<Warning>
  **Dedicated Deployments**

  Ersetze `api.langdock.com` durch `<your-deployment-url>/api/public` in allen Anfragen.
</Warning>

## Erforderliche Scopes

Dieser Endpoint erfordert den `PROMPT_API` Scope.

<Info>
  Das Teilen des Prompts mit dem Workspace erfordert die `sharePrompts` Berechtigung. Eine Ordnerzuweisung erfordert Schreibzugriff auf diesen Ordner.
</Info>

## Parameter

| Parameter             | Typ     | Erforderlich | Beschreibung                                                                                    |
| --------------------- | ------- | ------------ | ----------------------------------------------------------------------------------------------- |
| `title`               | string  | Ja           | Prompt-Titel. Minimum: 2 Zeichen. Maximum: 100 Zeichen.                                         |
| `prompt`              | string  | Ja           | Prompt-Inhalt. Minimum: 2 Zeichen. Maximum: 120000 Zeichen.                                     |
| `promptFolderId`      | string  | Nein         | UUID des zuzuweisenden Ordners. Darf nicht gesetzt sein, wenn `sharedWithWorkspace` `true` ist. |
| `sharedWithWorkspace` | boolean | Nein         | Teilt den Prompt mit dem Workspace. Darf nicht `true` sein, wenn `promptFolderId` gesetzt ist.  |

## Beispiel

```javascript theme={null}
const axios = require("axios");

async function createPrompt() {
  const response = await axios.post(
    "https://api.langdock.com/prompts/v1",
    {
      title: "Support Reply",
      prompt: "Write a concise customer reply. Include the next best action.",
      sharedWithWorkspace: true
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

  console.log("Created prompt:", response.data.prompt.id);
}

createPrompt();
```

## Antwortformat

### Erfolgsantwort (201 Created)

```typescript theme={null}
{
  prompt: {
    id: string;
    title: string;
    prompt: string;
    createdBy: string | null;
    promptFolderId: string | null;
    sharedWithWorkspace: boolean;
    createdAt: string | null;
    updatedAt: string | null;
  };
}
```

## Fehlerbehandlung

| Statuscode | Beschreibung                                                                              |
| ---------- | ----------------------------------------------------------------------------------------- |
| 400        | Ungültiger Request Body oder Workspace-Freigabe kombiniert mit einer Ordnerzuweisung      |
| 401        | Ungültiger oder fehlender API Key                                                         |
| 403        | Fehlender `PROMPT_API` Scope, keine Freigabe-Berechtigung oder kein Ordner-Schreibzugriff |
| 404        | Prompt-Ordner nicht gefunden                                                              |
| 429        | Rate Limit überschritten                                                                  |
| 500        | Interner Serverfehler                                                                     |

<Info>
  Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen und die Sicherheit deiner Anwendungen zu gewährleisten. Weitere Informationen findest du in unserem Guide zu [Best Practices für API-Schlüssel](/de/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


## OpenAPI

````yaml POST /prompts/v1
openapi: 3.0.0
info:
  title: Langdock API
  version: 3.0.0
servers:
  - url: https://api.langdock.com
    description: Production
security:
  - bearerAuth: []
paths:
  /prompts/v1:
    post:
      tags:
        - Prompts
      summary: Create a prompt
      description: Creates a prompt in your workspace.
      operationId: createPrompt
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePromptRequest'
      responses:
        '201':
          description: Prompt created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromptResponse'
        '400':
          description: Invalid request body
        '401':
          description: Invalid or missing API key
        '403':
          description: Missing required scope, share permission, or folder write access
        '404':
          description: Prompt folder not found
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
components:
  schemas:
    CreatePromptRequest:
      type: object
      required:
        - title
        - prompt
      additionalProperties: false
      properties:
        title:
          type: string
          minLength: 2
          maxLength: 100
          description: Prompt title.
        prompt:
          type: string
          minLength: 2
          maxLength: 120000
          description: Prompt content.
        promptFolderId:
          type: string
          format: uuid
          description: >-
            Folder UUID to assign. Cannot be set when sharedWithWorkspace is
            true.
        sharedWithWorkspace:
          type: boolean
          description: >-
            Share the prompt with the workspace. Cannot be true when
            promptFolderId is set.
    PromptResponse:
      type: object
      required:
        - prompt
      properties:
        prompt:
          $ref: '#/components/schemas/Prompt'
    Prompt:
      type: object
      required:
        - id
        - title
        - prompt
        - sharedWithWorkspace
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the prompt.
        title:
          type: string
          minLength: 2
          maxLength: 100
          description: Prompt title.
        prompt:
          type: string
          minLength: 2
          maxLength: 120000
          description: Prompt content.
        createdBy:
          type: string
          format: uuid
          nullable: true
          description: User ID of the prompt creator.
        promptFolderId:
          type: string
          format: uuid
          nullable: true
          description: Folder ID the prompt is assigned to.
        sharedWithWorkspace:
          type: boolean
          description: Whether the prompt is shared with the workspace.
        createdAt:
          type: string
          format: date-time
          nullable: true
          description: ISO 8601 timestamp for prompt creation.
        updatedAt:
          type: string
          format: date-time
          nullable: true
          description: ISO 8601 timestamp for the latest prompt update.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````