Skip to main content
POST
/
v2
/
history
/
revenue
{
  "success_count": 3,
  "error_count": 0,
  "total_revenue": 46.24,
  "errors": []
}
Bulk import up to 1,000 historical revenue records per request. Each record is tied to an existing message and offer. Successfully imported records automatically update the associated ListContact’s denormalized stats: revenue_total, conversion_count, and last_revenue_at.

Authentication

X-Api-Key
string
required
Your Trackly SMS API key. Format: trk_[32-char-alphanumeric].

Body Parameters

records
array
required
An array of revenue records to import. Maximum of 1,000 records per request. Each record accepts the following fields:

Response Fields

success_count
integer
Number of revenue records successfully imported.
error_count
integer
Number of records that failed validation or processing.
total_revenue
float
Sum of all successfully imported revenue amounts.
errors
array
Array of error objects (maximum 100 returned). Each object contains:
  • index (integer) — Position of the failed record in the input array.
  • code (string) — Machine-readable error code.
  • error (string) — Human-readable error description.
cURL
curl -X POST https://app.tracklysms.com/api/v2/history/revenue \
  -H "X-Api-Key: trk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {
        "message_id": "a1b2c3d4",
        "offer_id": "offer_123",
        "revenue": 24.99,
        "payout": 5.00,
        "attribution_type": "sale",
        "timestamp": "2025-11-15T16:00:00Z"
      },
      {
        "message_id": "e5f6g7h8",
        "offer_id": "offer_456",
        "revenue": 12.50,
        "timestamp": "2025-11-15T17:30:00Z"
      },
      {
        "message_id": "i9j0k1l2",
        "offer_id": "offer_123",
        "revenue": 8.75,
        "attribution_type": "migration"
      }
    ]
  }'
Python
import requests

response = requests.post(
    "https://app.tracklysms.com/api/v2/history/revenue",
    headers={
        "X-Api-Key": "trk_your_api_key_here",
        "Content-Type": "application/json",
    },
    json={
        "records": [
            {
                "message_id": "a1b2c3d4",
                "offer_id": "offer_123",
                "revenue": 24.99,
                "payout": 5.00,
                "attribution_type": "sale",
                "timestamp": "2025-11-15T16:00:00Z",
            },
            {
                "message_id": "e5f6g7h8",
                "offer_id": "offer_456",
                "revenue": 12.50,
                "timestamp": "2025-11-15T17:30:00Z",
            },
            {
                "message_id": "i9j0k1l2",
                "offer_id": "offer_123",
                "revenue": 8.75,
                "attribution_type": "migration",
            },
        ],
    },
)

print(response.json())
Node.js
const response = await fetch("https://app.tracklysms.com/api/v2/history/revenue", {
  method: "POST",
  headers: {
    "X-Api-Key": "trk_your_api_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    records: [
      {
        message_id: "a1b2c3d4",
        offer_id: "offer_123",
        revenue: 24.99,
        payout: 5.0,
        attribution_type: "click_through",
        timestamp: "2025-11-15T16:00:00Z",
      },
      {
        message_id: "e5f6g7h8",
        offer_id: "offer_456",
        revenue: 12.5,
        timestamp: "2025-11-15T17:30:00Z",
      },
      {
        message_id: "i9j0k1l2",
        offer_id: "offer_123",
        revenue: 8.75,
        attribution_type: "migration",
      },
    ],
  }),
});

const data = await response.json();
console.log(data);
{
  "success_count": 3,
  "error_count": 0,
  "total_revenue": 46.24,
  "errors": []
}

Error Codes

HTTP StatusError CodeDescription
400missing_recordsThe records field is required and must be a non-empty array.
413too_many_recordsExceeded the maximum of 1,000 records per request.
400missing_message_idA record is missing the message_id field.
400missing_offer_idA record is missing the offer_id field.
400missing_revenueA record is missing the revenue field.
404message_not_foundNo message exists with the given message_id.
404offer_not_foundNo offer exists with the given offer_id.
404contact_not_foundThe contact associated with the message could not be found.
500save_errorAn unexpected error occurred while saving the record.

Next Steps

Reporting Overview

Analyze revenue data

Bulk Create Contacts

Import contacts alongside history