All guides All guides

Basics

Automation tools

CRM and email

Guides CRM and email

How to send SendGrid emails only during business hours

Short answer: SendGrid can schedule an email with send_at, but it does not know when the recipient's business is open. Before you send, ask Netsware whether the recipient's business is open right now (GET /v1/check with their country and timezone). If it is closed, set send_at to the next opening time that Netsware returns. For a prepared campaign, let a Netsware job tell SendGrid to send it only during business hours. Either way, no email arrives on a weekend or a public holiday.


Why email timing matters

Business emails sent at the wrong moment get buried. An invoice reminder that arrives at 2 a.m. or on New Year's Day sits under other mail by the time the recipient opens their inbox, and a sales follow-up on Christmas Day looks automated.

SendGrid sends exactly when you tell it to. Deciding when is up to you: each recipient's timezone, their weekend (Friday and Saturday in Saudi Arabia, Saturday and Sunday in most countries) and their country's public holidays.

How Netsware works with SendGrid

Netsware does not have a SendGrid app, and you do not connect your SendGrid account to it. It answers one question, "is this business open, and if not, when does it open?", and you use the answer in one of two ways:

Method 1: "Ask, then schedule"Method 2: "Netsware sends the campaign"
HowYour code asks Netsware, then sends now or sets send_atA Netsware job calls SendGrid's API on a business-hours schedule
Best fortransactional and per-recipient emails (reminders, follow-ups)a prepared campaign or a fixed email to one audience or team
Personalisationfull, per recipient, in your codewhat you built in SendGrid; Netsware decides when

You need a Netsware API key: create one in the Netsware dashboard under API Keys. The free plan is enough to start.


Method 1: Ask Netsware, then send now or schedule

Node.js

const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);

const MAX_AHEAD_SECONDS = 71 * 3600; // SendGrid schedules at most 72 hours ahead

async function sendInBusinessHours(msg, country, timezone) {
  const params = new URLSearchParams({ country, timezone, open_time: '09:00', close_time: '18:00' });
  const res = await fetch('https://app.netsware.com/v1/check?' + params, {
    headers: { 'X-API-Key': process.env.NETSWARE_KEY },
  });
  if (!res.ok) throw new Error('Netsware check failed: HTTP ' + res.status); // never send blind
  const check = await res.json();

  if (!check.open) {
    if (!check.next_open) return { sent: false, reason: check.reason };
    const sendAt = Math.floor(Date.parse(check.next_open.utc) / 1000);
    if (sendAt - Date.now() / 1000 > MAX_AHEAD_SECONDS) {
      return { sent: false, retryAfter: check.next_open.utc }; // keep it in your own queue
    }
    msg.sendAt = sendAt;
  }
  await sgMail.send(msg);
  return { sent: true, scheduledFor: msg.sendAt || 'now' };
}

// Example: a reminder to a customer in Japan
sendInBusinessHours(
  { to: 'customer@example.com', from: 'billing@yourcompany.com',
    subject: 'Your invoice is due', text: 'Hi, a quick reminder...' },
  'JP', 'Asia/Tokyo'
);

Python

import os
import time
from datetime import datetime

import requests
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail, SendAt

MAX_AHEAD_SECONDS = 71 * 3600  # SendGrid schedules at most 72 hours ahead

def send_in_business_hours(message: Mail, country: str, timezone: str):
    r = requests.get(
        "https://app.netsware.com/v1/check",
        params={"country": country, "timezone": timezone,
                "open_time": "09:00", "close_time": "18:00"},
        headers={"X-API-Key": os.environ["NETSWARE_KEY"]},
        timeout=10,
    )
    r.raise_for_status()  # never send blind
    check = r.json()

    if not check["open"]:
        if not check.get("next_open"):
            return {"sent": False, "reason": check.get("reason")}
        utc = check["next_open"]["utc"].replace("Z", "+00:00")
        send_at = int(datetime.fromisoformat(utc).timestamp())
        if send_at - time.time() > MAX_AHEAD_SECONDS:
            return {"sent": False, "retry_after": check["next_open"]["utc"]}  # keep it in your own queue
        message.send_at = SendAt(send_at)

    SendGridAPIClient(os.environ["SENDGRID_API_KEY"]).send(message)
    return {"sent": True}

