🍿 Papcorns SDK Backend API
Complete API documentation for user analytics, event tracking, and third-party integrations. Built with Next.js, TypeScript, and BigQuery.
✅ Production Ready🔒 Secure⚡ Fast
🌐 Base URL
http://localhost:3000/api(Development)📚 API Endpoints
GET
/api/healthHealth check endpoint to verify service status
POST
/api/identify-userRecords user properties to BigQuery for analytics and tracking
✅ Required Fields
app_keyuser_propertiesuser_properties.idfv OR user_properties.gaid
⚪ Optional Fields
user_properties.user_iduser_properties.store_countryuser_properties.revenuecat_iduser_properties.adapty_profile_iduser_properties.appsflyer_iduser_properties.adjust_iduser_properties.payment_processor_iduser_properties.app_id
📤 Request Body Example
{
"app_key": "hair-app-ios",
"user_properties": {
"idfv": "ABC123-DEF456",
"user_id": "user_12345",
"subscription_status": "active",
"premium_user": true,
"country": "Turkey",
"app_version": "2.1.0"
}
}POST
/api/update-userUpdates existing user properties in BigQuery. Note: Due to BigQuery streaming buffer, updates only work on data older than 90 minutes.
✅ Required Fields
app_keyuser_propertiesidfv OR gaid OR user_id
⚪ Optional Fields
idfvgaiduser_idstore_countryrevenuecat_idadapty_profile_idappsflyer_idadjust_idpayment_processor_idapp_id
📤 Request Body Example
{
"app_key": "hair-app-ios",
"idfv": "ABC123-DEF456",
"user_id": "user_12345",
"user_properties": {
"subscription_status": "cancelled",
"premium_user": false,
"cancellation_date": "2025-01-21"
},
"revenuecat_id": "rc_user_updated_123"
}POST
/api/send-eventSends custom events to BigQuery user_events table
🔐 Authorization header required
✅ Required Fields
app_keyevent_typeprofile_id
⚪ Optional Fields
event_datetime...additional_event_properties
📤 Request Body Example
{
"app_key": "hair-app",
"event_type": "subscription_started",
"profile_id": "user_12345",
"event_datetime": "2025-01-21T09:30:00Z",
"revenue": 4.99,
"currency": "USD",
"subscription_tier": "premium"
}POST
/api/send-appsflyer-eventSends purchase events to AppsFlyer S2S API for attribution tracking
✅ Required Fields
app_keyaf_revenueaf_currencyat_least_one_device_identifier
⚪ Optional Fields
af_content_idcustomer_user_iduser_ipappsflyer_idadvertising_ididfvgaidoaidamazon_aidimeiapp_set_id
📤 Request Body Example
{
"app_key": "hair-app-ios",
"af_revenue": "4.99",
"af_currency": "USD",
"af_content_id": "premium_subscription",
"advertising_id": "IDFA-1234-5678-9ABC-DEF0",
"customer_user_id": "user_12345",
"user_ip": "192.168.1.1"
}POST
/api/adapty-webhookReceives subscription events from Adapty webhooks and stores them in BigQuery
🔐 Authorization header with webhook secret
✅ Required Fields
event_typeprofile_id
⚪ Optional Fields
event_datetimesubscription_idproduct_idrevenuecurrency...additional_adapty_fields
📤 Request Body Example
{
"event_type": "subscription_started",
"profile_id": "user_12345",
"event_datetime": "2025-01-21T09:30:00Z",
"subscription_id": "sub_abc123",
"product_id": "premium_yearly",
"revenue": 59.99,
"currency": "USD"
}🚀 Quick Start Examples
💾 Create a User
curl -X POST http://localhost:3000/api/identify-user \
-H "Content-Type: application/json" \
-d '{
"app_key": "hair-app-ios",
"user_properties": {
"idfv": "ABC123-DEF456",
"user_id": "user_12345",
"subscription_status": "active"
}
}'📊 Send an Event
curl -X POST http://localhost:3000/api/send-event \
-H "authorization: your_api_secret" \
-H "Content-Type: application/json" \
-d '{
"app_key": "hair-app",
"event_type": "subscription_started",
"profile_id": "user_12345"
}'🔄 Update a User
curl -X POST http://localhost:3000/api/update-user \
-H "Content-Type: application/json" \
-d '{
"app_key": "hair-app-ios",
"idfv": "ABC123-DEF456",
"user_properties": {
"subscription_status": "cancelled"
}
}'📚 Papcorns SDK Backend API Documentation
Built with Next.js, TypeScript, and BigQuery • Production Ready