Accept the additional argument on the type of custom message permalink

I have registered a custom foo Type of position:

register_post_type (& # 39; foo & # 39 ;, [
    'rewrite'         => ['slug' => 'foo'],
& # 39; bility_type & # 39; => & # 39; post & # 39;
])

If I created a foo with a slug of bar I can access it with

https://www.example.com/foo/bar/

I would like to add an extra parameter at the end:

https://www.example.com/foo/bar/baz/

It seems that I need to add a ep_mask key to the rewrite chart, but I do not know how. the baz a part will vary and will be used to generate the page differently.