🍿 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/health

Health check endpoint to verify service status

POST/api/identify-user

Records user properties to BigQuery for analytics and tracking

✅ Required Fields

  • app_key
  • user_properties
  • user_properties.idfv OR user_properties.gaid

⚪ Optional Fields

  • user_properties.user_id
  • user_properties.store_country
  • user_properties.revenuecat_id
  • user_properties.adapty_profile_id
  • user_properties.appsflyer_id
  • user_properties.adjust_id
  • user_properties.payment_processor_id
  • user_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-user

Updates existing user properties in BigQuery. Note: Due to BigQuery streaming buffer, updates only work on data older than 90 minutes.

✅ Required Fields

  • app_key
  • user_properties
  • idfv OR gaid OR user_id

⚪ Optional Fields

  • idfv
  • gaid
  • user_id
  • store_country
  • revenuecat_id
  • adapty_profile_id
  • appsflyer_id
  • adjust_id
  • payment_processor_id
  • app_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-event

Sends custom events to BigQuery user_events table

🔐 Authorization header required

✅ Required Fields

  • app_key
  • event_type
  • profile_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-event

Sends purchase events to AppsFlyer S2S API for attribution tracking

✅ Required Fields

  • app_key
  • af_revenue
  • af_currency
  • at_least_one_device_identifier

⚪ Optional Fields

  • af_content_id
  • customer_user_id
  • user_ip
  • appsflyer_id
  • advertising_id
  • idfv
  • gaid
  • oaid
  • amazon_aid
  • imei
  • app_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-webhook

Receives subscription events from Adapty webhooks and stores them in BigQuery

🔐 Authorization header with webhook secret

✅ Required Fields

  • event_type
  • profile_id

⚪ Optional Fields

  • event_datetime
  • subscription_id
  • product_id
  • revenue
  • currency
  • ...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