Skip to content

API keys and secrets

Functions of an app built on Sovyn often call other services: Stripe for payments, OpenAI or Anthropic for AI, Resend for emails. These services need an API key. In Sovyn, such a key is a secret of an environment.

  • Your AI assistant declares in the app which secrets it needs, by name, for example STRIPE_SECRET_KEY. The functions read them as ctx.secrets.STRIPE_SECRET_KEY.
  • You enter the values, in the Sovyn console or with the CLI. Your assistant never sees a value and never asks you for one.

Each app has two environments, Development and Production, and each gets its own values:

  • Development gets the test key of the service, for Stripe the one starting with sk_test_. With it, no real customer is charged while you try the app in development.
  • Production gets the live key, for Stripe the one starting with sk_live_.

Moving the app to production does not copy any values. If the app declares a secret that is missing in production, the move to production is refused until someone sets it. Your assistant then gives you a link straight to the right place in the console.

Sovyn recognizes common keys by their beginning. If a value looks like it belongs to the other environment (a live key in development, a test key in production), the console and the CLI warn you. You can still save it. Keys of services without a separate test key, such as OpenAI, Anthropic, Resend or AWS, always count as live keys, so development warns about them too.

  • In Development, every member of the team who builds apps.
  • In Production, only owners and admins of the team.

Nobody can display a value once it is set, not even an admin. You only see when and by whom it was set. You can replace or delete it at any time. A change applies from the next call of a function, without a new deploy.

  1. Open Apps in the console and choose the app, or follow the link your assistant gave you.

  2. Open the Secrets tab. The table shows one row per name and one column per environment. A cell says when and by whom the value was set, or missing (red) or not needed (grey).

  3. Click a cell, paste the value and click Save. If the value looks like a key of the other environment, the button becomes Save anyway.

To take several values at once, click Paste from .env above a column and paste the contents of a .env file. The text is read in your browser; the preview shows each name as new, replacing or skipped (with the reason), and never shows a value.

To delete a secret, open its cell and click Delete. If the running version in production still declares it, you confirm this once more, because functions that need it fail until someone sets it again. A secret marked not needed is deleted without asking.

On the overview of the app, a notice like 2 secrets are missing in production leads you there with Enter. Under Details you see which names the running version declares and the change log.

Run the commands in the project folder of the app, the folder your assistant created. Changing (set, delete, import) needs an access you get yourself in the console: in the Secrets tab, Access for the terminal gives a ready command with --token. It is valid for one hour, and the CLI does not store it in the project. Your assistant’s access only reads the list; it never sets values. --env dev stands for development, --env prod for production. deploy never uploads .env files from the project folder.

Terminal window
# Set a value: pipe it in, or type it at the hidden prompt
npx @sovyn/build secret set STRIPE_SECRET_KEY --env dev
# Names, set or missing, when and by whom; never values
npx @sovyn/build secret list
npx @sovyn/build secret list --env prod
# Delete a value
npx @sovyn/build secret delete STRIPE_SECRET_KEY --env dev
# Take all values of a .env file at once
npx @sovyn/build secret import .env.production --env prod
  • secret set never takes the value as an argument, because it would stay in the shell history. In a terminal, it asks for the value without showing it; in a script, pipe it in, for example printenv STRIPE_TEST_KEY | npx @sovyn/build secret set STRIPE_SECRET_KEY --env dev. If the value looks like a key of the other environment (a test key in production, a live key in development), it asks [y/N] before saving; --yes skips the question. A piped value cannot be confirmed: without --yes, the command then sets nothing and exits with an error.
  • secret import first shows a preview: new, replacing, skipped with the reason, not declared by the app, and warnings for keys of the other environment. Values never appear. Then it asks [y/N]; --yes skips the question, for example in CI. The import counts as one change: everything or nothing.

The CLI checks the same rights as the console: production only with the access of an owner or admin of the team.

  • Names are written UPPER_SNAKE_CASE: capital letters, digits and _, starting with a letter. Names starting with SOVYN_ are reserved.
  • At most 50 secrets per environment.
  • A value has at least 8 characters and at most 8 KB.
  • Secrets are available in every plan.

In the logs of a function, in error messages and in the output of a step, Sovyn replaces a value with [secret:NAME]. A value that a function encodes or splits is not recognized, so functions should never log a secret.