Create Prompt
Create a new prompt in your workspace
Creates a prompt in your workspace. The API key creator becomes the prompt owner and can manage it in the Prompt Library.
Base URL
https://api.ajan.io/prompts/v1Required Scopes
This endpoint requires the PROMPT_API scope.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Prompt title. Minimum: 2 characters. Maximum: 100 characters. |
prompt | string | Yes | Prompt content. Minimum: 2 characters. Maximum: 120000 characters. |
promptFolderId | string | No | UUID of the folder to assign. Cannot be set when sharedWithWorkspace is true. |
sharedWithWorkspace | boolean | No | Share the prompt with the workspace. Cannot be true when promptFolderId is set. |
Example
javascript
const axios = require("axios");
async function createPrompt() {
const response = await axios.post(
"https://api.ajan.io/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();Response Format
Success Response (201 Created)
typescript
{
prompt: {
id: string;
title: string;
prompt: string;
createdBy: string | null;
promptFolderId: string | null;
sharedWithWorkspace: boolean;
createdAt: string | null;
updatedAt: string | null;
};
}Error Handling
| Status Code | Description |
|---|---|
| 400 | Invalid request body, or workspace sharing combined with a folder assignment |
| 401 | Invalid or missing API key |
| 403 | Missing PROMPT_API scope, share permission, or folder write access |
| 404 | Prompt folder not found |
| 429 | Rate limit exceeded |
| 500 | Internal server error |
OpenAPI
openapi: 3.0.0
info:
title: ajan API
version: 3.0.0
servers:
- url: https://api.ajan.io
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"