Skip to main content
POST
/
v2
/
revenue
/
bulk
{
  "success_count": 2,
  "error_count": 0,
  "total_revenue": 37.49,
  "errors": []
}
Record up to 1,000 revenue events in a single API call. Each record follows the same schema as the single revenue endpoint. The response includes per-record error details so you can identify and retry failures individually.

Authentication

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

Body Parameters

records
array
required
An array of revenue records to process. Maximum of 1,000 records per request. Each record accepts the following fields:
imported
boolean
Set to true to mark these records as imported data.

Response Fields

success_count
integer
Number of revenue records successfully created.
error_count
integer
Number of records that failed validation or processing.
total_revenue
float
Sum of all successfully processed revenue amounts.
errors
array
Array of error objects for failed records. 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/revenue/bulk \
  -H "X-Api-Key: trk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {
        "message_id": "a1b2c3d4",
        "revenue": 24.99,
        "offer_id": "offer_123",
        "attribution_type": "sale"
      },
      {
        "message_id": "e5f6g7h8",
        "revenue": 12.50,
        "offer_id": "offer_456",
        "attribution_type": "click"
      }
    ],
    "imported": false
  }'
Python
import requests

response = requests.post(
    "https://app.tracklysms.com/api/v2/revenue/bulk",
    headers={
        "X-Api-Key": "trk_your_api_key_here",
        "Content-Type": "application/json",
    },
    json={
        "records": [
            {
                "message_id": "a1b2c3d4",
                "revenue": 24.99,
                "offer_id": "offer_123",
                "attribution_type": "sale",
            },
            {
                "message_id": "e5f6g7h8",
                "revenue": 12.50,
                "offer_id": "offer_456",
                "attribution_type": "click",
            },
        ],
        "imported": False,
    },
)

print(response.json())
Node.js
const response = await fetch("https://app.tracklysms.com/api/v2/revenue/bulk", {
  method: "POST",
  headers: {
    "X-Api-Key": "trk_your_api_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    records: [
      {
        message_id: "a1b2c3d4",
        revenue: 24.99,
        offer_id: "offer_123",
        attribution_type: "sale",
      },
      {
        message_id: "e5f6g7h8",
        revenue: 12.5,
        offer_id: "offer_456",
        attribution_type: "click",
      },
    ],
    imported: false,
  }),
});

const data = await response.json();
console.log(data);
{
  "success_count": 2,
  "error_count": 0,
  "total_revenue": 37.49,
  "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_revenueA record is missing the revenue field.
400missing_attribution_typeA record is missing the attribution_type field.
400invalid_revenueRevenue must be a number greater than or equal to 0.
400invalid_attribution_typeMust be one of: sale, click, or send.
400message_not_foundNo message exists with the given ID.
400contact_not_foundThe contact associated with the message could not be found.

Next Steps

Revenue Tracking

Track and attribute revenue

Send Message

Send messages to drive revenue