Skip to content

ptkl sandbox

Manage Sandbox sparks and runtimes from the command line.


Overview

Sandbox is the platform's compute layer for user-deployed code, with two execution models:

  • Spark — short-lived FaaS-style functions/apps, deployed by version, promoted from dev to live, and invoked by name (spark exec).
  • Runtime — long-running deployments (user-defined APIs).

ptkl sandbox maps 1:1 onto the SDK Sandbox client (@ptkl/sdk/beta).


Subcommands

Subcommand Description
spark list List all sparks for the current project
spark deploy Deploy a specific spark version to the dev environment
spark release Release a deployed spark version to the live/public environment
spark cancel Cancel an in-progress spark deployment
spark exec Execute a deployed spark by name
spark logs Fetch logs for a spark
runtime list List all runtimes for the current project
runtime deploy (Re)deploy a runtime
runtime restart Restart a running runtime
runtime logs Fetch logs for a runtime
tier Get the current project's spark tier (plan/quota)

Spark

ptkl sandbox spark list

List all sparks for the current project.

ptkl sandbox spark list

ptkl sandbox spark deploy

Deploy a specific spark version to the dev environment.

ptkl sandbox spark deploy -i <uuid> -v <version>
Option Description
-i, --id <uuid> Spark uuid (required)
-v, --version <version> Version to deploy (required)
ptkl sandbox spark deploy --id 3fae1c2e-... --version 3

ptkl sandbox spark release

Release a deployed spark version to the live/public environment.

ptkl sandbox spark release -i <uuid> -v <version>
Option Description
-i, --id <uuid> Spark uuid (required)
-v, --version <version> Version to release (required)
ptkl sandbox spark release --id 3fae1c2e-... --version 3

ptkl sandbox spark cancel

Cancel an in-progress spark deployment.

ptkl sandbox spark cancel -i <uuid> [--spark-env <env>]
Option Description
-i, --id <uuid> Spark uuid (required)
--spark-env <env> Spark environment: dev | live (defaults to dev on the server)
ptkl sandbox spark cancel --id 3fae1c2e-... --spark-env dev

ptkl sandbox spark exec

Execute a deployed spark by name.

ptkl sandbox spark exec -n <name> [-d <json>] [-m <method>] [-q <json>] [-H <json>]
Option Description
-n, --name <name> Spark name (required)
-d, --data <json> Request body as a JSON string
-m, --method <method> HTTP method: GET | POST | PATCH | PUT | DELETE (default: POST)
-q, --query <json> Query params as a JSON object string
-H, --headers <json> Request headers as a JSON object string
ptkl sandbox spark exec --name send-welcome-email --data '{"userId":"u_123"}'

ptkl sandbox spark logs

Fetch logs for a spark.

ptkl sandbox spark logs -i <uuid> [--spark-env <env>] [-l <limit>] [--level <level>] [--since <since>]
Option Description
-i, --id <uuid> Spark uuid (required)
--spark-env <env> Spark environment: dev | live
-l, --limit <limit> Number of log lines to fetch
--level <level> Filter by log level
--since <since> Only fetch logs since this timestamp
ptkl sandbox spark logs --id 3fae1c2e-... --spark-env live --limit 100

Spark Environment

A Spark has its own environment variables for dev and live. A variable that holds a key, token or password can be stored as a secret. Secrets are encrypted, write-only and never shown again. Read the security model for who can reach them.

You write Meaning Reads back as
secret::<value> Stores <value> as a secret, replacing the one at this key. secretref::
secretgen::random(n[, alnum\|alpha\|hex\|digits\|base64url]) Generated by the platform, only if the key has no secret yet. An existing value is kept. The generator is not stored. secretref::
secretref:: Keeps the secret already stored at this key. secretref::
literal::<value> A plain value that starts with a reserved prefix. literal::<value> when the value starts with a reserved prefix
  • A secret:: value is 8 characters to 32 KiB. A shorter or longer one is refused with 422.
  • n is at most 4096. A generator that gives less than 128 bits of entropy is refused with 422. uuid is not a generator.
  • Names that begin with GLOBAL_ are reserved for the project's global env and are refused.
  • A value starting with enc:: is refused.
  • secretref:: for a key with no stored secret is refused with 422. A write that leaves a secret key out removes it, so send secretref:: for every secret you want to keep.

To replace a secret, set it again with secret::<new value>. For a generated key, delete it and generate a new one.

Action Permission
Change the env manage::spark sandbox
Set, generate, replace or remove a secret spark::secrets::write sandbox, in addition to manage::spark sandbox
Keep a secret with secretref:: manage::spark sandbox only
Deploy or release a Spark whose env has secrets spark::secrets::read sandbox, in addition to the deploy permission

A refused change returns 403 and names the permission, for example spark: deploying a Spark with encrypted env values needs spark::secrets::read sandbox. Nothing is saved or deployed.

A deploy also hands the Spark the project's global env that the deploying user may read. Encrypted global values are included only when that user holds secrets::read global_env.


Runtime

ptkl sandbox runtime list

List all runtimes for the current project.

ptkl sandbox runtime list

ptkl sandbox runtime deploy

(Re)deploy a runtime.

ptkl sandbox runtime deploy -r <ref>
Option Description
-r, --ref <ref> Runtime name/uuid (required)
ptkl sandbox runtime deploy --ref api-gateway

ptkl sandbox runtime restart

Restart a running runtime.

ptkl sandbox runtime restart -r <ref>
ptkl sandbox runtime restart --ref api-gateway

ptkl sandbox runtime logs

Fetch logs for a runtime.

ptkl sandbox runtime logs -r <ref> [--lines <lines>]
ptkl sandbox runtime logs --ref api-gateway --lines 200

ptkl sandbox tier

Get the current project's spark tier (plan/quota).

ptkl sandbox tier

Typical Workflow

# 1. Deploy a spark version to dev
ptkl sandbox spark deploy --id 3fae1c2e-... --version 3

# 2. Try it
ptkl sandbox spark exec --name send-welcome-email --data '{"userId":"u_123"}'

# 3. Promote to live
ptkl sandbox spark release --id 3fae1c2e-... --version 3

# 4. For a runtime: deploy and restart
ptkl sandbox runtime deploy --ref api-gateway
ptkl sandbox runtime restart --ref api-gateway

See Also

  • ptkl forge — build, bundle, and deploy Forge apps (a different execution model)
  • Toolkit Overview — all available toolkit commands