Working with Environments

Environments in Maeris allow you to manage variables and configuration settings that can be reused across multiple API requests. This makes it easy to switch between different environments like development, staging, and production.

What are Environments?

Environments are containers for variables and settings that define the context in which your API requests run. They help you:

  • Store reusable variables like base URLs, API keys, and tokens
  • Switch between different environments (dev, staging, prod) easily
  • Avoid hardcoding values in your requests
  • Share configuration across team members
  • Maintain separate configurations for different environments

Creating Environments

  1. Open Environment Settings: Navigate to your collection settings and find the Environments section
  2. Create New Environment: Click "New Environment" or "Add Environment"
  3. Name Your Environment: Give it a descriptive name like "Development", "Staging", or "Production"
  4. Add Variables: Define key-value pairs for your variables

    Common variables include baseUrl, apiKey, token, userId, etc.

  5. Save Environment: Save your environment configuration

Using Variables in Requests

Once you've defined variables in an environment, you can use them in your API requests by referencing them with double curly braces.

Variable Syntax

Use {{variableName}} to reference a variable in:

  • URL paths: /api/users/{{userId}}
  • Headers: Authorization: Bearer {{token}}
  • Request body: {{email}}
  • Query parameters: ?page={{pageNumber}}

Example Environment Configuration

Here's an example of a Development environment configuration:

Development Environment:
baseUrl: https://api-dev.example.com
apiKey: dev-api-key-12345
token: dev-token-abc123
userId: test-user-001
timeout: 5000

And a Production environment:

Production Environment:
baseUrl: https://api.example.com
apiKey: prod-api-key-67890
token: prod-token-xyz789
userId: prod-user-001
timeout: 10000

Switching Between Environments

You can easily switch between environments when running your API requests. This allows you to test the same requests against different environments without modifying the requests themselves.

  1. Select the active environment from the environment dropdown in your collection
  2. All variables from the selected environment will be used when running requests
  3. You can switch environments at any time without changing your request definitions

Best Practices

  • Use Descriptive Names: Name your variables clearly (e.g., "baseUrl" instead of "url")
  • Separate Secrets: Store sensitive information like API keys and tokens in environments, not in requests
  • Use Consistent Naming: Use the same variable names across environments for consistency
  • Document Variables: Add descriptions to help team members understand what each variable is for
  • Version Control: Keep environment configurations in version control (excluding secrets)
  • Use Default Values: Set default values for variables when possible

Shared Environments

You can share environments with your team members so everyone uses the same configuration. Shared environments ensure consistency across the team and make it easier to collaborate.

Note: When sharing environments, be careful with sensitive information. Consider using environment-specific secrets management for production credentials.

Next Steps