How to Use Environment Variables for Secure Storage
Instructions on how to securely store and retrieve authentication tokens and other sensitive values using APImetrics' Environment Variables.
1. Obtain APImetrics API Key
To create an APImetrics API Key, follow the instructions on the APImetrics API Overview page.
2. Add Environment Variables
To add your environment variable:
- Go to Project Settings > Environment Variables (from left-hand navigation bar).
- Make sure you're in your desired workspace (the default is "global").
- Click
+ Add Property
. - Give your variable a name and enter some placeholder text in the value field (e.g., "SampleText").
- Click
Save
.
3. Assign a Value to an Environment Variable
Use the following API : Set Environment Variable to store the value to the Environment Variable created in last step.
- Fill in the Path Parameters:
- Workspace: (defaults to
global
) - Variable_name: (use the same name created in Step 2.4)
- Workspace: (defaults to
- Pass the new value in the request body using JSON format:
{
"value": "Enter-your-Environment-variable-value"
}
- Select the Authentication settings:
- Choose Authentication Setting:
APImetrics API
- Use the
Token
you created in Step 1.
- Choose Authentication Setting:
Executing this API call will update the environment variable with the new value.
4. Retrieve an Environment Variable value
Use the following API : Get Environment Variable to retrieve the value of an Environment Variable.
- Fill in the Path Parameters:
- Workspace: The name of your workspace (e.g., "global").
- Variable_name: The name of the environment variable you want to retrieve.
- Select the Authentication settings:
- Choose Authentication Setting:
APImetrics API
- Use the
Token
you created in Step 1.
- Choose Authentication Setting:
This API call returns the value of the specified environment variable in JSON format.
The response will have the following structure:
> "workspace_variable": { > "name": <string>, > "value": <string> > }
You can automate the secure storage and retrieval of your tokens and other sensitive values by incorporating the Set Environment Variable and Get Environment Variable API endpoints into your workflows.
Updated about 19 hours ago