Skip to main content
DELETE
/
workspaces
/
{workspace}
/
templates
/
{template}
Delete Template
curl --request DELETE \
  --url https://lancepilot.com/api/v3/workspaces/{workspace}/templates/{template} \
  --header 'Authorization: Bearer <token>'
{
  "message": "Resource deleted successfully.",
  "status": 200
}

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

ParameterTypeRequiredDescription
workspaceUUIDYesWorkspace ID
templateintegerYesTemplate 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 queued
2

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.


Error Scenarios

Error CodeCauseSolution
404Template not foundVerify template ID exists
401UnauthorizedCheck API token validity
403Insufficient permissionsVerify workspace access rights
500Server errorContact 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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

workspace
string<uuid>
required

ID of the workspace.

template
integer
required

Response

message
string
required
Example:

"Resource deleted successfully."

status
integer
required
Example:

200