check_admin_referer not working in custom meta box for custom post type

Now in saving function …

in which hook ? if you do this in “save_post_CPT”, it doesn’t work because this hook is called a first time a the object creation

then you have to do this :

add_action("save_post_CPT", function ($object_ID, \WP_Post $object, $update) {

    if (!$update) {

        // new object, here you can define default values



        return;

    }



    if (isset($_REQUEST["uniqueid"])) {

        check_admin_referer(
              "uniqueid"
            , "my_nonce"
        );



        // saving informations of the metabox


    }


    // here the code when the object is put in the trash or with quick edit e.g.




}, 10, 3);