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

# Create Prompt Folder

> Create a new prompt folder in your workspace

Creates a prompt folder in your workspace. The API key creator becomes the folder owner and can manage it in the Prompt Library.

## Base URL

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

<Warning>
  **Dedicated deployments**

  Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.
</Warning>

## Required Scopes

This endpoint requires the `PROMPT_API` scope.

<Info>
  Sharing the folder with the workspace requires workspace editor access or the `sharePrompts` permission. Sharing with a group requires group editor or admin membership, or workspace admin access.
</Info>

## Parameters

| Parameter             | Type    | Required | Description                                                                            |
| --------------------- | ------- | -------- | -------------------------------------------------------------------------------------- |
| `name`                | string  | Yes      | Folder name. Minimum: 2 characters. Maximum: 50 characters.                            |
| `sharedWithWorkspace` | boolean | No       | Share the folder with the workspace. Cannot be `true` when `sharedWithGroupId` is set. |
| `sharedWithGroupId`   | string  | No       | UUID of the group to share with. Cannot be set when `sharedWithWorkspace` is `true`.   |

## Example

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

async function createPromptFolder() {
  const response = await axios.post(
    "https://api.langdock.com/prompts/v1/folders",
    {
      name: "Support templates",
      sharedWithWorkspace: true
    },
    {
      headers: {
        Authorization: "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
      }
    }
  );

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

createPromptFolder();
```

## Response Format

### Success Response (201 Created)

```typescript theme={null}
{
  folder: {
    id: string;
    name: string;
    createdBy: string;
    sharedWithWorkspace: boolean;
    sharedWithGroupId: string | null;
    createdAt: string;
    updatedAt: string;
  };
}
```

## Error Handling

| Status Code | Description                                                            |
| ----------- | ---------------------------------------------------------------------- |
| 400         | Invalid request body, or workspace sharing combined with group sharing |
| 401         | Invalid or missing API key                                             |
| 403         | Missing `PROMPT_API` scope or share permission                         |
| 404         | Group not found                                                        |
| 429         | Rate limit exceeded                                                    |
| 500         | Internal server error                                                  |

<Info>
  Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on [API Key Best Practices](/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


## OpenAPI

````yaml POST /prompts/v1/folders
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/folders:
    post:
      tags:
        - Prompts
      summary: Create a prompt folder
      description: Creates a prompt folder in your workspace.
      operationId: createPromptFolder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePromptFolderRequest'
      responses:
        '201':
          description: Prompt folder created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromptFolderResponse'
        '400':
          description: Invalid request body
        '401':
          description: Invalid or missing API key
        '403':
          description: Missing required scope or share permission
        '404':
          description: Group not found
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
components:
  schemas:
    CreatePromptFolderRequest:
      type: object
      required:
        - name
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 2
          maxLength: 50
          description: Folder name.
        sharedWithWorkspace:
          type: boolean
          description: >-
            Share the folder with the workspace. Cannot be true when
            sharedWithGroupId is set.
        sharedWithGroupId:
          type: string
          format: uuid
          description: >-
            Group UUID to share with. Cannot be set when sharedWithWorkspace is
            true.
    PromptFolderResponse:
      type: object
      required:
        - folder
      properties:
        folder:
          $ref: '#/components/schemas/PromptFolder'
    PromptFolder:
      type: object
      required:
        - id
        - name
        - createdBy
        - sharedWithWorkspace
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the prompt folder.
        name:
          type: string
          minLength: 2
          maxLength: 50
          description: Folder name.
        createdBy:
          type: string
          format: uuid
          description: User ID of the folder creator.
        sharedWithWorkspace:
          type: boolean
          description: Whether the folder is shared with the workspace.
        sharedWithGroupId:
          type: string
          format: uuid
          nullable: true
          description: Group ID the folder is shared with.
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp for folder creation.
        updatedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp for the latest folder update.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````