Skip to content

Archive or delete template

There are two ways to remove a template via the API:

  1. Archive (Soft Delete): Hides the template from the library but retains its data. Processes already launched from it continue to run. Archived templates can be restored.
  2. Delete (Permanent): Permanently removes the template and its associated data. This action cannot be undone.

1. Archive Template

Endpoint

DELETE /organizations/{org_id}/checklists/{checklist_id}

This endpoint archives the specified template.

Request

Replace {org_id} with your Organization ID and {checklist_id} with the ID of the template to archive.

Headers

  • Authorization: Bearer {your_access_token}
  • Accept: application/json
  • X-Tallyfy-Client: APIClient

Body

No request body is needed for this DELETE request.

Code Samples (Archiving)

const accessToken = 'YOUR_PERSONAL_ACCESS_TOKEN';
const orgId = 'YOUR_ORGANIZATION_ID';
const checklistId = 'TEMPLATE_ID_TO_ARCHIVE';
const apiUrl = `https://go.tallyfy.com/api/organizations/${orgId}/checklists/${checklistId}`;
const headers = new Headers();
headers.append('Authorization', `Bearer ${accessToken}`);
headers.append('Accept', 'application/json');
headers.append('X-Tallyfy-Client', 'APIClient');
fetch(apiUrl, {
method: 'DELETE', // Use DELETE method
headers: headers
})
.then(response => {
if (!response.ok) { // Check for 200 OK
// Try to get error details
return response.json().then(errData => {
throw new Error(`HTTP error! status: ${response.status}, message: ${JSON.stringify(errData)}`);
}).catch(() => {
throw new Error(`HTTP error! status: ${response.status}`);
});
}
// For successful DELETE, often there's no JSON body, but check status
console.log(`Successfully archived template ${checklistId}. Status: ${response.status}`);
// Optionally return response.json() if the API sends back the archived object
return response.json();
})
.then(data => {
if (data) {
console.log('Archived template details:');
console.log(JSON.stringify(data, null, 2));
}
})
.catch(error => {
console.error('Error archiving template:', error);
});

Response (Archiving)

A successful archive request typically returns a 200 OK status code. The response body may contain the details of the archived template, now including an archived_at timestamp.

{
"data": {
"id": "TEMPLATE_ID_TO_ARCHIVE",
"title": "Template To Be Archived",
// ... other properties ...
"archived_at": "2024-05-20T13:00:00.000Z" // Timestamp indicates archival
}
}

2. Permanently Delete Template

Endpoint

DELETE /organizations/{org_id}/checklists/{checklist_id}/delete

Note the extra /delete path segment compared to the archive endpoint.

Request

Replace {org_id} and {checklist_id} as appropriate.

Headers

  • Authorization: Bearer {your_access_token}
  • Accept: application/json
  • X-Tallyfy-Client: APIClient

Body

No request body is needed.

Code Samples (Permanent Deletion)

The code samples are very similar to archiving, just change the apiUrl to include the /delete suffix.

// ... (setup accessToken, orgId, checklistId as before) ...
const apiUrl = `https://go.tallyfy.com/api/organizations/${orgId}/checklists/${checklistId}/delete`; // <-- Added /delete
// ... (fetch call using DELETE method as in archive example) ...
// Check for 200 OK or 204 No Content for successful deletion
fetch(apiUrl, { /* ... */ })
.then(response => {
if (response.status === 200 || response.status === 204) {
console.log(`Successfully deleted template ${checklistId}. Status: ${response.status}`);
} else {
// Error handling
return response.json().then(errData => { throw new Error(/*...*/); }).catch(() => { throw new Error(/*...*/); });
}
})
.catch(error => {
console.error('Error deleting template:', error);
});

Response (Permanent Deletion)

A successful permanent deletion typically returns a 200 OK or 204 No Content status code. The response body, if present for a 200 OK, might contain a success message.

// Example response for 200 OK
{
"data": {
"message": "Template deleted successfully"
}
}
// Or just a 204 No Content status with no body.