how to create Super Table field programmatically i am trying to create a super table field programmatically.
this is the code i tried.

i see super table field in field list but i can see fields inside of super table.

how can i do this?

    //create super table field itself
    $superTable = new SuperTableField([
        'name' =&gt; 'supertablefield',
        'handle' =&gt; 'supertablefield',
        'groupId' =&gt; 1
    ]);
    Craft::$app-&gt;getFields()-&gt;saveField($superTable);
    //field inside super table
    $field = new \craft\fields\PlainText([
        "name" =&gt; 'textfield',
        "handle" =&gt; 'textfield',
        "translationMethod" =&gt; "site",
        "multiline" =&gt; 0,
    ]);
   //create and set block type
    $blockModel = new SuperTableBlockTypeModel();
    $blockModel-&gt;fieldId = $superTable-&gt;id;
    $blockModel-&gt;uid = StringHelper::UUID();
    $blockModel-&gt;setFields([$field]);

    $superTable-&gt;setBlockTypes([$blockModel]);
    SuperTable::$plugin-&gt;service-&gt;saveBlockType($blockModel);
Not sure if this is the answer without playing, but try saving the plain text field before adding it to the super table:

    // Create the super table field

    $superTable = new SuperTableField([
        'name' =&gt; 'supertablefield',
        'handle' =&gt; 'supertablefield',
        'groupId' =&gt; 1
    ]);

    Craft::$app-&gt;getFields()-&gt;saveField($superTable);


    // Create plain text field

    $field = new \craft\fields\PlainText([
        "name" =&gt; 'textfield',
        "handle" =&gt; 'textfield',
        "translationMethod" =&gt; "site",
        "multiline" =&gt; 0,
    ]);


    // Save the plain text field

    Craft::$app-&gt;getFields()-&gt;saveField($field);


    // Retrieve the plain text field 

    $plainTextField = Craft::$app-&gt;fields-&gt;getFieldByHandle("textfield")


    // Create and set the block

    $blockModel = new SuperTableBlockTypeModel();
    $blockModel-&gt;fieldId = $superTable-&gt;id;
    $blockModel-&gt;uid = StringHelper::UUID();
    $blockModel-&gt;setFields([$plainTextField]);
    $superTable-&gt;setBlockTypes([$blockModel]);
    SuperTable::$plugin-&gt;service-&gt;saveBlockType($blockModel);