Your situation with one breaker in the main panel and another breaker in the disconnect near the spa is a common one. You're right: it can be confusing to figure out what's required and what's acceptable or allowed. Hopefully the following guidelines will help.
- Both of the breakers must have a rating equal to or greater than the "minimum circuit" called for in the spa manual.
- One of the breakers must have a rating that is equal to or less than the "maximum circuit" called for in the spa manual. The other breakers may also be chosen to be equal to or less than the "maximum circuit," or they may have ratings higher than this.
- One of the breakers must offer GFCI protection. I believe that technically both breakers could be GFCI, but this is more costly, can create confusion, and does not improve safety.
- The ampacity of the wire between the main-panel breaker and the spa-panel must match (or exceed) the rating of the main-panel breaker.
So: if you're in the situation of installing all new parts (main-panel breaker, wire, and spa-panel), I'd suggest the following. A 40 amp spa is relatively low-power; spas requiring as much as 60 amps are becoming more common. This suggests than a 60-amp spa might be in your future, so choose the difficult or expensive parts accordingly.
- Use a 60 amp GFCI spa disconnect panel outside.
- Use wire from the spa disconnect to the main panel suitable for 60 amps. The minimum wire gauge will vary depending on whether you use NM-B, copper THHN in conduit, aluminum THHN in conduit, aluminum SE cable, etc.
- In the main panel, use whatever equal-or-less-than-60-amp breaker the spa requires. In your case this would be 40 amps.
- Confirm that the main-panel breaker, 40 amps in your case, accepts the selected gauge of wire. If it does not then you'll have to use smaller wire and lose the future upgradability to 60 amps, or you'll have to adapt the large wire down to a breaker-accepted size with a block connector like Polaris or Mac/ILSCO.
The advantage of this approach is that if you desire a different spa in the future and it requires 50 or 60 amps, the only component you have to change is the breaker in the main panel (which also happens to be the least expensive part in the whole setup!).