A Config, sometimes called Environment Variable or Global Variable, is a user-defined value that can be included (embedded, referenced) in many requests.
Configs enable our users to parameterize their requests. By parameterizing your requests, your requests become more maintainable, flexible, and easier to refactor in the future.
Using configs in requests
Use configs in requests by typing
@ in any of the request form fields and selecting your config of choice from the list.
Create a new config
To create a new config, please follow the below steps:
- In the left navbar, click on the "Config" link.
- Click on the New Config button.
- Enter a name for your new config. You can use alphanumeric and hyphen for your config name.
- Select the type of config value.
- Provide a Default value for the new config, more about the Default value below.
- Leave the Environment Values section empty
- Click on Save to create the new config.
What is a
As a technologist, oftentimes we interact with different versions of the same API in
Production environments. There are scenarios in which a Config has the same value for all environments (e.g.
user-agent). Rather than duplicating value for all environments, you can set the value using the
Default Value field and use it against all of the environments.
What is an
Environment Value is the opposite of the
Default Value; it's unique to an Environment and will be used only when the request is sent to the parent environment.
Environment Value allows you to define a dedicated and non-sharable config value for an Environment. The value will be only used against the target environment.
api-key config is a good example. You won't want to send the same API Key to both
Production instances of your API, but rather have a dedicated API key for each environment.
Use config values in requests
Once added, a Config can be referenced from within any request in your workspace. Currently, you can reference configs in
Request Header Value,
Response Body Validation, and
Response Header Validation fields by typing
@ and selecting one of the available configs.
Let's say we got two versions of our API running on
Dev (https://dev-api.my-co.com) and
Prod (https://api.my-co.com) environments. To make our requests work against both environments, we should define a new Config called
base-api-url and use it to construct the API endpoints.
- We pick
base-api-urlas a self-explanatory name for our config.
https://dev-api.my-co.comas we don't want requests to accidentally be sent to the production API.
- Reference the
base-api-urlin the URL field of any available requests.
When sending requests that have used the
- When no environment is selected, Testfully would use the
Default Value(in this case
- When an environment is selected, Testfully would use the
Environment Valuefor the selected environment.