Skip to main content
Best answer

How do I access rollup values using Notion's API?

  • March 26, 2026
  • 12 replies
  • 58 views

Hi everyone,

I’m facing a limitation with Zapier and Notion rollup fields. As far as I understand, Zapier doesn’t properly support rollup properties.

My current approach is to use a Code by Zapier (JavaScript) step to force reading all database items via the Notion API. However, I’m not sure if I can reliably retrieve and use all rollup values, especially since my rollup is a total/count field (e.g., total number of related items).

What I’m trying to achieve is:

  • Read the rollup value (total count) from Notion
  • Compare it against a threshold (e.g., > 5)
  • Trigger an email notification when that threshold is reached

My concerns are:

  1. Can I reliably access rollup values (rollup.number) via the API in Zapier?
  2. What’s the best way to handle cases where the database is large (pagination / limits)?
  3. Is there a better workaround than using a Code step for this use case?

Any suggestions or best practices would be really helpful 🙌

Best answer by Troy Tessalone

@Learning together 

Help links for using Code app: https://zapier.com/apps/code/integrations#help

Specifically reference this help link: https://help.zapier.com/hc/en-us/articles/8496310939021-Use-JavaScript-code-in-Zaps#h_01J5DANRK3PXFXHH1A1MAY61VV

 

LOOPING

FYI...info about the Looping app: https://zapier.com/apps/looping/integrations#help

 

Here is why…

Output data from Code steps

Code steps return a single output variable, which is an object or array of objects that will be the result of this step. 

If the output is an array of objects, subsequent steps will run multiple times, once for each object in the array.

 

Key takeaway

  • return [] → controls Zap execution (looping)
  • return { items: [] } → controls data structure only, not execution count

 

Your code was outputting an array of items, rather than an object that has an array of items. (see examples below)

[
{
"id": "string",
"name": "string",
"countLeads": number,
"properties": { ...object }
}
]

VS

{
"items": [
{
"id": "string",
"name": "string",
"countLeads": number,
"properties": { ...object }
}
]
}

 

 

Try this updated JavaScript Code:

const databaseId = inputData.databaseId;
const notionToken = inputData.notionToken;

