Since you have to hitYou can use a table with an auto-incrementing id as the Web API anyways to checkbasis for the validity of theyour code. If need be, you might instead have the Web API generatestart the codeincrements at 100,000 for you6 digits. This way it can guarantee Insert a row, get the id, and return it. It will be guaranteed to be unique code per request.
If you want them generated client sideDepending on your expected usage levels, you can generate them in batches, send the batchmight consider tacking on a few random letters to the Web API for verification, and then use the first oneid. So that is approvedcode '1234' becomes '1234AB'. This will minimizemakes it more difficult to stumble upon other people's codes.
You can also implement the backabove as a lookup-table. Fill a table with suitable codes, and forth betweenreturn the Web APIcorresponding one based on the auto-incremented id.