The first question is whether there is a lease or rental agreement which provides for attorney's fees to the prevailing party. If yes, then there is a legal basis to award attorney's fees. In California, in an action to enforce a contract authorizing an award of fees and costs to one party, the party “prevailing on the contract” is entitled to reasonable fees. (Civil Code § 1717.) Such fee awards are allowable as court costs under Code of Covil Procedure § 1032. (Code Civ. Proc., § 1033.5(a)(10)(A).)
The second question is whether the lease is enforceable. If you provide that the dwelling has no permit and no certificate of occupancy, and the court agrees that the lease is not valid, then the court should not award attorney's fees.
Assuming that the lease is enforceable, the court would still have to make a determination that the landlord is the prevailing party and that the amount of attorney's fees sought is reasonable. "The judge has discretion in determining what constitutes reasonable attorney’s fees. The judge should consider the time the attorney has spent on the case, and the nature of the litigation, its difficulty, the amount involved, the skill required and employed, the attention given, the success of failure, and other circumstances of the case." (Serrano v. Priest (1977) 20 Cal.3d 25, 49; Nightingale v. Hyundai Motor Am. (1994) 31 Cal.App.4th 99, 104.)
The tenant in your instance might seriously consider getting an attorney or at least legal aid help. Assuming the lease is enforceable and has a fee provision, if a tenant defendant is the prevailing party in an unlawful detainer action, and there is a written lease or rental agreement which provides for attorney's fees to the prevailing party, the court can award attorney's fees to the tenant defendant if he or she prevails. (California Civil Code section 1717). Even if the defendant is represented by a “non-profit” organization for which no attorney’s fees are paid, if the defendant is the prevailing party, the non-profit organization is entitled to an award of reasonable attorney’s fees if fees were actually “incurred.
The information presented here is general in nature and is not intended, nor should be construed, as legal advice. This posting does not create any attorney-client relationship with the author (who is only admitted to practice law in the State of California). For specific advice about your particular situation, consult your own attorney.
If the rental is illegal, attorneys fees shouldn't be awarded. That being said, you still don't want to be evicted. It can make if more difficult in renting your next apartment. I would recommend calling the landlord and trying to negotiate something to get the unlawful detainer action dismissed.
I hope this helps.
Scott Rights, Esq.