API gets interrupted because it takes too long

I tried to move all the "heavy " calculation in scheduled API, but I still got in troubles.

The API interrupts because is too long?
For the records:
currently there are 681 records of “Labor Time Cost”
and 2000 records of TS project hours
what is the limitation on list to change in APIs?
am I doing something wrong?