A selection of verses showing that forgiveness is conditional on our confession.

2 Samuel 12 verse 13
13 David said to Nathan, “I have sinned against the LORD.”
Nathan said to David, “The LORD also has put away your sin. You will not die.

Psalms 32 verse 5
5 I acknowledged my sin to you.
I didn’t hide my iniquity.
I said, I will confess my transgressions to the LORD,
and you forgave the iniquity of my sin.

Proverbs 28 verse 13
13 He who conceals his sins doesn’t prosper,
but whoever confesses and renounces them finds mercy.

1 John 1 verse 9
9 If we confess our sins, he is faithful and righteous to forgive us the sins, and to cleanse us from all unrighteousness.