Run Tests

Manage Environments

Managing Test Environments

Environments in Vaktum allow you to define the target servers and configurations for running your API tests across different stages of development.

What is an Environment?

An environment represents a specific deployment of your API, such as:

  • Development
  • Staging
  • Production
  • QA

Each environment contains the base URL and any authentication details required to access that instance of your API.

Creating Environments

Via Vaktum.com

  1. Navigate to the Environments section of Vaktum.com
  2. Click "Create Environment"
  3. Provide the following details:
    • Name: A descriptive name for the environment (e.g., "Production", "Staging")
    • Base URL: The root URL for the API in this environment
    • Authentication: Configure authentication details if required
    • Headers: Add any environment-specific headers
    • Variables: Define environment variables that can be used in tests
  4. Click "Save" to create the environment

Via Vaktum API

You can programmatically create environments using the Vaktum API:

🖥️ Shell
curl -X POST "https://api.vaktum.com/v1/environments" \
  -H "X-API-KEY: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production",
    "baseUrl": "https://api.example.com",
    "headers": {
      "Content-Type": "application/json"
    },
    "variables": {
      "apiVersion": "v1"
    },
    "auth": {
      "type": "bearer",
      "token": "your-token"
    }
  }'

Environment Variables

Environment variables allow you to parameterize your tests for different environments:

  • API Keys: Store different API keys for each environment
  • User Credentials: Maintain separate test accounts for each environment
  • Feature Flags: Toggle features that may only exist in certain environments

Exporting and Importing Environments

For local testing or CI/CD integration, you can:

  1. Export environments as JSON files from Vaktum.com
  2. Use these files with the Vaktum CLI:
🖥️ Shell
vaktum test --tests tests.json --env exported-environment.json

Best Practices

  • Create Multiple Environments: Maintain separate environments for each stage of your development pipeline
  • Use Variables: Leverage environment variables to avoid hardcoding values in tests
  • Rotate Credentials: Regularly update API keys and tokens used in test environments