async function getDatabaseItems() {

const body = {
filter: {
property: "Count Leads",
rollup: {
number: {
greater_than: 0
}
}
},
page_size: 100
};

const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${notionToken}`,
'Notion-Version': '2022-06-28',
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});

const data = await response.json();
return data.results || [];
}

async function main() {

const items = await getDatabaseItems();

return {
items: items.map(item => ({
id: item.id,
name: item.properties?.["Course/Mobility"]?.title[0]?.text?.content || 'Sem título',
countLeads: item.properties?.["Count Leads"]?.rollup?.number || 0,
properties: item.properties
}))
};

}

return await main();

 

12 replies

Sparsh from Automation Jinn
Forum|alt.badge.img+6

Hey ​@Learning together,

It is a limitation of Notion Zapier integration that you can’t access the rollup properties.

But as you said yourself, you can access it through Notion API. Please find the answers to your questions below-

  • Yes it’s possible but you use Retrieve Page Property.
  • Yeah you can handle pagination using a code step. The exact code will really depend on the data and your usecase. Another alternative to handle pagination will be to use Looping by Zapier.
  • You can also probably achieve this using a combination of Notion automations and Zapier if you don’t want to use a code step.

Hope it helps!

PS: If you need more active help, I’m happy to connect through my Zapier Solution Partner page if you’d like to reach out here- https://zapier.com/partnerdirectory/automation-jinn


Thanks a lot!
I’ve already implemented it using a Code Step in Zapier, and it successfully reads the rollup values from Notion. However, it currently sends each item as a separate email. I’d like to group all the items into a single email instead.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • March 26, 2026

Hi ​@Learning together 

For us to have more context…

  • post screenshots showing how your Zap steps are outlined/configured
  • post the code you are using in the Code step

const databaseId = inputData.databaseId;

const notionToken = inputData.notionToken;

async function getDatabaseItems() {

  const body = {

    filter: {

      property: "Count Leads",

      rollup: {

        number: {

          greater_than: 0

        }

      }

    },

    page_size: 100 // limita para evitar timeout

  };

  const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {

    method: 'POST',

    headers: {

      'Authorization': `Bearer ${notionToken}`,

      'Notion-Version': '2022-06-28',

      'Content-Type': 'application/json'

    },

    body: JSON.stringify(body)

  });

  const data = await response.json();

  return data.results || [];

}

async function main() {

  const items = await getDatabaseItems();

 

  return items.map(item => ({

    id: item.id,

    name: item.properties?.["Course/Mobility"]?.title[0]?.text?.content || 'Sem título',

    countLeads: item.properties?.["Count Leads"]?.rollup?.number || 0,

    // Mantém todas as propriedades caso precise de mais detalhes

    properties: item.properties

  }));

}

return await main(); 


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • March 26, 2026

@Learning together 

Clarify what you mean by this and expect for this:

However, it currently sends each item as a separate email. I’d like to group all the items into a single email instead.

 

Based on your screenshot of the Zap steps only 1 email is sent each time the Zap Runs if the Filter step is passed.

 

STEPS

  1. Trigger: Schedule
  2. Action: Code
  3. Action: Filter
  4. Action: Gmail - Send Email

 

CODE

The code outputs an array of objects.

const databaseId = inputData.databaseId;

const notionToken = inputData.notionToken;

async function getDatabaseItems() {

const body = {

filter: {

property: "Count Leads",

rollup: {

number: {

greater_than: 0

}

}

},

page_size: 100 // limita para evitar timeout

};

const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {

method: 'POST',

headers: {

'Authorization': `Bearer ${notionToken}`,

'Notion-Version': '2022-06-28',

'Content-Type': 'application/json'

},

body: JSON.stringify(body)

});

const data = await response.json();

return data.results || [];

}

async function main() {

const items = await getDatabaseItems();



return items.map(item => ({

id: item.id,

name: item.properties?.["Course/Mobility"]?.title[0]?.text?.content || 'Sem título',

countLeads: item.properties?.["Count Leads"]?.rollup?.number || 0,

// Mantém todas as propriedades caso precise de mais detalhes

properties: item.properties

}));

}

return await main();

 


Thanks for your reply.

I understand that only one email step exists in the Zap, but the Code step is returning multiple items (one per course). Because of that, Zapier processes each item individually, which results in multiple emails being sent — one per item that passes the filter.

What I’m trying to achieve is to aggregate all those items into a single output, so that only one email is sent per Zap run, containing all the courses together.

So instead of:
- 1 item → 1 email
- 1 item → 1 email

I want:
- Multiple items → 1 aggregated email
 

 

This post has been edited by a moderator to remove personally identifiable information (PII). Please remember that this is a public forum and avoid sharing personal or potentially sensitive details.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • March 26, 2026

@Learning together 

Screenshot of the emails does not show timestamps for true context.

 

The Zap as shown in the screenshot is only configured to send 1 email each time the Zap runs, as there is no looping configured.

Each time the Zap Runs and sends an email, it will use 2 Tasks, which you can see in the Zap Run history.

Check your Zap Run history details to see activity, timestamps, and the DATA IN/OUT for each step to help you trace the data flow: https://zapier.com/app/history/

 

Post screenshots showing:

  • how your Zap trigger step Schedule is configured
  • how your Filter step is configured
  • how your Gmail Zap step is configured in the CONFIGURE tab while in EDIT mode with the field mappings visible
  • Zap Run activity with the timestamps and tasks

I understand that there is no explicit looping step in the Zap. However, the behavior I’m experiencing comes from the Code step returning multiple items.

Even without a Looping step, when a Code step outputs multiple items (an array), Zapier automatically processes each item individually. This effectively creates an implicit loop within the Zap.

Because of that:
- The Code step returns multiple items (one per course)
- Each item is processed separately by the Filter and Gmail steps
- As a result, multiple emails are sent (one per item)

So although there is no visible looping step, the loop is happening due to the structure of the Code step output.

What I would like to achieve instead is to aggregate all items into a single output, so that the Gmail step runs only once and sends a single email with all the results.

b41abc09b2d10074d3e20f7ed17560ab.png
ef4d811f8a0bf910385f283d9f985ef7.png
8675e29cebeb1cf0517b1482478cb0c1.png
74b0f2eb1ff85209a4ce7cd482528f90.png
 

 

This post has been edited by a moderator to remove sensitive information. Please remember that this is a public forum and avoid sharing credentials, tokens, or other private details that could compromise your account security.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • March 26, 2026

@Learning together 

For this: However, the behavior I’m experiencing comes from the Code step returning multiple items.

 

FEEDBACK

There seems to be discrepancies with the info you are sharing.

In the most recent screenshots, it shows Gmail as Zap step 5. (see screenshot below)

In your original Zap step outline it showed only 4 steps with Gmail as Zap step 4.

You need to clarify the current Zap step outline order again by posting screenshots.

 

Also, you still have not shown proof of your claim about sending multiple emails for a single Zap Run.

The screenshot below does not show timestamps (date/time).

The screenshots shared have not shown Zap Run history activity that shows timestamps from here: https://zapier.com/app/history/

 

 

 

 


To clarify, the Zap structure has changed slightly during testing, which is why the screenshots showed different step counts. The current structure is:

Trigger: Schedule
Action: Code (fetch data from Notion)
Action: Filter
Action: Gmail (send email)


Regarding the multiple emails:

Even though there is no explicit looping step, the Code step returns multiple items (one per course). Because of that, Zapier processes each item individually, which results in multiple emails being sent within a single Zap run.

So the behavior is:
- One Zap run is triggered
- The Code step outputs multiple items
- Each item passes through Filter and Gmail → multiple emails
 

ca54e087f4e5a1f5596e5a1ef094f509.png
fbc045e5f57bd7e489656fc273b656ca.png
 

This post has been edited by a moderator to remove personally identifiable information (PII). Please remember that this is a public forum and avoid sharing personal or potentially sensitive details.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • Answer
  • March 26, 2026

@Learning together 

Help links for using Code app: https://zapier.com/apps/code/integrations#help

Specifically reference this help link: https://help.zapier.com/hc/en-us/articles/8496310939021-Use-JavaScript-code-in-Zaps#h_01J5DANRK3PXFXHH1A1MAY61VV

 

LOOPING

FYI...info about the Looping app: https://zapier.com/apps/looping/integrations#help

 

Here is why…

Output data from Code steps

Code steps return a single output variable, which is an object or array of objects that will be the result of this step. 

If the output is an array of objects, subsequent steps will run multiple times, once for each object in the array.

 

Key takeaway

  • return [] → controls Zap execution (looping)
  • return { items: [] } → controls data structure only, not execution count

 

Your code was outputting an array of items, rather than an object that has an array of items. (see examples below)

[
{
"id": "string",
"name": "string",
"countLeads": number,
"properties": { ...object }
}
]

VS

{
"items": [
{
"id": "string",
"name": "string",
"countLeads": number,
"properties": { ...object }
}
]
}

 

 

Try this updated JavaScript Code:

const databaseId = inputData.databaseId;
const notionToken = inputData.notionToken;

async function getDatabaseItems() {

const body = {
filter: {
property: "Count Leads",
rollup: {
number: {
greater_than: 0
}
}
},
page_size: 100
};

const response = await fetch(`https://api.notion.com/v1/databases/${databaseId}/query`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${notionToken}`,
'Notion-Version': '2022-06-28',
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
});

const data = await response.json();
return data.results || [];
}

async function main() {

const items = await getDatabaseItems();

return {
items: items.map(item => ({
id: item.id,
name: item.properties?.["Course/Mobility"]?.title[0]?.text?.content || 'Sem título',
countLeads: item.properties?.["Count Leads"]?.rollup?.number || 0,
properties: item.properties
}))
};

}

return await main();

 


Thank you for the help, it really worked! 🙌

However, I previously had a Filter step in Zapier that compared the number of leads coming from the Code step. Now, since I’m returning an object containing an array, I can no longer compare the number of leads in the Filter step to continue the Zap and still send everything in a single email.