Skip to main content
Create a test case from an existing task. This allows you to use the input and output of a completed task as a test case for validating prompt performance.

Create Test Case from Task

const API_KEY = process.env.TELA_API_KEY;
const taskId = 'task_uuid';

const testCaseData = {
  title: "Test Case from Task",
  description: "Test case generated from a completed document analysis task",
  feedback: "The output correctly identified all key points"
};

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

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

Parameters

NameTypeRequiredDescription
idstringYesThe UUID of the task to create a test case from

Request Body

FieldTypeRequiredDescription
titlestringYesTitle for the test case
descriptionstringNoDescription of the test case
feedbackstringNoFeedback or notes about the test case

Response

The response will contain the created test case with all fields including the task’s input and output data.

Example Response

{
  "id": "550e8400-e29b-41d4-a716-446655440010",
  "title": "Test Case from Task",
  "description": "Test case generated from a completed document analysis task",
  "promptId": "550e8400-e29b-41d4-a716-446655440001",
  "messages": [],
  "variables": {
    "document": "Sample document content"
  },
  "expectedOutput": "This is a summary of the document.",
  "metadata": {
    "source": "task",
    "taskId": "550e8400-e29b-41d4-a716-446655440000",
    "feedback": "The output correctly identified all key points"
  },
  "createdAt": "2023-01-02T00:00:00.000Z",
  "updatedAt": "2023-01-02T00:00:00.000Z"
}