Configuration APIs
Modified on Mon, Jul 27 at 5:40 PM
Configuration APIs
User Configuration APIs allow you to save and retrieve user-specific configuration values using key-value pairs.
These APIs can be used to manage:
- Runtime variables
- User preferences
- Environment settings
- Custom configuration values
The APIs can also be configured and used directly in Codeless test execution.
Available APIs
- Save Config API – Saves or updates a configuration value.
- Get Config API – Retrieves a previously saved configuration value.
Save Config API
The Save Config API stores a user-specific configuration as a key-value pair.
If the specified key already exists for the user, its value is updated. If the key does not exist, a new configuration entry is created.
Request
Method: POST
Endpoint:
/api/save-config
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_token | String | Yes | Authentication token of the user. |
key | String | Yes | Configuration key to save, for example, username, password, environment, or user. |
value | String | Yes | Value associated with the configuration key. |
cURL
curl --location 'https://<your-domain>.testgrid.io/api/save-config' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'user_token=<USER_TOKEN>' \ --data-urlencode 'key=<CONFIG_KEY>' \ --data-urlencode 'value=<CONFIG_VALUE>'
Response
{ "success": true, "message": "Configuration saved successfully." }
Get Config API
The Get Config API retrieves the value of a previously saved configuration key for the authenticated user.
This API can be used to view saved configuration values and retrieve runtime variables or user-specific settings during test execution.
Request
Method: POST
Endpoint:
/api/get-config
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_token | String | Yes | Authentication token of the user. |
key | String | Yes | Configuration key whose value should be retrieved. |
cURL
curl --location 'https://<your-domain>.testgrid.io/api/get-config' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'user_token=<USER_TOKEN>' \ --data-urlencode 'key=<CONFIG_KEY>'
Response
{ "success": true, "key": "user", "value": "xxx" }
The saved configuration value can be viewed in the value field of the response.
Using Configuration APIs in Codeless
You can configure and use the Get Config API directly in Codeless to retrieve saved configuration values during test execution.
Steps to Configure the API
- Go to the Project section.
- Open the required project.
- Navigate to the API Request section.
- Click Add API Request.
- Enter an API Request Name.
- Select the required HTTP method, such as POST or GET.
- Enter the API URL.
Example:
https://<your-domain>.testgrid.io/api/get-config
- Add the required parameters:
user_tokenkey
- Enter the required values for the parameters.
- Click Test API.
- The API response is displayed in the Data Preview section.
- Select the required Key Path from the response.
- Select the required Data Type, such as:
- String
- Integer
- Boolean
- Save the API configuration.
View the Saved Configuration Value
After clicking Test API, the API response is displayed in the Data Preview section.
Example:
{ "success": true, "key": "user", "value": "xxx" }
To retrieve the saved configuration value:
- Select
valueas the Key Path. - Select the appropriate Data Type, such as
String. - Save the API configuration.
Use the Configuration Value in Codeless
After saving the API configuration, the retrieved value can be used in Codeless test steps.
You can:
- Use the configured key directly in the required field.
- Save the API response as a variable.
- Use the saved variable in subsequent Codeless steps.
The configured key is automatically suggested in Codeless wherever the saved configuration value can be used.
Example
If the configuration key is:
user
and the saved value is:
xxx
You can retrieve the value using the Get Config API and use it in subsequent Codeless steps either by:
- Using the configured key directly in Type action
- Saving the value as a variable and using the variable in later steps.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article