Soku Revenue API
Send the revenue your BI has already attributed to ads. Soku lines it up with the spend it syncs from TikTok, Google and Facebook by ad account, campaign, ad group, ad, country and day, and computes same-day ROAS and D0 / D7 / D30 payback ROAS for dashboards, analysis and automation rules.
| Endpoint | POST https://api.soku.ai/api/v1/revenue/rows |
| Authentication | Authorization: Bearer sk_live_... |
| Format | HTTPS, JSON request and response |
| Batch size | Up to 1000 rows and 5 MB per request |
| Rate limit | 60 requests per minute per API key |
Getting Started
Create an API key, validate one row with a dry run, then push for real.
revenue:write scope and acts for the whole organization: rows always land in the key's organization.sk_live_...) is shown only once. Store it in your server-side secret manager. Never put it in frontend, mobile app or other client code.Rows must reference an ad account that is already connected to the same Soku organization. With ?dry_run=true Soku runs every check, including ad account ownership and timezone, and writes nothing.
curl -X POST "https://api.soku.ai/api/v1/revenue/rows?dry_run=true" \
-H "Authorization: Bearer $SOKU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{
"channel": "tiktok",
"ad_account_id": "7301234567890123456",
"campaign_id": "1789012345678901",
"adgroup_id": "1789012345678902",
"ad_id": "1789012345678903",
"country": "ZA",
"app_id": "com.example.app",
"event_date": "2026-09-22",
"event_hour": 14,
"active_date": "2026-09-20",
"timezone": "+08:00",
"revenue_type": "ad",
"event_name": "ad_revenue",
"revenue_usd": 12.345678,
"payer_count": 31,
"event_count": 2204
}
]
}'{
"batch_id": "rb_3f9c2a7d1e8b4c6a9d0e1f2a",
"dry_run": true,
"accepted": 1,
"rejected": []
}Once rejected is empty, send the same request without dry_run. The accepted rows are written and Soku schedules a dashboard refresh for the affected days.
API Reference
Writes a batch of revenue rows. Each row is the aggregated revenue of one combination of dimensions. A well-formed request returns 200; bad rows are listed in rejected and the other rows are written anyway, all in one transaction.
| Name | Required | Description |
|---|---|---|
| Authorization | Required | Bearer sk_live_... — an organization API key. |
| Content-Type | Recommended | application/json. The body is always parsed as JSON. |
| Name | Required | Description |
|---|---|---|
| dry_run | Optional | true or 1: run every check, including ad account ownership and timezone, without writing anything. false, 0 or omitted: write. Case-insensitive. Any other value returns 400 invalid_dry_run. |
An object with a rows array of up to 1000 rows; an empty array is valid and returns accepted: 0.
"1789012345678901". Numeric IDs are rejected, since large integers lose precision in JSON.app_id 255; event_name 64.| Field | Type | Required | Description |
|---|---|---|---|
| channel | string | Required | tiktok, google or facebook. |
| ad_account_id | string | Required | The ad account ID on the ad platform. It must be an account connected to the same Soku organization as the API key. TikTok: advertiser ID. Google: 10-digit customer ID, dashes optional. Facebook: ad account ID, act_ prefix optional. |
| campaign_id | string | Required | Campaign ID. |
| adgroup_id | string | Optional | Ad group ID (ad set ID on Facebook). |
| ad_id | string | Optional | Ad ID. When set, adgroup_id is required too. |
| country | string | Optional | Two uppercase letters, as the ad platform reports country, e.g. US, ZA. |
| app_id | string | Optional | Android package name or iOS App Store ID, e.g. id387683439. Up to 255 characters. |
| Field | Type | Required | Description |
|---|---|---|---|
| event_date | string | Required | Day the revenue happened, YYYY-MM-DD. |
| event_hour | integer | Optional | Hour the revenue happened, 0–23. Omit for a whole-day row. It is part of the unique key, but ROAS is daily and cannot be viewed by hour. |
| active_date | string | Required | Install (activation) day of the users who produced the revenue, YYYY-MM-DD. Drives payback ROAS. A row whose active_date is after its event_date is accepted but only counts toward same-day ROAS. |
| timezone | string | Required | UTC offset of both dates, ±HH:MM, e.g. +08:00. It must equal the ad account's timezone offset on event_date, otherwise the row is rejected. For accounts in a timezone with daylight saving time, the offset changes with the date. |
| Field | Type | Required | Description |
|---|---|---|---|
| revenue_type | string | Required | iap (in-app purchase), ad (ad monetization), subscription or other. |
| event_name | string | Optional | Your own event name, e.g. purchase, ad_revenue. Up to 64 characters. Soku shows revenue per revenue type and event name. |
| revenue_usd | number | Required | Revenue in US dollars. A JSON number, ≥ 0, at most 6 decimal places. |
| payer_count | integer | Optional | Distinct users who paid or produced revenue. ≥ 0. |
| event_count | integer | Optional | Number of events. ≥ 0. Shown as the conversions of the revenue action. |
| Field | Type | Description |
|---|---|---|
| batch_id | string | ID of this request. Include it when you contact Soku about a push. |
| dry_run | boolean | Whether this was a validate-only request. |
| accepted | integer | Rows that passed validation. Unless dry_run is true they are written. |
| rejected | array | Rejected rows, sorted by index: index (0-based position in rows), field and reason. Only the first problem of a row is reported, so a fixed row can surface the next one. accepted plus the length of rejected always equals the length of rows. |
Example: the second of two rows sent a country name instead of a code.
{
"batch_id": "rb_8e1d4b2c9a7f3e6d5c4b3a21",
"dry_run": false,
"accepted": 1,
"rejected": [
{
"index": 1,
"field": "country",
"reason": "must be a 2-letter ISO 3166-1 code, got \"South Africa\""
}
]
}These fields together form a row's unique key within your organization: channel, ad_account_id, campaign_id, adgroup_id, ad_id, country, app_id, event_date, event_hour, active_date, revenue_type and event_name. An omitted field takes part as "empty", so two rows that both omit ad_id have the same key.
payer_count or event_count clears them. Always send the full row.accepted.revenue_usd set to 0.Every error in the table below (4xx) has the body {"error": "<code>", "message": "<text>"}.
{
"error": "invalid_token",
"message": "API key is invalid or revoked"
}| Status | error | Meaning | What to do |
|---|---|---|---|
| 200 | — | Request processed. Row-level results are in rejected. | Fix the rejected rows and push them again. |
| 400 | invalid_json, missing_rows, invalid_dry_run | Body is not valid JSON (NaN and Infinity included), is not an object with a "rows" array, or dry_run has an unsupported value. | Fix the request. Do not retry it unchanged. |
| 401 | missing_bearer, invalid_token | No Bearer key, or the key is unknown or revoked. | Check the key; create a new one if needed. |
| 403 | insufficient_scope | The key lacks the revenue:write scope. Keys created in Settings → API Keys always have it. | Contact Soku. |
| 413 | payload_too_large | More than 1000 rows, or a body over 5 MB. | Split into smaller batches. |
| 429 | rate_limited | Over 60 requests in the current minute for this key, or over 20 failed key attempts from this IP in the current minute. | Wait the number of seconds in the Retry-After header, then retry. |
| 5xx | — | Soku server error. The body is not guaranteed to be JSON. | Retry with exponential backoff. The overwrite rules make retries safe. |
429 rate_limited.429 instead of 401. Valid keys from the same IP are never blocked by this limit.Retry-After: the seconds left in the current minute.Examples
Every example uses the same endpoint and the overwrite rules above.
We recommend pushing today's rows every hour, and once a day re-pushing the last 3 days to pick up late ad revenue corrections. Keep pushing revenue from older installs (an earlier active_date with today's event_date): payback ROAS depends on it.
# Every hour: today's rows (event_date = today in the ad account timezone)
curl -X POST "https://api.soku.ai/api/v1/revenue/rows" \
-H "Authorization: Bearer $SOKU_API_KEY" \
-H "Content-Type: application/json" \
-d @rows_2026-09-22.jsonPush the same dimensions again with the corrected metrics. Send every metric, not only the one that changed.
{
"rows": [
{
"channel": "tiktok",
"ad_account_id": "7301234567890123456",
"campaign_id": "1789012345678901",
"adgroup_id": "1789012345678902",
"ad_id": "1789012345678903",
"country": "ZA",
"app_id": "com.example.app",
"event_date": "2026-09-22",
"event_hour": 14,
"active_date": "2026-09-20",
"timezone": "+08:00",
"revenue_type": "ad",
"event_name": "ad_revenue",
"revenue_usd": 13.1,
"payer_count": 33,
"event_count": 2251
}
]
}Push the same dimensions with zero metrics. The row stays stored with zero revenue.
{
"rows": [
{
"channel": "tiktok",
"ad_account_id": "7301234567890123456",
"campaign_id": "1789012345678901",
"adgroup_id": "1789012345678902",
"ad_id": "1789012345678903",
"country": "ZA",
"app_id": "com.example.app",
"event_date": "2026-09-22",
"event_hour": 14,
"active_date": "2026-09-20",
"timezone": "+08:00",
"revenue_type": "ad",
"event_name": "ad_revenue",
"revenue_usd": 0,
"payer_count": 0,
"event_count": 0
}
]
}event_date at a time, split into batches of up to 1000 rows, and stay under 60 requests per minute.ROAS
Pushed revenue drives ROAS through conversion groups.
After the first push on a USD ad account, each combination of revenue_type and event_name appears as a conversion action named S2S revenue: <event_name> (<revenue_type>); without an event name, the revenue type is used in its place. Add the action to a conversion group in the dashboard. That group's value and ROAS then come from pushed revenue, and its conversions from event_count.
event_date = D ÷ spend on D.active_date = D and event_date 0 to n days after active_date ÷ spend on D. Soku provides D0, D7 and D30 for conversion groups that report ROAS and include an S2S revenue action.event_hour only takes part in the unique key. Revenue is summed per day and cannot be viewed by hour.Pushed revenue can be broken down by ad account, campaign, ad group, ad, country and day. A row shows up only at the levels it carries: campaign-level rows count toward campaign totals but are absent from ad group and ad breakdowns.
Migration
Fields differ from the Mobvista XMP self-attribution v2 API, so map them on your side before pushing.
| XMP v2 | Soku | Notes |
|---|---|---|
| xmp_token (in body) | Authorization header | Use a Bearer API key. |
| activity_kind | — | Not needed. |
| data[] (up to 200 rows) | rows[] (up to 1000 rows) | Array renamed. |
| channel | channel | Same values; only tiktok, google and facebook are supported. |
| — | ad_account_id | New, required: the ad platform account ID. |
| campaign_id | campaign_id | Same. |
| adset_id | adgroup_id | Renamed; optional in Soku. |
| ad_id | ad_id | Same; optional in Soku. |
| country | country | Same. |
| subsource_id | — | Not supported. Merge rows first (see below). |
| event_name | event_name + revenue_type | revenue_type is new and required. Events marked as in-app purchase revenue in XMP Event Management map to iap; events marked as ad revenue map to ad. |
| event_revenue_usd | revenue_usd | Renamed; required in Soku. |
| event_count | event_count | Same. |
| event_unique_users | payer_count | Renamed. |
| event_value | — | Not supported. |
| event_date, active_date | event_date, active_date | Same. |
| timezone (e.g. UTC+8, optional) | timezone (e.g. +08:00, required) | Different format, and it must match the ad account timezone. |
| request_id | — | Not needed: Soku deduplicates by the unique key. |
| app_id | app_id | Same; optional in Soku. |
subsource_id land on the same Soku unique key, so the last row overwrites the others and their revenue is lost. Add them up across subsource_id first. revenue_usd and event_count can be summed; payer_count can only be summed if no user appears in more than one subsource, so recount distinct users or omit it.Example: two XMP rows of 8.25 and 4.75 USD (2 and 3 events) for subsources A and B become one row.
{
"rows": [
{
"channel": "tiktok",
"ad_account_id": "7301234567890123456",
"campaign_id": "1789012345678901",
"adgroup_id": "1789012345678902",
"ad_id": "1789012345678903",
"country": "ZA",
"app_id": "com.example.app",
"event_date": "2026-09-22",
"active_date": "2026-09-20",
"timezone": "+08:00",
"revenue_type": "iap",
"event_name": "purchase",
"revenue_usd": 13.0,
"event_count": 5
}
]
}Limitations
tiktok, google and facebook only, and the ad account must be connected to the Soku organization that owns the API key.event_hour is stored and is part of the unique key, but you cannot view revenue by hour.adgroup_id) is counted in campaign totals but not in ad group or ad breakdowns.revenue_usd 0 to clear a row.Questions about the integration: contact your Soku team and include the batch_id of the request.