@archastro/sdk
    Preparing search index...
    Index

    Constructors

    Methods

    • Archive a notification Moves a notification to "archived" status regardless of whether it is currently "unread" or "read". Archived notifications are excluded from the default inbox view but remain retrievable by passing status: "archived" to the list endpoint. The authenticated user must own the notification. Passing a notification ID that belongs to a different user returns a 404. If the notification is already archived this call succeeds without error (idempotent). Requires an app-scoped token. Returns 204 No Content on success.

      Parameters

      • notification: string

        Notification ID (ntf_...) to archive. Must belong to the authenticated user.

      Returns Promise<void>

      No content

    • List a user's notifications Returns a cursor-paginated list of inbox notifications for the authenticated user, ordered by creation time descending (newest first). All status groups are included by default; pass status to narrow results to a specific group. Each notification's rendered field contains type-specific display data resolved at request time. Notifications whose type is no longer registered in the platform are rendered with kind: "unknown" rather than being omitted. Pagination is forward-only: supply after_cursor from a previous response to fetch the next (older) page. The before_cursor field is always null for this endpoint. Requires an app-scoped token.

      Parameters

      • Optionalparams: { afterCursor?: string; limit?: number; status?: string }

        Query parameters.

        • OptionalafterCursor?: string

          Opaque pagination cursor from a previous response's after_cursor field. Omit to fetch the most recent notifications.

        • Optionallimit?: number

          Maximum number of notifications to return per page. Defaults to 20; maximum is 100.

        • Optionalstatus?: string

          Filter by notification status. One of "all", "active", "unread", "read", or "archived". Defaults to "all" when omitted.

      Returns Promise<
          {
              after_cursor?: string;
              before_cursor?: string;
              data: {
                  archived_at?: string;
                  created_at: string;
                  id: string;
                  read_at?: string;
                  rendered: Record<string, unknown>;
                  status: string;
                  type: string;
              }[];
              has_more: boolean;
          },
      >

      Successful response

    • Mark a notification as read Transitions a notification from "unread" to "read" status. If the notification is already "read" or "archived", the call succeeds without changing its status (idempotent). The authenticated user must own the notification. Passing a notification ID that belongs to a different user returns a 404. Requires an app-scoped token. Returns 204 No Content on success.

      Parameters

      • notification: string

        Notification ID (ntf_...) to mark as read. Must belong to the authenticated user.

      Returns Promise<void>

      No content

    • Mark all notifications as read Marks every "unread" notification belonging to the authenticated user as "read" in a single operation. Notifications that are already "read" or "archived" are not affected. This call is safe to retry — if there are no unread notifications, it succeeds without error. Requires an app-scoped token. Returns 204 No Content on success.

      Returns Promise<void>

      No content

    • Send a custom notification to a user Delivers a custom-typed notification to one of the calling app's users. Apps define notification types by declaring NotificationType config objects in their bundle (one per lookup_key). Supply the type as "custom:<lookup_key>" and provide a data map that is merged with platform-provided context to render the notification's display fields. Only app-scoped tokens may call this endpoint — user tokens are rejected with 403. The app scope is stamped onto the notification automatically; an app cannot target recipients outside its tenant. Built-in platform types such as "app_info" and "billing_alert" are not accepted here. The notifications.send script binding also accepts the viewer a script runs as: a user, an agent, or a team's system viewer. Such a sender may notify only a user it can see in its own organization and sandbox. When the sender is a user, the recipient must also be able to see the sender. An agent cannot see user records, so an agent sender must name a source message: it may then notify a user in its own organization and sandbox who can read that message. Pass thread and message together to name the message the notification is about. The send is then refused unless that message is in that thread and both the sender and the recipient can read it, so a notification cannot quote a message its recipient cannot open. Pass idempotency_key to deduplicate sends. If you call this endpoint twice with the same idempotency_key for the same recipient, the second call returns the original notification without creating a duplicate. The key is scoped to the calling app, so the same raw key used by different apps cannot collide.

      Parameters

      • input: {
            data?: Record<string, unknown>;
            idempotency_key?: string;
            message?: string;
            thread?: string;
            type: string;
            user: string;
        }

        Request body.

        • Optionaldata?: Record<string, unknown>

          Arbitrary key-value payload merged with platform-provided context (recipient, app, org, brand) when rendering the notification's display fields. Defaults to an empty object when omitted.

        • Optionalidempotency_key?: string

          Optional deduplication key. A second call with the same idempotency_key for the same recipient returns the originally-created notification without inserting a new record. Scoped per calling app.

        • Optionalmessage?: string

          Source message (msg_...) that the sender and the recipient must both be able to read.

        • Optionalthread?: string

          Thread (thr_...) of the source message. Requires message.

        • type: string

          Custom notification type identifier in the form "custom:<lookup_key>", where <lookup_key> matches a NotificationType config declared in the calling app's bundle.

        • user: string

          Recipient user ID (usr_...). Must be a member of the calling app's tenant.

      Returns Promise<Notification>

      The created notification, or the existing notification when deduplicated by idempotency_key.

    • Unarchive a notification Restores an "archived" notification to its previous active status: "read" if the notification had been read before archiving, or "unread" otherwise. The notification will appear again in the default inbox view. The authenticated user must own the notification. Passing a notification ID that belongs to a different user returns a 404. If the notification is not currently archived this call succeeds without changing its status (idempotent). Requires an app-scoped token. Returns 204 No Content on success.

      Parameters

      • notification: string

        Notification ID (ntf_...) to unarchive. Must belong to the authenticated user.

      Returns Promise<void>

      No content

    • Get the unread notification count Returns the total number of "unread" notifications for the authenticated user. Useful for displaying a badge or indicator in your UI without fetching the full notification list. Notifications with "read" or "archived" status are not included in the count. Requires an app-scoped token.

      Returns Promise<{ count: number }>

      Successful response