If you accidentally locked yourself out, first make sure you really can't get in. Look for the key again. See if there's a hidden spare. Check all doors and windows for an unlocked one that would allow you easy access. Contact anyone else who'd have a key: roommates, a partner, friend, family member, or trusted neighbor. Then, if you're still stuck, contact your landlord or property manager.