Skip to main content

Populator - Template Remove

Endpoint

/i/populator/templates/remove

Overview

Deletes a populator template and performs cascade cleanup for environments and generated environment users tied to that template.

Authentication

Countly API supports three authentication methods:

  1. API key query parameter: api_key=YOUR_API_KEY
  2. Auth token query parameter: auth_token=YOUR_AUTH_TOKEN
  3. Auth token header: countly-token: YOUR_AUTH_TOKEN

Permissions

Requires Delete permission for the Populator feature.

Request Parameters

ParameterTypeRequiredDescription
app_idStringYesApp context used for environment-user cleanup pattern.
api_keyStringConditionalRequired when auth_token is not provided.
auth_tokenStringConditionalRequired when api_key is not provided.
template_idStringYesTemplate ID to delete.

Response

Success Response

{
"result": "Success"
}

Response Fields

FieldTypeDescription
resultStringSuccess when template and cascade cleanup complete.

Error Responses

400 Bad Request

{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}

401 Unauthorized

{
"result": "No app_id provided"
}

500 Internal Server Error

{
"result": "Invalid template id."
}

500 Internal Server Error

{
"result": "Database error: operation failed"
}

Behavior/Processing

Behavior Modes

ModeTriggerProcessing PathResponse Shape
Cascade deleteValid template_id and permissionsDeletes template, then deletes environment users and environments linked to template.Wrapped object: { "result": "Success" }
Invalid IDtemplate_id cannot be parsedStops before delete execution.Wrapped object: { "result": "Invalid template id." }

Impact on Other Data

  • Deletes one template document from countly.populator_templates.
  • Deletes matching generated users from countly.populator_environment_users.
  • Deletes matching environment metadata from countly.populator_environments.

Audit & System Logs

ActionTriggerPayload
populator_template_removedTemplate delete succeeds{ templateId }
populator_environment_removed_through_templateEnvironment cascade cleanup succeeds{ templateId, appId }

Database Collections

CollectionUsed forData touched by this endpoint
countly.populator_templatesTemplate storageDeletes the target template document by _id.
countly.populator_environment_usersGenerated environment usersDeletes records whose _id starts with app_id + '_' + template_id.
countly.populator_environmentsEnvironment metadataDeletes documents where templateId equals removed template ID.
countly.membersAuthentication and authorizationReads member context for permission checks.
countly.appsApp rights validationReads app access context from app_id.

Examples

Remove a deprecated template and its generated environments

https://your-server.com/i/populator/templates/remove?
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY&
template_id=65f0cbf8bca6b8e8fbf7f901

Operational Considerations

  • Cleanup cost increases with the number of generated users tied to the template.
  • Deletes are sequential and not transactional; partial cleanup is possible if an intermediate delete fails.

Limitations

  • Success response does not include counts of deleted users/environments.
  • Cleanup of environment users depends on the _id prefix pattern built from app_id and template_id.

Last Updated

2026-02-17