Bellaso Agent API

Tools backed by the ads module


Ad performance summary

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_performance_summary
Bearer (ck_ endpoint token)

Organization-wide paid-ad totals for one window: spend, impressions, clicks, ctr, cpm, cpc, roas, fatigue_score and this organization's custom metrics (metric_1..metric_10). This is the grounding call for "how are we doing" — start here, then drill in with the per-entity tools. Optional filters narrow to one product, network, ad account or campaign. Omit both dates for the default window: the last 30 complete days ending yesterday. Recompute rates (ctr, cpc, cpm, roas) from summed numerators and denominators — ROAS is total revenue ÷ total spend over the window. Never average the per-row rate columns. Read get_metric_definitions before interpreting or comparing any metric_N column: the slots mean different things per organization.

Ad performance summary › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

Ad performance summary › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Daily ad performance

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_daily_performance
Bearer (ck_ endpoint token)

Per-day paid-ad performance series for a window, filterable to one product, network, ad account, campaign, ad set or ad. Use it for trends, pacing and "what changed on ". Omit both dates for the default window: the last 30 complete days ending yesterday. Rows are complete days. If you bucket days into weeks, use MONDAY-start weeks — that is the week boundary the Bellaso app and every other report in this product use. Recompute rates (ctr, cpc, cpm, roas) from summed numerators and denominators — ROAS is total revenue ÷ total spend over the window. Never average the per-row rate columns.

Daily ad performance › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

adset_id
​string · minLength: 1 · maxLength: 128

Filter to one ad set id.

ad_id
​string · minLength: 1 · maxLength: 128

Filter to one ad id.

Daily ad performance › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Performance by ad account

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_accounts_performance
Bearer (ck_ endpoint token)

Paid-ad performance rolled up per ad account, including this organization's custom KPI counts and values. Use it to compare accounts or to find which account carries the spend. For any 'top / most / best by X' question pass sort_by AND limit: the full row set is ranked server-side before the slice, so the answer arrives in one call instead of several narrowing ones. An invalid sort_by comes back with the list of valid columns, so you can retry in one step. Omit both dates for the default window: the last 30 complete days ending yesterday. Recompute rates (ctr, cpc, cpm, roas) from summed numerators and denominators — ROAS is total revenue ÷ total spend over the window. Never average the per-row rate columns.

Performance by ad account › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

sort_by
​string · minLength: 1 · maxLength: 64

Sort rows by this column, descending, before returning. Best on numeric metric columns: spend, impressions, clicks, ctr, cpc, cpm, roas, metric_1..metric_10 (for CRM-source orgs metric_1 = MQLs — see get_metric_definitions). An invalid value returns the list of valid columns so you can retry in one step.

limit
​integer · min: 1 · max: 200

Max rows to return after sorting (default 50, max 200).

Performance by ad account › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Performance by campaign

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_campaigns_performance
Bearer (ck_ endpoint token)

Paid-ad performance rolled up per campaign — "top campaigns", "which campaigns are underperforming", "where did the spend go". Filter to one network or account first when the question is scoped that way. For any 'top / most / best by X' question pass sort_by AND limit: the full row set is ranked server-side before the slice, so the answer arrives in one call instead of several narrowing ones. An invalid sort_by comes back with the list of valid columns, so you can retry in one step. Omit both dates for the default window: the last 30 complete days ending yesterday. Recompute rates (ctr, cpc, cpm, roas) from summed numerators and denominators — ROAS is total revenue ÷ total spend over the window. Never average the per-row rate columns.

Performance by campaign › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

sort_by
​string · minLength: 1 · maxLength: 64

Sort rows by this column, descending, before returning. Best on numeric metric columns: spend, impressions, clicks, ctr, cpc, cpm, roas, metric_1..metric_10 (for CRM-source orgs metric_1 = MQLs — see get_metric_definitions). An invalid value returns the list of valid columns so you can retry in one step.

limit
​integer · min: 1 · max: 200

Max rows to return after sorting (default 50, max 200).

Performance by campaign › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Performance by ad set

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_adsets_performance
Bearer (ck_ endpoint token)

Paid-ad performance rolled up per ad set, optionally inside one campaign (campaign_id) or for one ad set (adset_id). Use it after a campaign-level answer, to see which audience or placement inside the campaign is doing the work. For any 'top / most / best by X' question pass sort_by AND limit: the full row set is ranked server-side before the slice, so the answer arrives in one call instead of several narrowing ones. An invalid sort_by comes back with the list of valid columns, so you can retry in one step. Omit both dates for the default window: the last 30 complete days ending yesterday. Recompute rates (ctr, cpc, cpm, roas) from summed numerators and denominators — ROAS is total revenue ÷ total spend over the window. Never average the per-row rate columns.

Performance by ad set › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

adset_id
​string · minLength: 1 · maxLength: 128

Filter to one ad set id.

sort_by
​string · minLength: 1 · maxLength: 64

Sort rows by this column, descending, before returning. Best on numeric metric columns: spend, impressions, clicks, ctr, cpc, cpm, roas, metric_1..metric_10 (for CRM-source orgs metric_1 = MQLs — see get_metric_definitions). An invalid value returns the list of valid columns so you can retry in one step.

limit
​integer · min: 1 · max: 200

Max rows to return after sorting (default 50, max 200).

