Line a 9x9 inch baking pan with parchment paper, allowing overhang for easy removal. Lightly grease the parchment.
In a heavy-bottom saucepan, combine granulated sugar and corn syrup. Stir well and place over medium heat.
Allow the mixture to boil without stirring until it reaches 240°F (soft-ball stage).
Reduce heat to low and whisk in unsalted butter until melted. Gradually add heavy cream while stirring constantly.
Add cocoa powder, espresso powder, and vanilla extract. Stir until smooth.
Increase heat to medium and cook, stirring frequently, until the mixture reaches 245°F (firm-ball stage).
Pour the mixture into the prepared pan and sprinkle flaky sea salt on top if desired. Let cool completely at room temperature.
Lift the caramels out using the parchment overhang, cut into desired shapes, and wrap individually for gifting or storage.