After it restarted, did you see a dialog box resembling this one:
If so, next time it occurs click Report...
Before you send it to Apple, copy the text of the report. Paste it in a reply. Remove or obscure any personal information, should it appear.
If problems continues to occur please determine if they also occur in "Safe Mode":
- Safe Mode or "Safe Boot" is a troubleshooting mode that bypasses all third party system extensions and loads only required system components. Read about it: Starting up in Safe Mode
- Starting your Mac in Safe Mode will take longer than usual, graphics will not render smoothly, audio is disabled on some Macs, and some programs (iTunes for example) may not work at all.
- To end Safe Mode restart your Mac normally. Shutdown will take longer as well.
Perform an SMC reset.
Read all the steps. If the MacBook Air never gets beyond the login screen before it spontaneously shuts down you won't be able to perform the "Before Resetting the SMC" steps, so just skip to the next section.
Before Resetting the SMC
Try each of the following steps in this order before you reset the SMC. Test the issue after completing each troubleshooting step to determine if the issue still occurs.
- Press Command + Option + Escape to force quit any application that is not responding.
- Put your Mac to sleep by choosing the Apple () menu from the upper-left menu bar and then choosing Sleep. Wake the computer after it has gone to sleep.
- Restart your Mac by choosing the Apple () menu from the upper-left menu bar and then choosing Restart.
- Shut down your Mac by choosing the Apple () menu from the upper-left menu bar and then choosing Shut Down.
Resetting the SMC on portables with a battery you should not remove on your own
- Shut down the computer.
- Plug in the MagSafe power adapter to a power source, connecting it to the Mac if it's not already connected.
- On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
- Release all the keys and the power button at the same time.
- Press the power button to turn on the computer.
Determine if the Mac starts and allows you to log in.