Skip to content
DocsNotifications API

Theme

Notifications API

Every /v1/notifications endpoint: send a notification.

Base URL: https://api.nibify.app.

Send a notification

POST/v1/notifications

Creates an informational Message: it arrives on the phone, lands in the Inbox and is marked read when it is looked at, and asks for nothing back. There is no pending state, no expiry and no callback — what happens to it next reaches you as the message.delivered and message.read events of a webhook endpoint, if you subscribe to them. Send surface for a rich body; a surface that dispatches an action belongs to POST /v1/requests and is refused here. Send threadKey to say it inside a conversation you have already opened: the Message takes the next sequence of that Thread and stays informational, because it still asks for nothing.

Headers

Headers
FieldDescription
Authorizationstring · requiredBearer sk_test_…: an API key of your project.

Request body

Request body
FieldDescription
senderobject · requiredWho the person sees the Notification as coming from.
sender.namestring · requiredThe name the person sees, free text. Not empty.
sender.iconstringAn icon for the sender, free text, kept and returned as sent. Nothing draws it: the person sees the sender by its name. Not empty.
notificationobject · requiredWhat the push says.
notification.titlestring · requiredThe title of the push and of its Inbox row. Not empty.
notification.bodystring · requiredThe text of the push and of its Inbox row. Not empty.
prioritystringHow loudly the Notification announces itself: low only in the Inbox, normal with a push, high with a push that may break through the person’s quiet hours. One of low, normal, high. Defaults to normal.
surfaceobjectUI shown when the person opens the Notification, checked against the catalog. It may not dispatch an action: a Surface that asks for an answer is a Request.
surface.rootstring · requiredThe id of the component the Surface is drawn from: always root, and one of components must carry it. Not empty.
surface.dataModelobject · requiredThe flat JSON state the components bind to by JSON Pointer, and the source of the values an action sends back.
surface.componentsarray of objects · requiredThe components, as a flat list, each one checked against the catalog. Not empty.
threadKeystringYour name for a conversation: the Notification joins the Thread with this key, and asks for nothing there either. Without it, the Notification is a Thread of its own. 1 to 200 characters.

Example

import { Card, Column, Nibify, Text } from '@nibify/sdk';

const nibify = new Nibify({ apiKey: 'sk_test_…' });

const surface = {
  root: 'root',
  dataModel: {},
  components: [
    Card('root', { child: 'body' }),
    Column('body', { children: ['title', 'text'] }),
    Text('title', { text: 'Kiwi Studio invoice filed', variant: 'h4' }),
    Text('text', { text: '$1,420, consulting, due Oct 30.' }),
  ],
};

await nibify.notify({
  sender: { name: 'invoice-flow' },
  notification: {
    title: 'Kiwi Studio invoice filed',
    body: '$1,420, consulting, due Oct 30.',
  },
  surface,
});

Responses

Responses
StatusDescription
201The notification was created and is on its way.
401unauthorized for a missing or unusable key, api_key_revoked for a revoked one.
402plan_limit_reached. The Messages the account’s plan allows this month in this key’s Environment are spent — Requests and notifications together, across every Project of the account, counted from the first day of the month in UTC. test and live have a monthly allowance each, counted apart, so a spent test never refuses a live key, nor the other way round. The message names the Environment, the plan, its limit, the day the count starts again and where to upgrade. Nothing was created. Unlike a 429 there is no Retry-After: retrying is refused the same way until the month turns or the plan changes.
422surface_invalid names the component and property at fault, the root the renderer would not find, or a surface that dispatches an action — which is a Request and belongs to POST /v1/requests. invalid_request_body is a malformed envelope, and it is also what a field of a Request sent here gets: quickActions, expiresAt and callbackUrl are refused by name rather than ignored, because a notification that silently dropped a callbackUrl would leave an agent waiting for a call that is never made.
429rate_limited. This project is over its requests-per-second ceiling or its daily volume in the environment this key speaks for; the message says which of the two it was. The budget is the project’s and not the key’s, so another API key of the same project shares it — the test and live halves are counted apart. Nothing was created and nothing was counted: retrying after Retry-After is safe. Header Retry-After: how many seconds to wait before retrying. Always a whole number, never below 1.

Response body, 201

Response body, 201
FieldDescription
messageIdstring · requiredThe Notification’s id, as the message.delivered and message.read events name it.
threadIdstring · requiredThe Thread the Notification joined.
sequenceinteger · requiredThe Notification’s position in its Thread, starting at 1.
interactionTypestring · requiredA Notification asks for nothing, in a Thread or out of one. Always informational.
createdAtstring · requiredWhen the Notification was created. An RFC 3339 timestamp.
environmentstring · requiredThe Environment of the API key that created it. One of test, live.
minCatalogVersioninteger or null · requiredThe lowest catalog version that can draw the Surface, worked out by the server. Null when there is no Surface.
warningsarray of objects · requiredWhat did not stop the Message but changes how it is shown: catalog_version_too_low when no installed app can draw the Surface.
warnings[].codestring · requiredWhat the warning is about, for a program to branch on. Always catalog_version_too_low.
warnings[].messagestring · requiredThe same warning, in a sentence for a person.