Soku Revenue API

Push attributed revenue from your servers to Soku

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.

Server-only sk_live_ API key
Idempotent upserts, safe to retry
EndpointPOST https://api.soku.ai/api/v1/revenue/rows
AuthenticationAuthorization: Bearer sk_live_...
FormatHTTPS, JSON request and response
Batch sizeUp to 1000 rows and 5 MB per request
Rate limit60 requests per minute per API key

Getting Started

Send your first row

Create an API key, validate one row with a dry run, then push for real.

1. Create an API key

  1. Sign in to Soku as an organization admin and open Settings → API Keys.
  2. Click Create API key and give it a name. Every key gets the revenue:write scope and acts for the whole organization: rows always land in the key's organization.
  3. The full key (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.
  4. If a key leaks or is no longer used, revoke it on the same page and create a new one. Requests with a revoked key are rejected immediately.

2. Validate one row with a dry run

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.

dry run
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
    }
  ]
}'
200 OK
{
  "batch_id": "rb_3f9c2a7d1e8b4c6a9d0e1f2a",
  "dry_run": true,
  "accepted": 1,
  "rejected": []
}

3. Push for real

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

POST /api/v1/revenue/rows

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.

Headers

NameRequiredDescription
AuthorizationRequiredBearer sk_live_... — an organization API key.
Content-TypeRecommendedapplication/json. The body is always parsed as JSON.

Query parameters

NameRequiredDescription
dry_runOptionaltrue 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.

Request body

An object with a rows array of up to 1000 rows; an empty array is valid and returns accepted: 0.

  • Send every ID as a JSON string, e.g. "1789012345678901". Numeric IDs are rejected, since large integers lose precision in JSON.
  • IDs are at most 128 characters; app_id 255; event_name 64.
  • In optional string fields, an empty string is treated as omitted. Unknown fields are ignored.

Ad dimensions

FieldTypeRequiredDescription
channelstringRequiredtiktok, google or facebook.
ad_account_idstringRequiredThe 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_idstringRequiredCampaign ID.
adgroup_idstringOptionalAd group ID (ad set ID on Facebook).
ad_idstringOptionalAd ID. When set, adgroup_id is required too.
countrystringOptionalTwo uppercase letters, as the ad platform reports country, e.g. US, ZA.
app_idstringOptionalAndroid package name or iOS App Store ID, e.g. id387683439. Up to 255 characters.

Time

FieldTypeRequiredDescription
event_datestringRequiredDay the revenue happened, YYYY-MM-DD.
event_hourintegerOptionalHour 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_datestringRequiredInstall (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.
timezonestringRequiredUTC 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.

Revenue and metrics

FieldTypeRequiredDescription
revenue_typestringRequirediap (in-app purchase), ad (ad monetization), subscription or other.
event_namestringOptionalYour own event name, e.g. purchase, ad_revenue. Up to 64 characters. Soku shows revenue per revenue type and event name.
revenue_usdnumberRequiredRevenue in US dollars. A JSON number, ≥ 0, at most 6 decimal places.
payer_countintegerOptionalDistinct users who paid or produced revenue. ≥ 0.
event_countintegerOptionalNumber of events. ≥ 0. Shown as the conversions of the revenue action.

Response

FieldTypeDescription
batch_idstringID of this request. Include it when you contact Soku about a push.
dry_runbooleanWhether this was a validate-only request.
acceptedintegerRows that passed validation. Unless dry_run is true they are written.
rejectedarrayRejected 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.

200 OK
{
  "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\""
    }
  ]
}

Overwrite rules and unique key

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.

  • Pushing an existing key again replaces its values; nothing is added up. Retries are safe, and you correct data by pushing it again.
  • All metrics are replaced, including omitted ones: a re-push without payer_count or event_count clears them. Always send the full row.
  • If one request repeats a key, the last row wins; every copy counts toward accepted.
  • To clear a row, push it with revenue_usd set to 0.
Keep one granularity per campaign and day. If you already push ad-level rows for a campaign, do not also push a campaign-only row for the same day: both are counted and the campaign's revenue is doubled.

Errors and rate limits

Every error in the table below (4xx) has the body {"error": "<code>", "message": "<text>"}.

