---
title: "Create an environment"
method: POST
path: "/_api/environments"
tags: ["Environments"]
---

# Create an environment

`POST /_api/environments`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_api/environments/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates a new environment.

**Note**: Requires *administrator* permissions.

## Request body

- CreateEnvironmentDatabase
  - `name` string, required: Has to contain a valid environment name.
  - `tenant` string: Name of the tenant to associate with environment. This option is applicable and optional when system tenant *_mm* invokes the API. Other tenants should not specify this option as the tenant invoking API shall be associated with environment.
  - `options` CreateEnvironmentDatabaseOptions: Has to be a dictionary of Database options used when creating the environment. If this is not specified, default options are used. If one of the dict members is not specified, defaults is used for that dict member. The members of the *options* dictionary are as follows:
    - `spotDc` string: The Edge Location (data center) where on-spot operations for the given environment is performed. By default, a random data center is chosen from those which are capable.
    - `metadata` object: Object with user defined key-value pairs.
  - `users` string[]: Enter an array of user ids that has admin access to the new environment. If this field is left blank, the default user *root* has admin access.

## Response `201`

Successfully created new environment.

- CreateEnvironmentExamplesRc201
  - `code` integer: HTTP response code.
  - `error` boolean: Flag if there is an error in response. *False* for this response.
  - `result` boolean: Whether the environment was created successfully.

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `403`: Failed to validate because you do not have access to the server.
- `409`: Failed because environment already exists.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
