How to create a FieldLayout?

Hi,
I want to create a project including all schemes from scratch in a jira app. When the app is installed the project should be automatically set up.

Currently I am stuck at the creation of a new FieldLayoutScheme for my project. Apparently I need a FieldLayout to generate the FieldLayoutEntitiys, but I do not know how to create a FieldLayout. I only found the possibility to get an existing one with its id.

Alternatively I thought to copy the default FieldLayout with ID 10000L. But I did not find a way to copy it, only how to associate it in a new FieldLayoutScheme.

So far I can create a new FieldLayoutScheme with the FieldLayoutManager.createfieldLayoutScheme() method. Then I think I need to create a new FieldLayout. Then I create FieldLayoutSchemeEntitys for every IssueType I have in my project. But for the creation I alredy need the FieldLayout id.

This is my current code with the ??? included at the fieldLayoutSchemeEntity;

void createFieldLayoutScheme() {
        FieldLayoutScheme fieldLayoutScheme = fieldLayoutManager.createFieldLayoutScheme(FIELD_LAYOUT_NAME, FIELD_LAYOUT_DESC);

        FieldLayout defaultFieldLayout = fieldLayoutManager.getFieldLayout(10000L);

        for (IssueType type : issueTypeList) {
            FieldLayoutSchemeEntity fieldLayoutSchemeEntity = fieldLayoutManager.createFieldLayoutSchemeEntity(fieldLayoutScheme, type.getId(), ???);
            fieldLayoutScheme.store();
            fieldLayoutScheme.addEntity(fieldLayoutSchemeEntity);
        }

        for (CustomField field : customFieldList) {
            fieldLayoutManager.getEditableFieldLayout(10000L).setRendererType(defaultFieldLayout.getFieldLayoutItem(field), AtlassianWikiRenderer.RENDERER_TYPE);
        }
    }

But this does not add up. Can somebody help me?