Every function in the API requires the session_id as first parameter as http is a stateless protocol. In your script you did not pass the session_id to the sites_web_domain_add function as first parameter.