Performance by ad set › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Performance by ad

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_ads_performance
Bearer (ck_ endpoint token)

Paid-ad performance rolled up per individual ad. Ad grain exists for facebook_ads, linkedin_ads and tiktok_ads only — other networks do not report it, so an empty result for google_ads or bingads is expected rather than a data problem. For CRM-source organizations these rows are CRM-attributed at ad grain and match the platform's Ads page, which makes this THE authoritative source for per-ad and per-creative MQL ranking: rank by metric_1 (see get_metric_definitions). Never take that ranking from get_creative_fatigue or get_creative_leaderboard — their conversion columns are platform-pixel and near zero by design for those organizations. For any 'top / most / best by X' question pass sort_by AND limit: the full row set is ranked server-side before the slice, so the answer arrives in one call instead of several narrowing ones. An invalid sort_by comes back with the list of valid columns, so you can retry in one step. Omit both dates for the default window: the last 30 complete days ending yesterday.

Performance by ad › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

adset_id
​string · minLength: 1 · maxLength: 128

Filter to one ad set id.

sort_by
​string · minLength: 1 · maxLength: 64

Sort rows by this column, descending, before returning. Best on numeric metric columns: spend, impressions, clicks, ctr, cpc, cpm, roas, metric_1..metric_10 (for CRM-source orgs metric_1 = MQLs — see get_metric_definitions). An invalid value returns the list of valid columns so you can retry in one step.

limit
​integer · min: 1 · max: 200

Max rows to return after sorting (default 50, max 200).

Performance by ad › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Performance by keyword

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_keywords_performance
Bearer (ck_ endpoint token)

Keyword-level performance with match_type, for google_ads and bingads only (the social networks have no keyword grain, so filtering this to one of them returns nothing by design). Filter with campaign_id / adset_id to scope to one ad group, or keyword_id for a single keyword. For any 'top / most / best by X' question pass sort_by AND limit: the full row set is ranked server-side before the slice, so the answer arrives in one call instead of several narrowing ones. An invalid sort_by comes back with the list of valid columns, so you can retry in one step. Omit both dates for the default window: the last 30 complete days ending yesterday.

Performance by keyword › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

adset_id
​string · minLength: 1 · maxLength: 128

Filter to one ad set id.

keyword_id
​string · minLength: 1 · maxLength: 128

Filter to one keyword id.

sort_by
​string · minLength: 1 · maxLength: 64

Sort rows by this column, descending, before returning. Best on numeric metric columns: spend, impressions, clicks, ctr, cpc, cpm, roas, metric_1..metric_10 (for CRM-source orgs metric_1 = MQLs — see get_metric_definitions). An invalid value returns the list of valid columns so you can retry in one step.

limit
​integer · min: 1 · max: 200

Max rows to return after sorting (default 50, max 200).

Performance by keyword › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Performance by geography

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_geo_performance
Bearer (ck_ endpoint token)

Country-level spend, clicks and conversions, rolled up either by ad account (level="account", the default) or by campaign (level="campaign"). country_code narrows to a single country. Coverage depends on what each network reports geographically, so a country missing from the rows means "not reported", not "zero". Omit both dates for the default window: the last 30 complete days ending yesterday.

Performance by geography › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

product_id
​string · minLength: 1 · maxLength: 128

Filter to one product id from the org context.

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

account_id
​string · minLength: 1 · maxLength: 128

Filter to one ad account id.

campaign_id
​string · minLength: 1 · maxLength: 128

Filter to one campaign id.

level
​string · enum

Rollup grain: 'account' (default) or 'campaign'.

Enum values:
account
campaign
country_code
​string · minLength: 2 · maxLength: 3 · pattern: ^[A-Za-z]{2,3}$

Filter to one country, as its 2- or 3-letter code (e.g. US).

Performance by geography › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.


Fatigued ads

POST
https://dtrgbxembnbwlmpvhhms.supabase.co/functions/v1/cortex-mcp
/api/v1/tools/get_creative_fatigue
Bearer (ck_ endpoint token)

Ads whose creative fatigue score is elevated, highest first — the tool for "which ads are burning out / need a refresh". The score adds a CTR-decay component (up to 50), an impression-pressure component (up to 30) and a creative-age component (up to 20), and an ad younger than 7 days always scores 0. min_score defaults to 30; only ads with spend in the window are considered, and at most 200 rows come back. This reads engagement and delivery metrics plus PLATFORM-PIXEL conversions: for CRM-source organizations the conversion columns here are near zero by design, so never rank creatives by MQL or lead volume with this tool — use get_ads_performance. Omit both dates for the default window: the last 30 complete days ending yesterday.

Fatigued ads › Request Body

start_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window start, YYYY-MM-DD (inclusive). Omit both dates for the default window: the last 30 complete days ending yesterday.

end_date
​string · pattern: ^\d{4}-\d{2}-\d{2}$

Window end, YYYY-MM-DD (inclusive).

ad_network_id
​string · minLength: 1 · maxLength: 64

Filter to one network: facebook_ads | google_ads | tiktok_ads | linkedin_ads | bingads.

min_score
​number · min: 0 · max: 100

Minimum fatigue score to include, 0-100 (default 30).

Fatigued ads › Responses

The tool ran

ok
​boolean · const · required
Const value:
tool
​string · required
data
​required

The tool's payload — byte-identical to what the same tool returns over MCP.