Are you trying to do natural consequences/gentle parenting?
This is the kind of thing I would do, when I was trying to follow some impossible ideal and then some incident of behaviour would not be manageable with the fantasy system, to the point that I was seriously losing it and would impulsively do something incredibly childish because it's like I would go "Well I have to do SOMETHING. I have to STOP them!" And then immediately as soon as it had happened I would utterly regret it, realise that I was being a shit parent and wish I could undo it.
What actually helped me not get to that point in the first place was ditching the weird ideal fantasy parenting style, using some kind of system with clearer decided-in-advance consequences (quelle horreur) and having much clearer boundaries which were drawn at a place I could actually handle the child stepping over them, rather than having the boundary drawn RIGHT at the place where when they were over the boundary, it was causing a major problem.
And - my kids tend to get hyped up and overexcited and utterly, overly silly and unreasonable after events like that too - if you have a child who is very sensitive to excitement in that way (plus a long period without food and access to a toilet and if they are tired) then it can be extremely difficult to manage them and you will probably have to put a lot more pre-emptive work in to do that compared with what other parents have to do. I know it's not that uncommon, because I do see other children doing it, though it is definitely not the majority. So again the systems, and pre-empting that kind of thing is really helpful, but nobody hands you a manual when you give birth much less tells you when you happen to have one of the extra-challenging models, so you only tend to find this kind of thing out through experience, and you can only pre-empt things AFTER you've had that experience, and got it wrong a few times.
The thing is everyone screws up sometimes and does something against their parenting principles. As long as you're not doing that all day every day you are really doing fine. If you do notice a pattern forming, then that is more of a sign you're not coping (or what you're doing isn't working) and something needs to change. But it doesn't mean you have traumatised him for life because you did something which would have upset him.
You have apologised to your son so move on from it. Don't stay in guilt about it forever. Use it as a marker of "Right. Not the best response - how could I handle that better another time?"
He probably will be upset about it for a while - that's life. He will be OK. He will probably tease you about it when he's a teenager, if he even remembers 