# Delete template by ID

**Endpoint**

`DELETE/v2/messages/templates/{id}`

**Link**

{% embed url="<https://stagep.tst-apidmndelss.com/openapi/v2.html#/operations/Messages_DeleteTemplate>" %}

### **Request**

#### **Path Parameters**

| Parameter | Type     | Description                | Required | Example       |
| --------- | -------- | -------------------------- | -------- | ------------- |
| **`id`**  | `string` | **Template ID** to delete. | Yes      | `"tpl_12345"` |

#### **Headers**

| Key             | Value              | Required |
| --------------- | ------------------ | -------- |
| `Authorization` | `Bearer <JWT>`     | Yes      |
| `Accept`        | `application/json` | Yes      |

***

### **Response (200 OK)**

Returns a success status indicating whether the template was deleted.

#### **Response Fields**

| Field         | Type      | Description                                        | Example |
| ------------- | --------- | -------------------------------------------------- | ------- |
| **`success`** | `boolean` | `true` if deleted successfully, `false` otherwise. | `true`  |

**Example Response:**

json

```
{
  "success": true
}
```

***

### **Examples**

#### **Request**

bash

```
curl -X DELETE 'https://stagep.tst-apidmndelss.com/v2/messages/templates/tpl_12345' \
  -H 'Authorization: Bearer eyJhbGci...wNLGA' \
  -H 'Accept: application/json'
```

#### **Error Response**

If the template doesn't exist or is already deleted:

json

```
{
  "success": false,
  "error": "Template not found"
}
```

***

### **Error Responses**

1. **Template Not Found**:

   json

   ```
   { "error": "Template not found: tpl_99999" }
   ```
2. **Unauthorized**:

   json

   ```
   { "error": "Unauthorized" }
   ```
3. **Template in Use**:

   json

   ```
   { "error": "Template is currently active and cannot be deleted" }
   ```

***

### **Notes**

* **Irreversible Action**: Deleted templates cannot be recovered.
* **Dependencies**: Ensure the template is not actively being used before deletion.
* **Soft Delete**: Some systems may implement soft deletion (marking as deleted but retaining data).
* **Response Codes**:
  * `200`: Success (even if `success=false` for soft failures)
  * `404`: Template not found
  * `403`: Authorization failure

**Recommended Workflow**:

1. First retrieve the template to confirm it's the correct one
2. Deactivate the template if active (`isActive: false`)
3. Then proceed with deletion

Real request:

```postman_json
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE2NCwiZXhwIjoxNzYxNTcxMjkyLCJrZXkiOiI1Y2ZiOGZjN2RmYjk4ZjVkYmIyZTgwNTVkZWFhN2U2Zjk4MzEyYmE3Iiwib3RwX3ZlcmlmaWVkIjpmYWxzZX0.Zu6m0G61S-1fLp32JUyJp-btyvxAi1NTLo7CrmuYwus
id*: io75SdrpdBSW
```

Real response:

```postman_json
{
"success": true
}

```

<br>


---

# 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://docs.delos.financial/messages/delete-template-by-id.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.
