With such an immediate problem returning it to your dealer or to S&W directly makes sense. It is a warranty issue.
However, since you asked, it seems you may be willing to fix it yourself if it is simple and quick. Without knowing more, I'd guess you can.
function on these boards sucks, making it hard to easily find similar threads that already cover almost every topic/problem.
From just within the past week on your same experience:
New 9mm M&P Shield - slide getting jammed back.
Shield slide sticking back
In short, there may be a lack of clearance between the sides of the barrel immediately in front the square chamber and the corresponding area in the front slide barrel hole when the slide is back contacting the breech.
Get it unstuck by covering a piece of wood with a couple of rags and while holding the gun vertically, barrel down, gently tapping the muzzle on the wood until the slide releases and comes forward.
Then remove the barrel from the slide. Remove a little material from each side of the barrel. Do not relieve the slide hole. Reassemble with a little grease. Rack your slide hard. If it doesn't stick, shoot it.
If the problem is not resolved, there is a different problem. Send it back. Your minor effort on the barrel area should not interfere with your warranty claim.