All guides All guides

Basics

Automation tools

CRM and email

Guides Basics

How to run a webhook only during business hours

Short answer: Cron cannot limit a webhook to business hours, because it knows the time but not opening hours, country-specific weekends or public holidays. With Netsware, you create a business-hours schedule (for example Monday to Friday, 09:00 to 18:00, in India, closed on public holidays) and attach your webhook job to it. When a call comes due while the business is closed, Netsware holds it and sends it at the next opening minute.


When a webhook should wait for business hours

Some endpoints trigger work that people notice: a batch of emails, a Slack message, a call to a customer or a new support ticket. Running them at 3 a.m., on New Year's Day or on Christmas creates a poor experience, and often a real problem, such as a lead that no sales rep is there to answer or a queue that grows over a long weekend.

The rule you need is simple: call this webhook only while the business is open.

Why cron and most schedulers cannot do this

A cron expression such as */15 9-17 * * 1-5 covers part of it: every 15 minutes, from 09:00 to 17:00, Monday to Friday. It still misses:

  • Public holidays. Cron does not know that 26 January is Republic Day in India or that 23 November is a holiday in Japan. Without a holiday list that someone updates every year for every country, the job runs anyway.
  • Country-specific weekends. The weekend in Saudi Arabia is Friday and Saturday, and many businesses elsewhere work a half day on Saturday, so a single 1-5 does not fit. With Netsware you set the open days per schedule, for example SUN to THU for Saudi Arabia, and GET /v1/hours/meta/countries returns each country's usual weekend.
  • Time zones and daylight saving. Your server runs in UTC while the office is in New York, London or Sydney, and their clocks change twice a year on different dates.
  • Missed runs. When cron skips a run, nothing records why and nothing runs it later. The work is lost.

What you need is a scheduler that checks "is the business open right now?" before every run.

Set it up in 3 steps

You can do all of this in the Netsware dashboard without code. The API version below shows exactly what happens. Every request sends your API key in the X-API-Key header.

Step 1: Define the business hours

curl -X POST https://app.netsware.com/v1/schedules \
  -H "X-API-Key: $NETSWARE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "India office hours",
    "country_code": "IN",
    "timezone": "Asia/Kolkata",
    "days": ["MON","TUE","WED","THU","FRI"],
    "open_time": "09:00",
    "close_time": "18:00",
    "respect_holidays": true
  }'

Keep the id in the response (it starts with sch_). A schedule is reusable, so any number of jobs can follow it.

Step 2: Create the webhook job and attach the schedule

This job calls your endpoint every 15 minutes, but only while the India office is open:

curl -X POST https://app.netsware.com/v1/jobs \
  -H "X-API-Key: $NETSWARE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "recurring",
    "name": "Send email batch",
    "url": "https://api.example.com/send",
    "method": "POST",
    "timezone": "Asia/Kolkata",
    "cron": "*/15 * * * *",
    "business_hours_schedule_id": "sch_..."
  }'

For a single call at opening time instead, use "cron": "0 9 * * MON-FRI". On a public holiday it moves to the next working morning.

The response, and GET /v1/jobs/{id} later, includes next_run_at (UTC) and next_run_at_local (India time). That is the next cron time. If the business is closed at that moment, the run is held until the next opening, and GET /v1/schedules/{id}/check returns when that is.

If your endpoint needs a token, do not put it in the job. Store it once as a secret variable:

curl -X PUT https://app.netsware.com/v1/variables \
  -H "X-API-Key: $NETSWARE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "SEND_TOKEN",
    "value": "your-token",
    "is_secret": true,
    "allowed_destinations": ["api.example.com"]
  }'

Then reference it in the job's headers as "Authorization": "Bearer {{SEND_TOKEN}}". Netsware uses the value without ever showing it again, and with allowed destinations set, it sends the value only to the hosts you list.

Step 3: Run a test call

curl -X POST https://app.netsware.com/v1/jobs/job_.../trigger \
  -H "X-API-Key: $NETSWARE_KEY"

