Ok, you're referring to two-step verification.
When you set up two-step verification, it gave you also as backup a "Recovery Key" to use in case you lose your device.
If you lost the trusted device or phone number associated with your Apple ID
As long as you still have your Recovery Key and remember your Apple ID password, you can sign in and add a new trusted device or phone number to your account. You can also remove any devices you may have lost, sold, or given away.
- Go to your Apple ID account page and enter your Apple ID and password.
- On the Verify Your Identity screen, select "Can’t access your trusted devices?"
- In the pop-up window, enter your Recovery Key.
- Go to the Security section and click Edit.
Remove the device you no longer wish to use to verify your identity. If you have additional devices with Find My iPhone enabled, you can verify them as trusted devices. You can also add additional trusted phone numbers.
If you lost your Recovery Key
As long as you remember your Apple ID password and still have access to one of your trusted devices, you can sign in and create a new Recovery Key.
- Go to your Apple ID account page.
- Sign in with your password and trusted device.
- In the Security section, click Edit > Replace Lost Key.
Keep your new Recovery Key in a safe place. Your old Recovery Key won't work anymore and you can't use it to reset your password or access your account.
If you lost two or more of the required sign-in items
Two-step verification requires at least two of the items below to sign in successfully:
- Your Apple ID password
- Access to one of your trusted devices
- Your Recovery Key
If you've permanently lost any two of these items, you can't sign in or regain access to your account. You'll need to create a new Apple ID. You can create a new one from the Apple ID site.