> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://akamai.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://akamai.ferndocs.com/_mcp/server.

# Create a new version

POST https://{hostname}/edgeworkers/v1/ids/{edgeWorkerId}/versions
Content-Type: application/gzip

Create a new version of an EdgeWorker. In order to run this operation you need to build an [EdgeWorkers code bundle](https://techdocs.akamai.com/edgeworkers/docs/create-a-code-bundle) and save it in GZIP format. You need to provide the GZIP binary file in the request body, with a `Content-Type` of `application/gzip`.

Reference: https://akamai.ferndocs.com/edge-workers/api/edge-workers-api/versions/post-versions

## Request

### Path parameters

- `edgeWorkerId` (string, required)

### Query parameters

- `accountSwitchKey` (string, optional) — For customers who manage more than one account, this [runs the operation from another account](https://techdocs.akamai.com/developer/docs/manage-many-accounts-with-one-api-client). The Identity and Access Management API provides a [list of available account switch keys](https://techdocs.akamai.com/iam-api/reference/get-client-account-switch-keys).

### Body (application/gzip)

This endpoint expects binary data of type application/gzip.

- Binary request body.

## Response

### 201

Provides details for an EdgeWorker version.

- `accountId` (string, required) — Identifier for the account where the EdgeWorker was created.
- `checksum` (string, required) — A SHA-256 hash digest of the tarball.
- `createdBy` (string, required) — Username of the person who created the EdgeWorker version.
- `createdTime` (datetime, required) — ISO 8601 timestamp indicating when the EdgeWorker version was created.
- `edgeWorkerId` (integer, required) — Unique identifier of the EdgeWorker.
- `version` (string, required) — Unique identifier of the EdgeWorker version.
- `sequenceNumber` (string, optional) — An incrementing number indicating the upload order of the EdgeWorker versions.

## Examples

**Response**

```json
{
  "accountId": "A-CCT5678",
  "checksum": "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3",
  "createdBy": "jsmith",
  "createdTime": "2020-07-05T18:17:46Z",
  "edgeWorkerId": 42,
  "version": "5"
}
```

**SDK Code**

```python
import requests

url = "https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions"

querystring = {"accountSwitchKey":"{{accountSwitchKey}}"}

headers = {"Content-Type": "application/gzip"}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D';
const options = {method: 'POST', headers: {'Content-Type': 'application/gzip'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Content-Type", "application/gzip")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/gzip'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D")
  .header("Content-Type", "application/gzip")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D', [
  'headers' => [
    'Content-Type' => 'application/gzip',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/gzip");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/gzip"]

let request = NSMutableURLRequest(url: NSURL(string: "https://{hostname}/edgeworkers/v1/ids/edgeWorkerId/versions?accountSwitchKey=%7B%7BaccountSwitchKey%7D%7D")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```