Skip to main content

Subscription Status API

Check whether a visitor is already subscribed to your newsletter before showing subscription popups or forms.

Key takeaway

Use this API to avoid showing subscription popups to already-subscribed users, improving user experience and reducing annoyance.

Overview

GET https://api.edrone.me/subscription_status

This endpoint checks if a visitor (identified by fingerprint cookie) is subscribed to your newsletter and whether they're identified as a known customer.


Request

Endpoint

GET https://api.edrone.me/subscription_status?app_id={app_id}&fpcid={fpcid}

Parameters

ParameterTypeRequiredDescription
app_idstringYesYour edrone App ID
fpcidstringYesFingerprint cookie ID (from fp_ccid cookie)
forcebooleanNoForce fresh check, bypass cache

Example request

curl "https://api.edrone.me/subscription_status?app_id=YOUR_APP_ID&fpcid=abc123def456"

Response

Success response

{
"identified": true,
"status": true,
"message": "Success"
}

Response fields

FieldTypeDescription
identifiedbooleantrue if user is known to edrone (has email associated)
statusboolean | nulltrue = subscribed, false = unsubscribed, null = unknown
messagestringStatus message

Status values explained

identifiedstatusMeaning
truetrueKnown user, subscribed
truefalseKnown user, unsubscribed
truenullKnown user, subscription status unknown
falsenullAnonymous visitor, not in database

Implementation examples

JavaScript (Browser)

async function checkSubscriptionStatus(appId) {
// Get fingerprint cookie
const fpcid = getCookie('fp_ccid');

if (!fpcid) {
return { identified: false, status: null };
}

try {
const response = await fetch(
`https://api.edrone.me/subscription_status?app_id=${appId}&fpcid=${fpcid}`,
{ credentials: 'include' }
);

if (!response.ok) {
throw new Error('Failed to check subscription status');
}

return await response.json();
} catch (error) {
console.error('Subscription check failed:', error);
return { identified: false, status: null };
}
}

function getCookie(name) {
const match = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return match ? match[2] : null;
}

// Usage: Show popup only for non-subscribers
async function maybeShowPopup(appId) {
const { status, identified } = await checkSubscriptionStatus(appId);

if (status === true) {
console.log('User already subscribed, skipping popup');
return;
}

if (identified && status === false) {
console.log('User unsubscribed previously, skipping popup');
return;
}

// Show popup for unknown or anonymous users
showNewsletterPopup();
}

React Hook

import { useState, useEffect } from 'react';

function useSubscriptionStatus(appId) {
const [data, setData] = useState({
identified: false,
status: null,
loading: true
});

useEffect(() => {
const checkStatus = async () => {
const fpcid = getCookie('fp_ccid');

if (!fpcid) {
setData({ identified: false, status: null, loading: false });
return;
}

try {
const response = await fetch(
`https://api.edrone.me/subscription_status?app_id=${appId}&fpcid=${fpcid}`,
{ credentials: 'include' }
);
const result = await response.json();
setData({ ...result, loading: false });
} catch {
setData({ identified: false, status: null, loading: false });
}
};

checkStatus();
}, [appId]);

return data;
}

function getCookie(name) {
const match = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return match ? match[2] : null;
}

// Usage in component
function NewsletterPopup({ appId }) {
const { status, loading } = useSubscriptionStatus(appId);
const [dismissed, setDismissed] = useState(false);

if (loading || status === true || dismissed) {
return null;
}

return (
<div className="popup">
<h2>Subscribe to our newsletter</h2>
<form>
{/* form fields */}
</form>
<button onClick={() => setDismissed(true)}>Close</button>
</div>
);
}

PHP

<?php

function checkSubscriptionStatus(string $appId, string $fpcid): array {
$url = sprintf(
'https://api.edrone.me/subscription_status?app_id=%s&fpcid=%s',
urlencode($appId),
urlencode($fpcid)
);

$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode !== 200 || !$response) {
return ['identified' => false, 'status' => null];
}

return json_decode($response, true);
}

// Usage
$appId = 'YOUR_APP_ID';
$fpcid = $_COOKIE['fp_ccid'] ?? '';

if ($fpcid) {
$subscriptionStatus = checkSubscriptionStatus($appId, $fpcid);

if ($subscriptionStatus['status'] !== true) {
// Show newsletter form
include 'newsletter-form.php';
}
}

Python

import requests

def check_subscription_status(app_id: str, fpcid: str) -> dict:
"""Check if visitor is subscribed to newsletter."""
try:
response = requests.get(
'https://api.edrone.me/subscription_status',
params={'app_id': app_id, 'fpcid': fpcid},
timeout=5
)
response.raise_for_status()
return response.json()
except requests.RequestException:
return {'identified': False, 'status': None}


# Usage
result = check_subscription_status('YOUR_APP_ID', 'visitor-fingerprint-id')

if result['status'] is True:
print('User is subscribed')
elif result['status'] is False:
print('User unsubscribed')
else:
print('Unknown subscription status')

Use cases

1. Conditional popup display

Only show newsletter popups to visitors who aren't already subscribed:

const { status } = await checkSubscriptionStatus(appId);

if (status !== true) {
showNewsletterPopup();
}

2. Personalized messaging

Show different content based on subscription status:

const { identified, status } = await checkSubscriptionStatus(appId);

if (identified && status === true) {
showMessage('Check your inbox for exclusive deals!');
} else if (identified && status === false) {
showMessage('We miss you! Resubscribe for 10% off');
} else {
showMessage('Join our newsletter for 15% off');
}

3. Form pre-fill check

Determine if you should show a simplified form for known users:

const { identified } = await checkSubscriptionStatus(appId);

if (identified) {
// User is known - show simplified one-click subscribe
showOneClickSubscribe();
} else {
// Anonymous - show full form with email input
showFullSubscribeForm();
}

Caching behavior

The API uses cookies to cache subscription status:

CookiePurpose
CustomerSubscribedChecked_{app_id}Indicates status was checked
CustomerSubscribedStatus_{app_id}Cached subscription status
CustomerSubscribedIdentified_{app_id}Cached identification status

To bypass cache and force a fresh check, use force=true:

GET /subscription_status?app_id=X&fpcid=Y&force=true

Error handling

Invalid App ID

HTTP 400 Bad Request

The app_id parameter is invalid or missing.

Server error

{
"identified": false,
"status": null,
"message": "An error occurred while processing the request"
}

Always handle the case where status is null - treat it as "unknown" and show the subscription form.


Best practices

  1. Always provide fallback - If API fails, default to showing the popup
  2. Use with delay - Don't block page load; check status after page loads
  3. Respect user choice - If status is false, user explicitly unsubscribed
  4. Cache results - Store result in sessionStorage to avoid repeated API calls
async function getSubscriptionStatus(appId) {
const cacheKey = `subscription_status_${appId}`;
const cached = sessionStorage.getItem(cacheKey);

if (cached) {
return JSON.parse(cached);
}

const result = await checkSubscriptionStatus(appId);
sessionStorage.setItem(cacheKey, JSON.stringify(result));
return result;
}