Environments and Variables

An environment is a named set of variables, such as a base URL, an API key or a user ID. Switch environments to send the same request to staging or production without editing it.

Copy of Copy of Untitled Design (13).png

#

Environment types

Type Who can see it
Global Environment Everyone in your workspace. Marked with a globe icon in the list.
Private Environment Only you.

Use a global environment for shared values like base URLs. Use a private one for your own tokens.

#

Create an environment

  1. Open any endpoint. The environment dropdown appears in the tab bar.
  2. Click the dropdown (Select environment) and choose Add Environment.
  3. Enter an Environment Name (3 to 50 characters).
  4. Choose Global Environment or Private Environment.
  5. Add variables. Each one has an Initial value and a Current value.
  6. Click Save.
#

Use variables in a request

  1. Pick the environment from the dropdown.
  2. Write variables as {{name}} in the URL, params, headers or body, for example {{BASE_URL}}/orders?limit={{pageSize}}. Typing { in the URL or a table field suggests variables from the selected environment.
  3. Click Send. DocStar replaces each variable with its current value.

Choose No Environment to send requests without variables.

#

Edit, export and delete

  • Edit: click the eye icon next to the dropdown to edit the selected environment.
  • Manage: choose Manage Environment in the dropdown to see every environment, edit it or delete it. Deleting asks you to confirm.
  • Export: hover over an environment in the dropdown and click the export icon. DocStar downloads it as a Postman-compatible JSON file.
#

Import an environment

  1. In the dropdown, choose Import Environment.
  2. Drop a Postman environment file (JSON), or click files to pick one.
  3. Click Import.
#

Set variables from scripts

Scripts can read and change the selected environment. For example, a Post-Script can save a token from a login response:

hm.environment.set("token", hm.response.body.access_token);

Scripts update the Current value. The Initial value stays as it was. See Scripts.

#

Publish an environment for readers

In an API collection you can share selected variables with readers of your published docs. They see a Variables panel on endpoint pages and can use it when they click TRY.

  1. Open Settings in the collection sidebar and go to the Public Environment tab.
  2. Under Select Environment to Publish, click Select Environment and pick one of your environments.
  3. In the Public Environment dialog, choose which variables to share:
    • Tick a row to include it. Use Select to select or deselect all.
    • Turn on Editable to let readers change the value, for example to enter their own API key.
    • Change any value, click Add Variable for a new row, or delete rows you don't want to share.
  4. Click Publish Environment.

To change it later, click View in the Public Environment tab, edit the rows and click Publish Environment again. Click Delete All to remove the public environment.

Important: Published values are visible to anyone who can read your docs. Never publish real secrets. Leave key fields empty and mark them Editable so readers fill in their own.