Tutorial: spend per provider
This is a tutorial on how to use the API to query spend per provider.
This task can be broken to stages
- Query the API for the "cost" funnel step
- Get the cost funnelStepId from the response
- Query the performance metrics for this funnel step
- Fetch providers so we can translate provider IDs to human readable format
Step 1: Query the API for the "cost" funnel step
graphql
query Portfolio($teamId: Int!, $portfolioId: Int!) {
portfolioV2(teamId: $teamId, portfolioId: $portfolioId) {
teamId
portfolioId
title
start
end
funnelSteps {
funnelStepId
type
title
}
}
}Step 2: Get the cost funnelStepId from the response
From the response, we find that the funnel step ID we are looking for is 329.
json
{
"data": {
"portfolioV2": {
"teamId": 1,
"portfolioId": 1,
"title": "Lightning e-commerce",
"start": "2025-01-01",
"end": "2026-01-01",
"funnelSteps": [
{
"funnelStepId": 329,
"type": "COST",
"title": "COST"
},
{
"funnelStepId": 330,
"type": "AWARENESS",
"title": "Impressions"
},
{
"funnelStepId": 331,
"type": "CONSIDERATION",
"title": "Clicks"
},
{
"funnelStepId": 333,
"type": "CONSIDERATION",
"title": "Add to Cart"
},
{
"funnelStepId": 334,
"type": "CONVERSION",
"title": "Orders"
},
{
"funnelStepId": 335,
"type": "CONVERSION_VALUE",
"title": "Revenue"
}
]
}
}
}Step 3: Query the performance metrics for this funnel step
graphql
query SpendPerProvider($teamId: Int!, $portfolioId: Int!, $period: DateRangeInput! $funnelStepId: Float!) {
portfolioV2(teamId: $teamId, portfolioId: $portfolioId) {
performance(period: $period) {
funnelStep(funnelStepId: $funnelStepId) {
dailyMetrics {
day
providers {
providerId
value {
adSpend
}
}
}
}
}
}
}Example response:
json
{
"data": {
"portfolioV2": {
"performance": {
"funnelStep": {
"dailyMetrics": [
{
"day": "2025-05-01",
"providers": [
{
"providerId": 24,
"value": {
"adSpend": 123456
}
},
{
"providerId": 60,
"value": {
"adSpend": 1234
}
}
]
},
{
"day": "2025-05-02",
"providers": [
{
"providerId": 24,
"value": {
"adSpend": 123456
}
},
{
"providerId": 60,
"value": {
"adSpend": 1234
}
}
]
}
]
}
}
}
}
}Step 4: Fetch providers so we can translate provider IDs to human readable format
graphql
query {
providers {
provider_id
name
}
}Example response:
json
{
"data": {
"providers": [
{
"provider_id": 1,
"name": "{provider.salesforce}",
"logo": "https://cdn.nexoya.io/img/00_provider_salesforce-icon.svg"
},
{
"provider_id": 2,
"name": "{provider.google.analytics}",
"logo": "https://cdn.nexoya.io/img/00_provider_google_analytics-icon.svg"
}
...
]
}
}