Skip to content
tako
Esc
↑↓navigate↵open⌘Jpreview
On this page

Secrets

Set and rotate Tako app secrets, access typed values from JavaScript, Go, or Rust, and distinguish app secrets from provider credentials.

App secrets are encrypted per environment and delivered to your app through the Tako SDK. Use secrets for database URLs, API keys, and other private application values. Non-secret process variables belong in [vars] or [vars.<env>] in tako.toml.

Set a secret

From the directory containing tako.toml, select the environment explicitly:

tako secrets set DATABASE_URL --env development
tako secrets set DATABASE_URL --env production
tako generate

The CLI prompts for a masked value. Non-interactive calls read stdin; MCP setters accept stdin as a named argument. Pass the secret through that input rather than putting its value into a command line. Non-interactive set requires --env.

Secret edits are encrypted in the worktree-local .tako/secrets.local.json, ignored by Git. Device keys and the cache of published ciphertext live under the local Tako home. Setting or removing a secret makes no network request. Keep tako.toml and application code in Git.

Read from application code

Use the SDK matching your backend:

import { tako } from "tako.sh";

const databaseUrl = tako.secrets.DATABASE_URL;
if (!databaseUrl) throw new Error("DATABASE_URL is not configured");
package main

import "tako.sh"

func databaseURL() string {
    return tako.GetSecret("DATABASE_URL")
}
fn database_url() -> Option<String> {
    tako::secret("DATABASE_URL")
}

For JavaScript, tako generate refreshes tako.d.ts with known secret names. Do not edit generated declarations. Read individual values: serialization of the secrets object is redacted, and spreading it does not copy its values. An individually accessed value is an ordinary string; do not log it or return it to a browser.

Go uses tako.GetSecret("DATABASE_URL") or the generated Secrets.DatabaseUrl() accessor after tako generate. Rust uses tako::secret("DATABASE_URL"), which returns Option<String>. See the matching SDK skill for listener and bootstrap setup.

Ordinary app code does not receive app secrets as individual process environment variables. Native processes receive SDK bootstrap on fd 3; containers and tako run use TAKO_BOOTSTRAP_DATA. Use the SDK rather than reading the envelope yourself. Release commands additionally receive decrypted secrets as process environment variables.

Apply changes to deployed apps

Publish and deploy the selected environment:

tako secrets set DATABASE_URL --env production
tako deploy --env production

Deploy first pulls published state, merges this worktree’s edits, and publishes changed values before building. A later build failure does not undo publication. To publish without deploying, run tako secrets sync --env production; it updates shared state and leaves running app processes unchanged. To refresh only the device cache, use tako network sync NETWORK_NAME.

Different secret names merge independently. Concurrent changes to the same key resolve deterministically by the servers’ logical revision and tie breakers, rather than laptop wall clocks. Removal publishes a tombstone, so a stale cache cannot restore a deleted value. Storage access/secret keys form a single record to keep each credential pair together. If a publication response is lost, Tako keeps a durable request for retry; an unconfirmed request may require its original server to return. Each request has a fixed seven-day retry window. After it expires, deploy and sync stop with local drafts preserved. Review those drafts, then run tako secrets sync --env production --retry-expired to publish their current values as new changes. This can replace newer remote values for the keys you edited.

Shared state keeps only the current encrypted value and its recipient keys for each secret name, or a versioned deletion marker. Overwriting removes superseded values from the application tables and caches during synchronization; there is no secret-history or rollback API. Corrosion retains its own replication metadata. The limit of 10,000 current records and 8 MiB per network includes deletion markers; repeated edits to one key do not consume a lifetime history allowance. Short-lived publication receipts and unfinished requests are retained separately for safe retries. Backup encryption keys use distinct key IDs, so keys needed to decrypt retained backups remain available. Keep server state backed up, because Git no longer carries published ciphertext.

Upgrade servers and clients together for this protocol change. Existing stored values and recipient keys migrate during synchronization. Requests left pending by the older protocol have no retry deadline and require the same explicit --retry-expired step; review the preserved drafts before publishing.

