MegaRewards API Integration Guide

API Documentation

MegaRewards API Integration Guide

Welcome to the MegaRewards API integration guide. This guide provides detailed instructions for integrating with our rewards platform.

Getting Started

Prerequisites

Before you begin integrating with the MegaRewards API, you’ll need:

  1. A MegaRewards account with API access
  2. Your API key and placement IDs
  3. Basic understanding of RESTful APIs and JSON

Integration Flow

The typical integration flow includes:

  1. User Identification: Send user information to the API
  2. Question Handling: Display and collect answers to qualification questions if required
  3. Reward Delivery: Show available rewards to users
  4. Tracking: Capture impressions and entries

API Endpoints

Base URL

All API requests should be made to:

https://api.megarewards.co

Authentication

Ensure you are using a placement ID in the rewards request.

Retrieving Rewards

To fetch available rewards for a user:

Endpoint: POST /v1/rewards

Required Header: Content-Type: application/json

Request body:

{
  "placement_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "user_ip": "123.123.123.123",
  "device_type": "ios",
  "identifiers": {
    "app_user_id": "user123"
  },
  "attributes": {
    "gender": "male",
    "age": 32,
    "spender_profile": "spender"
  },
  "image_size": "x2"
}

User Attributes Explained:

The image_size parameter is optional and controls the size of reward images returned. Available sizes:

Response:

{
  "rewards": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "entry_url": "https://entry.example.com/reward/123",
      "impression_url": "https://impression.example.com/reward/123",
      "creative": {
        "rectangle_image_url": "https://example.com/images/reward.jpg",
        "logo_background_color": "#FFFFFF",
        "offer_text": "Get $5 for completing this offer!",
        "description_text": "Simple steps to earn your reward",
        "button_text": "Start Now",
        "disclaimer_text": "Terms and conditions apply"
      }
    }
  ]
}

Handling User Questions

Some rewards require additional user information. When this happens, the API will return a 202 status with questions that need to be answered:

{
  "rewards": [],
  "questions": [
    {
      "id": 1,
      "text": "What is your gender?",
      "answer_type": "single_choice",
      "answer_data_type": "string",
      "options": {
        "values": [
          {"name": "Male", "value": "male"},
          {"name": "Female", "value": "female"},
          {"name": "Prefer not to say", "value": "not_specified"}
        ]
      }
    },
    {
      "id": 2,
      "text": "What is your age?",
      "answer_type": "text",
      "answer_data_type": "number",
      "options": {
        "validation": {
          "min_number_value": 1,
          "max_number_value": 125
        }
      }
    },
    {
      "id": 3,
      "text": "Spender Profile",
      "answer_type": "single_choice",
      "answer_data_type": "string",
      "options": {
        "values": [
          {"name": "Non-Spender", "value": "non_spender"},
          {"name": "Spender", "value": "spender"}
        ]
      }
    }
  ]
}

After collecting the answers, include them in the user attributes in your next request.

Reward Targeting

Rewards can be targeted based on user attributes:

The system automatically matches user attributes against reward targeting criteria to show the most relevant offers.

Revenue Event Webhooks

MegaRewards can notify your system when revenue is attributed to your users. This allows you to track earnings in real-time and take appropriate actions in your application.

Configuration

To enable revenue webhooks:

  1. Provide your webhook URL to your MegaRewards contact
  2. Choose your webhook method: POST (batch requests) or GET (individual requests)
  3. Configure the webhook interval (default: 5 minutes, can be set from 1-60 minutes)
  4. Enable revenue webhooks for your app

Webhook Signature Verification

If a webhook secret is configured for your app, all outbound webhook requests will include an X-MegaRewards-Signature header containing an HMAC-SHA256 hex digest.

POST webhooks: the signature is computed over the raw JSON body.

GET webhooks: the signature is computed over the full URL before the &sig= parameter is appended. The same signature value is also appended as &sig=<hex_digest> for integrators who cannot inspect request headers.

If no secret is configured, webhooks are sent without any signature.

POST Webhook Format

For POST webhooks, MegaRewards will send batch requests to your configured URL:

HTTP Method: POST
Content-Type: application/json

Request Body Example:

{
  "data": [
    {
      "app_user_id": "your-app-user-123",
      "idfa": "12345678-1234-1234-1234-123456789012",
      "gaid": "87654321-4321-4321-4321-210987654321",
      "email": "[email protected]",
      "phone": "+1555000000",
      "age": 32,
      "gender": "male",
      "revenue_transactions": [
        {
          "publisher_revenue_usd": 2.50,
          "transaction_id": "your-transaction-id-123",
          "conversion_event_id": "your-conversion-event-456",
          "conversion_event_timestamp": "2025-05-29T14:30:00Z",
          "conversion_event_name": "signup",
          "placement_id": "11111111-2222-3333-4444-555555555555",
          "placement_name": "Home Screen Offerwall"
        },
        {
          "publisher_revenue_usd": 1.75,
          "transaction_id": "your-transaction-id-789",
          "conversion_event_id": "your-conversion-event-012",
          "conversion_event_timestamp": "2025-05-29T14:35:00Z",
          "conversion_event_name": "purchase",
          "placement_id": "11111111-2222-3333-4444-555555555555",
          "placement_name": "Home Screen Offerwall"
        }
      ]
    }
  ],
  "count": 1
}

GET Webhook Format

For GET webhooks, MegaRewards will make individual HTTP GET requests for each revenue transaction using URL templates with placeholders:

HTTP Method: GET

URL Template Format: Configure your webhook URL with placeholders that will be replaced with actual values.

Example URL Template: https://your-domain.com/webhook?user_id={app_user_id}&revenue={publisher_revenue_usd}&tx_id={transaction_id}&event_id={conversion_event_id}&timestamp={conversion_event_timestamp}&age={age}&gender={gender}

Example Generated Request: GET https://your-domain.com/webhook?user_id=user_abc123&revenue=2.75&tx_id=tx_456789&event_id=evt_789012&timestamp=2025-01-15T10:30:00Z&age=28&gender=male

Available Placeholders:

Note: Only placeholders for data that exist will be replaced. Missing data will result in empty placeholder values.

Webhook Revenue Event Details

Expected Response

Your webhook endpoint should return a 2xx status code to indicate successful receipt. Any other status code will be considered a failure.

Common Issues

Rate Limiting

The API enforces rate limits of 100 requests per minute per API key. If you exceed this limit, you’ll receive a 429 response.

Error Handling

All API errors include a descriptive message and appropriate HTTP status code.

Support

For additional assistance, contact our support team at [email protected] or open a ticket in your dashboard.