Put script content

Put script content from a worker with an environment

/accounts/{account_identifier}/workers/services/{service_name}/environments/{environment_name}/content

put

Worker Environment

worker-environment-put-script-content

Debug "planAvailability"

null

Debug "tokenPermissions"

{
  "enum": [
    "com.cloudflare.edge.worker.script.create"
  ]
}

Debug "parameters"

[
  {
    "in": "path",
    "name": "account_identifier",
    "required": true,
    "schema": {
      "description": "Identifier",
      "example": "023e105f4ecef8ad9ca31a8372d0c353",
      "maxLength": 32,
      "readOnly": true,
      "type": "string"
    }
  },
  {
    "in": "path",
    "name": "service_name",
    "required": true,
    "schema": {
      "description": "Name of Worker to bind to",
      "example": "my-worker",
      "type": "string"
    }
  },
  {
    "in": "path",
    "name": "environment_name",
    "required": true,
    "schema": {
      "description": "Optional environment if the Worker utilizes one.",
      "example": "production",
      "type": "string"
    }
  },
  {
    "description": "The multipart name of a script upload part containing script content in service worker format. Alternative to including in a metadata part.",
    "in": "header",
    "name": "CF-WORKER-BODY-PART",
    "schema": {
      "type": "string"
    }
  },
  {
    "description": "The multipart name of a script upload part containing script content in es module format. Alternative to including in a metadata part.",
    "in": "header",
    "name": "CF-WORKER-MAIN-MODULE-PART",
    "schema": {
      "type": "string"
    }
  }
]

Debug "requestBody"

{
  "content": {
    "multipart/form-data": {
      "encoding": {
        "<any part name>": {
          "contentType": "application/javascript+module, text/javascript+module, application/javascript, text/javascript, application/wasm, text/plain, application/octet-stream"
        }
      },
      "schema": {
        "properties": {
          "<any part name>": {
            "description": "A module comprising a Worker script, often a javascript file. Multiple modules may be provided as separate named parts, but at least one module must be present. This should be referenced either in the metadata as `main_module` (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` (esm) /`CF-WORKER-BODY-PART` (service worker) by part name.",
            "items": {
              "format": "binary",
              "type": "string"
            },
            "type": "array"
          },
          "metadata": {
            "description": "JSON encoded metadata about the uploaded parts and Worker configuration.",
            "properties": {
              "body_part": {
                "description": "Name of the part in the multipart request that contains the script (e.g. the file adding a listener to the `fetch` event). Indicates a `service worker syntax` Worker.",
                "example": "worker.js",
                "type": "string"
              },
              "main_module": {
                "description": "Name of the part in the multipart request that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker.",
                "example": "worker.js",
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      }
    }
  },
  "required": true
}

Debug "responses"

{
  "200": {
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "created_on": {
              "description": "When the script was created.",
              "example": "2017-01-01T00:00:00Z",
              "format": "date-time",
              "readOnly": true,
              "type": "string"
            },
            "etag": {
              "description": "Hashed script content, can be used in a If-None-Match header when updating.",
              "example": "ea95132c15732412d22c1476fa83f27a",
              "readOnly": true,
              "type": "string"
            },
            "id": {
              "description": "The id of the script in the Workers system. Usually the script name.",
              "example": "my-workers-script",
              "readOnly": true,
              "type": "string"
            },
            "logpush": {
              "description": "Whether Logpush is turned on for the Worker.",
              "example": false,
              "type": "boolean"
            },
            "modified_on": {
              "description": "When the script was last modified.",
              "example": "2017-01-01T00:00:00Z",
              "format": "date-time",
              "readOnly": true,
              "type": "string"
            },
            "pipeline_hash": {
              "description": "Deprecated. Deployment metadata for internal usage.",
              "example": "ea95132c15732412d22c1476fa83f27a",
              "readOnly": true,
              "type": "string"
            },
            "placement_mode": {
              "description": "Specifies the placement mode for the Worker (e.g. 'smart').",
              "example": "smart",
              "type": "string"
            },
            "tail_consumers": {
              "description": "List of Workers that will consume logs from the attached Worker.",
              "items": {
                "description": "A reference to a script that will consume logs from the attached Worker.",
                "properties": {
                  "environment": {
                    "description": "Optional environment if the Worker utilizes one.",
                    "example": "production",
                    "type": "string"
                  },
                  "namespace": {
                    "description": "Optional dispatch namespace the script belongs to.",
                    "example": "my-namespace",
                    "type": "string"
                  },
                  "service": {
                    "description": "Name of Worker that is to be the consumer.",
                    "example": "my-log-consumer",
                    "type": "string"
                  }
                },
                "required": [
                  "service"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "usage_model": {
              "description": "Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound').",
              "example": "unbound",
              "pattern": "^(bundled|unbound)$",
              "type": "string"
            }
          }
        }
      }
    },
    "description": "Put script content"
  },
  "4XX": {
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "errors": {
              "allOf": [
                {
                  "example": [],
                  "items": {
                    "properties": {
                      "code": {
                        "minimum": 1000,
                        "type": "integer"
                      },
                      "message": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "code",
                      "message"
                    ],
                    "type": "object",
                    "uniqueItems": true
                  },
                  "type": "array"
                }
              ],
              "example": [
                {
                  "code": 7003,
                  "message": "No route for the URI"
                }
              ],
              "minLength": 1
            },
            "messages": {
              "allOf": [
                {
                  "example": [],
                  "items": {
                    "properties": {
                      "code": {
                        "minimum": 1000,
                        "type": "integer"
                      },
                      "message": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "code",
                      "message"
                    ],
                    "type": "object",
                    "uniqueItems": true
                  },
                  "type": "array"
                }
              ],
              "example": []
            },
            "result": {
              "enum": [
                null
              ],
              "nullable": true,
              "type": "object"
            },
            "success": {
              "description": "Whether the API call was successful",
              "enum": [
                false
              ],
              "example": false,
              "type": "boolean"
            }
          },
          "required": [
            "success",
            "errors",
            "messages",
            "result"
          ],
          "type": "object"
        }
      }
    },
    "description": "Put script content failure"
  }
}

Debug "security"

[
  {
    "api_token": []
  },
  {
    "api_email": [],
    "api_key": []
  }
]