Sajad,
just to be explicit:
in FreeSWITCH, when a person say "API" it means "sending a command from the freeswitch command line" (and you *can* execute lua from freeswitch command line)
maybe, you are executing a LUA script from dialplan or configuration, so you are not using the freeswitch API
in that case, you are executing a lua script from dialplan. That lua script is written to execute the lua API to interact with freeswitch
in that case, for clarity, in future, you want to write: "I am executing a lua script"
If a lua script is started from dialplan, it always has a session object, until the call is hangup
the other case: if a lua script is started from the command line (eg, from the freeswitch API) it never has a session object, you must create it getting the uuid of the call from the freeswitch API (or because you know in advance the call uuid because you originated that call giving the uuid as parameter).