Skip to main content
Create one or more tasks for a prompt application. Tasks represent individual processing jobs that can be tracked and managed.

Create a Task

const API_KEY = process.env.TELA_API_KEY;

const task = {
  name: "Document Analysis Task",
  promptApplicationId: "prompt_application_uuid",
  inputContent: {
    variables: {
      document: "Content to analyze"
    }
  },
  tags: ["analysis", "documents"]
};

const response = await fetch('https://api.tela.ai/task', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(task)
});

const data = await response.json();
console.log(data);

Create Multiple Tasks

const API_KEY = process.env.TELA_API_KEY;

const tasks = [
  {
    name: "Document Analysis Task 1",
    promptApplicationId: "prompt_application_uuid",
    inputContent: {
      variables: {
        document: "First document content"
      }
    },
    tags: ["batch", "analysis"]
  },
  {
    name: "Document Analysis Task 2",
    promptApplicationId: "prompt_application_uuid",
    inputContent: {
      variables: {
        document: "Second document content"
      }
    },
    tags: ["batch", "analysis"]
  }
];

const response = await fetch('https://api.tela.ai/task', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(tasks)
});

const data = await response.json();
console.log(data);

Request Body

The request body can be either a single task object or an array of task objects.

Task Object

FieldTypeRequiredDescription
namestringYesName of the task
promptApplicationIdstring (UUID)YesUUID of the prompt application
approvedAtstring or nullNoApproval timestamp (ISO 8601)
completionRunIdstring (UUID) or nullNoUUID of the associated completion run
workflowRunIdstring (UUID) or nullNoUUID of the associated workflow run
rawInputobjectNoRaw input configuration
outputContentobject or nullNoOutput content for the task
inputContentobjectNoInput content for the task
metadataobjectNoTask metadata
tagsstring[]NoTags to associate with the task
useTempFunctionbooleanNoWhether to use temporary function

Input Content Object

FieldTypeDescription
variablesobjectKey-value pairs of variables
messagesarrayArray of message objects
filesarrayArray of file objects

Raw Input Object

FieldTypeDescription
version_idstring (UUID)Version ID to use
canvas_idstring (UUID)Canvas ID to use
application_idstring (UUID)Application ID
webhook_urlstringWebhook URL for notifications
variablesobjectVariables to pass
messagesarrayMessages to include
streambooleanWhether to stream the response
asyncbooleanWhether to run asynchronously
overrideobjectOverride settings

Response

The response will contain the created task(s) with all fields including the generated IDs and timestamps.

Example Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Document Analysis Task",
  "status": "created",
  "promptApplicationId": "550e8400-e29b-41d4-a716-446655440001",
  "inputContent": {
    "variables": {
      "document": "Content to analyze"
    }
  },
  "outputContent": null,
  "tags": ["analysis", "documents"],
  "createdAt": "2023-01-01T00:00:00.000Z",
  "updatedAt": "2023-01-01T00:00:00.000Z",
  "approvedAt": null
}