Follow these guidelines from the Building Act 2004 if you are siting a garden shed or similar small building on your property.
For various options refer to the linked Garden Shed Fact Sheet above.
Neighbour consent to site accessory buildings close to legal boundaries is almost always a condition of a building and resource consent. A neighbour has a right to refuse to give consent.