If you know the Apple ID and can access the device, go to Settings > General > Transfer or Reset iPad > Erase All Content and Settings
If you do not know the passcode, put the iPad into recovery mode
Connect the iPad to a computer with Finder on Mac or iTunes on Windows or older macOS
Turn off the iPad
Enter recovery mode:
For iPad with Face ID: press and quickly release Volume Up, press and quickly release Volume Down, then press and hold the Top button until the recovery screen appears
For iPad with Home button: press and hold the Home button and the Top or Side button until the recovery screen appears
On the computer, choose Restore when prompted
Wait for the restore process to finish
Set up the iPad as new or restore from a backup
If Activation Lock appears, enter the Apple ID and password previously used on the iPad
If you cannot access the Apple ID, contact Apple Support with proof of purchase
