Asterisk Server SIP

How can I set an endpoint as available or not available without actually closing the sip phone. I want the sip phone to be on all the time and set the endpoint programmatically as online and offline. thanks in advance.

Why are you trying to do this? The answer may give you a better solution.

You can easily control any extension that gives outgoing access to the endpoint, of course.