It sounds like you're trying to hold all this in your head rather than taking notes! Why?
Are you sure the task really requires going three+ levels deep into what the API is doing??! On the surface, being asked to "port the API" sounds more like a request for a work-alike API not a complete redesign, although with the idiom of the target language of course.
I don't think this has anything to do with age! You should be at the top of your game at age 40, if not still improving, but maybe there are personal/stress factors that are affecting you.
Are you sure the task really requires going three+ levels deep into what the API is doing??! On the surface, being asked to "port the API" sounds more like a request for a work-alike API not a complete redesign, although with the idiom of the target language of course.
I don't think this has anything to do with age! You should be at the top of your game at age 40, if not still improving, but maybe there are personal/stress factors that are affecting you.