Skip to main content

User Deleted

This event is triggered when creator deletes one or more users from the customers page, by using the Delete Customers (for bulk deleting subscribers) or by using the action item for specific user from the customers table.

Event Type

user.deleted

Setting Up the Webhook

To subscribe to user deletion events, configure your webhook endpoint with the following:

curl -X 'POST' \
'https://api-prod-new.tagmango.com/api/v1/integration/webhook/webhook' \
-H 'accept: application/json' \
-H 'x-api-key: <Your API Key>' \
-H 'Content-Type: application/json' \
-d '{
"hookUrl": "<your webhook url>",
"event": "user.deleted"
}'

Parameters

ParameterTypeRequiredDescription
hookUrlstringYesYour webhook endpoint URL
eventstringYesMust be `user.deleted`

Webhook Payload

When a user is deleted, TagMango will send a POST request to your webhook URL with the following payload:

Example

{
"_id": "66b810000000000000000000",
"name": "John Doe",
"email": "someone@example.com",
"phone": 9999999999,
"country": "IN",
"host": "example.tagmango.com",
"profilePicUrl": "https://example.com/profile.jpg"
}

Schema

_id
string
Unique identifier of the deleted user
name
string
Full name of the deleted user
email
string
Email address of the deleted user
phone
number
Phone number of the deleted user
country
string
Country code of the deleted user (ISO 3166-1 alpha-2)
host
string
Host of the deleted user
profilePicUrl
string
URL to the deleted user's profile picture

Handling the Webhook

Your webhook endpoint should:

  1. Respond with 200 status - Return a 200 HTTP status code to acknowledge receipt
  2. Process quickly - Respond within 30 seconds to avoid timeouts
  3. Implement idempotency - Handle duplicate events gracefully
  4. Verify authenticity - Validate the request using the provided authentication headers

Example Implementation

// Node.js Express example
app.post("/webhook", (req, res) => {
const payload = req.body;

// Verify the webhook authenticity (implement based on your security setup)
if (!verifyWebhook(req)) {
return res.status(401).send("Unauthorized");
}

// Process the webhook event
try {
console.log("Event data:", JSON.stringify(payload, null, 2));

// Your business logic here
// Process the event data according to your application needs
processWebhookEvent(eventType, payload);
} catch (error) {
console.error("Error processing webhook:", error);
// You might want to return 500 here depending on your retry policy
}

// Acknowledge receipt
res.status(200).send("OK");
});

function processWebhookEvent(eventType, payload) {
// Implement your custom logic based on the event type and payload
// This is where you'll handle the webhook data according to your business requirements

// Examples of what you might do:
// - Store event data in your database
// - Send notifications to users
// - Update user records
// - Trigger automated workflows
// - Sync data with external systems

console.log(`Processing ${eventType} event for your application`);
}