Each worktree has separate drafts. A new worktree can initialize from the machine’s published cache; existing drafts are preserved when it next syncs. Merging a Git branch does not publish secrets. Set required values in the release worktree or publish them explicitly before deploying merged code. Concurrent releases to the same environment still need coordination: shared state does not provide a global deployment lock or atomic multi-key rotation.

Commands targeting one environment load published values from the local cache only for that environment. For example, an expired membership in staging’s network does not prevent tako deploy --env production from using a healthy production network. Deployment to the selected environment still requires valid membership and keys. Commands that inspect all environments, such as tako secrets list, can report problems in any configured environment.

tako secrets rm OLD_API_KEY --env production
tako secrets sync --env production

In development, attached tako dev sessions watch local secret changes; restart a background session when needed. The development environment remains local unless configured for a supported shared deployment flow.

Use an alternate configuration

tako --config release.toml secrets set DATABASE_URL --env production
tako --config release.toml deploy --env production

The selected config supplies the app name and network IDs. Its parent directory is the project directory, including the local .tako/ state. Two config files in the same directory therefore share a draft store. The first edit to a configured environment binds its drafts to that app and network, even before the machine joins the network or downloads shared values. Tako rejects attempts to reuse those drafts for a different app or network. Use a separate worktree or directory for that target, and keep the original worktree for publishing its pending edits.

Migrate a tracked secret file

tako secrets migrate
# Review and commit the deletion of .tako/secrets.json.
tako secrets sync --env production

Migration validates every existing encrypted value with its original local environment key, writes ignored local state, and retains an ignored .tako/secrets.legacy.json recovery copy. A missing key stops migration; recover or import that key rather than replacing it. Set the environment’s network ID in tako.toml before publishing. Migration does not rewrite Git history; old encrypted blobs remain in previous commits.

Expiry and key access

Set an optional expiry with --expires-on YYYY-MM-DD or --expires-on "in 30 days". Deployment rejects expired secrets for its selected environment and warns when expiry is within 30 days.

Enroll a new machine using a network invitation. Authorized administrators receive shared values; scoped deployment clients receive only app secrets for their app/environment grants. Clients sync through servers, with no client-to-client connection. Revoking a device excludes it from future encryption recipients once servers enforce the revocation; it cannot erase previously copied values.

If all administrator clients are lost, use a surviving server’s administrator recovery command. It grants a replacement device independent authority and access to published values. It requires intact server state and keys.

An invitation cannot recover the original environment key for a legacy file or unpublished local drafts. Import that key before migration or publication, even if this machine already has a cache of shared values:

tako secrets key import --env production
# If the original key was derived from a passphrase, use this instead:
tako secrets key import --env production --passphrase

Import prompts for the exported key or passphrase, or reads it from stdin in automation. It validates the key against existing encrypted values before installing it. See the CLI reference for key export and troubleshooting for recovery checks.

Provider and storage credentials

These serve different consumers:

Value Set with Used by
App secret, such as DATABASE_URL tako secrets set Your app through its SDK
ssl.cloudflare tako credentials set Tako certificate management
postgres_url tako credentials set Shared channel, presence, store, and workflow state
S3 access credentials tako storages add or tako storages credentials The configured storage binding or backup resource
tako credentials set ssl.cloudflare --env production
tako credentials set postgres_url --env production

Provider credentials are for deployed environments and are encrypted in the same ignored local state and shared network records. They are not exposed through app secrets. tako secrets sync publishes them for authorized administrators; deployment applies the relevant runtime bindings. Your application’s own database URL remains a separate app secret even if Tako’s runtime state also uses Postgres.

Verify

Use tako secrets list --json and tako credentials list --json to inspect configured metadata. Test the app’s real connection or authenticated operation in the intended environment, without printing credentials. After rotation, confirm that the new app processes can use the value and inspect finite logs for failures.

Last updated on

Was this page helpful?