Create a context

Create a new context with the specified type, id, and data. Returns 409 if context already exists.

type and id are required fields, data is optional, if the context already exists, it returns the 409 response

POST
/v2/contexts

Authorization

Authorization<token>

API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".

In: header

Request Body

application/jsonRequired
typeRequiredstring

Context type (e.g., tenant, app, workspace). Must be lowercase alphanumeric with optional separators.

Minimum length: 1Maximum length: 100Pattern: "^[a-zA-Z0-9_-]+$"
idRequiredstring

Unique identifier for this context. Must be lowercase alphanumeric with optional separators.

Minimum length: 1Maximum length: 100Pattern: "^[a-zA-Z0-9_-]+$"
dataobject

Optional custom data to associate with this context.

Header Parameters

idempotency-keystring

A header for idempotency purposes

Response Body

Created

typeRequiredstring

Context type (e.g., tenant, app, workspace)

idRequiredstring

Unique identifier for this context

dataRequiredobject

Custom data associated with this context

createdAtRequiredstring

Creation timestamp

updatedAtRequiredstring

Last update timestamp

export interface Response {
  /**
   * Context type (e.g., tenant, app, workspace)
   */
  type: string;
  /**
   * Unique identifier for this context
   */
  id: string;
  /**
   * Custom data associated with this context
   */
  data: {
    [k: string]: unknown;
  };
  /**
   * Creation timestamp
   */
  createdAt: string;
  /**
   * Last update timestamp
   */
  updatedAt: string;
}
 
curl -X POST "https://api.novu.co/v2/contexts" \
  -H "idempotency-key: string" \
  -H "Authorization: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "tenant",
    "id": "org-acme",
    "data": {
      "tenantName": "Acme Corp",
      "region": "us-east-1",
      "settings": {
        "theme": "dark"
      }
    }
  }'
{
  "type": "string",
  "id": "string",
  "data": {},
  "createdAt": "string",
  "updatedAt": "string"
}

On this page

No Headings
Edit this page on GitHub