---
title: "Saves every file of the lambda as a new version"
method: POST
path: "/lambdas/{privateKey}/versions"
tags: ["Versions"]
---

# Saves every file of the lambda as a new version

`POST /lambdas/{privateKey}/versions`

## Request

- Base URL: `https://genhttp.dev/api/v1`
- URL: `https://genhttp.dev/api/v1/lambdas/{privateKey}/versions`
- Auth: none declared

`files` is the whole lambda, `lambda.cs` first: a file the newest version has and this request does not is not in
the new version. To change a few files, `POST …/versions/changes` sends only those.

A file name may be refused - a C# file has to be named as C# names its files, a resource needs an extension, and
no name may hold spaces or be one Windows reserves; the message says what is wrong with which. The files together
may not come to more than the tier of the lambda allows a version (see the limits). Whether the code compiles is
not checked unless it is deployed: `POST …/code/check` compiles it without saving.

## Path parameters

- `privateKey` string, required

## Query parameters

- `deploy` boolean

## Request body

- VersionRequest: Every file of a lambda, to be saved as its next version, and why it was written.
  - `Files` LambdaFile[], nullable: Every file of the lambda, `lambda.cs` first
    - `Name` string: Its path, with forward slashes: `lambda.cs`, `Store.cs`, `resources/web/index.html`, `docs/product.md`. Case sensitive, and also what the compiler's messages name.
    - `Code` string: Its content: the text itself, or base64 where `encoding` says so
    - `Encoding` string, nullable: `base64` for a file that is not text - a picture, a font; left out for text. C# files are always text.
    - `IsCompiled` boolean
    - `IsCode` boolean
    - `IsResource` boolean
    - `Bytes` string, byte
  - `Specification` string, nullable: What the user wants from this version and why - their requirements, in their own words where possible. Optional, and cut past 4000 characters.
  - `Change` string, nullable: What this version changes, in one line for the owner. Optional, and cut past 500 characters.

## Response `201`

The version was saved. If it was to be deployed as well, `deployment` says whether that worked.

- SavedVersionResponse: A version that was just saved.
  - `Version` integer: Its number
  - `Created` string, date-time: When it was saved
  - `Specification` string, nullable: What the user wanted and why, as it was kept
  - `Change` string, nullable: What it changes, as it was kept
  - `Origin` string, nullable: How it was saved
  - `Deployment` DeploymentOutcomeResponse: What came of an attempt to put a version online.
    - `Success` boolean: Whether it compiled and is online now. Where it is not, whatever was online before still is.
    - `Lambda` LambdaResponse: A lambda, as whoever holds its editor key sees it.
      - `PublicKey` string: Names its address below the hosting domain. Not a secret; its owner may change it.
      - `PrivateKey` string: The editor key, which authorizes every call about the lambda. Treat it like a password.
      - `Tier` string: `Free`, `Premium` or `Demo`, assigned by the operator. Decides its limits, whether it is kept online while nobody uses it, and whether it may answer at a domain of its own.
      - `Created` string, date-time: When it was created
      - `Modified` string, date-time: When something about it last changed: a save, a deployment, a setting
      - `ActiveVersion` integer, nullable: The version that is online; absent while nothing is
      - `LatestVersion` integer, nullable: The newest version saved, which may be ahead of the one online
      - `PublicUrl` string: Its address below the hosting domain, named after its public key: `https://quiz.genhttp.run/`. While it answers at a domain of its own, this address sends its visitors on to the domain.
      - `EditorPath` string: Where its editor is on this site: `/editor/{privateKey}`. Holds the editor key.
      - `DeployedAt` string, date-time, nullable: When the version online went online; absent while nothing is
      - `DeployedUntil` string, date-time, nullable: When it is taken offline unless it is visited or edited before then - each visit and each edit moves this on. Absent while it is offline, and for a tier that keeps it online.
      - `KeptUntil` string, date-time, nullable: When it is deleted unless it is visited or edited before then. Absent for a tier that keeps it.
      - `Domain` string, nullable: The domain of its own it is configured to answer at, whether or not its tier lets it
      - `DomainServed` boolean: Whether it answers at that domain: it has one, and its tier includes it
      - `Address` string: Where to link to it: its domain while that is served, `publicUrl` otherwise
      - `View` string: How its editor opens for somebody who has not chosen a view of their own: `Full` or `Simple`
      - `GitPath` string: Where it is cloned with git and pushed to, on this site. The versions are the commits of `main`, the features the other branches. Holds the editor key, like the editor's path.
    - `Diagnostics` CompilationDiagnostic[]: What the compiler said: the errors that kept it offline, or the warnings of a version that went online
      - `Severity` string: `Error`, which keeps the code from going online, or `Warning`
      - `Id` string: What kind of message it is: the C# compiler's (`CS1002`), `LAMBDA0001` for something lambdas may not do, `LAMBDA0002` for a handler the platform cannot serve, or `LAMBDA` for anything else the platform refused
      - `Message` string: What is wrong, and often what to do about it
      - `Line` integer: The line in the file, counting from 1; 0 when it is about no line
      - `Column` integer: The column in the line, counting from 1; 0 when it is about no line
      - `File` string, nullable: The name of the file it is in, as the lambda names it; absent when it is about none of them

## Other responses

- `400`: There are no files, `lambda.cs` is not the first, a name or an encoding cannot be used, or the files are larger than a version may be. Nothing was saved.
- `403`: The lambda is a demo, which anybody may read and nobody may change. Create a lambda of your own from it instead: `POST /lambdas` with the demo's id as `template`.
- `404`: No lambda has this editor key. A key that never existed and the key of a deleted lambda are answered alike.

---

[API](https://skmtc.dev/genhttp/apis/genhttp-lambda-api.md) · [All operations](https://skmtc.dev/genhttp/apis/genhttp-lambda-api/llms.txt) · [OpenAPI document](https://skmtc.dev/genhttp/apis/genhttp-lambda-api/revisions/8b36699e03df?raw)
