Create an environment

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.

POST
/v1/environments

Authorization

Authorization<token>

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

In: header

Request Body

application/jsonRequired
nameRequiredstring

Name of the environment to be created

parentIdstring

MongoDB ObjectId of the parent environment (optional)

colorRequiredstring

Hex color code for the environment

Header Parameters

idempotency-keystring

A header for idempotency purposes

Response Body

Created

_idRequiredstring

Unique identifier of the environment

nameRequiredstring

Name of the environment

_organizationIdRequiredstring

Organization ID associated with the environment

identifierRequiredstring

Unique identifier for the environment

apiKeysarray<object>

List of API keys associated with the environment

@minItems 0

_parentIdstring

Parent environment ID

slugstring

URL-friendly slug for the environment

export interface Response {
  /**
   * Unique identifier of the environment
   */
  _id: string;
  /**
   * Name of the environment
   */
  name: string;
  /**
   * Organization ID associated with the environment
   */
  _organizationId: string;
  /**
   * Unique identifier for the environment
   */
  identifier: string;
  /**
   * List of API keys associated with the environment
   *
   * @minItems 0
   */
  apiKeys?: ApiKeyDto[];
  /**
   * Parent environment ID
   */
  _parentId?: string;
  /**
   * URL-friendly slug for the environment
   */
  slug?: string;
}
export interface ApiKeyDto {
  /**
   * API key
   */
  key: string;
  /**
   * User ID associated with the API key
   */
  _userId: string;
  /**
   * Hashed representation of the API key
   */
  hash?: string;
}
 
curl -X POST "https://api.novu.co/v1/environments" \
  -H "idempotency-key: string" \
  -H "Authorization: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Environment",
    "parentId": "60d5ecb8b3b3a30015f3e1a1",
    "color": "#3498db"
  }'
{
  "_id": "60d5ecb8b3b3a30015f3e1a1",
  "name": "Production Environment",
  "_organizationId": "60d5ecb8b3b3a30015f3e1a2",
  "identifier": "prod-env-01",
  "apiKeys": [
    {
      "key": "sk_test_1234567890abcdef",
      "_userId": "60d5ecb8b3b3a30015f3e1a4",
      "hash": "hash_value_here"
    }
  ],
  "_parentId": "60d5ecb8b3b3a30015f3e1a3",
  "slug": "production"
}

On this page

No Headings
Edit this page on GitHub