Upload Version
client.workers.scripts.versions.create(stringscriptName, VersionCreateParams { account_id, metadata, bindings_inherit, files } params, RequestOptionsoptions?): VersionCreateResponse { resources, id, exports_reconciliation, 3 more }
POST/accounts/{account_id}/workers/scripts/{script_name}/versions
Upload a Worker Version without deploying to Cloudflare’s network. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Upload Version
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const version = await client.workers.scripts.versions.create('this-is_my_script-01', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
metadata: { main_module: 'worker.js' },
});
console.log(version.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": {
"resources": {
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"script": {
"etag": "13a3240e8fb414561b0366813b0b8f42b3e6cfa0d9e70e99835dae83d0d8a794",
"handlers": [
"fetch"
],
"last_deployed_from": "api",
"named_handlers": [
{
"handlers": [
"fetch"
],
"name": "MyClass"
}
]
},
"script_runtime": {
"compatibility_date": "2022-11-08",
"compatibility_flags": [
"x"
],
"exports": {
"Admin": {
"type": "worker",
"cache": {
"enabled": true
},
"state": "created"
},
"Counter": {
"storage": "sqlite",
"type": "durable-object",
"container": "my-container",
"state": "created"
},
"OldCounter": {
"state": "renamed",
"type": "durable-object"
},
"default": {
"type": "worker",
"cache": {
"enabled": false
},
"state": "created"
}
},
"limits": {
"cpu_ms": 50
},
"migration_tag": "v1",
"usage_model": "standard"
}
},
"id": "18f97339-c287-4872-9bdd-e2135c07ec12",
"exports_reconciliation": {
"created": [
"string"
],
"deleted": [
"string"
],
"info": [
{
"class": "class",
"message": "message",
"scenario": "code_class_not_in_exports",
"namespace_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"referencing_scripts": [
"string"
]
}
],
"removable_entries": [
"string"
],
"renamed": [
{
"from": "from",
"to": "to"
}
],
"transfer_pending": [
{
"class": "class",
"from": "from"
}
],
"transferred": [
{
"class": "class",
"phase": "committed",
"to": "to"
}
],
"updated": [
"string"
],
"warnings": [
{
"class": "class",
"message": "message",
"scenario": "code_class_not_in_exports",
"namespace_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
]
},
"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,
"startup_time_ms": 10
},
"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": {
"resources": {
"bindings": [
{
"name": "MY_ENV_VAR",
"text": "my_data",
"type": "plain_text"
}
],
"script": {
"etag": "13a3240e8fb414561b0366813b0b8f42b3e6cfa0d9e70e99835dae83d0d8a794",
"handlers": [
"fetch"
],
"last_deployed_from": "api",
"named_handlers": [
{
"handlers": [
"fetch"
],
"name": "MyClass"
}
]
},
"script_runtime": {
"compatibility_date": "2022-11-08",
"compatibility_flags": [
"x"
],
"exports": {
"Admin": {
"type": "worker",
"cache": {
"enabled": true
},
"state": "created"
},
"Counter": {
"storage": "sqlite",
"type": "durable-object",
"container": "my-container",
"state": "created"
},
"OldCounter": {
"state": "renamed",
"type": "durable-object"
},
"default": {
"type": "worker",
"cache": {
"enabled": false
},
"state": "created"
}
},
"limits": {
"cpu_ms": 50
},
"migration_tag": "v1",
"usage_model": "standard"
}
},
"id": "18f97339-c287-4872-9bdd-e2135c07ec12",
"exports_reconciliation": {
"created": [
"string"
],
"deleted": [
"string"
],
"info": [
{
"class": "class",
"message": "message",
"scenario": "code_class_not_in_exports",
"namespace_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"referencing_scripts": [
"string"
]
}
],
"removable_entries": [
"string"
],
"renamed": [
{
"from": "from",
"to": "to"
}
],
"transfer_pending": [
{
"class": "class",
"from": "from"
}
],
"transferred": [
{
"class": "class",
"phase": "committed",
"to": "to"
}
],
"updated": [
"string"
],
"warnings": [
{
"class": "class",
"message": "message",
"scenario": "code_class_not_in_exports",
"namespace_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
]
},
"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,
"startup_time_ms": 10
},
"success": true
}