HubSpot logo

How to set up a cron job on HubSpot: schedule triggers, custom code or an external scheduler

HubSpot has no crontab and no field where you type a cron expression. To run something on a schedule you have three options: a workflow that starts on a schedule, a custom code action inside that workflow, or a scheduler outside HubSpot that calls the HubSpot API, or your own endpoint, at the times you set. Which one fits depends on how often the job runs, how long it takes and which HubSpot subscription you have.

Everything below was checked against HubSpot's Knowledge Base and developer documentation in November 2026. Two changes from this autumn matter here: new private apps can no longer be created, and custom code actions have moved to Node.js 24.

Key takeaways

  • The workflow trigger Based on a schedule is HubSpot's built-in scheduler. Its most frequent setting is Daily, and Daily, Weekly and Monthly need Data Hub Professional or Enterprise.
  • A custom code action runs your Node.js 24 code (Python is in beta) inside a workflow, for at most 20 seconds per run. Node.js 24 handlers return their outputs; callback() no longer works.
  • For API access, create a service key and send it as Authorization: Bearer …. New legacy private apps can't be created since October 26, 2026.
  • Jobs that run more often than daily, take longer than 20 seconds, or live on a plan without Data Hub need a scheduler outside HubSpot.

Does HubSpot have a cron scheduler?

No. HubSpot runs your automation, but it doesn't give you a clock you can program with cron syntax. The closest thing is a workflow trigger where you pick a frequency and a time of day from lists. Custom code actions run when a record reaches their workflow step, and serverless functions run when something calls them; neither has a schedule of its own. Meeting links and task due dates put times on people's calendars, but they don't run anything.

So a "cron job on HubSpot" ends up as a scheduled workflow, a scheduled workflow with code in it, or a clock outside HubSpot that calls in. If cron syntax itself is new to you, how to use cron covers the five fields.

Which option fits your job

Two questions decide most cases: how often and how long the job runs, and whether your account has Data Hub, the hub HubSpot used to call Operations Hub.

Decision diagram: if the job runs more often than daily or longer than 20 seconds, use an external scheduler that calls your endpoint and the HubSpot API; otherwise, with Data Hub Professional or Enterprise, use a workflow schedule trigger with custom code if needed; other hubs only get Once and Annually.
Start at the top left. Without Data Hub, a daily or weekly job ends up outside HubSpot.

The options also differ in what they give you once they run:

Workflow schedule triggerCustom code actionExternal scheduler
Finest scheduleDaily, at a time you chooseWhatever its workflow usesEvery minute, any 5-field cron expression
Time zoneThe account's time zone settingThe account's time zone settingSet on the scheduler
Your codeNone: built-in actions onlyNode.js 24 or Python (beta), 20 seconds, 128 MBAny language, on your own server or function
Where you see runsThe workflow's Action logsAction logs, plus Logs when you testThe scheduler's log, plus the key's View logs

Option 1: a workflow with a schedule trigger

Workflows need a Professional or Enterprise subscription of Marketing Hub, Sales Hub, Service Hub, Data Hub, Smart CRM or Revenue Hub, and Super Admin or Workflows permissions. If the job only changes HubSpot data with built-in actions, this is all you need: no code and no token.

  1. Go to Automation → Workflows and create a workflow. Pick the record type in the Enroll dropdown; you can't change it later.
  2. Choose On a schedule as the trigger. In an existing workflow, click the Trigger enrollment for [object] card, then Change start trigger and Based on a schedule. This erases the triggers it had.
  3. Set the Frequency: Once, Annually, Monthly, Weekly or Daily. Monthly runs on specific days of the month, such as the 15th, or on a flexible day: the first Monday or the last day of the month. Weekly runs on a day of the week. Once and Annually take a fixed date or a date property.
  4. Set the time of day: Morning, Daytime, Night or Specific time. With the first three, HubSpot chooses the moment within that window, so use Specific time when the hour matters.
  5. Under Only enroll [records] that meet the conditions, click Add conditions. Without conditions nobody enrolls automatically; only records you enroll by hand go through, and they run at once rather than on the schedule.
  6. Click Next (or Save in an existing workflow), add your actions and publish the workflow.

Three behaviours to plan for:

  • The frequency depends on your subscription. Once and Annually work with any of the subscriptions above. Monthly, Weekly and Daily need Data Hub Professional or Enterprise.
  • Every run enrolls every match. On each scheduled date and time, all records that meet the conditions go through the workflow. A weekly workflow that creates a task for stale deals creates another one next week for every deal that still matches, so let the workflow set a property that the conditions then exclude.
  • Times follow the account's time zone setting.

Before options 2 and 3: create a service key

Code that calls the HubSpot API needs a token. Until this autumn that was a private app's access token, but HubSpot stopped the creation of new legacy private apps on October 26, 2026, and on September 28 for accounts created on or after that date. For a key that only makes REST API calls, HubSpot now points you to service keys. Super admins and users with the Developer tools access permission can create them.

  1. In HubSpot, go to Development, then Keys → Service keys in the left sidebar.
  2. Click Create service key and enter a name, such as "Nightly sync".
  3. Click Add new scope, tick only the scopes the job needs (for example crm.objects.contacts.read) and click Update.
  4. Click Create and confirm.
  5. Open the key, click Show, then Copy. You can come back and copy it again later.

