Function for when new custom post type is created should do something

You can do something on a post creation with the action save_post_

$customPostType = "custom";


add_action("save_post_" . $customPostType, function ($post_ID, \WP_Post $post, $update) {

    if (!$update) {
        // creation of the custom post
        // ...

        return;
    }


    // updating of the custom post
    // ...



}, 10, 3);