I call register_post_type() and register_taxonomy() on the init hook. The important arguments are labels, public, has_archive, rewrite, supports, show_in_rest, and the capability settings. show_in_rest => true is needed for the block editor and for the REST API.
add_action( 'init', 'amitex_register_post_types' );
function amitex_register_post_types() {
register_post_type( 'amitex_event', array(
'labels' => array(
'name' => __( 'Events', 'amit-example' ),
'singular_name' => __( 'Event', 'amit-example' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'events', 'with_front' => false ),
'show_in_rest' => true,
'rest_base' => 'events',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields' ),
'menu_icon' => 'dashicons-calendar-alt',
'map_meta_cap' => true,
) );
register_taxonomy( 'amitex_event_type', array( 'amitex_event' ), array(
'labels' => array( 'name' => __( 'Event Types', 'amit-example' ) ),
'hierarchical' => true,
'show_in_rest' => true,
// ...
Example of the approach