Skip to main content

secrets

Creates, updates, deletes, gets or lists a secrets resource.

Overview

Namesecrets
TypeResource
Idcloudflare.workers_for_platforms.secrets

Fields

The following fields are returned by SELECT queries:

Get script secret (Workers for Platforms).

NameDatatypeDescription
namestringA JavaScript variable name for the binding. (example: myBinding)
algorithmobjectAlgorithm-specific key parameters. Learn more.
formatstringData format of the key. Learn more. (raw, pkcs8, spki, jwk) (example: raw)
key_base64stringBase64-encoded key data. Required if format is "raw", "pkcs8", or "spki".
key_jwkobjectKey data in JSON Web Key format. Required if format is "jwk".
textstringThe secret value to use. (example: My secret.)
typestringThe kind of resource that the binding provides. (secret_text)
usagesarrayAllowed operations with the key. Learn more. (x-stainless-collection-type: set)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, dispatch_namespace, script_name, secret_nameurl_encodedGet a given secret binding (value omitted) on a script uploaded to a Workers for Platforms namespace.
listselectaccount_id, dispatch_namespace, script_nameList secrets bound to a script uploaded to a Workers for Platforms namespace.
updatereplaceaccount_id, dispatch_namespace, script_name, name, typeAdd a secret to a script uploaded to a Workers for Platforms namespace.
deletedeleteaccount_id, dispatch_namespace, script_name, secret_nameurl_encodedRemove a secret from a script uploaded to a Workers for Platforms namespace.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
dispatch_namespacestringThe Workers-for-Platforms dispatch namespace.
script_namestringThe Worker script name.
secret_namestring
url_encodedboolean

SELECT examples

Get a given secret binding (value omitted) on a script uploaded to a Workers for Platforms namespace.

SELECT
name,
algorithm,
format,
key_base64,
key_jwk,
text,
type,
usages
FROM cloudflare.workers_for_platforms.secrets
WHERE account_id = '{{ account_id }}' -- required
AND dispatch_namespace = '{{ dispatch_namespace }}' -- required
AND script_name = '{{ script_name }}' -- required
AND secret_name = '{{ secret_name }}' -- required
AND url_encoded = '{{ url_encoded }}'
;

REPLACE examples

Add a secret to a script uploaded to a Workers for Platforms namespace.

REPLACE cloudflare.workers_for_platforms.secrets
SET
name = '{{ name }}',
text = '{{ text }}',
type = '{{ type }}',
algorithm = '{{ algorithm }}',
format = '{{ format }}',
key_base64 = '{{ key_base64 }}',
key_jwk = '{{ key_jwk }}',
usages = '{{ usages }}'
WHERE
account_id = '{{ account_id }}' --required
AND dispatch_namespace = '{{ dispatch_namespace }}' --required
AND script_name = '{{ script_name }}' --required
AND name = '{{ name }}' --required
AND type = '{{ type }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Remove a secret from a script uploaded to a Workers for Platforms namespace.

DELETE FROM cloudflare.workers_for_platforms.secrets
WHERE account_id = '{{ account_id }}' --required
AND dispatch_namespace = '{{ dispatch_namespace }}' --required
AND script_name = '{{ script_name }}' --required
AND secret_name = '{{ secret_name }}' --required
AND url_encoded = '{{ url_encoded }}'
;