Get logged in user id in api calls I am working on an existing site where it has exposed api's via a custom module. 

There's a new requirement where an api should only be accessed by authenticated user. For that theres a login api provided. 

How can I make sure to add login information such that drupal recognises which user is making the call.

Does keeping SESSIONID in header will make drupal identify the user.

Note the API calls are made from android/ios app.
If the user is not logged into your app and if you don't let anonymous users to access the API, how can you let them to log in without accessing API?

What you can do is you can maintain a API key for your application. You should call the API using the key all the time. That should be your first check point. Then you should add that API key validation for accessing the API. Then you can give access to your login API function using that key.

Once user is successfully login to the system you can return a dynamically genarated(random) session key to your APP so that the user login to the app and he/she has a session key. From that point call the API using the session key and add validation method to validate both session key and API key.

So all API functions are accessed by logged in users only. When the user logs out from the app call a session key function to remove your key.

I think you are looking for this kind of a solution.