Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview

Create an environment

Creates an environment in a project, empty or as a copy of another. A copy takes the code of from, and its data when data is set, which also needs data:read on the source. Secrets are never copied.

POST/_luna/orgs/{org}/projects/{project}/environments
Authorization
AuthorizationBearer token · headerrequired

An account key (la_…), an API key (lt_…) or a session token (ls_…). The scopes listed are the permissions the operation needs.

Scopes:environments:write
Path parameters
orgstringrequired

The organisation, by its slug.

projectstringrequired

The project, by its slug.

Request body
requiredapplication/json
namestringrequired

Lower-case letters, digits and single dashes. production is taken.

fromstring | null

An environment to copy the code from, by its name or its id. Leave it out for an empty environment.

expiresIninteger<int64> | null

Seconds from now until the environment is deleted. Leave it out for one that stays.

min 0
databoolean

With from, copies the data of its lunas as well as its code.

Responses
200

The new environment.

idstringrequired
namestringrequired
tenantstringrequired

The environment's default tenant. Deploys, secrets, keys and telemetry name it.

createdMsinteger<int64>required
min 0
createdBystringrequired

Who made it: an email address or a key's label.

expiresMsinteger<int64> | null

When it is deleted, in milliseconds since the Unix epoch. Null when it stays.

min 0
fromstring | null

The environment it was copied from.

copyCopyProgress | null
Show properties
One of:
CopyProgress
fromstringrequired

The environment the data comes from.

statestringrequired

counting, copying, done or failed.

atMsinteger<int64>required

The moment of the source the copy is of, in milliseconds since the Unix epoch.

min 0
totalinteger<int64> | null

How many lunas there are to copy. Null until they have been counted.

min 0
doneinteger<int64>required

How many lunas are dealt with: copied or skipped.

min 0
copiedinteger<int64>required
min 0
skippedinteger<int64>required

Lunas passed over because they were made after atMs or copied by an earlier try.

min 0
errorstring | null

Why a failed copy stopped.

startedMsinteger<int64>required
min 0
finishedMsinteger<int64> | null
min 0
null
null
versioninteger<int64> | null

The version of the code copied into it, when it was made from another environment.

min 0
default

The request failed. The status says how and error.message says why.

errorErrorDetailrequired
Show properties
codestring | null

A code for programs to branch on, when the error has one.

messagestringrequired

What went wrong, in a sentence a person can read.

Try it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST 'https://luna.example.com/_luna/orgs/string/projects/string/environments' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "from": "string",
  "expiresIn": 0,
  "data": true
}'
Response
{
  "id": "string",
  "name": "string",
  "tenant": "string",
  "createdMs": 0,
  "createdBy": "string",
  "expiresMs": 0,
  "from": "string",
  "copy": {
    "from": "string",
    "state": "string",
    "atMs": 0,
    "total": 0,
    "done": 0,
    "copied": 0,
    "skipped": 0,
    "error": "string",
    "startedMs": 0,
    "finishedMs": 0
  },
  "version": 0
}

Was this page helpful?