{
"success": true,
"cleared": {
"sends": 150,
"clicks": 45,
"revenue": 32
}
}
{
"success": true,
"cleared": {
"sends": 150
}
}
{
"error": "confirm must be true",
"code": "confirm_required"
}
{
"error": "Invalid entities: orders. Valid: sends, clicks, revenue",
"code": "invalid_entities"
}
Data Import (v2)
Clear History
Clear imported historical data from your account.
DELETE
/
v2
/
history
/
clear
{
"success": true,
"cleared": {
"sends": 150,
"clicks": 45,
"revenue": 32
}
}
{
"success": true,
"cleared": {
"sends": 150
}
}
{
"error": "confirm must be true",
"code": "confirm_required"
}
{
"error": "Invalid entities: orders. Valid: sends, clicks, revenue",
"code": "invalid_entities"
}
Permanently delete imported historical data from your account. You can selectively clear sends, clicks, and/or revenue records.
Authenticated requests can also fail with
Important scoping differences:
- Sends: Only records where
imported=trueare cleared. Records from normal API sends or scheduled sends are never affected. - Clicks: Clicks are cleared based on the message IDs of imported send records. Only clicks associated with imported messages are removed.
- Revenue: All revenue records for the account are cleared, not just those from imported messages. This includes revenue from live sends.
This is a destructive operation that cannot be undone. Cleared data is permanently deleted and cannot be recovered. Always verify your selection and consider using the
before_date parameter to limit the scope of deletion.Authentication
string
required
Your Trackly SMS API key. Format:
trk_[32-char-alphanumeric].Body Parameters
array
required
An array of entity types to clear. Valid values:
sends, clicks, revenue. You may include one or more entity types.datetime
Only clear records with timestamps before this ISO 8601 datetime. If omitted, all matching records are cleared regardless of date.For
clicks, before_date is applied to the parent send’s timestamp, not the click’s own timestamp.boolean
required
Safety confirmation flag. Must be set to
true to proceed with deletion. Requests with confirm: false or a missing confirm field are rejected.Response Fields
boolean
Whether the clear operation completed successfully.
object
An object with counts of cleared records by entity type. Only includes entities that were requested.
sends(integer) — Number of send records cleared.clicks(integer) — Number of click records cleared.revenue(integer) — Number of revenue records cleared.
cURL
curl -X DELETE https://api.tracklysms.com/api/v2/history/clear \
-H "X-Api-Key: trk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"entities": ["sends", "clicks", "revenue"],
"before_date": "2025-12-01T00:00:00Z",
"confirm": true
}'
Python
import requests
response = requests.delete(
"https://api.tracklysms.com/api/v2/history/clear",
headers={
"X-Api-Key": "trk_your_api_key_here",
"Content-Type": "application/json",
},
json={
"entities": ["sends", "clicks", "revenue"],
"before_date": "2025-12-01T00:00:00Z",
"confirm": True,
},
)
print(response.json())
Node.js
const response = await fetch("https://api.tracklysms.com/api/v2/history/clear", {
method: "DELETE",
headers: {
"X-Api-Key": "trk_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
entities: ["sends", "clicks", "revenue"],
before_date: "2025-12-01T00:00:00Z",
confirm: true,
}),
});
const data = await response.json();
console.log(data);
{
"success": true,
"cleared": {
"sends": 150,
"clicks": 45,
"revenue": 32
}
}
{
"success": true,
"cleared": {
"sends": 150
}
}
{
"error": "confirm must be true",
"code": "confirm_required"
}
{
"error": "Invalid entities: orders. Valid: sends, clicks, revenue",
"code": "invalid_entities"
}
Error Codes
| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | missing_entities | The entities field is required and must be a non-empty array. |
| 400 | confirm_required | The confirm field must be set to true to proceed. |
| 400 | invalid_entities | One or more entity types are not valid. Must be sends, clicks, or revenue. |
401 invalid_credentials or 403 account_suspended — see Error Codes.
Next Steps
Reporting Overview
Understand your analytics
Bulk Create Contacts
Re-import after clearing