Compare resources between environments
Compares workflows and other resources between the source and target environments, returning detailed diff information including additions, modifications, and deletions.
Authorization
Authorization<token>API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".
In: header
Request Body
application/jsonRequiredDiff request configuration
sourceEnvironmentIdstringSource environment ID to compare from. Defaults to the Development environment if not provided.
Path Parameters
targetEnvironmentIdRequiredstringTarget environment ID (MongoDB ObjectId) to compare against
Header Parameters
idempotency-keystringA header for idempotency purposes
Response Body
OK
sourceEnvironmentIdRequiredstringSource environment ID
targetEnvironmentIdRequiredstringTarget environment ID
resourcesRequiredarray<object>Diff resources by resource type
summaryRequiredobjectOverall summary
export interface Response {
/**
* Source environment ID
*/
sourceEnvironmentId: string;
/**
* Target environment ID
*/
targetEnvironmentId: string;
/**
* Diff resources by resource type
*/
resources: ResourceDiffResultDto[];
/**
* Overall summary
*/
summary: EnvironmentDiffSummaryDto;
}
export interface ResourceDiffResultDto {
/**
* Type of the layout
*/
resourceType: "REGULAR" | "ECHO" | "BRIDGE";
/**
* Source resource information
*/
sourceResource?: ResourceInfoDto;
/**
* Target resource information
*/
targetResource?: ResourceInfoDto1;
/**
* List of specific changes for this resource
*/
changes: ResourceDiffDto[];
/**
* Summary of changes for this resource
*/
summary: DiffSummaryDto;
/**
* Dependencies that affect this resource
*/
dependencies?: ResourceDependencyDto[];
}
export interface ResourceInfoDto {
/**
* Resource ID (workflow ID or step ID)
*/
id?: string | null;
/**
* Resource name (workflow name or step name)
*/
name?: string | null;
/**
* User who last updated the resource
*/
updatedBy?: UserInfoDto;
/**
* When the resource was last updated
*/
updatedAt?: string | null;
}
export interface UserInfoDto {
/**
* User ID
*/
_id: string;
/**
* User first name
*/
firstName: string;
/**
* User last name
*/
lastName?: string | null;
/**
* User external ID
*/
externalId?: string;
}
export interface ResourceInfoDto1 {
/**
* Resource ID (workflow ID or step ID)
*/
id?: string | null;
/**
* Resource name (workflow name or step name)
*/
name?: string | null;
/**
* User who last updated the resource
*/
updatedBy?: UserInfoDto;
/**
* When the resource was last updated
*/
updatedAt?: string | null;
}
export interface ResourceDiffDto {
/**
* Source resource information
*/
sourceResource?: ResourceInfoDto2;
/**
* Target resource information
*/
targetResource?: ResourceInfoDto3;
/**
* Type of the layout
*/
resourceType: "REGULAR" | "ECHO" | "BRIDGE";
/**
* Type of change
*/
action: "added" | "modified" | "deleted" | "unchanged" | "moved";
/**
* Detailed changes (only for modified resources)
*/
diffs?: {
/**
* Previous state of the resource (null for added resources)
*/
previous?: {
[k: string]: unknown;
} | null;
/**
* New state of the resource (null for deleted resources)
*/
new?: {
[k: string]: unknown;
} | null;
};
/**
* Step type (only for step resources)
*/
stepType?: string;
/**
* Previous index in steps array (for moved/deleted steps)
*/
previousIndex?: number;
/**
* New index in steps array (for moved/added steps)
*/
newIndex?: number;
}
export interface ResourceInfoDto2 {
/**
* Resource ID (workflow ID or step ID)
*/
id?: string | null;
/**
* Resource name (workflow name or step name)
*/
name?: string | null;
/**
* User who last updated the resource
*/
updatedBy?: UserInfoDto;
/**
* When the resource was last updated
*/
updatedAt?: string | null;
}
export interface ResourceInfoDto3 {
/**
* Resource ID (workflow ID or step ID)
*/
id?: string | null;
/**
* Resource name (workflow name or step name)
*/
name?: string | null;
/**
* User who last updated the resource
*/
updatedBy?: UserInfoDto;
/**
* When the resource was last updated
*/
updatedAt?: string | null;
}
export interface DiffSummaryDto {
/**
* Number of added resources (workflows and steps)
*/
added: number;
/**
* Number of modified resources (workflows and steps)
*/
modified: number;
/**
* Number of deleted resources (workflows and steps)
*/
deleted: number;
/**
* Number of unchanged resources (workflows and steps)
*/
unchanged: number;
}
export interface ResourceDependencyDto {
/**
* Type of the layout
*/
resourceType: "REGULAR" | "ECHO" | "BRIDGE";
/**
* ID of the dependent resource
*/
resourceId: string;
/**
* Name of the dependent resource
*/
resourceName: string;
/**
* Whether this dependency blocks the operation
*/
isBlocking: boolean;
/**
* Reason for the dependency
*/
reason: "LAYOUT_REQUIRED_FOR_WORKFLOW" | "LAYOUT_EXISTS_IN_TARGET";
}
export interface EnvironmentDiffSummaryDto {
/**
* Total number of entities compared
*/
totalEntities: number;
/**
* Total number of changes detected
*/
totalChanges: number;
/**
* Whether any changes were detected
*/
hasChanges: boolean;
}
curl -X POST "https://api.novu.co/v2/environments/6615943e7ace93b0540ae377/diff" \
-H "idempotency-key: string" \
-H "Authorization: <token>" \
-H "Content-Type: application/json" \
-d '{
"sourceEnvironmentId": "507f1f77bcf86cd799439011"
}'{
"sourceEnvironmentId": "string",
"targetEnvironmentId": "string",
"resources": [
{
"resourceType": "REGULAR",
"sourceResource": {
"id": "string",
"name": "string",
"updatedBy": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"externalId": "string"
},
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"targetResource": {
"id": "string",
"name": "string",
"updatedBy": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"externalId": "string"
},
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"changes": [
{
"sourceResource": {
"id": "string",
"name": "string",
"updatedBy": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"externalId": "string"
},
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"targetResource": {
"id": "string",
"name": "string",
"updatedBy": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"externalId": "string"
},
"updatedAt": "2024-01-15T10:30:00.000Z"
},
"resourceType": "REGULAR",
"action": "added",
"diffs": {
"previous": {},
"new": {}
},
"stepType": "string",
"previousIndex": 0,
"newIndex": 0
}
],
"summary": {
"added": 0,
"modified": 0,
"deleted": 0,
"unchanged": 0
},
"dependencies": [
{
"resourceType": "REGULAR",
"resourceId": "string",
"resourceName": "string",
"isBlocking": true,
"reason": "LAYOUT_REQUIRED_FOR_WORKFLOW"
}
]
}
],
"summary": {
"totalEntities": 0,
"totalChanges": 0,
"hasChanges": true
}
}