# AddTestcasesToTestsuite

## Parameters

The following URL, Headers and Parameters are required for requests to this API endpoint. Where a parameter is optional, it will be indicated. Otherwise treat all parameters as *mandatory*.

### Headers

```
POST /api/ss/testsuite/:id/testcases HTTP/1.1
Host: localhost:3000
X-SSAPI-KEY: APIKey
Content-Type: application/json
Connection: close
```

### Query

**id (*****string*****)**

Id of the testsuite.

Example:

```
POST /api/ss/testsuite/5eac95f1e594ea09107e9bb5/testcases HTTP/1.1
```

### **Body**

**testcases (array of objects)**

A list of all test cases to add to the test suite.

Example:

```
"testcases": [
    {   
        "testcase": "..."
    }
]
```

**testcase (*****string*****)**

Details for the test case.

Example:

```
"testcases": [
    {   
        "testcase": "..."
    }
]
```

**details (*****string*****)**

Details for the test case. Supports rich-text.

Example:

```
{   
    "details": "<p>...</p>"
}
```

**code (*****string*****) (*****optional*****)**

Code for the test case.

Example:

```
"testcases": [
    {   
        "code": "..."
    }
]
```

**sort\_order (*****number*****) (*****optional*****)**

Sort Order to apply to the test case.

Example:

<pre><code>"testcases": [
<strong>    {   
</strong>        "sort_order": 1
    }
]
</code></pre>

**tags (*****array of strings*****) (optional)**

Tags for the test case.

Example:

```
"testcases": [
    {   
        "tags": ["..."]
    }
]
```

**execution\_flow (*****array of objects*****) (*****optional*****)**

Execution flows for the test case.

Example:

```
"testcases": [
    {   
        "execution_flow": [
            {
                "title": "...",
                "details": "...",
                "details_type": "PLAINTEXT/RICHTEXT"
            }
        ]
    }
]
```

**custom\_fields (*****array of objects*****) (*****optional*****)**

Custom fields. Must include a key and value. Key must be unique and letters, number and underscores only.

For more information visit <https://support.attackforge.com/attackforge-enterprise/getting-started/custom-fields-and-forms#using-custom-fields-with-apis>

Example:

```
"testcases": [
    {   
        "custom_fields": [{"key": "...", "value": "..."}]
    }
]
```

## Example

The following example is a cURL request to add a test case on a testsuite.

### Request

Include API Token instead of stars in 'X-SSAPI-KEY: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' parameter.

```
curl -X POST 'https://localhost:3000/api/ss/testsuite/5eac95f1e594ea09107e9bb5/testcases' -H 'Host: localhost:3000' -H 'X-SSAPI-KEY: ***************************************' -H 'Content-Type: application/json' -H 'Connection: close' -d '{
  "testcases": [
    {
      "testcase": "Verify X, Y and Z",
      "code": "WEBAPP-001",
      "sort_order": 1,
      "tags": ["01", "Web App"]
    }
  ]
}'
```

### Response

Response contains a status.

```
{
  "status": "Added Testcases to Testsuite",
  "testcases": [
    {
      "id": "...",
      "created": "...",
      "testcase": "...",
      "details": "...",
      "code": "...",
      "sort_order": 1,
      "tags": [
        "..."
      ],
      "execution_flow": [
        {
          "title": "...",
          "details": "..."
        }
      ],
      "custom_fields": [
        {
          "key": "...",
          "value": "...",
          "type": "Field"
        }
      ]
    }
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.attackforge.com/attackforge-enterprise/modules/self-service-restful-api/addtestcasestotestsuite.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
