Registering trackable entities for an event

Hello All

The DHIS2 documentation mentions that is it possible, via the API, to
link tracked entities to events (i.e. events with registration) - but
does not provide an example of what the resulting data structure would
look like. Does anybody know where I could find an example?

Also, does the trackedEntity have to already be linked to the relevant
program - or will registering them for the event automagically link them
to the program as well?

Thanks

Rory McKinley