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
- 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
Compares workflows and other resources between the source and target environments, returning detailed diff information including additions, modifications, and deletions.
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());
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
targetEnvironmentId |
String | ✔️ | Target environment ID (MongoDB ObjectId) to compare against | 6615943e7ace93b0540ae377 |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes | |
body |
DiffEnvironmentRequestDto | ✔️ | Diff request configuration |
EnvironmentsControllerDiffEnvironmentResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ErrorDto | 414 | application/json |
| models/errors/ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| models/errors/ValidationErrorDto | 422 | application/json |
| models/errors/ErrorDto | 500 | application/json |
| models/errors/APIException | 4XX, 5XX | */* |
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.
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());
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
targetEnvironmentId |
String | ✔️ | Target environment ID (MongoDB ObjectId) to publish resources to | 6615943e7ace93b0540ae377 |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes | |
body |
PublishEnvironmentRequestDto | ✔️ | Publish request configuration |
EnvironmentsControllerPublishEnvironmentResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ErrorDto | 414 | application/json |
| models/errors/ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| models/errors/ValidationErrorDto | 422 | application/json |
| models/errors/ErrorDto | 500 | application/json |
| models/errors/APIException | 4XX, 5XX | */* |
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.
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());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
body |
CreateEnvironmentRequestDto | ✔️ | N/A |
EnvironmentsControllerV1CreateEnvironmentResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ErrorDto | 402, 414 | application/json |
| models/errors/ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| models/errors/ValidationErrorDto | 422 | application/json |
| models/errors/ErrorDto | 500 | application/json |
| models/errors/APIException | 4XX, 5XX | */* |
This API returns a list of environments for the current organization. Each environment contains its configuration, API keys (if user has access), and metadata.
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());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
EnvironmentsControllerV1ListMyEnvironmentsResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ErrorDto | 414 | application/json |
| models/errors/ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| models/errors/ValidationErrorDto | 422 | application/json |
| models/errors/ErrorDto | 500 | application/json |
| models/errors/APIException | 4XX, 5XX | */* |
Update an environment by its unique identifier environmentId. You can modify the environment name, identifier, color, and other configuration settings.
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());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
environmentId |
String | ✔️ | The unique identifier of the environment |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
body |
UpdateEnvironmentRequestDto | ✔️ | N/A |
EnvironmentsControllerV1UpdateMyEnvironmentResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ErrorDto | 414 | application/json |
| models/errors/ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| models/errors/ValidationErrorDto | 422 | application/json |
| models/errors/ErrorDto | 500 | application/json |
| models/errors/APIException | 4XX, 5XX | */* |
Delete an environment by its unique identifier environmentId. This action is irreversible and will remove the environment and all its associated data.
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
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
environmentId |
String | ✔️ | The unique identifier of the environment |
idempotencyKey |
Optional<String> | ➖ | A header for idempotency purposes |
EnvironmentsControllerV1DeleteEnvironmentResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/ErrorDto | 414 | application/json |
| models/errors/ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| models/errors/ValidationErrorDto | 422 | application/json |
| models/errors/ErrorDto | 500 | application/json |
| models/errors/APIException | 4XX, 5XX | */* |