Delete Template
curl --request DELETE \
--url https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template} \
--header 'Authorization: Bearer <token>'import requests
url = "https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "Resource deleted successfully.",
"status": 200
}{
"message": "Unauthenticated."
}{
"message": "Resource not found.",
"status": 404
}Templates
Delete Template
Delete a template by ID in the specified workspace.
DELETE
/
workspaces
/
{workspace}
/
templates
/
{template}
Delete Template
curl --request DELETE \
--url https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template} \
--header 'Authorization: Bearer <token>'import requests
url = "https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "Resource deleted successfully.",
"status": 200
}{
"message": "Unauthenticated."
}{
"message": "Resource not found.",
"status": 404
}Overview
Delete a WhatsApp message template from both your workspace and Meta’s system.This action is irreversible. The template will be deleted from Meta and cannot be recovered.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspace | UUID | Yes | Workspace ID |
template | integer | Yes | Template ID to delete |
Response
Success (200 OK)
{
"success": true,
"message": "Template deleted successfully"
}
Not Found (404)
{
"success": false,
"message": "Template not found"
}
What Happens on Deletion?
1
Job Dispatched
A background job
DeleteTemplateInApiProvider is queued2
Meta Deletion
The template is deleted from Meta’s WhatsApp Business API
3
Local Deletion
The template is removed from your workspace database
Example Usage
cURL
curl -X DELETE \
https://lancepilot.com/api/v3/workspaces/{workspace}/templates/1234 \
-H 'Authorization: Bearer YOUR_API_TOKEN'
JavaScript
async function deleteTemplate(workspaceId, templateId) {
const response = await fetch(
`https://lancepilot.com/api/v3/workspaces/${workspaceId}/templates/${templateId}`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${YOUR_API_TOKEN}`
}
}
);
const data = await response.json();
if (data.success) {
console.log('Template deleted successfully');
} else {
console.error('Deletion failed:', data.message);
}
}
Python
import requests
def delete_template(workspace_id, template_id, api_token):
url = f"https://lancepilot.com/api/v3/workspaces/{workspace_id}/templates/{template_id}"
headers = {"Authorization": f"Bearer {api_token}"}
response = requests.delete(url, headers=headers)
return response.json()
# Usage
result = delete_template("workspace-uuid", 1234, "your_token")
print(result['message'])
Before Deleting
Check Usage
Verify if the template is currently being used in active campaigns
Backup Data
Save template configuration if you might need it later
Consider Alternatives
Could you update instead of delete? Use Update Template
Test First
Test deletion on non-production templates first
Important Notes
Async ProcessingDeletion from Meta happens in the background. The local database entry is removed immediately, but Meta deletion may take a few seconds.
Active CampaignsIf the template is used in active campaigns or automations, deleting it will cause those to fail. Check dependencies before deletion.
Soft Delete AlternativeConsider implementing a soft delete pattern where templates are marked as archived instead of permanently deleted.
Related Endpoints
- Get Template - View template details before deletion
- Get Templates - List all templates to find the one to delete
- Update Template - Alternative to deletion
Error Scenarios
| Error Code | Cause | Solution |
|---|---|---|
| 404 | Template not found | Verify template ID exists |
| 401 | Unauthorized | Check API token validity |
| 403 | Insufficient permissions | Verify workspace access rights |
| 500 | Server error | Contact support or retry later |
Bulk Deletion Example
async function bulkDeleteTemplates(workspaceId, templateIds) {
const results = [];
for (const templateId of templateIds) {
try {
const result = await deleteTemplate(workspaceId, templateId);
results.push({ templateId, success: true, ...result });
} catch (error) {
results.push({ templateId, success: false, error: error.message });
}
// Add delay to avoid rate limiting
await new Promise(resolve => setTimeout(resolve, 1000));
}
return results;
}
// Usage
const deletedTemplates = await bulkDeleteTemplates('workspace-uuid', [1, 2, 3, 4]);
console.log(`Deleted ${deletedTemplates.filter(r => r.success).length} templates`);
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.