you can pass the api key using command line variables similar to how you are passing env.

mvn test -PSmokeTests -Denv=QA -DapiKey="keyvalue123"

You can ccess api key inside your java project using the following command

String apiKey = System.getProperty("apiKey");
Answer from user2391218 on Stack Overflow
🌐
Maven Repository
mvnrepository.com β€Ί artifact β€Ί io.rest-assured β€Ί rest-assured
Maven Repository: io.rest-assured Β» rest-assured
January 16, 2026 - Rest-Assured is a Java library for testing REST services. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module ...
🌐
Maven Central
central.sonatype.com β€Ί artifact β€Ί io.rest-assured β€Ί rest-assured
Maven Central: io.rest-assured:rest-assured
--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <properties> <httpclient.version>4.5.13</httpclient.version> </properties> <parent> <groupId>io.rest-assured</groupId> <artifactId>rest-assured-parent</artifactId> <version>6.0.0</version> </parent> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>6.0.0</version> <packaging>bundle</packaging> <name>REST Assured</name> <de
🌐
Rest-assured
rest-assured.io
REST Assured
2025-12-12: REST Assured 6.0.0 is released. It raises the baseline to Java 17+, upgrades to Groovy 5, adds Spring 7 + Jackson 3 support (and bumps minimum versions for Spring/Yasson/Johnzon).
🌐
GitHub
github.com β€Ί rest-assured β€Ί rest-assured β€Ί wiki β€Ί gettingstarted
GettingStarted Β· rest-assured/rest-assured Wiki Β· GitHub
Standalone JsonPath (included if you depend on the rest-assured artifact). Makes it easy to parse JSON documents. Note that this JsonPath implementation uses Groovy's GPath syntax and is not to be confused with Kalle Stenflo's JsonPath implementation. Maven: <dependency> <groupId>io.rest-assured</groupId> <artifactId>json-path</artifactId> <version>6.0.0</version> <scope>test</scope> </dependency> Gradle: testImplementation 'io.rest-assured:json-path:6.0.0' Stand-alone XmlPath (included if you depend on the rest-assured artifact).
Author Β  rest-assured
🌐
Baeldung
baeldung.com β€Ί home β€Ί http client-side β€Ί a guide to rest-assured
A Guide to REST-assured | Baeldung
January 11, 2025 - If we’re using Maven, we add the rest-assured dependency in the pom.xml file:
🌐
Medium
medium.com β€Ί @reddy.lavi29 β€Ί what-is-rest-assured-and-how-to-create-simple-rest-assured-api-automation-framework-b23a64b950f0
What is Rest Assured and How to Create Simple rest-assured API Automation Framework? | by Lavanya Reddy | Medium
January 12, 2024 - Here are the primary uses of RestAssured dependencies in a Maven project: ... <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.5</version> <scope>test</scope> </dependency> ... Create a test class in the src/test/java directory. For example, create a class named API_Test_Code.Java ... Creating a test case for a REST API using Rest Assured involves defining the request, sending it to the server, and then validating the response.
🌐
Maven Repository
mvnrepository.com β€Ί artifact β€Ί io.rest-assured
Maven Repository: io.rest-assured
Rest-Assured is a Java library for testing REST services. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module ...
Find elsewhere
🌐
Maven Repository
mvnrepository.com β€Ί artifact β€Ί io.qameta.allure β€Ί allure-rest-assured
Maven Repository: io.qameta.allure Β» allure-rest-assured
December 12, 2025 - Module allure-rest-assured of Allure Framework. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module npm osgi ...
🌐
GitHub
github.com β€Ί rest-assured β€Ί rest-assured
GitHub - rest-assured/rest-assured: Java DSL for easy testing of REST services Β· GitHub
2025-12-12: REST Assured 6.0.0 is released. It raises the baseline to Java 17+, upgrades to Groovy 5, adds Spring 7 + Jackson 3 support (and bumps minimum versions for Spring/Yasson/Johnzon).
Starred by 7.1K users
Forked by 1.9K users
Languages Β  Java 85.6% | Groovy 12.9%
🌐
Blazemeter
blazemeter.com β€Ί blog β€Ί rest-assured-api-testing
REST Assured API Testing: Complete Guide With Serenity | Perforce BlazeMeter
In our example, the Serenity framework will be used as a wrapper around the REST Assured API tests. We will learn how to set up a project structure to use Serenity’s important features. The main thing we will try to cover is how you can avoid code duplication by creating reusable methods and specifications.Back to top Β· Let’s start with the project creation. All you need in the first step is to create a Maven project with a basic structure in your favorite development environment (as for me, I prefer IntelliJ IDEA):
🌐
Stackademic
blog.stackademic.com β€Ί set-up-robust-api-automation-framework-with-rest-assured-using-maven-22a88de8ccce
Set up Robust API Automation Framework with Rest Assured using Maven | by Chandan Kumar | Stackademic
March 17, 2025 - RestAssuredFramework │── src/main/java # Main framework utilities β”‚ β”œβ”€β”€ base # Base classes (setup, config) β”‚ β”‚ β”œβ”€β”€ BaseTest.java β”‚ β”‚ β”œβ”€β”€ ConfigReader.java β”‚ β”œβ”€β”€ utils # Utility classes β”‚ β”‚ β”œβ”€β”€ APIUtils.java β”‚ β”‚ β”œβ”€β”€ JsonHelper.java │── src/test/java # Test cases β”‚ β”œβ”€β”€ testcases # API Test cases β”‚ β”‚ β”œβ”€β”€ GetAPITests.java β”‚ β”‚ β”œβ”€β”€ PostAPITests.java β”‚ β”œβ”€β”€ data # Test data β”‚ β”‚ β”œβ”€β”€ testData.json │── src/test/resources # Configuration files β”‚ β”œβ”€β”€ config.properties │── pom.xml # Maven dependencies │── testng.xml # Test execution configuration
🌐
Allure Report
allurereport.org β€Ί docs β€Ί restassured
Allure Report Docs – REST Assured
Add the Allure REST Assured integration to your project's dependencies. MavenGradle (Kotlin)Gradle (Groovy) xml Β·
🌐
Maven Central
central.sonatype.com β€Ί artifact β€Ί io.rest-assured β€Ί rest-assured β€Ί 4.1.1
Maven Central: io.rest-assured:rest-assured:4.1.1
--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <properties> <httpclient.version>4.5.3</httpclient.version> </properties> <parent> <groupId>io.rest-assured</groupId> <artifactId>rest-assured-parent</artifactId> <version>4.1.1</version> </parent> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>4.1.1</version> <packaging>bundle</packaging> <name>REST Assured</name> <des
🌐
Medium
naodeng.medium.com β€Ί rest-assured-tutorial-building-a-rest-assured-interface-automation-test-program-from-0-to-1-aa8c3f98c6d2
REST Assured Tutorial: Building a REST Assured API Automation Test Program from 0 to 1 | by Nao | Medium
January 4, 2024 - Initialization complete: After completing the wizard, Maven will create a new project directory and a basic Maven project structure Β· Add the following to the pom.xml file in your project Β· You can copy the contents of the pom.xml file in this project. For more information on configuration, please refer to the official documentation. <!-- dependencies config --> <dependencies> <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured --> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>5.3.1</version> <scope>test</scope> </dependency>
🌐
True Sparrow Blog
truesparrow.com β€Ί blog β€Ί rest-assured-step-by-step-installation-and-setup
REST Assured: Step-by-step Installation and Setup.
August 5, 2022 - Here we will explain, step-by-step installation and setup of REST assured. It requires mainly Java, Eclipse, Maven and some dependencies.
🌐
Google Groups
groups.google.com β€Ί g β€Ί rest-assured β€Ί c β€Ί opulYbQFfIY
Maven issue with REST Assured, and how I fixed it
If your project uses some of the same libraries that rest-assured uses, it could cause conflicts if there are different versions. I also had to include this right after the above dependency: <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.1</version> <scope>test</scope> </dependency> Maven was for some reason unable to resolve this one on its own.