401 Unauthorized
{
  "error": "invalid_token",
  "message": "API key is invalid or revoked"
}
StatuserrorMeaningWhat to do
200—Request processed. Row-level results are in rejected.Fix the rejected rows and push them again.
400invalid_json, missing_rows, invalid_dry_runBody 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.
401missing_bearer, invalid_tokenNo Bearer key, or the key is unknown or revoked.Check the key; create a new one if needed.
403insufficient_scopeThe key lacks the revenue:write scope. Keys created in Settings → API Keys always have it.Contact Soku.
413payload_too_largeMore than 1000 rows, or a body over 5 MB.Split into smaller batches.
429rate_limitedOver 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.
  • Each API key may send 60 requests per calendar minute, dry runs included. The 61st returns 429 rate_limited.
  • A client IP may make 20 failed key attempts (unknown or revoked key) per minute. After that, further failures return 429 instead of 401. Valid keys from the same IP are never blocked by this limit.
  • Every 429 carries Retry-After: the seconds left in the current minute.

Examples

Common push patterns

Every example uses the same endpoint and the overwrite rules above.

Push today's data every hour

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.

cron
# 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.json

Correct a row

Push the same dimensions again with the corrected metrics. Send every metric, not only the one that changed.

rows.json
{
  "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
    }
  ]
}

Clear a row

Push the same dimensions with zero metrics. The row stays stored with zero revenue.

rows.json
{
  "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
    }
  ]
}

Backfill history

  • Backfill uses the same endpoint, with no limit on how far back you go.
  • Push one event_date at a time, split into batches of up to 1000 rows, and stay under 60 requests per minute.
  • Days for which Soku has no synced spend get no ROAS.

ROAS

How Soku computes ROAS

Pushed revenue drives ROAS through conversion groups.

Make revenue visible

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.

Formulas

  • Same-day ROAS for day D = revenue with event_date = D ÷ spend on D.
  • Payback ROAS (Dn) for install day D = revenue with 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.
  • Immature windows are hidden. Dn for install day D appears only once day D + n has ended in every timezone; for a date range, the last install day decides. Until then the value is left out rather than shown as a low ROAS.
  • USD accounts only. Soku does not convert currencies. On an ad account whose currency is not USD, revenue is stored but produces no conversion action and no ROAS.
  • Daily only. event_hour only takes part in the unique key. Revenue is summed per day and cannot be viewed by hour.

Where it shows

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

Migrating from XMP

Fields differ from the Mobvista XMP self-attribution v2 API, so map them on your side before pushing.

XMP v2SokuNotes
xmp_token (in body)Authorization headerUse a Bearer API key.
activity_kind—Not needed.
data[] (up to 200 rows)rows[] (up to 1000 rows)Array renamed.
channelchannelSame values; only tiktok, google and facebook are supported.
—ad_account_idNew, required: the ad platform account ID.
campaign_idcampaign_idSame.
adset_idadgroup_idRenamed; optional in Soku.
ad_idad_idSame; optional in Soku.
countrycountrySame.
subsource_id—Not supported. Merge rows first (see below).
event_nameevent_name + revenue_typerevenue_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_usdrevenue_usdRenamed; required in Soku.
event_countevent_countSame.
event_unique_userspayer_countRenamed.
event_value—Not supported.
event_date, active_dateevent_date, active_dateSame.
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_idapp_idSame; optional in Soku.
Merge subsource_id rows before pushing. XMP rows that differ only by 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.json
{
  "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

Known limitations

  • Channels: tiktok, google and facebook only, and the ad account must be connected to the Soku organization that owns the API key.
  • ROAS is computed for USD ad accounts only. Revenue on other accounts is stored but produces no ROAS.
  • ROAS is daily. event_hour is stored and is part of the unique key, but you cannot view revenue by hour.
  • Payback windows are fixed at D0, D7 and D30.
  • Pushed revenue can be broken down by ad account, campaign, ad group, ad, country and day. Other breakdowns (device, keyword, landing page, …) show no pushed revenue, and multi-dimension breakdowns show no payback ROAS.
  • A row only appears at the levels it carries: a campaign-level row (no adgroup_id) is counted in campaign totals but not in ad group or ad breakdowns.
  • The endpoint is write-only: there is no endpoint to list or delete rows. Push revenue_usd 0 to clear a row.
  • Each rejected row reports only its first problem.
  • The XMP request format is not accepted; map fields as described in Migrating from XMP.

Questions about the integration: contact your Soku team and include the batch_id of the request.