# Creating Models Programmatically (C8)

**URL:** <https://forum.camunda.io/t/creating-models-programmatically-c8/37473>\
**Category:** Discussion & Questions\
**Created:** [May 8, 2022, 6:01am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473 "2022-05-08T06:01:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hassang](https://forum.camunda.io/user_avatar/forum.camunda.io/hassang/32/16498_2.png) [@hassang](https://forum.camunda.io/u/hassang)\
**Post date:** [May 8, 2022, 6:01am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473/1 "2022-05-08T06:01:34Z")

</div>

In platform 7, BPMN models can be created programmatically.  
I wonder if such a possibility is available in platform 8.

> **[Create a Model | docs.camunda.org](https://docs.camunda.org/manual/latest/user-guide/model-api/bpmn-model-api/create-a-model/)**
>
> documentation of the Camunda Platform 7

> **[Fluent Builder API | docs.camunda.org](https://docs.camunda.org/manual/latest/user-guide/model-api/bpmn-model-api/fluent-builder-api/)**
>
> documentation of the Camunda Platform 7

---

<div class="post-metadata">

**Author:** ![Zelldon](https://forum.camunda.io/user_avatar/forum.camunda.io/zelldon/32/869_2.png) [@Zelldon](https://forum.camunda.io/u/Zelldon)\
**Post date:** [May 8, 2022, 6:05am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473/2 "2022-05-08T06:05:05Z")

</div>

Hey @hassang

yes we have a port of it for Zeebe as well. It is part of the Zeebe repo see here [zeebe/bpmn-model at main · camunda/zeebe · GitHub](https://github.com/camunda/zeebe/tree/main/bpmn-model)

Greets  
Chris

---

<div class="post-metadata">

**Author:** ![hassang](https://forum.camunda.io/user_avatar/forum.camunda.io/hassang/32/16498_2.png) [@hassang](https://forum.camunda.io/u/hassang)\
**Post date:** [May 8, 2022, 6:32am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473/3 "2022-05-08T06:32:52Z")

</div>

Hi @Zelldon,

Are there any related examples or documentation?  
Thanks in advance…

---

<div class="post-metadata">

**Author:** ![hassang](https://forum.camunda.io/user_avatar/forum.camunda.io/hassang/32/16498_2.png) [@hassang](https://forum.camunda.io/u/hassang)\
**Post date:** [May 8, 2022, 7:25am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473/4 "2022-05-08T07:25:24Z")

</div>

Thanks @Zelldon

I managed to do a small test.

- Imported the required maven dependency as below

```auto
<dependency>
	<groupId>io.camunda</groupId>
	<artifactId>zeebe-bpmn-model</artifactId>
	<version>8.0.2</version>
</dependency>

```

- Code is identical to C7 code

```auto
BpmnModelInstance modelInstance;
File file;

modelInstance = 
		Bpmn.createProcess()
			.name("Example process")
			.id("example-process")
			.executable()
		.startEvent()
		.userTask()
			.name("Task 1")
			.id("ut-task1")
			.zeebeAssignee("test-user")
		.endEvent()
		.done();

file = new File("C:\\model-api-test\\example-c8-process.bpmn");

try {
	
	file.createNewFile();
	
} catch (IOException e) {

	System.out.println("Error: " + e.getMessage());
}

Bpmn.writeModelToFile(file, modelInstance);

```

---

<div class="post-metadata">

**Author:** ![Zelldon](https://forum.camunda.io/user_avatar/forum.camunda.io/zelldon/32/869_2.png) [@Zelldon](https://forum.camunda.io/u/Zelldon)\
**Post date:** [May 9, 2022, 6:24am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473/5 "2022-05-09T06:24:58Z")

</div>

Hey @hassang

sorry for the late reply. I was not able to send a good example before since I was only available via mobile. Thanks for sharing your solution 🙂

You can also take a look at the engine tests, e.g. [zeebe/CreateProcessInstanceTest.java at main · camunda/zeebe · GitHub](https://github.com/camunda/zeebe/blob/main/engine/src/test/java/io/camunda/zeebe/engine/processing/processinstance/CreateProcessInstanceTest.java#L38-L41) where we use the model API everywhere.

Greets  
Chris

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [January 31, 2024, 10:15am UTC](https://forum.camunda.io/t/creating-models-programmatically-c8/37473/6 "2024-01-31T10:15:03Z")

</div>

Closed on January 31, 2024, 10:15am UTC


