Step 1. Create an input

1. Generate your API key

Create a Custom Feed on the Setup page to generate server-to-server API credentials.

2. Add the mParticle SDK dependency

Our Java SDK is available via Gradle or Maven.

Add the SDK dependency to your build.gradle file.

dependencies {
  implementation 'com:mparticle:server-events-sdk:2+'

Add the SDK dependency to your pom.xml file.


3. Call the Events API

Now you can integrate mParticle in your Java application.

// configure API
EventsApi api = new ApiClient(

// assemble an event batch
Batch batch = new Batch();
batch.userIdentities(new UserIdentities()

// Set a Data Plan
Context context = new Context();
DataPlanContext dpContext = new DataPlanContext();

// create an event
CustomEvent customEvent = new CustomEvent().data(
        new CustomEventData()

// create attributes
Map customAttributes = new HashMap<>();
customAttributes.put("price", 33);

// add them to an event

// upload
Call<Void> singleResult = api.uploadEvents(batch);
Response<Void> singleResponse = singleResult.execute();
System.out.println("Returned code: " + singleResponse.code());

4. Verify installation

Go to the Live Stream and watch new events come in as you run your application.

Next Steps 🎉

Congrats on sending your first event to mParticle!

Some suggestions on what to do next:

Was this page helpful?