Create an EdgeWorker version with the API

Update your code by creating a new version.

Before you begin

To complete this step, you need to have the edgeWorkerId for an existing Edgeworker. Refer to the Download code with the EdgeWorkers API section for instructions on how to update an existing EdgeWorkers code bundle.

Develop quickly and iteratively by creating a new version of a code bundle.

How to

  1. Issue a POST request with the code bundle containing the modified script and the edgeWorkerId.
    POST /edgeworkers/v1/ids/{edgeWorkerId}/versions

    Example HTTPie syntax:

    http --timeout=90 --auth-type edgegrid -a <authgroup>: POST :/edgeworkers/v1/ids/42/versions Content-Type:application/gzip @code_bundle.tgz
    View the response for details on the EdgeWorker version.
    {
        "edgeWorkerId": 42,
        "version": 3,
        "accountId": "A-B-1CD23",
        "checksum": "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3",
        "createdBy": "jsmith",
        "createdTime": "2019-03-05T18:17:46Z"
    }
  2. Form a JSON request that specifies the network and version.
    {
        "network": "STAGING",
        "version": 3
    }
  3. Issue a POST request to activate the new version.
    POST /edgeworkers/v1/ids/{edgeWorkerId}/activations

    Example HTTPie syntax:

    http --timeout=90 --auth-type edgegrid -a <authgroup>: POST :/edgeworkers/v1/ids/42/activations network=STAGING version=3