Send it as a Bearer token. This is HubSpot's own test request, with your key in place of the stars:

curl --request GET \
  --header "Authorization: Bearer pat-na1-*********-****-****-****-************" \
  --url "https://api.hubapi.com/crm/v3/objects/contacts?limit=10&archived=false"
  • Limits. Service keys get the same rate limits as privately distributed apps (see rate limits below). An account can have 100 project-based apps, service keys and MCP connectors combined.
  • Rotation. Rotate offers Rotate and expire now for a leaked key and Rotate and expire later, which keeps the old key working for 7 more days. HubSpot recommends rotating about every six months; automatic rotation (off by default) does it every 3, 6 or 12 months. Every place that stores the key needs the new value.
  • REST calls only. A service key can't authenticate webhooks or run inside UI extensions. For those you build an app on the developer platform.

Option 2: run code in a custom code action

A custom code action is a workflow step that runs your code on HubSpot's infrastructure (AWS Lambda underneath). In a workflow with a schedule trigger it is the closest thing HubSpot has to a cron job running a script, once per enrolled record. It needs Data Hub Professional or Enterprise. Each run must finish within 20 seconds and use at most 128 MB of memory, and all of an action's secrets together can be at most 1,000 characters long.

  1. In the workflow, click the + icon to add an action, then search for and select Custom code.
  2. In Language, choose Node.js 24.x.
  3. Under Secret, click Add secret, enter a Secret name such as BILLING_API_TOKEN and the Secret value, and click Save. Your code reads it as process.env.BILLING_API_TOKEN.
  4. Under Properties to include in code, click Select a property, pick the property and enter the name your code uses for it.
  5. Paste the code.
  6. Under Data outputs, click Add output, choose a Data type and enter the name your code returns.

This example asks your own billing system for the enrolled contact's seat count and hands it back to the workflow. customer_id stands for a custom property that holds your customer ID:

const axios = require("axios");

exports.main = async (event) => {
  const customerId = event.inputFields["customer_id"];

  try {
    const response = await axios.get(
      `https://billing.example.com/api/customers/${customerId}/usage`,
      { headers: { Authorization: `Bearer ${process.env.BILLING_API_TOKEN}` } }
    );

    return {
      outputFields: {
        seats_used: response.data.seats
      }
    };
  } catch (err) {
    console.error(err);
    // Rethrow so HubSpot retries rate limit, 429 and 5XX errors
    throw err;
  }
};

Add a Number output called seats_used, and a later Edit records action can copy it into a contact property without a second API call. To call the HubSpot API instead, store the service key as the secret and use the bundled client, which is version 13 in the Node.js 24 runtime: new hubspot.Client({ accessToken: process.env.HUBSPOT_KEY }) after const hubspot = require("@hubspot/api-client");.

Watch out

Code copied from older guides ends with callback({ outputFields: … }). Node.js 24 supports only async handlers, so return the object instead, and await every call before you return: code still running after return isn't guaranteed to finish. Since November 3, 2026 you can't create Node.js 20 actions, and from November 17, 2026 you can't save changes to existing ones. They keep running, but the next edit means moving to Node.js 24.

Before you publish, click Test action at the bottom of the action, pick a record in the Object dropdown, click Test and confirm. The panel shows the Status, the Data outputs and Logs with memory used and runtime. The test really changes the record you picked, so use a test record. Then click Save. Two more things matter once the schedule is live:

  • Retries. If a call fails with a rate limit error, or a 429 or 5XX error from axios or @hubspot/api-client, and your code rethrows it, HubSpot retries the action for up to three days: first one minute after the failure, then at growing intervals up to eight hours apart. HubSpot's docs name only those two libraries, so use one of them rather than fetch() if you want the retries.
  • Rate limit. Configure rate limit at the bottom of the action has a Turn on rate limiting switch that caps executions per second, minute or hour, and holds back the actions after it too. A schedule trigger enrolls every match at once, so a run with thousands of records is a good reason to turn it on.

Option 3: an external scheduler that calls HubSpot

Keep the clock outside HubSpot when the job must run more often than daily, needs more than 20 seconds, spans other systems, or your account has no Data Hub. The scheduler sends an HTTP request on a cron expression. The request goes either to your own endpoint, which does the work and calls HubSpot, or straight to a HubSpot API endpoint when one fixed request is the whole job.

Diagram: a Cronit job calls your endpoint every 15 minutes with the endpoint's own secret; the endpoint checks it, does the work and calls the HubSpot REST API with the service key as a Bearer token. Cronit logs each run and the service key's View logs shows the API requests.
Two secrets: one for your endpoint, one for HubSpot. The scheduler only holds the first.

