Skip to content
Start here

List Versions

client.Workers.Scripts.Versions.List(ctx, scriptName, params) (*V4PagePagination[ScriptVersionListResponse], error)
GET/accounts/{account_id}/workers/scripts/{script_name}/versions

List of Worker Versions. The first version in the list is the latest version.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Workers Tail ReadWorkers Scripts WriteWorkers Scripts Read
ParametersExpand Collapse
scriptName string

Name of the script.

params ScriptVersionListParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
Deployable param.Field[bool]Optional

Query param: Only return versions that can be used in a deployment. Ignores pagination.

Page param.Field[int64]Optional

Query param: Current page.

PerPage param.Field[int64]Optional

Query param: Items per-page.

ReturnsExpand Collapse
type ScriptVersionListResponse struct{…}
ID stringOptional

Unique identifier for the version.

Metadata ScriptVersionListResponseMetadataOptional
AuthorEmail stringOptional

Email of the user who created the version.

AuthorID stringOptional

Identifier of the user who created the version.

CreatedOn stringOptional

When the version was created.

HasPreview boolOptional

Whether the version can be previewed.

ModifiedOn stringOptional

When the version was last modified.

Source ScriptVersionListResponseMetadataSourceOptional

The source of the version upload.

One of the following:
const ScriptVersionListResponseMetadataSourceUnknown ScriptVersionListResponseMetadataSource = "unknown"
const ScriptVersionListResponseMetadataSourceAPI ScriptVersionListResponseMetadataSource = "api"
const ScriptVersionListResponseMetadataSourceWrangler ScriptVersionListResponseMetadataSource = "wrangler"
const ScriptVersionListResponseMetadataSourceTerraform ScriptVersionListResponseMetadataSource = "terraform"
const ScriptVersionListResponseMetadataSourceDash ScriptVersionListResponseMetadataSource = "dash"
const ScriptVersionListResponseMetadataSourceCfCli ScriptVersionListResponseMetadataSource = "cf_cli"
const ScriptVersionListResponseMetadataSourceDashTemplate ScriptVersionListResponseMetadataSource = "dash_template"
const ScriptVersionListResponseMetadataSourceIntegration ScriptVersionListResponseMetadataSource = "integration"
const ScriptVersionListResponseMetadataSourceQuickEditor ScriptVersionListResponseMetadataSource = "quick_editor"
const ScriptVersionListResponseMetadataSourcePlayground ScriptVersionListResponseMetadataSource = "playground"
const ScriptVersionListResponseMetadataSourceWorkersci ScriptVersionListResponseMetadataSource = "workersci"
Number float64Optional

Sequential version number.

List Versions

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/workers"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  page, err := client.Workers.Scripts.Versions.List(
    context.TODO(),
    "this-is_my_script-01",
    workers.ScriptVersionListParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "items": [
      {
        "id": "18f97339-c287-4872-9bdd-e2135c07ec12",
        "metadata": {
          "author_email": "user@example.com",
          "author_id": "408cbcdfd4dda4617efef40b04d168a1",
          "created_on": "2022-11-08T17:19:29.176266Z",
          "hasPreview": true,
          "modified_on": "2022-11-08T17:19:29.176266Z",
          "source": "api"
        },
        "number": 1
      }
    ]
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "items": [
      {
        "id": "18f97339-c287-4872-9bdd-e2135c07ec12",
        "metadata": {
          "author_email": "user@example.com",
          "author_id": "408cbcdfd4dda4617efef40b04d168a1",
          "created_on": "2022-11-08T17:19:29.176266Z",
          "hasPreview": true,
          "modified_on": "2022-11-08T17:19:29.176266Z",
          "source": "api"
        },
        "number": 1
      }
    ]
  },
  "success": true
}