Midio docs
  • Getting Started
    • Welcome
    • Quick Start Guide
  • Your First Midio App
  • Guides
    • HTTP
      • Making HTTP Requests
      • Responding to HTTP Requests
      • How to reach your own endpoints
      • CORS
      • Server-Sent Events (SSE)
    • Branching
    • Loops
    • Map, filter, reduce
    • Working with Data
    • Expressions
    • Building Agents
      • Streaming Agent API (experimental)
    • Debugging
    • Secrets and Environment variables
    • Convert JSON to data nodes
    • Writing tests
    • Cleaning up your flows
  • Package Manager
  • Integrating with third party services
  • Troubleshooting
  • Tutorials
    • Connecting LLMs to MCP-servers using the MCP-client package
    • Making Your Own MCP Server in Midio
    • A Fast Path to Functional RAG Agents
    • How to build a streaming agent using Server-Sent Events (SSE)
  • Reference
    • The Midio Editor
      • The Node Editor
      • User Traces
      • Traces (execution)
      • Processes
      • Log
      • Services
      • Problems
      • Function Signature
      • Data
      • Settings
    • The Midio Language
      • Nodes and execution
      • Functions and Events
        • Anonymous functions
      • Modules
      • Contexts
      • Data type
      • Local variables
      • Portals
      • Waypoint node
      • Partial function application
  • The Midio Engine
  • Built in Nodes
    • Core (std)
    • HTTP
    • LLM
Powered by GitBook
On this page
  • Secrets and environment variables
  • Managing secrets and variables
  • Secret types
  • Using secrets and variables
  • Production application

Was this helpful?

Edit on GitHub
  1. Guides

Secrets and Environment variables

PreviousDebuggingNextConvert JSON to data nodes

Last updated 2 months ago

Was this helpful?

Secrets and environment variables

When integrating with third-party services, you commonly need to supply an API key or other credentials when interacting with it. It is not a good idea to store these keys directly in your flows, as it increases the likelihood of them being forgotten, or leaked.

Midio has a separate system for storing these values as either secrets or environment variables. There is also a special node () that you can use for accessing these values in your code. You can also configure different values for the same key, to be used for the different environments your application can run in (which currently is either the editor, or as a deployed app).

We recommend storing sensitive data as secrets. Secrets have an additional guarantee that regular variables do not have: they are encrypted for as long as they exist in the , and are only decrypted once they leave with an HTTP request to whatever service you access.

Managing secrets and variables

Environment secrets and variables are declared in project settings and are available in the project they are declared in.

To create a secret or variable:

  1. Click on the hamburger menu in the project panel.

  2. Click on Add secret/variable.

  3. Fill out the form to create a secret/variable. The form will look slightly different if you a creating a variable.

  4. Click Add and watch it appear in the table!

    • If you created it in only one environment, the new secret/variable should appear as a missing value if you toggle to the other environment.

From the secrets/variables window you can update or delete the environment value by clicking on the menu that appears on the table row. You can also duplicate the value into the other environment from here.

Secret types

Midio currently only support Bearer tokens as the secret type. A bearer token is a type of access token used in HTTP authentication. It is a string that proves the sender is authorized to access a specific API or service. When included in the Authorization header of an HTTP request (as Authorization: Bearer <token>), it tells the server that the request comes from an authenticated client.

In Midio, when assigning a Bearer secret to a headers object, the Bearer <token> formatting is done automatically.

Support for more secret types will be added in the future.

Using secrets and variables

To use secrets and variables in the editor, make sure you have created a value in the Development environment.

Raw values of regular environment variables are available in the Midio engine, which means you can access the string value associated with the key directly in the editor.

But since the raw value of secrets are not available in the Midio engine, you will instead see a placeholder value.

Production application

When you deploy your Midio code, make sure any environment variable or secret your application needs has a value for the production environment. You can choose to deploy anyway, but be aware that your application will not have access to variables only defined for the development environment.

Fetching an environment secret or variable can be done by using the node.

To use a secret, you have to use a node that is aware of how to handle a secret value, like or Llm Chat Complete. There are two ways to pass a secret bearer token to these nodes: either directly, or as the value of the Authorization HTTP header key.

All HTTP requests in Midio have to go through these nodes, but you might not use them directly. For instance, the Chat complete node in the open-ai package uses to make the HTTP request. This node has an api key input parameter that you can pass a secret bearer token to, since it internally passes this value to an Authorization HTTP header.

Midio engine
Fetch
Fetch
Get Environment Variable
Get Environment Variable