Even in cities like NYC and Paris where many of our friends rent out, it’s easy to bypass rules if you know what you’re doing. You can let guests know ahead of time and also the MOST important person is typically the doorman.
If there is a doorman. Plenty of nicer non-doorman buildings in NY.
This being said, if the building is a co-op which doesn’t allow subleasing and the board gets a bug up its collective butthole about you, you could conceivably lose the place. Highly unlikely – they’re more likely to fine you or send you a nasty letter signed by an atty – but theoretically possible. Co-op isn’t real property: you’re buying shares in a nonprofit that owns the building and leasing your apt back for the cost of common charges, basically.