K

Send notifications

Send app news — an approval request, say — to people at your company. It lands in the console's notification bell, and can go out as email too.

Your app can send its own news to people at your company as a notification.
They see it right away in the notification bell at the top right of the console, and clicking it takes them to the matching screen in your app.

What you need

  • An app deployed to AxHub — the two values needed for sending arrive in your app automatically at deploy time
  • The recipient's user ID — read it from the X-AxHub-User-ID header in Read the SSO user info

A deployed app already has these two environment variables. You don't set them yourself.

Environment variableValue
AXHUB_APP_TOKENThe key this app sends notifications with
AXHUB_API_URLThe address to send them to

Sending

import { createAppMessagingClient } from '@ax-hub/sdk';

// The token and address are read from the environment variables above.
const app = createAppMessagingClient();

const result = await app.sendNotification({
  to: [userId],                    // array of user IDs
  title: 'An approval request arrived',
  body: "Kim's time-off request",
  link: '/approvals/123',          // a path inside your app
});

if (result.failedCount > 0) {
  console.warn(result.results.filter((r) => r.status === 'failed'));
}

Here is what goes into a notification.

FieldWhat it is
toArray of recipient user IDs — 1 to 100 per send
titleNotification title (required, up to 200 characters)
bodyBody text (optional, up to 2000 characters)
linkA path inside your own app to open on click (optional, must start with /). External addresses like https://… are rejected
emailtrue sends the same content as email as well (optional)

Recipients must be active members of the company your app belongs to. If the list includes someone who isn't, everyone else still receives it and only that person shows up as failed in the results. If nobody can receive it, you get a 404.

What the recipient sees

Notifications stack up in real time in the bell-shaped inbox at the top right of the console. The same inbox shows them no matter which app they're looking at, and notifications are kept for 90 days.

  • Each notification carries the sending app's icon, so it's clear at a glance where it came from
  • They can filter by app — the list of sending apps appears at the top of the inbox
  • Clicking a notification marks it read and opens the link path. With no link, it just expands the body instead of navigating

The inbox list shows only the first 28 characters of the title and 60 of the body, truncating the rest. Clicking expands the full text, but put what matters at the front.

They can also check from the terminal with the CLI.

axhub notifications list --unread-only
axhub notifications read <notification-id>

Recipients turn delivery on and off per kind — email and inbox separately — under Settings → Notifications in the console, or with axhub notifications prefs from the terminal. So sending doesn't guarantee arrival: the recipient may have that kind switched off.

Sending email too

Passing email: true on a notification sends the same content as email. To send only email, send it separately.

await app.sendMail({
  to: [userId],
  subject: 'An approval request arrived',
  html: "<p>Kim's time-off request is waiting for you.</p>",
});

You address it by user ID, not by email address — AxHub fills in the address. The sender appears as Your app name <noreply@axhub.ai>.

Limits

ItemValue
Recipients per send1–100
Title and body lengthTitle 200 characters, body 2000 (mail subject 500)
Per app, per day5,000 notifications, 1,000 emails
Per company, per day20,000 notifications, 5,000 emails
Notification retention90 days

The daily allowance is drawn down by the number of people actually sent to, and refills at midnight Korea time.

When something goes wrong

SituationResponse
Empty title, or an external address in link400
Bad token401
Not a single valid recipient404
Over the daily limit429 — send again after midnight
Temporary outage503 — retry shortly

You're done when

You send a notification from your app, it appears in the recipient's console notification bell, and clicking it opens the screen you pointed at in your app.

Next, wire a company database into your app in Connect company data with a connector.