Environments

April 13, 2026 ยท View on GitHub

Overview

Environments allow you to manage different stages of your application development lifecycle. Each environment has its own set of API keys and configurations, enabling you to separate development, staging, and production workflows. https://docs.novu.co/platform/environments

Available Operations

  • diff - Compare resources between environments
  • publish - Publish resources to target environment
  • create - Create an environment
  • list - List all environments
  • update - Update an environment
  • delete - Delete an environment

diff

Compares workflows and other resources between the source and target environments, returning detailed diff information including additions, modifications, and deletions.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.DiffEnvironmentRequestDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentsControllerDiffEnvironmentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        EnvironmentsControllerDiffEnvironmentResponse res = sdk.environments().diff()
                .targetEnvironmentId("6615943e7ace93b0540ae377")
                .body(DiffEnvironmentRequestDto.builder()
                    .sourceEnvironmentId("507f1f77bcf86cd799439011")
                    .build())
                .call();

        if (res.diffEnvironmentResponseDto().isPresent()) {
            System.out.println(res.diffEnvironmentResponseDto().get());
        }
    }
}

Parameters

ParameterTypeRequiredDescriptionExample
targetEnvironmentIdString:heavy_check_mark:Target environment ID (MongoDB ObjectId) to compare against6615943e7ace93b0540ae377
idempotencyKeyOptional<String>:heavy_minus_sign:A header for idempotency purposes
bodyDiffEnvironmentRequestDto:heavy_check_mark:Diff request configuration

Response

EnvironmentsControllerDiffEnvironmentResponse

Errors

Error TypeStatus CodeContent Type
models/errors/ErrorDto414application/json
models/errors/ErrorDto400, 401, 403, 404, 405, 409, 413, 415application/json
models/errors/ValidationErrorDto422application/json
models/errors/ErrorDto500application/json
models/errors/APIException4XX, 5XX*/*

publish

Publishes all workflows and resources from the source environment to the target environment. Optionally specify specific resources to publish or use dryRun mode to preview changes.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.*;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentsControllerPublishEnvironmentResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        EnvironmentsControllerPublishEnvironmentResponse res = sdk.environments().publish()
                .targetEnvironmentId("6615943e7ace93b0540ae377")
                .body(PublishEnvironmentRequestDto.builder()
                    .sourceEnvironmentId("507f1f77bcf86cd799439011")
                    .resources(List.of(
                        ResourceToPublishDto.builder()
                            .resourceType(ResourceTypeEnum.REGULAR)
                            .resourceId("workflow-id-1")
                            .build()))
                    .build())
                .call();

        if (res.publishEnvironmentResponseDto().isPresent()) {
            System.out.println(res.publishEnvironmentResponseDto().get());
        }
    }
}

Parameters

ParameterTypeRequiredDescriptionExample
targetEnvironmentIdString:heavy_check_mark:Target environment ID (MongoDB ObjectId) to publish resources to6615943e7ace93b0540ae377
idempotencyKeyOptional<String>:heavy_minus_sign:A header for idempotency purposes
bodyPublishEnvironmentRequestDto:heavy_check_mark:Publish request configuration

Response

EnvironmentsControllerPublishEnvironmentResponse

Errors

Error TypeStatus CodeContent Type
models/errors/ErrorDto414application/json
models/errors/ErrorDto400, 401, 403, 404, 405, 409, 413, 415application/json
models/errors/ValidationErrorDto422application/json
models/errors/ErrorDto500application/json
models/errors/APIException4XX, 5XX*/*

create

Creates a new environment within the current organization. Environments allow you to manage different stages of your application development lifecycle. Each environment has its own set of API keys and configurations.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.CreateEnvironmentRequestDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentsControllerV1CreateEnvironmentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        EnvironmentsControllerV1CreateEnvironmentResponse res = sdk.environments().create()
                .body(CreateEnvironmentRequestDto.builder()
                    .name("Production Environment")
                    .color("#3498db")
                    .parentId("60d5ecb8b3b3a30015f3e1a1")
                    .build())
                .call();

        if (res.environmentResponseDto().isPresent()) {
            System.out.println(res.environmentResponseDto().get());
        }
    }
}

