Skip to content
Start here

Get Script Content

client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Get(ctx, dispatchNamespace, scriptName, query) (*Response, error)
GET/accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/content

Fetch script content from a script uploaded to a Workers for Platforms namespace.

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
dispatchNamespace string

Name of the Workers for Platforms dispatch namespace.

scriptName string

Name of the script, used in URLs and route configuration.

query DispatchNamespaceScriptContentGetParams
AccountID param.Field[string]

Identifier.

maxLength32
ReturnsExpand Collapse
type DispatchNamespaceScriptContentGetResponse interface{…}

Get Script Content

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_for_platforms"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  content, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Get(
    context.TODO(),
    "my-dispatch-namespace",
    "this-is_my_script-01",
    workers_for_platforms.DispatchNamespaceScriptContentGetParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", content)
}
Returns Examples