Contact your-local-building/zoning-department for your-local-regulations,
and whether you require a license/permit.
Refer to the NEC/National-Eletrical-Code for proper insulation/wire-size/type selection;
40-Amp circuits require AT LEAST #8 AWG Copper wire, at ambient room temperatures.
There are circumstances, like high-ambient-temperatures,
where your-wire-capacities are required to be "de-rated" and you need to use larger-gauge-wire,
refer to the appropriate tables in NEC Article 310.