Skip to main content

Course Completion 100%

This event is triggered when a subscriber completes watching/consuming the entire course content.

Event Type

course.completed.100

Setting Up the Webhook

To subscribe to this webhook event, 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": "course.completed.100",
"course": "<course to be associated> (optional sends all course related events if not specified)"
}'

Parameters

ParameterTypeRequiredDescription
hookUrlstringYesYour webhook endpoint URL
eventstringYesMust be `course.completed.100`
coursestringNoSpecific course ID to monitor. If not specified, receives events for all courses

Webhook Payload

When a subscriber completes the entire course, TagMango will send a POST request to your webhook URL with the following payload:

Example

{
"name": "Student Name",
"email": "student@example.com",
"phone": 1234567890,
"course": "Example course",
"courseId": "634fc35ddaf58580e2418c40",
"lastProgressOn": "2023-11-20T18:30Z"
}

Schema

name
string
The student's full name
email
string
The student's email address
phone
number
The student's phone number
course
string
Name of the course completed by the student
courseId
string
Unique identifier for the course
lastProgressOn
string
Timestamp of when the student completed the course, in UTC

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`);
}