# Environment Variables

### About this export

| Field | Value |
| --- | --- |
| **content_type** | lesson |
| **platform** | contentstack-academy |
| **source_url** | https://www.contentstack.com/academy/courses/launch-foundations/environment-variables |
| **course_slug** | launch-foundations |
| **lesson_slug** | environment-variables |
| **markdown_file_url** | /academy/md/courses/launch-foundations/environment-variables.md |
| **generated_at** | 2026-05-04T05:36:54.055Z |

> Part of **[Launch Foundations](https://www.contentstack.com/academy/courses/launch-foundations)** on Contentstack Academy. **Academy MD v3** — structured for retrieval; no quiz or assessment keys.

<!-- ai_metadata: {"lesson_id":"09","type":"text","duration_minutes":1,"topics":["Environment","Variables"]} -->

#### Lesson text

## Environment Variables

Environment Variables are key-value pairs configured outside your source code so that each value can change depending on the [Environment](https://www.contentstack.com/docs/developers/launch/environments).

Your source code can read these values to change behavior during the Build Step or Launch [Cloud Function](https://www.contentstack.com/docs/developers/launch/cloud-functions) execution.

All values are visible to any user that has access to the Project. It is safe to use both non-sensitive and sensitive data, such as tokens.

**Note**: Changes to Environment Variables are not applied to previous deployments. They only apply to new deployments.

You can add environment variables while creating a new project or environment, or configure the environment variables later at **Environments > Settings > Env. Variables**.

## Add Environment Variables

1.  Click the project card to open your project from the Launch landing page.
    
      
    
2.  In the Environments screen, click an existing environment or create a new environment. For this tutorial, we will add an environment variable to the ‘Default’ environment for the Contentstack API key.  
    Hover over the **Default** environment and click the **Settings** icon to go to the Settings page.
    
      
    
3.  In Environments under Settings, click **Environment Variables**.  
      
    ![Launch\_Env\_Var\_Navigate.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt5523d390422ee656/64a65d3eb62fa40371ab8544/Launch_Env_Var_Navigate.png)  
      
    
  
5.  Under the **Key Value Edit** tab, enter the environment variable key and value. You can click the **\+ Add Environment Variable** button to add additional environment variables.
    
    **Note**: You can add up to **100** environment variables per environment.  
    
      
    You can also add or edit environment variables in bulk in key-value format, separated by new lines by clicking the **Bulk Edit** tab.
    
      
    
      
    An environment variable can be added in the key=value format, or an existing variable's key or value can be edited in the bulk edit mode. The updated environment variables will also be reflected in the Key Value Edit tab.
    
    The bulk edit mode allows you to paste code blocks with key=value pairs, thereby reducing the effort of individually entering environment variables in the key-value edit mode.
    
6.  Click the **Save** button.
    

**Note**: You must trigger a new deployment after adding/modifying environment variables.  
  

## Auto-populate Environment Variables from a Linked Stack

Importing a Starter app or any application with Contentstack SDK requires adding key-value pairs of environment variables like CONTENTSTACK\_API\_KEY, CONTENTSTACK\_DELIVERY\_TOKEN, etc. Adding these environment variables manually is a tedious task.

Launch allows you to auto-populate the Environment Variables from your stack, by linking the stack to your project. This allows you to easily use the CMS environment variables while deploying your Launch project.

This step-by-step guide lets you link a stack to your project to auto-populate Environment Variables.

**Note**: This feature can also be used when creating or configuring an environment.

## Prerequisites

1.  [Contentstack account](https://www.contentstack.com/login/)
    
2.  Access to Launch for your organization
    

## Steps for execution

Follow the steps to link a stack to your project:

1.  Click **Launch** in the left navigation panel, as shown below.  
      
    ![Launch-LinkedStack-LaunchIcon.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltd6795befb5942ba3/64354575c6373410f6840530/Launch-LinkedStack-LaunchIcon.png)  
      
    
2.  Click the **\+ New Project** button.  
      
    ![Launch-New\_Project.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt312818ae4f29de6b/643e70a6a39e8e5aa0f4588e/Launch-New_Project.png)  
      
    
3.  Select [Import from a Git Repository](https://www.contentstack.com/docs/developers/launch/import-project-using-github) or [Upload a file](https://www.contentstack.com/docs/developers/launch/import-project-using-file-upload) as usual from the **Create New Project** modal.
    
4.  In the **Environment Variables** section, click the **Connect and Import Variables** button.  
      
    ![Launch-LinkedStack-Connect\_n\_Import.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt17af4819d7fa38b3/6435082ceb41fa1100c83ad5/Launch-LinkedStack-Connect_n_Import.png)  
      
    
5.  Select the **Stack** which has the Starter app installed and then select the **Delivery Token** for your stack.  
      
    ![Launch-LinkedStack-Select\_Stack\_DeliveryToken.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte2e9d91734b317c0/6435082d41f63e1131dec78c/Launch-LinkedStack-Select_Stack_DeliveryToken.png)  
      
    **Note**: On selecting a delivery token, Launch automatically selects a Stack environment available for the selected token.
    
6.  Click the **Import Variables** button.  
      
    ![Launch-LinkedStack-Import\_Variables.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt4490387c1d2ef2ad/6435082db2ef0d11ece9fee2/Launch-LinkedStack-Import_Variables.png)  
      
    
    You can see the Environment Variables auto-populated from your selected stack.  
    
7.  Click the **Deploy** button.  
      
    ![Launch-LinkedStack-Env\_Var\_List.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltc65752cd124d93c6/6435082dc3a87d1213a87a02/Launch-LinkedStack-Env_Var_List.png)  
      
    
8.  Your project is now deployed.  
      
    ![Launch-LinkedStack-Deployed.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt74a4e7e884cec340/6435082d8485c010da11a929/Launch-LinkedStack-Deployed.png)
    

## View a linked stack

Follow the step to view the linked stack after project creation:

1.  Click the **Settings** icon in the left panel and then click **Stack Integration** to view the linked stack.  
      
    ![Launch-LinkedStack-StackIntegration.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte9818b96b83a1c32/64a65eb4b7aec33465d889ad/Launch-LinkedStack-StackIntegration.png)
    
  
3.  You can see the linked stack.
    
      
    

## Update a linked stack

Follow the steps below to update a linked stack:

This will sync your new stack’s Environment Variables to your project.

1.  Click the **Settings** icon in the left panel and then click **Stack Integration**.
    
2.  Choose a stack from the dropdown and then click **Connect Stack** button.  
      
    ![Launch-LinkedStack-UpdateStack.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte023ddf17b951c76/64a65eb44eb51cb4ed35d971/Launch-LinkedStack-UpdateStack.png)  
      
    
3.  Once you choose a different stack, you must sync the stack variables. To do this, follow the steps below:
    
    1.  Click **Environments** under Settings.
        
    2.  Select your environment (Default in this example).
        
    3.  Click **Environment Variables**.
        
    4.  Click **Sync Stack Variables.**
        
      
    6.  A popup displays asking for your confirmation. Select your delivery token and then click the **Yes, Proceed** button.  
          
        ![Launch-LinkedStack-SyncStackProceed.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltb1c340082f87249f/6435082c6bfe3410b96a8ea7/Launch-LinkedStack-SyncStackProceed.png)

#### Key takeaways

- Connect **Environment Variables** back to your stack configuration before moving to the next module.
- Capture one concrete artifact (screenshot, Postman call, or code snippet) that proves the step works in your environment.
- Re-read the delivery versus management boundary for anything you changed in the entry model.

## Supplement for indexing

### Content summary

Environment Variables. Environment Variables Environment Variables are key-value pairs configured outside your source code so that each value can change depending on the Environment (https://www.contentstack.com/docs/developers/launch/environments). Your source code can read these values to change behavior during the Build Step or Launch Cloud Function (https://www.contentstack.com/docs/developers/launch/cloud-functions) execution. All values are visible to any user that has access to the Project. It is safe to use both non-sensitive and sensitive data, such as tokens. Note : Changes to Environment Variables are not applied to previous deployments. They only apply to new deployments. You can add environment variab

### Retrieval tags

- Environment
- Variables
- launch-foundations
- lesson 09
- Environment Variables
- launch-foundations lesson

### Indexing notes

Index this lesson as a primary chunk tagged with lesson_id "09" and topics: [Environment, Variables].
Parent course slug: launch-foundations. Use asset_references URLs as thumbnail hints in search results when present.
Never surface LMS quiz content or assessment answers from this file.

### Asset references

| Label | URL |
| --- | --- |
| Launch\_Env\_Var\_Navigate.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt5523d390422ee656/64a65d3eb62fa40371ab8544/Launch_Env_Var_Navigate.png` |
| Launch-LinkedStack-LaunchIcon.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltd6795befb5942ba3/64354575c6373410f6840530/Launch-LinkedStack-LaunchIcon.png` |
| Launch-New\_Project.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt312818ae4f29de6b/643e70a6a39e8e5aa0f4588e/Launch-New_Project.png` |
| Launch-LinkedStack-Connect\_n\_Import.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt17af4819d7fa38b3/6435082ceb41fa1100c83ad5/Launch-LinkedStack-Connect_n_Import.png` |
| Launch-LinkedStack-Select\_Stack\_DeliveryToken.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte2e9d91734b317c0/6435082d41f63e1131dec78c/Launch-LinkedStack-Select_Stack_DeliveryToken.png` |
| Launch-LinkedStack-Import\_Variables.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt4490387c1d2ef2ad/6435082db2ef0d11ece9fee2/Launch-LinkedStack-Import_Variables.png` |
| Launch-LinkedStack-Env\_Var\_List.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltc65752cd124d93c6/6435082dc3a87d1213a87a02/Launch-LinkedStack-Env_Var_List.png` |
| Launch-LinkedStack-Deployed.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt74a4e7e884cec340/6435082d8485c010da11a929/Launch-LinkedStack-Deployed.png` |
| Launch-LinkedStack-StackIntegration.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte9818b96b83a1c32/64a65eb4b7aec33465d889ad/Launch-LinkedStack-StackIntegration.png` |
| Launch-LinkedStack-UpdateStack.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte023ddf17b951c76/64a65eb44eb51cb4ed35d971/Launch-LinkedStack-UpdateStack.png` |
| Launch-LinkedStack-SyncStackProceed.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltb1c340082f87249f/6435082c6bfe3410b96a8ea7/Launch-LinkedStack-SyncStackProceed.png` |

### External links

| Label | URL |
| --- | --- |
| Contentstack Academy home | `https://www.contentstack.com/academy/` |
| Training instance setup | `https://www.contentstack.com/academy/training-instance` |
| Academy playground (GitHub) | `https://github.com/contentstack/contentstack-academy-playground` |
| Contentstack documentation | `https://www.contentstack.com/docs/` |
| Environment | `https://www.contentstack.com/docs/developers/launch/environments` |
| Cloud Function | `https://www.contentstack.com/docs/developers/launch/cloud-functions` |
| Launch\_Env\_Var\_Navigate.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt5523d390422ee656/64a65d3eb62fa40371ab8544/Launch_Env_Var_Navigate.png` |
| Contentstack account | `https://www.contentstack.com/login/` |
| Launch-LinkedStack-LaunchIcon.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltd6795befb5942ba3/64354575c6373410f6840530/Launch-LinkedStack-LaunchIcon.png` |
| Launch-New\_Project.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt312818ae4f29de6b/643e70a6a39e8e5aa0f4588e/Launch-New_Project.png` |
| Import from a Git Repository | `https://www.contentstack.com/docs/developers/launch/import-project-using-github` |
| Upload a file | `https://www.contentstack.com/docs/developers/launch/import-project-using-file-upload` |
| Launch-LinkedStack-Connect\_n\_Import.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt17af4819d7fa38b3/6435082ceb41fa1100c83ad5/Launch-LinkedStack-Connect_n_Import.png` |
| Launch-LinkedStack-Select\_Stack\_DeliveryToken.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte2e9d91734b317c0/6435082d41f63e1131dec78c/Launch-LinkedStack-Select_Stack_DeliveryToken.png` |
| Launch-LinkedStack-Import\_Variables.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt4490387c1d2ef2ad/6435082db2ef0d11ece9fee2/Launch-LinkedStack-Import_Variables.png` |
| Launch-LinkedStack-Env\_Var\_List.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltc65752cd124d93c6/6435082dc3a87d1213a87a02/Launch-LinkedStack-Env_Var_List.png` |
| Launch-LinkedStack-Deployed.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt74a4e7e884cec340/6435082d8485c010da11a929/Launch-LinkedStack-Deployed.png` |
| Launch-LinkedStack-StackIntegration.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte9818b96b83a1c32/64a65eb4b7aec33465d889ad/Launch-LinkedStack-StackIntegration.png` |
| Launch-LinkedStack-UpdateStack.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blte023ddf17b951c76/64a65eb44eb51cb4ed35d971/Launch-LinkedStack-UpdateStack.png` |
| Launch-LinkedStack-SyncStackProceed.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/bltb1c340082f87249f/6435082c6bfe3410b96a8ea7/Launch-LinkedStack-SyncStackProceed.png` |
