Subscription Sync
Keep subscription status synchronized between edrone and your e-commerce platform.
Two-way sync
- Platform → edrone: Send subscription changes to edrone
- edrone → Platform: Receive webhook when status changes in edrone
Send subscription to edrone
- cURL
- Python
- PHP
# Subscribe user
curl -X POST https://api.edrone.me/trace \
-d "app_id=YOUR_APP_ID" \
-d "sender_type=server" \
-d "action_type=subscribe" \
-d "email=john@example.com" \
-d "subscriber_status=1"
# Unsubscribe user
curl -X POST https://api.edrone.me/trace \
-d "app_id=YOUR_APP_ID" \
-d "sender_type=server" \
-d "action_type=subscribe" \
-d "email=john@example.com" \
-d "subscriber_status=0"
import requests
def update_subscription(email, subscribed):
response = requests.post('https://api.edrone.me/trace', data={
'app_id': 'YOUR_APP_ID',
'sender_type': 'server',
'action_type': 'subscribe',
'email': email,
'subscriber_status': '1' if subscribed else '0'
})
return response.status_code == 200
# Subscribe
update_subscription('john@example.com', True)
# Unsubscribe
update_subscription('john@example.com', False)
<?php
function updateSubscription($email, $subscribed) {
$data = http_build_query([
'app_id' => 'YOUR_APP_ID',
'sender_type' => 'server',
'action_type' => 'subscribe',
'email' => $email,
'subscriber_status' => $subscribed ? '1' : '0'
]);
$ch = curl_init('https://api.edrone.me/trace');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
// Subscribe
updateSubscription('john@example.com', true);
// Unsubscribe
updateSubscription('john@example.com', false);
Receive webhook from edrone
Configure a webhook endpoint to receive subscription changes from edrone.
Webhook payload
{
"email": "john@example.com",
"subscriber_status": 0,
"reason": "unsubscribed_by_user",
"timestamp": "2024-01-15T10:30:00Z"
}
Example webhook handler
- Python (Flask)
- PHP
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/webhooks/edrone/subscription', methods=['POST'])
def handle_subscription_webhook():
data = request.json
email = data['email']
subscribed = data['subscriber_status'] == 1
reason = data.get('reason', '')
# Update your database
update_user_subscription(email, subscribed, reason)
return jsonify({'status': 'ok'}), 200
<?php
// webhooks/edrone-subscription.php
$payload = json_decode(file_get_contents('php://input'), true);
$email = $payload['email'];
$subscribed = $payload['subscriber_status'] === 1;
$reason = $payload['reason'] ?? '';
// Update your database
updateUserSubscription($email, $subscribed, $reason);
http_response_code(200);
echo json_encode(['status' => 'ok']);
Status reasons
| Reason | Description |
|---|---|
unsubscribed_by_user | User clicked unsubscribe link |
unsubscribed_by_admin | Admin unsubscribed user |
bounced | Email bounced |
complained | User marked as spam |
Configure webhook in Mission Control
- Go to Settings → Integrations → Webhooks
- Add your endpoint URL
- Select Subscription status change event
- Save and test
SMS subscription sync
Include sms_subscriber_status for SMS subscriptions:
curl -X POST https://api.edrone.me/trace \
-d "app_id=YOUR_APP_ID" \
-d "sender_type=server" \
-d "action_type=subscribe" \
-d "email=john@example.com" \
-d "phone=+1234567890" \
-d "subscriber_status=1" \
-d "sms_subscriber_status=1"