Store your app's API keys securely, out of the code

Secrets is where your Hercules app keeps API keys, passwords and connection strings. Save a key once, such as the Twilio key your appointment texts use. Hercules uses it to build the feature and never sees the value. You decide whether each secret reaches your live app, your test backends or both.

What can you do with Secrets?

Add a key from the sidebar

Secrets sits under Advanced in your app's sidebar. Each secret's name is the one your code reads, written in capitals with underscores, such as TWILIO_API_KEY.

Secrets
Secrets screen with the Add Secret form (key, value, environments, Sensitive) and saved keys
Hercules in chat listing the extra Twilio secrets the feature needs before it can send messages

Let Hercules build with it

Ask Hercules to "send SMS with Twilio" and it writes the feature to read your TWILIO_API_KEY. Hercules sees each secret's name, which is enough to write that code, and never its value.

Secrets
Secrets list with TWILIO_API_KEY saved once for Development and once for Production

Use a test key and a live key

Add the same key twice, once scoped to Production and once to Development, each with its own value. Your live app texts customers on the live Twilio key while every branch uses the test one.

Secrets
Add Secret form with Sensitive checked for a production key, above saved secrets where sensitive ones show a lock

Hide a value for good

Check Sensitive when you add a secret, and Hercules encrypts and hides the value once you save. Nobody can reveal a Sensitive value again, you included.

Secrets

Connect an outside database or service

Backend functions can call any domain over HTTP, with no allowlist to configure. Keep the connection string for an outside Postgres database in Secrets and reach it through an HTTP driver, because the default backend runtime doesn't offer raw TCP connections.

Secrets

How do you add a key and use it?

  1. 1. Copy the key from the provider

    Create an API key in Twilio's dashboard and copy its value.

  2. 2. Save it in Secrets

    Add TWILIO_API_KEY under Advanced, then Secrets, with the live value scoped to Production and marked Sensitive. Add a test value scoped to Development.

  3. 3. Ask Hercules to build the feature

    Text each customer a reminder the day before their appointment, using Twilio.

    Hercules writes the scheduled job that reads TWILIO_API_KEY. Try it on a branch, which gets the Development value, then merge and publish.

    Branches

What could this look like for a contractor?

In this hypothetical example, a commercial HVAC contractor with 90 technicians replaces their Twilio key without rewriting the text alerts that tell building managers a technician is on the way. The live key sits in Production, marked Sensitive, so nobody in the office can copy it out of Hercules. Then the dispatcher who set up Twilio leaves. The office manager deletes the old key in Twilio and in Secrets and saves a new one under the same name. The app still reads TWILIO_API_KEY, and a test text confirms the new key works.

Related features

Frequently asked questions

What should you know before you add secrets?
  • A secret scoped to one environment is invisible to the other, so a key saved only for Production won't work on a branch.
  • You can't scope a secret to a single branch. Adding, changing or removing a Development secret applies to every branch. Branches
  • You can't edit or delete the managed secrets Hercules adds for its own API keys and sign-in tokens.
  • See what each plan includes on the pricing page.
How do I change a Sensitive secret?

To change a Sensitive secret, edit it and enter the new value. Leave the value field blank to keep the current one. Secrets

Where can I find the IP addresses my backend calls from?

Your app's backend calls from the public IP addresses listed on the Backend docs page. An outside database or service that only accepts known addresses needs them.

How does my code read a secret?

Your app's code reads a secret as process.env followed by the secret's name, such as process.env.TWILIO_API_KEY. Secrets

Why does my app say a secret is missing?

When your app says every secret is missing, it usually resolves within 30 seconds, and if it doesn't, contact support. When one secret is missing, check that it exists and is scoped to the environment that needs it.

How do you get started?

Open Advanced, then Secrets, in your app's sidebar and save the key your next feature needs. Start building.