Parameters

ParameterTypeRequiredDescription
idempotencyKeyOptional<String>:heavy_minus_sign:A header for idempotency purposes
bodyCreateEnvironmentRequestDto:heavy_check_mark:N/A

Response

EnvironmentsControllerV1CreateEnvironmentResponse

Errors

Error TypeStatus CodeContent Type
models/errors/ErrorDto402, 414application/json
models/errors/ErrorDto400, 401, 403, 404, 405, 409, 413, 415application/json
models/errors/ValidationErrorDto422application/json
models/errors/ErrorDto500application/json
models/errors/APIException4XX, 5XX*/*

list

This API returns a list of environments for the current organization. Each environment contains its configuration, API keys (if user has access), and metadata.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentsControllerV1ListMyEnvironmentsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        EnvironmentsControllerV1ListMyEnvironmentsResponse res = sdk.environments().list()
                .call();

        if (res.environmentResponseDtos().isPresent()) {
            System.out.println(res.environmentResponseDtos().get());
        }
    }
}

Parameters

ParameterTypeRequiredDescription
idempotencyKeyOptional<String>:heavy_minus_sign:A header for idempotency purposes

Response

EnvironmentsControllerV1ListMyEnvironmentsResponse

Errors

Error TypeStatus CodeContent Type
models/errors/ErrorDto414application/json
models/errors/ErrorDto400, 401, 403, 404, 405, 409, 413, 415application/json
models/errors/ValidationErrorDto422application/json
models/errors/ErrorDto500application/json
models/errors/APIException4XX, 5XX*/*

update

Update an environment by its unique identifier environmentId. You can modify the environment name, identifier, color, and other configuration settings.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.UpdateEnvironmentRequestDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentsControllerV1UpdateMyEnvironmentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        EnvironmentsControllerV1UpdateMyEnvironmentResponse res = sdk.environments().update()
                .environmentId("<id>")
                .body(UpdateEnvironmentRequestDto.builder()
                    .build())
                .call();

        if (res.environmentResponseDto().isPresent()) {
            System.out.println(res.environmentResponseDto().get());
        }
    }
}

Parameters

ParameterTypeRequiredDescription
environmentIdString:heavy_check_mark:The unique identifier of the environment
idempotencyKeyOptional<String>:heavy_minus_sign:A header for idempotency purposes
bodyUpdateEnvironmentRequestDto:heavy_check_mark:N/A

Response

EnvironmentsControllerV1UpdateMyEnvironmentResponse

Errors

Error TypeStatus CodeContent Type
models/errors/ErrorDto414application/json
models/errors/ErrorDto400, 401, 403, 404, 405, 409, 413, 415application/json
models/errors/ValidationErrorDto422application/json
models/errors/ErrorDto500application/json
models/errors/APIException4XX, 5XX*/*

delete

Delete an environment by its unique identifier environmentId. This action is irreversible and will remove the environment and all its associated data.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentsControllerV1DeleteEnvironmentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        EnvironmentsControllerV1DeleteEnvironmentResponse res = sdk.environments().delete()
                .environmentId("<id>")
                .call();

        // handle response
    }
}

Parameters

ParameterTypeRequiredDescription
environmentIdString:heavy_check_mark:The unique identifier of the environment
idempotencyKeyOptional<String>:heavy_minus_sign:A header for idempotency purposes

Response

EnvironmentsControllerV1DeleteEnvironmentResponse

Errors

Error TypeStatus CodeContent Type
models/errors/ErrorDto414application/json
models/errors/ErrorDto400, 401, 403, 404, 405, 409, 413, 415application/json
models/errors/ValidationErrorDto422application/json
models/errors/ErrorDto500application/json
models/errors/APIException4XX, 5XX*/*