Detected country: US
logo
Sign InBook a Demo
GuideRecipesDeveloper

Developer Docs

  • Developer foundations
    • How do I authenticate with the Ballet API?
    • How do I connect to Ballet's MCP endpoint?
    • How do I run a playbook over the REST API?
    • How do I stream playbook run events?
    • How do I trigger and react to playbooks with webhooks?
    • How do I wake a suspended run with reply or resume?
  • How do I use Ballet playbooks in an agent framework?
    • How do I call Ballet playbooks from Google ADK?
    • How do I call Ballet playbooks from LangChain?
    • How do I call Ballet playbooks from Mastra?
    • How do I call Ballet playbooks from Pydantic AI?
    • How do I call Ballet playbooks from the Vercel AI SDK?
  • How do playbooks connect to external systems?
    • How do I call external APIs and SDKs from a playbook?
    • How do I connect external MCP servers to playbooks?
    • How do I use secrets and env vars in steps?
  • Introduction
Loading…
logo

Powered by

How do I use secrets and env vars in steps?

TL;DR: Store every credential in Secrets, then reference it with ${VAR} in connector headers and HTTP steps, or read it from the environment in Code steps. Secrets are encrypted per workspace and resolved at run time, so keys never live in playbook bodies, source control, or run output.

Who this is for

Developers handling API keys, tokens, and other credentials inside playbooks.

Where do secrets live?

Secrets are stored in Ballet's per-tenant encrypted store. You add them once and reference them by name wherever a credential is needed — they are never written into the playbook definition.

How do I reference a secret?

  • Connector headers and HTTP steps — use ${VAR} interpolation:
Authorization: Bearer ${EXAMPLE_API_KEY}
  • Code steps — read from the environment:
const key = process.env.EXAMPLE_API_KEY;

The placeholders are resolved at connect/run time from the workspace secret store.

How is this different from an API token?

SecretAPI token
PurposeCredentials a playbook uses to call out to other systemsA credential others use to call into Ballet
Where usedSteps, connector headersAuthorization: Bearer on Ballet API/MCP requests
Managed inSecretsSettings → API tokens

See authentication for API tokens.

Best practices

  • One secret per credential; give it a clear, specific name.
  • Never paste keys directly into a step, prompt, or commit.
  • Rotate by updating the secret value — references keep working.
  • Return only non-sensitive data from steps so secrets don't leak into run output.

Related articles

  • How do I store credentials with Secrets?
  • How do playbooks connect to external systems?
  • How do I call external APIs and SDKs from a playbook?
  • How do I authenticate with the Ballet API?