You need the city owner to tell you what the ID of the city is. If a ship is assigned to you, it will show you in ship stats, or if it is your own ship, you can mouseover the checkbox beside it in your inventory. For facilities, it works the same as with ships.
NPCs cost 50K for conversation NPCs (like miners or builders) and 200K for custom NPCs.