The primary character in "An Occurrence at Owl Creek Bridge" by Ambrose Bierce is Peyton Farquhar, and we meet him as he is standing on a plank over Owl Creek with a noose around his neck. He does not appear to be a vicious man or a hardened criminal; in fact, he is quite the opposite. He is about 35 years old and is dressed in the clothing of a gentleman farmer or planter. He is a civilian and his expression is "kindly," which is rather surprising since he is about to be hanged. He comes from a well respected family, but he is a slave owner and therefore a secessionist. That automatically puts him at odds with the Union Army.
The only other real characters in the story are the unnamed soldiers who are responsible for Peyton's hanging and death, his wife who we learn virtually nothing about, and his children, whom we never meet.
The story is set in northern Alabama during the Civil War, so the conditions for the South are not very good. In fact, things are pretty grim. Farquhar is set up by a Federal scout (though Farquhar does not know it), who tells him the Union Army is repairing railroad lines and preparing to attack. The nearest railroad site is the nearby Owl Creek Bridge. But the man warns Farquhar that
any civilian caught interfering with the railroad, its bridges, tunnels or trains will be summarily hanged.
As an ardent supporter of the Southern cause, Farquhar does what he should not have done and now he is paying the price.
The social conditions are still very much pro-slavery, and the white people are fighting what they know is a battle to keep the lives they know. The black slaves are still just property, but that will soon change. Economic conditions are getting worse, and the Yankees have begun to isolate the South, cutting off all supplies by destroying the railroad system. While Farquhar is obviously still doing well, he knows the day will come when he and his family will suffer.
Bierce was an ardent believer in presenting the horrors and grotesqueness of war, and he does that here through the psychological/emotional torture Farquhar endures.
While he uses the artifice of the "surprise ending" (one of the artistic devices you asked about), he also wants his readers to be quite aware of the power of the mind. Farquhar's mind tells him something that is not true, yet he believes it. He feels as if he has escaped and is free, but he is not. This is not just a literary trick; it is the way our minds can work under duress.
Above all, Bierce has a bitter and cynical view of life. He wants his audience to be fooled into thinking that this story is going to have a so-called happy ending, but of course it does not. Even worse, he gives us plenty of clues that this story will not end well, yet he presumes that his readers will deceive themselves (much like Farquhar himself) into believing that all will be well.
As I mentioned, the surprise ending is one artistic device in this story. Another is the division of the story into three distinct parts. We get the setting, without much explanation, in the first section. In the second we get the only significant dialogue in the story, as well as the background of Farquhar's current circumstances.
The third section is full of overblown details, such as "the prismatic colors in all the dewdrops upon a million blades of grass" and "the music of aeolian harps.” This style of writing and description is drastically different, and we should see that what we are reading is neither real nor true.