Requesting an achievement code in Microsoft Learn depends on how you're enrolled in the course:
Instructor-Led Training (ILT)
Self-Paced Learning
If you're unsure about your enrollment type, checking the course details or contacting Microsoft Learn support might be helpful https://learn.microsoft.com/en-us/training/support/.
Sign in with your Microsoft account.
Navigate to your profile by clicking on your avatar in the upper-right corner.
Go to Profile and then to Achievements to see if the code is automatically provided.