Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8d75fc6
Docs for content page and CRUD operations for context
Aviatorscode2 Oct 10, 2025
8e14aa2
Docs for context
Aviatorscode2 Oct 10, 2025
937af0e
change page description
Aviatorscode2 Oct 10, 2025
8e5201d
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 13, 2025
6b0a85a
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 13, 2025
50e4d96
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 13, 2025
b3cec4c
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 13, 2025
8defd4b
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 13, 2025
3ffe7ac
Update based on feedback
Aviatorscode2 Oct 13, 2025
6fb394e
Update context based on Adam's feedback
Aviatorscode2 Oct 13, 2025
6a609bf
Add new update
Aviatorscode2 Oct 13, 2025
7ddb7f7
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 14, 2025
fb7392f
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 14, 2025
a6ec1aa
Update content/docs/platform/workflow/contexts.mdx
Aviatorscode2 Oct 17, 2025
82ca9c0
Content for the context page in the workflow section
Aviatorscode2 Oct 21, 2025
e4f3589
Docs for the inbox with context page
Aviatorscode2 Oct 21, 2025
74b5e91
Update the JS and React SDK guide
Aviatorscode2 Oct 21, 2025
e6538dc
Update content/docs/platform/workflow/contexts/index.mdx
Aviatorscode2 Oct 21, 2025
a92cebf
Update content/docs/platform/inbox/configuration/inbox-with-context.mdx
Aviatorscode2 Oct 21, 2025
5949cd6
Update content/docs/platform/workflow/contexts/manage-contexts.mdx
Aviatorscode2 Oct 21, 2025
0dc510b
Fixed code errors
Aviatorscode2 Oct 22, 2025
7347e70
Merge branch 'MRK-1074' of https://github.com/novuhq/docs into MRK-1074
Aviatorscode2 Oct 22, 2025
5f64a99
Update docs for workflow trigger and Inbox to not upsert context but …
Aviatorscode2 Oct 24, 2025
db5e4a1
Add contexts image
Aviatorscode2 Oct 24, 2025
f6705f2
Update code block
Aviatorscode2 Oct 24, 2025
5634e12
fix: PR suggestions and issues
jainpawan21 Oct 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/docs/platform/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"workflow/step-conditions",
"workflow/tags",
"workflow/translations",
"workflow/contexts",
"---Channels---",
"...integrations",
"---Account---",
Expand Down
158 changes: 158 additions & 0 deletions content/docs/platform/workflow/contexts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
pageTitle: 'Contexts'
title: 'Contexts'
description: 'Learn how to use delay steps to control timing and pacing in your notification workflows.'
icon: 'Timer'
---

Contexts are flexible, user-defined data objects that help you organize and personalize your notifications. They let you attach metadata (such as tenant, region, or app details) and enable contextual behavior to workflows, notifications, and other entities across Novu.

Think of it as a payload that isn't tied to a single workflow run, enabling you to organize, customize, and route notifications based on broader application scenarios like the tenant, application, or region that initiated the workflow.

In simple terms, a Context acts like an extended version of the payload. While the payload exists only for the duration of a single workflow execution, Contexts are persistent and can be reused across multiple workflows or API calls. This makes them ideal for multi-tenant environments, dynamic branding, and use cases where notifications depend on shared or reusable data.

<Callout type='warn'>You can pass a maximum of 5 contexts per workflow trigger and the serialized `data` object for each context is limited to 64KB.</Callout>

## How Context works

Imagine you have a single subscriber entity, `[email protected]`, who uses two different applications you offer: "Notion Email" and "Notion Calendar". You want to send notifications specific to each application.

Without Context, you might have to create two different subscribers or use workarounds with subscriber ID prefixes to differentiate the notifications.

```javascript
// Problem: How does Novu know which app is sending the notification?

// Notion Email notification
await novu.trigger('new-email-received', {
to: '[email protected]',
payload: { title: 'You have 1 new email' }
});

// Notion Calendar notification
await novu.trigger('new-calendar-event', {
to: '[email protected]',
payload: { title: 'You have a new meeting invite' }
});
```

With Context, you can provide this metadata directly in the trigger. This allows you to use a single workflow and subscriber entity, while dynamically changing content or logic based on the context.

```javascript
// Solution: Pass an 'app' context to differentiate triggers.

// Notion Email notification
await novu.trigger('new-email-received', {
to: '[email protected]',
payload: { title: 'You have 1 new email' },
context: {
app: 'notion-email',
branding: {
logo: "url_for_email_logo.png"
}
}
});

// Notion Calendar notification
await novu.trigger('new-calendar-event', {
to: '[email protected]',
payload: { title: 'You have a new meeting invite' },
context: {
app: 'notion-calendar',
branding: {
logo: "url_for_calendar_logo.png"
}
}
});
```

You can then access this data within your workflow templates and conditions using variables like `{{context.app}}` or `{{context.branding.logo}}`.

## How to use Context in workflows

Once a context is created, you can access its properties anywhere variables are supported, such as in template editors or condition steps.

## Managing Context

You can create and manage Contexts through the Novu dashboard, the API or passing them directly when triggering a workflow. Once attached, their values can be accessed anywhere Novu supports variables, for example, in templates, step conditions, or layouts.

### Create Context

You can create a new Context via Novu dashboard or API, when you want to register reusable metadata. After creation, this context becomes available to all workflows and templates within your environment.

#### Dashboard

Use the dashboard to manually define contexts that represent key business entities.

1. Log in to the Novu dashboard
2. Click **Contexts** on the sidebar.
3. Click **Create context**.
4. Fill in the following fields:
- **Identifier**: A unique identifier within that type (for example, acme-corp).
- **Context type**: A category such as tenant, app, or region.
- **Custom data (JSON)**: An optional JSON object that contains metadata, such as branding, plan, or region details.
5. Click **Create context** to save the context.

#### API

You can create a context by sending a **POST** request. If a context with the same type:id combination already exists, the request will fail.

```bash
POST /v2/contexts
{
"type": "tenant",
"id": "acme-corp",
"data": {
"name": "Acme Corporation",
"plan": "enterprise"
}
}
```

#### Just-in-Time

Contexts can also be created automatically when you trigger a workflow that includes a new context object. If the specified `type:id` doesn’t exist, Novu automatically creates it before running the workflow.

```
await novu.trigger('welcome-email', {
to: '[email protected]',
payload: { userName: 'John' },
context: {
tenant: 'acme-corp', // Created automatically if it doesn’t exist
app: 'jira'
}
});
```

### Update a Context

You can update the data payload of any existing context. The content type and identifier are immutable.

#### Dashboard

#### API


### View a Context

#### Dashboard

#### API

### List or Search Contexts

#### Dashboard

#### API

### Delete a Context

You can delete a Context if it’s no longer relevant to your workflows. Deleting a context permanently removes it from your Novu environment.

<Callout type='warn'>This action cannot be undone, so ensure the context is no longer required by any active or historical workflows you might need to analyze.</Callout>

#### Dashboard


#### API