Create nested paragraphs programmatically Similar to the question here but for D8. I've managed to create the child paragraphs but failing to generate the parent paragraphs and attaching the child to them.

$questions = [];

foreach($data['questions'] as $question) {
    $answers = [];
    foreach($question['answers'] as $answer) {
        $correct = $answer['field_correct'] === 'Yes' ? 1 : 0;

        $answers[] = Paragraph::create([
            'type' =&gt; 'quiz_answers',
            'field_answer' =&gt; $answer['field_answer'],
            'field_correct' =&gt; $correct,
        ])-&gt;save();
    }

    $questions[] = Paragraph::create([
        'type' =&gt; 'quiz_question',
        'field_question' =&gt; $question['field_question'],
        'field_answers' =&gt; $answers,
    ])-&gt;save();
}


$new_submission = Node::create([
    'type' =&gt; 'quiz_submissions',
    'title' =&gt; 'Quiz Submission',
    'field_quiz' =&gt; $data['quizID'],
    'field_question_submission' =&gt; $questions,
]);
save() returns the status of the save operation, not the entity. And you probably don't need to save the paragraphs, saving the node should save new paragraphs automatically. 

So you can try this version:

$questions = [];

foreach($data['questions'] as $question) {
    $answers = [];
    foreach($question['answers'] as $answer) {
        $correct = $answer['field_correct'] === 'Yes' ? 1 : 0;

        $answers[] = Paragraph::create([
            'type' =&gt; 'quiz_answers',
            'field_answer' =&gt; $answer['field_answer'],
            'field_correct' =&gt; $correct,
        ]);
    }

    $questions[] = Paragraph::create([
        'type' =&gt; 'quiz_question',
        'field_question' =&gt; $question['field_question'],
        'field_answers' =&gt; $answers,
    ]);
}


$new_submission = Node::create([
    'type' =&gt; 'quiz_submissions',
    'title' =&gt; 'Quiz Submission',
    'field_quiz' =&gt; $data['quizID'],
    'field_question_submission' =&gt; $questions,
]);
$new_submission-&gt;save();