

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Unity Projects Environments API (Public)",
    "version": "1.0.0",
    "description": "Public Unity API for managing project environments.",
    "contact": {
      "name": "Services Foundation Identity",
      "x-slack-channel-alerts": "#services-foundation-alerts"
    }
  },
  "servers": [
    {
      "url": "https://services.api.unity.com/unity/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ServiceAccount": []
    },
    {
      "UnityUser": []
    }
  ],
  "tags": [
    {
      "name": "environments"
    }
  ],
  "paths": {
    "/projects/{projectId}/environments": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectId"
        }
      ],
      "get": {
        "description": "List all the environments for a project.",
        "operationId": "unity-public-listEnvironments",
        "summary": "List environments for a project",
        "tags": [
          "environments"
        ],
        "parameters": [
          {
            "description": "If true, the API returns only archived environments. Otherwise it returns only active environments.",
            "in": "query",
            "name": "archived",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of environments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEnvironmentsResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          },
          "504": {
            "$ref": "#/components/responses/GatewayTimeout"
          }
        }
      },
      "post": {
        "description": "Create an environment under a project. A project can have at most 25 environments.",
        "operationId": "unity-public-createEnvironment",
        "summary": "Create an environment in a project",
        "tags": [
          "environments"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvironmentRequestBody"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Environment created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvironmentResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          },
          "504": {
            "$ref": "#/components/responses/GatewayTimeout"
          }
        }
      }
    },
    "/projects/{projectId}/environments/{environmentId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectId"
        },
        {
          "$ref": "#/components/parameters/EnvironmentId"
        }
      ],
      "get": {
        "description": "Get a single environment.",
        "operationId": "unity-public-getEnvironment",
        "summary": "Get an environment",
        "tags": [
          "environments"
        ],
        "responses": {
          "200": {
            "description": "The requested environment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvironmentResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          },
          "504": {
            "$ref": "#/components/responses/GatewayTimeout"
          }
        }
      },
      "delete": {
        "description": "Delete an existing environment. You cannot delete the default environment. That request returns 400.",
        "operationId": "unity-public-deleteEnvironment",
        "summary": "Delete an environment",
        "tags": [
          "environments"
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/ServiceUnavailable"
          },
          "504": {
            "$ref": "#/components/responses/GatewayTimeout"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ServiceAccount": {
        "type": "http",
        "scheme": "basic",
        "description": "Service Account key ID and secret. To get started with Authentication, please visit the\n[Service Account Authentication section](https://services.docs.unity.com/docs/service-account-auth)."
      },
      "UnityUser": {
        "type": "http",
        "scheme": "bearer",
        "description": "A Unity user access token."
      }
    },
    "parameters": {
      "ProjectId": {
        "name": "projectId",
        "in": "path",
        "description": "ID of the project. Usually a UUID, but some legacy projects use a numeric string, so treat it as a string.",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "8bdacc33-6eef-4577-beb0-633c86259f0b"
      },
      "EnvironmentId": {
        "name": "environmentId",
        "in": "path",
        "description": "ID of the environment",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "8bdacc33-6eef-4577-beb0-633c86259f0a"
      }
    },
    "schemas": {
      "EnvironmentResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "ID of the environment",
            "example": "390121ca-bb43-494f-b418-55be4e0c0faf"
          },
          "projectId": {
            "type": "string",
            "description": "ID of the project. Usually a UUID, but some legacy projects use a numeric string, so treat it as a string.",
            "example": "390121ca-bb43-494f-b418-55be4e0c0faf"
          },
          "name": {
            "type": "string",
            "description": "Name of the environment",
            "example": "production"
          },
          "isDefault": {
            "type": "boolean",
            "description": "Indicates if the environment is the default environment for the project",
            "example": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC date and time describing when the entity was created",
            "example": "2020-07-20T18:30:51.243Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC date and time describing when the entity was last updated",
            "example": "2020-08-25T11:55:20.651Z"
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC date and time describing when the entity was last archived (null if not archived)",
            "example": "2020-08-25T11:55:20.651Z",
            "nullable": true
          }
        }
      },
      "ListEnvironmentsResponse": {
        "title": "ListEnvironmentsResponse",
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "description": "An array of Environments",
            "items": {
              "$ref": "#/components/schemas/EnvironmentResponse"
            }
          }
        }
      },
      "EnvironmentRequestBody": {
        "description": "Data payload for creating an environment",
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "example": "staging",
            "description": "The name of the environment. The API accepts letters, digits, hyphens, and underscores, up to 255 characters. It trims whitespace and stores the name in lowercase."
          }
        }
      },
      "ErrorResponseBody": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "The HTTP status code (RFC7231, Section 6) generated by the origin server for this occurrence of the problem."
          },
          "detail": {
            "type": "string",
            "description": "A human-readable explanation specific to this occurrence of the problem."
          },
          "title": {
            "type": "string",
            "description": "A short, human-readable summary of the problem type."
          },
          "type": {
            "type": "string",
            "description": "A URI reference (RFC3986) that identifies the problem type."
          },
          "code": {
            "type": "integer",
            "description": "A service-specific error code."
          },
          "requestId": {
            "$ref": "#/components/schemas/RequestId"
          }
        },
        "required": [
          "type",
          "status",
          "detail",
          "title",
          "code"
        ]
      },
      "ServiceErrorResponse": {
        "title": "Service error response",
        "description": "Error response produced by the Environments service. The gateway adds the requestId field.",
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The error class name, such as ValidationError, NotFoundError, or ConflictError.",
            "example": "ConflictError"
          },
          "message": {
            "type": "string",
            "description": "A human-readable explanation specific to this occurrence of the problem."
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code (RFC7231, Section 6) generated by the origin server for this occurrence of the problem."
          },
          "errors": {
            "type": "array",
            "description": "Machine-readable validation messages. Present on validation errors only.",
            "items": {
              "type": "string"
            }
          },
          "code": {
            "type": "integer",
            "description": "A service-specific error code."
          },
          "type": {
            "type": "string",
            "description": "A URI reference (RFC3986) that identifies the problem type."
          },
          "requestId": {
            "$ref": "#/components/schemas/RequestId"
          }
        },
        "required": [
          "name",
          "message",
          "status",
          "code",
          "type"
        ]
      },
      "BasicErrorResponse": {
        "title": "Basic error response",
        "description": "Referenced from - https://tools.ietf.org/html/rfc7807#page-3",
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "A URI reference [RFC3986] that identifies the problem type. This\nspecification encourages that, when dereferenced, it provide\nhuman-readable documentation for the problem type (e.g., using HTML\n[W3C.REC-html5-20141028]). When this member is not present, its\nvalue is assumed to be \"about:blank\".\n\n[RFC3986]: https://www.rfc-editor.org/rfc/rfc3986\n[W3C.REC-html5-20141028]: https://www.rfc-editor.org/rfc/rfc7807#ref-W3C.REC-html5-20141028\n"
          },
          "title": {
            "type": "string",
            "description": "A short, human-readable summary of the problem type. It SHOULD NOT\nchange from occurrence to occurrence of the problem, except for\npurposes of localization (e.g., using proactive content negotiation;\nsee [RFC7231, Section 3.4]).\n\n[RFC7231, Section 3.4]: https://www.rfc-editor.org/rfc/rfc7231#section-3.4\n"
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code ([RFC7231, Section 6]) generated by the origin\nserver for this occurrence of the problem.\n\n[RFC7231, Section 6]: https://www.rfc-editor.org/rfc/rfc7231#section-6\n"
          },
          "requestId": {
            "$ref": "#/components/schemas/RequestId"
          },
          "code": {
            "description": "Service specific error code",
            "type": "integer"
          },
          "detail": {
            "type": "string",
            "description": "A human-readable explanation specific to this occurrence of the problem."
          }
        }
      },
      "RequestId": {
        "title": "Request ID",
        "type": "string",
        "description": "An identifier Unity uses internally to investigate what happened to\na particular request that went through the Unity Services or Game API\nGateway.\n"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ServiceErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Invalid Authentication Token",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponseBody"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponseBody"
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ServiceErrorResponse"
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ServiceErrorResponse"
            },
            "example": {
              "name": "ConflictError",
              "message": "Environment with the provided name already exists for this project.",
              "status": 409,
              "code": 58,
              "type": "https://services.docs.unity.com/docs/errors/#58",
              "requestId": "684529e0-265b-4875-8ee2-3f839c6aced2"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "The number of seconds until a request will be accepted"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/BasicErrorResponse"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Internal Server Error",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/BasicErrorResponse"
            }
          }
        }
      },
      "ServiceUnavailable": {
        "description": "Service Unavailable",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/BasicErrorResponse"
            }
          }
        }
      },
      "GatewayTimeout": {
        "description": "Gateway Timeout. The upstream service did not respond within 30 seconds.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/BasicErrorResponse"
            }
          }
        }
      }
    }
  }
}
```