Alex Nicholls scored the winner as Northampton dumped last season's runners-up Cardiff out of the Capital One Cup.
Nicholls's winner came three minutes after the interval when his header beat Joe Lewis following a corner.
Heidar Helguson had given Cardiff the lead with a penalty after three minutes when he was fouled by Kelvin Langmead.
David Artell's header brought Northampton level on 37 minutes before Nicholls's winner.
With eight players away on international duty, Cardiff started with five teenagers as well as summer signings Helguson and Joe Lewis.
And within two minutes Cardiff were awarded a penalty when Helguson fell under the clumsy challenge of captain Langmead.
Helguson took the kick and sent 17-year-old goalkeeper Dean Snedker the wrong way to give Cardiff an early lead.
Northampton v Cardiff facts
Northampton won the only previous League Cup tie between the sides in the first round 16 years ago, courtesy of a 2-1 aggregate score.
The League Two side responded swiftly to going a goal down and within a minute Artell sent a powerful header wide from Chris Hackett's corner
Luke Guttridge also fired over from long range for Aidy Boothroyd's side while Cardiff's Joe Mason fired straight at Snedker
Stephen McPhail's involvement in the game came to an end on 18 minutes when he was replaced by youngster Tommy O'Sullivan.
Northampton deservedly drew level eight minutes before the break when Artell's header from Ben Tozer's long throw trickled past Lewis.
Ben Harding missed a great chance to put Northampton in front three minutes later but he could only shoot wide.
But the home side took the lead three minutes after the interval.
Lewis, making his Cardiff debut, failed to deal with an inswinging corner from Hardin and Nicholls nipped in to head home at the far post.
Cardiff at the time of the goal were down to ten men as substitute Jordan Mutch, who replaced Joe Mason at the start of the second half, was in the dressing room.
Mutch had white ankle tape on and new rules insist any tape worn has to be the same colour as the socks, in Cardiff's case blue.
Langmead came close to increasing Northampton's lead five minutes later when he turned well in the box but Lewis blocked his close-range effort.
Malky Mackay's Championship side offered little in response apart from a Joe Ralls long-range effort which flew over.
Nicholls nearly scored his second and Northampton's third with seven minutes remaining when his neat flick went just wide following Henoc Mukendi cross.
Substitute O'Sullivan wasted a glorious opportunity to level for Cardiff in the final minute but Northampton survived to book their place in round two.
Northampton Town 13 Snedker 02 Johnson 03 Widdowson 05 Langmead 12 Tozer 18 Artell Booked 04 Guttridge Booked 08 Harding 11 Hackett (Mukendi - 56' ) 09 Platt (Akinfenwa - 71' Booked ) 14 Nicholls Substitutes 26 Heath 06 Charles 07 Demontagnac 10 Akinfenwa 15 Mukendi 16 Wilson 17 Robinson Cardiff City 32 Lewis 28 Keinan 31 Nugent 35 Oshilaja Booked 11 Conway 21 Ralls 36 Sainte-Luce Booked 37 McPhail (O'Sullivan - 19' ) 42 John 20 Mason (Mutch - 51' ) 22 Helguson (Jarvis - 61' ) Substitutes 29 Parish 43 Hill 18 Mutch 34 Darco 38 O'Sullivan 33 Jarvis 45 Wharton