Prefer your own endpoint for anything with logic, such as paging through records or checking before writing. It should reject any request without the right secret, and the service key stays in its environment. If the scheduler calls api.hubapi.com directly, the service key sits in the job's header, so give that key only the scopes for that one request. Keep keys in headers, never in URLs, which end up in logs.

Rate limits for scheduled API calls

Service keys, legacy private apps and privately distributed apps on the developer platform share these limits, as of November 2026. The 10-second limit applies to each app on its own; the daily limit is shared by every app in the account.

Your HubSpot subscription (any hub)Per 10 seconds, each appPer day, whole account
Free and Starter100250,000
Professional190625,000
Enterprise1901,000,000

An API limit increase add-on raises both. Over a limit, HubSpot answers 429, and the body's policyName says whether you hit the daily or the 10-second limit. The CRM search API has its own, stricter limits. A job that loops over many records should use batch endpoints and slow down when X-HubSpot-RateLimit-Remaining gets low.

Schedule the call with Cronit

Any scheduler that sends HTTP requests works here. In Cronit it looks like this:

  1. Create a new recurring job in Cronit.
  2. Method POST, URL https://example.com/jobs/hubspot-sync (your endpoint).
  3. In Headers, add Authorization: Bearer YOUR_ENDPOINT_SECRET. If you call HubSpot directly instead, this is where the service key goes.
  4. Enter the schedule, for example */15 * * * *, and set the job's time zone. The preview shows the schedule in plain English and the runs per month, about 2,880 here.
  5. Send the test request before saving, and check that your endpoint answered with a 2xx status.

Every run then appears in the job's execution log with its status. After repeated failures, for example after a key rotation nobody passed on, the job switches itself off, so make updating the stored secret part of every rotation. Compare the monthly runs with your plan's allowance in the pricing section.

What about HubSpot's serverless functions?

HubSpot also runs JavaScript functions for you, but neither kind has a schedule:

  • Functions in developer projects (platform version 2026.03 and later) need an Enterprise subscription to install, work only in privately distributed apps with static auth, and time out after 15 seconds. A private function runs when a UI extension calls it. A public endpoint needs Content Hub Enterprise and has no authentication, so a scheduler could call it, but you add your own token check.
  • Design manager serverless functions, the older CMS kind under /_hcms/api/, are being retired: no new ones since November 3, 2026, no edits from November 17, 2026, and they stop running on February 1, 2027. They move to developer projects, served from /hs/serverless/.

So functions change where the code lives, not who keeps the clock.

Duplicates, time zones and logs

Assume every job can run twice. HubSpot retries a failed custom code action for up to three days, and someone may start an external job by hand while debugging. Write each job so a second run changes nothing: check whether the task or note exists before creating it, and compare a property's value before writing it.

Use one time zone. Workflow schedules and the reset of the daily API limit (midnight) follow the account's time zone setting; an external scheduler follows its own. Set the job to the account's time zone so 08:00 means the same on both sides, and remember that daylight saving time moves local times twice a year.

Know where to look. A workflow's Action logs tab (in the workflow's details) keeps 90 days of action log data and 6 months of enrollment history. After 100,000 successful executions in a day, HubSpot stops storing success and information logs until the next day; errors still appear. A service key's View logs lists its recent requests. For an external job, the scheduler's log answers "did it run?", and our guide to monitoring cron jobs covers being told when it didn't.

Go-live checklist

  • The schedule trigger has conditions, and you know how many records match today.
  • The service key has only the scopes the job needs, and someone owns its rotation.
  • Custom code runs on Node.js 24, returns its outputs, rethrows errors and passed Test action on a test record.
  • A second run of the job creates no duplicates.
  • The external job's time zone matches the account's, and its test request returned a 2xx status.
  • Someone looks at the logs, or gets an alert, when runs fail.

FAQ

Why didn't my scheduled workflow enroll anyone on the first day?
With Morning, Daytime or Night as the time of day, HubSpot starts checking for records the day after you turn the workflow on. If you turn on or update an annual workflow on its scheduled day with one of those settings, records wait for next year's date. Choose Specific time if it has to enroll on the day itself.
What happens to the private apps I already have?
They keep working. You find them under Development → Legacy apps, where you can still show, copy and rotate the token, and HubSpot e-mails super admins when a token hasn't been rotated for more than 180 days. You just can't create new ones.
How can I see how many API calls my scheduled job uses?
Read the response headers: X-HubSpot-RateLimit-Remaining counts down the 10-second window and X-HubSpot-RateLimit-Daily-Remaining the day. Search API responses carry none of these headers. For apps on the new developer platform, Development → Monitoring → API call usage shows the totals, and for legacy private apps GET /account-info/v3/api-usage/daily/private-apps returns the day's usage.
Can I write the custom code action in Python?
Only if your account is in the Python beta; then pick Python in the Language dropdown. The entry point is def main(event):, it returns a dictionary with outputFields, secrets come from os.getenv(), and the editor shows no lint errors for Python. The bundled libraries include requests 2.28.2.

Run online cronjobs without server setup

Plan, schedule and run periodic tasks and scripts, from your browser with the first online cronjob platform.

Try for free