{
"success": true,
"revenue_id": "67a1b2c3d4e5f6a7b8c9d0e1",
"message_id": "a1b2c3d4",
"revenue": 24.99
}
{
"code": "invalid_attribution_type",
"error": "attribution_type must be one of: click, sale, send"
}
{
"code": "message_not_found",
"error": "Message ID not found"
}
Revenue (v2)
Record Revenue
Record revenue attribution for a sent message.
POST
/
v2
/
revenue
{
"success": true,
"revenue_id": "67a1b2c3d4e5f6a7b8c9d0e1",
"message_id": "a1b2c3d4",
"revenue": 24.99
}
{
"code": "invalid_attribution_type",
"error": "attribution_type must be one of: click, sale, send"
}
{
"code": "message_not_found",
"error": "Message ID not found"
}
Record a single revenue event against a previously sent message. The message is looked up by its opaque, variable-length message identifier. If an offer is not explicitly provided, the system will attempt to resolve it from the message’s short link.
Authentication
string
required
Your Trackly SMS API key, formatted as
trk_ followed by 32 lowercase alphanumeric characters.Body Parameters
string
required
The opaque, variable-length message identifier returned when the message was sent. This is the same value passed via the
{{sendId}} macro.float
required
Revenue amount to attribute. Must be greater than or equal to
0.string
required
How the revenue was attributed. One of:
sale, click, or send.string
The offer ID this revenue is associated with. Can be either the
externalId or the offer ID generated by TracklySMS. If omitted, the system will attempt to resolve the offer from the message’s short link.datetime
ISO 8601 timestamp for the revenue event. Assumed to be UTC if no timezone is provided. Defaults to the current time if omitted.
Response Fields
boolean
Whether the revenue was recorded successfully.
string
The unique ID of the created revenue record.
string
The message ID the revenue was attributed to.
float
The revenue amount that was recorded.
cURL
curl -X POST https://api.tracklysms.com/api/v2/revenue \
-H "X-Api-Key: trk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"message_id": "a1b2c3d4",
"revenue": 24.99,
"offer_id": "offer_123",
"attribution_type": "sale",
"timestamp": "2026-02-08T12:00:00Z"
}'
Python
import requests
response = requests.post(
"https://api.tracklysms.com/api/v2/revenue",
headers={
"X-Api-Key": "trk_your_api_key_here",
"Content-Type": "application/json",
},
json={
"message_id": "a1b2c3d4",
"revenue": 24.99,
"offer_id": "offer_123",
"attribution_type": "sale",
"timestamp": "2026-02-08T12:00:00Z",
},
)
print(response.json())
Node.js
const response = await fetch("https://api.tracklysms.com/api/v2/revenue", {
method: "POST",
headers: {
"X-Api-Key": "trk_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
message_id: "a1b2c3d4",
revenue: 24.99,
offer_id: "offer_123",
attribution_type: "sale",
timestamp: "2026-02-08T12:00:00Z",
}),
});
const data = await response.json();
console.log(data);
{
"success": true,
"revenue_id": "67a1b2c3d4e5f6a7b8c9d0e1",
"message_id": "a1b2c3d4",
"revenue": 24.99
}
{
"code": "invalid_attribution_type",
"error": "attribution_type must be one of: click, sale, send"
}
{
"code": "message_not_found",
"error": "Message ID not found"
}
Error Codes
| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | missing_message_id | The message_id field is required. |
| 400 | missing_revenue | The revenue field is required. |
| 400 | missing_attribution_type | The attribution_type field is required. |
| 400 | invalid_message_id | The message_id field must be a string. |
| 400 | invalid_body | The request body must be a JSON object. |
| 400 | invalid_revenue | Revenue must be a number greater than or equal to 0. |
| 400 | invalid_attribution_type | Must be one of: sale, click, or send. The accepted values may appear in any order in the returned error string. |
| 400 | message_not_found | No message exists with the given ID. |
Next Steps
Revenue Tracking
Track and attribute revenue
Send Message
Send messages to drive revenue