First, make sure that your Instagram is set up as a "Professional" account. If your account is just a "personal" account, you won't be able get a Partnership Ad Code. Follow the steps here to convert your account to "Professional".
Second, be sure you're eligible to create branded content.
Go to Settings and Activity
Under the “For professionals” section, go to “Creator tools and controls” then “Branded Content”
From there, make sure that the Status under “Branded Content” is set to "Eligible".
Finally, generate the ad code. Select the post, story or reel that you want to turn into a partnership ad from your Instagram profile.
Tap the 3 dots in the top right corner of your post, story or reel.
Tap Partnership label & ads.
Turn on the Add partnership label toggle.
Note: You can stop a code from being used to create any new ads by turning the toggle off. Any active ads using the code will continue running.The code will appear. Tap Copy to save it to your clipboard.
You can find more details on this final step here.