Skip to content
Start here

List Versions

client.workers.scripts.versions.list(stringscriptName, VersionListParams { account_id, deployable, page, per_page } params, RequestOptionsoptions?): V4PagePagination<VersionListResponse { id, metadata, number } >
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: VersionListParams { account_id, deployable, page, per_page }
account_id: string

Path param: Identifier.

maxLength32
deployable?: boolean

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

page?: number

Query param: Current page.

per_page?: number

Query param: Items per-page.

ReturnsExpand Collapse
VersionListResponse { id, metadata, number }
id?: string

Unique identifier for the version.

metadata?: Metadata { author_email, author_id, created_on, 3 more }
author_email?: string

Email of the user who created the version.

author_id?: string

Identifier of the user who created the version.

created_on?: string

When the version was created.

hasPreview?: boolean

Whether the version can be previewed.

modified_on?: string

When the version was last modified.

source?: "unknown" | "api" | "wrangler" | 7 more

The source of the version upload.

One of the following:
"unknown"
"api"
"wrangler"
"terraform"
"dash"
"dash_template"
"integration"
"quick_editor"
"playground"
"workersci"
number?: number

Sequential version number.

List Versions

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const versionListResponse of client.workers.scripts.versions.list(
  'this-is_my_script-01',
  { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
)) {
  console.log(versionListResponse.id);
}
{
  "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
}