The response shows whether the call worked: success, the http_status your endpoint returned, duration_ms and any error. A test run uses one execution from your plan.

A manual test run never sends a failure alert, so testing does not fill your inbox. Alerts come only from scheduled runs.

What happens when the business is closed

When a run comes due on a weekend, outside business hours or on a public holiday, Netsware defers it:

  • the run moves to the schedule's next opening minute,
  • the reason is logged (weekend, before_hours, after_hours or public_holiday, with the holiday's name),
  • it is not counted as a failure,
  • and if you subscribe to the job.scheduled webhook event, your systems are notified.

If the schedule cannot be found, Netsware fails safe: it holds the run instead of firing at the wrong time.

Check whether a business is open from your own code

To ask "is it open right now?" from your own code, one request is enough:

curl "https://app.netsware.com/v1/check?timezone=Asia/Kolkata&country=IN&open_time=09:00&close_time=18:00" \
  -H "X-API-Key: $NETSWARE_KEY"

It returns open (true or false), the reason (for example weekend or public_holiday, plus holiday_name on a holiday, such as "Republic Day"), the local time and the next opening time. Each check counts as one API request against your plan's monthly quota (20,000 on the free plan).

Quick reference

You want toUse
Call a URL only during business hoursA recurring job with business_hours_schedule_id
Call once at opening time on working days"cron": "0 9 * * MON-FRI" with the schedule
Run if any of several offices is openbusiness_hours_schedule_ids with "business_hours_match": "any"
Run only when every office is openthe same with "business_hours_match": "all"
Use shorter hours on Saturdaytwo schedules, for example Monday to Friday 09:00 to 18:00 and Saturday 09:00 to 13:00, on one job with "business_hours_match": "any"
Look up a country's usual weekendGET /v1/hours/meta/countries
Ask "open right now?"GET /v1/check
List a country's public holidaysGET /v1/holidays?country=IN&year=2026

FAQ

How do I stop a webhook from firing on weekends and public holidays?

Attach the job to a Netsware business-hours schedule with the open days and hours you need and respect_holidays set to true. Runs that fall on a weekend or public holiday move to the next opening minute.

Which countries are covered?

226 countries and territories, including regional and state holidays where they apply. You choose each schedule's open days (for example SUN to THU for a Friday and Saturday weekend), and GET /v1/hours/meta/countries returns every country's usual weekend. A schedule has one opening and closing time for all its days; for a shorter Saturday, add a second schedule. The free Essentials plan includes 10 holiday countries: the US, India, the UK, Germany, France, Canada, Australia, Japan, Singapore and Brazil. Paid plans include all 226.

Is it free to try?

Yes. The Essentials plan is free forever and does not require a credit card.

Does Netsware send the emails itself?

No. Netsware calls your endpoint at the right moment, and your code does the work, so your sending setup stays the same.

What happens if my endpoint is down?

Netsware alerts you when a run fails: by email and in the app on every plan, including the free one; on Slack, Telegram, Discord and Google Chat from Standard; and on Microsoft Teams and signed webhooks on Pro and Max. A recurring job then runs again at its next scheduled time, while one-time jobs and sequence steps are retried according to their retry policy. Every attempt is logged with its HTTP status, timing and error.

Can an AI assistant set this up for me?

Yes. Give it an API key and point it to https://app.netsware.com/llms-full.txt, a guide written for AI assistants that covers every endpoint.

Summary

Cron answers "what time is it?". Business-hours scheduling answers "is the business open?". Create one schedule for the location, attach your webhook job to it, and Netsware handles weekends, public holidays, time zones and daylight saving, and logs every run it held back.

Related guides: How to skip public holidays in an n8n workflow · How to make Zapier skip weekends and public holidays

Start free. No credit card, no trial period. The Essentials plan is free forever, so you can build and test your software, apps and workflows for as long as you need, and upgrade only when you are ready.

Start free

Spotted a mistake or something out of date? Tell us and we will fix it.

Keep reading