Never sends blind: if the check fails, the code throws and nothing is sent, so a wrong key or an invalid country never sends an email at the wrong time.

The 72-hour limit: SendGrid schedules at most 72 hours ahead, and a Friday evening send to a country with a holiday on Monday can open later than that. The code above already handles it: if the next opening is more than about 71 hours away, the function doesn't send; it returns retryAfter so you can queue the email and try again later.

Netsware doesn't guess the weekend: it uses the open days you pass, Monday to Friday by default. For a Friday and Saturday weekend, as in Saudi Arabia, add days: 'SUN,MON,TUE,WED,THU' to the parameters.

Cost note: each check is one Netsware API request against your plan's monthly quota (20,000 on the free plan). If many recipients share a country and timezone, check once per country, not once per email.


Method 2: Let a Netsware job send a prepared campaign on working days

Build the email in SendGrid as a Single Send, then let Netsware press "send" at the right moment, for example at 10:00 on the next working day in the UK. Marketing Campaigns Single Sends aren't limited to 72 hours, so this works for any date.

Step 1: Store your SendGrid API key in Netsware as a secret

Use a restricted SendGrid key with only the access it needs, and allow it only for SendGrid's API host:

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

Netsware uses it but never shows it again, and only sends it to api.sendgrid.com.

Step 2: Create a business-hours schedule

curl -X POST https://app.netsware.com/v1/schedules \
  -H "X-API-Key: $NETSWARE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "UK business hours",
    "country_code": "GB",
    "timezone": "Europe/London",
    "days": ["MON","TUE","WED","THU","FRI"],
    "open_time": "09:00",
    "close_time": "17:30",
    "respect_holidays": true
  }'

Step 3: Create a one-off job that sends the Single Send

curl -X POST https://app.netsware.com/v1/jobs \
  -H "X-API-Key: $NETSWARE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "once",
    "name": "Send December newsletter (SendGrid)",
    "url": "https://api.sendgrid.com/v3/marketing/singlesends/YOUR_SINGLE_SEND_ID/schedule",
    "method": "PUT",
    "timezone": "Europe/London",
    "run_at": "2026-12-01T10:00:00",
    "headers": { "Authorization": "Bearer {{SENDGRID_KEY}}" },
    "payload": { "send_at": "now" },
    "business_hours_schedule_id": "sch_..."
  }'

If 1 December at 10:00 turns out to be a holiday, Netsware holds the job and sends at the next opening minute. The run is logged with its reason (for example public_holiday), and if SendGrid doesn't answer, the call is retried and you can be alerted, by email even on the free plan.

Good to know: a Netsware job sends the same request each time, with your {{VARIABLES}} filled in. Per-recipient personalised emails come from your own code (Method 1) or from what you built in SendGrid. Netsware decides when.


FAQ

Is there a Netsware app for SendGrid?

No. Netsware works with SendGrid through SendGrid's own API: your code asks Netsware and then calls SendGrid, or a Netsware job calls SendGrid directly. You do not connect your SendGrid account, and Netsware never sees your recipients unless you add them to a job yourself.

How do I schedule SendGrid emails in the recipient's business hours?

Call GET /v1/check with the recipient's country and timezone before sending. If open is false, set SendGrid's send_at to the next opening time in the response. SendGrid schedules at most 72 hours ahead, so handle longer closures as shown in Method 1.

Which countries are covered?

226 countries and territories, including regional and state holidays where they apply. 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. On the free plan, a check for a country outside those 10 returns an error that names the plan needed. GET /v1/hours/meta/countries returns every country's usual weekend.

Does this work with other email providers?

Yes. Method 1 works with any provider that can send immediately or schedule a send. The Netsware check is independent of the email provider.

Does it cost anything?

The Netsware Essentials plan is free forever and does not require a credit card. SendGrid pricing is separate.

Summary

SendGrid delivers the email. Netsware knows when the recipient's business is open. Ask Netsware before each send and use send_at for anything outside business hours, or let a Netsware job send a prepared campaign only on working days. Either way, there is no holiday list to maintain.

Related guides: How to run a webhook only during business hours · How to run HubSpot workflow actions only during each contact's business hours

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