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

# Update Test Case

> Update an existing test case

Update an existing test case by its unique identifier.

## Update a Test Case

<CodeGroup>
  ```typescript theme={null}
  const API_KEY = process.env.TELA_API_KEY;
  const testCaseId = 'test_case_uuid';

  const updateData = {
    title: "Updated Customer Support Query Test",
    expectedOutput: "I'll help you track down your order right away, John. Let me check the status of order ORD-12345.",
    messages: [
      {
        role: "system",
        content: "You are a helpful and efficient customer support assistant."
      },
      {
        role: "user",
        content: "My order hasn't arrived yet."
      }
    ]
  };

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

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

  ```python theme={null}
  import requests

  API_KEY = os.getenv('TELA_API_KEY')
  test_case_id = 'test_case_uuid'

  update_data = {
    "title": "Updated Customer Support Query Test",
    "expectedOutput": "I'll help you track down your order right away, John. Let me check the status of order ORD-12345.",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful and efficient customer support assistant."
      },
      {
        "role": "user",
        "content": "My order hasn't arrived yet."
      }
    ]
  }

  response = requests.patch(
      f'https://api.tela.ai/test-case/{test_case_id}',
      headers={
          'Authorization': f'Bearer {API_KEY}',
          'Content-Type': 'application/json'
      },
      json=update_data
  )

  print(response.json())
  ```

  ```javascript theme={null}
  const API_KEY = process.env.TELA_API_KEY;
  const testCaseId = 'test_case_uuid';

  const updateData = {
    title: "Updated Customer Support Query Test",
    expectedOutput: "I'll help you track down your order right away, John. Let me check the status of order ORD-12345.",
    messages: [
      {
        role: "system",
        content: "You are a helpful and efficient customer support assistant."
      },
      {
        role: "user",
        content: "My order hasn't arrived yet."
      }
    ]
  };

  fetch(`https://api.tela.ai/test-case/${testCaseId}`, {
    method: 'PATCH',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(updateData)
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
  ```
</CodeGroup>

### Parameters

| Name | Type   | Required | Description                         |
| ---- | ------ | -------- | ----------------------------------- |
| `id` | string | Yes      | The UUID of the test case to update |

### Request Body

The request body can include any of the following fields to update. Only include the fields you want to modify.

| Field                  | Type   | Description                                        |
| ---------------------- | ------ | -------------------------------------------------- |
| `title`                | string | Title of the test case                             |
| `messages`             | array  | Array of message objects with role and content     |
| `variables`            | object | Key-value pairs of variables used in the test case |
| `variablesRichContent` | object | Key-value pairs of rich content variables          |
| `files`                | array  | Array of file objects to attach to the test case   |
| `promptId`             | string | UUID of the prompt this test case belongs to       |
| `expectedOutput`       | string | Expected output for evaluation purposes            |
| `answers`              | object | Evaluation answers with good/bad results and evals |
| `promptApplicationId`  | string | UUID of the prompt application if applicable       |
| `metadata`             | object | Metadata about the test case including source      |

### Response

The response will contain the updated test case with all fields reflecting the changes.


## OpenAPI

````yaml PATCH /test-case/{id}
openapi: 3.0.1
info:
  title: Tela API
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tela.com
security: []
paths:
  /test-case/{id}:
    patch:
      description: Update an existing test case
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TestCaseUpdateRequest'
      responses:
        '200':
          description: Test case updated successfully
components:
  schemas:
    TestCaseUpdateRequest:
      type: object
      properties:
        title:
          type: string
          description: Title of the test case
        variablesRichContent:
          type: object
          description: Key-value pairs of rich content variables
          additionalProperties:
            type: string
        promptId:
          type: string
          format: uuid
          description: UUID of the prompt this test case belongs to
        expectedOutput:
          type: string
          nullable: true
          description: Expected output for evaluation purposes
        promptApplicationId:
          type: string
          format: uuid
          nullable: true
          description: UUID of the prompt application if applicable
        messages:
          type: array
          description: Array of message objects with role and content
          items:
            type: object
            properties:
              role:
                type: string
                enum:
                  - user
                  - system
                  - assistant
                  - function
                  - developer
              content:
                oneOf:
                  - type: string
                  - type: object
                    additionalProperties: true
            required:
              - role
              - content
        variables:
          type: object
          nullable: true
          description: Key-value pairs of variables used in the test case
          additionalProperties:
            type: string
        files:
          type: array
          nullable: true
          description: Array of file objects to attach to the test case
          items:
            type: object
            properties:
              index:
                type: number
              name:
                type: string
              mimeType:
                type: string
              vaultUrl:
                type: string
              variableName:
                type: string
              url:
                type: string
            required:
              - index
              - name
              - mimeType
              - vaultUrl
              - variableName
              - url
        metadata:
          type: object
          description: Metadata about the test case
          properties:
            source:
              type: string
              enum:
                - workstation
                - craft
                - test-case

````