Plaintiff, Superior Equipment Company, Inc., appeals from the dismissal with prejudice of its petition for failure to state a claim against five defendants, Maryland Casualty Company, Transamerica Insurance Company, Northern Insurance Company of New York, American Alliance Insurance Company, and Safety National Casualty Corporation (hereinafter collectively referred to as insurers) in a declaratory judgment action to determine plaintiffs coverage under liability insurance policies issued by insurers. We reverse and remand.
In October 1993, in an underlying action filed in United States District Court, Eastern District of Missouri (hereinafter referred to as the federal action), Wastex Joint Steering Committee (WJSC) sought to recover from plaintiff the “response costs” it had incurred or would incur in the future to clean up hazardous substances which plaintiff allegedly transported and deposited at a site in East St. Louis, Illinois. During the time period pertinent to the federal action, plaintiff was insured under nine separate policies issued by the insurers. Although using different language, each policy in essence agreed to defend any action against plaintiff for property damage covered by the policy and to indemnify plaintiff for damages it was legally obligated to pay for such property damage; but excluded from coverage property damage caused by the discharge or escape of pollutants, unless such discharge was sudden and accidental.
Plaintiff reported the claims raised by WJSC in the federal action to the insurers, requesting that each insurer defend plaintiff in the federal action and acknowledge coverage of any judgment WJSC might obtain against plaintiff. The insurers denied the duty to defend and any coverage under their respective policies.
In April 1994, plaintiff brought the present action against the insurers in the Circuit Court of St. Louis County, seeking a declaratory. judgment that the insurers had a duty (1) to defend plaintiff in the federal action under the various policies and (2) to indemnify plaintiff against any liability in accordance with the provisions of the policies. Plaintiff moved for summary judgment on Count I, which dealt with the issue of the insurers’ duty to defend in the federal action. The trial court denied that motion. The insurers then moved to dismiss plaintiff’s petition on the basis that it failed to state a claim upon which relief could be granted. The court sustained that motion and dismissed plaintiffs petition with prejudice.
On appeal, the arguments of the parties are directed to the merits of plaintiffs declaratory judgment action. Yet, the trial court’s ruling was a dismissal of plaintiffs petition for failure to state a claim upon which relief could be granted.1 The salient issue is whether the petition for declaratory judgment was sufficient to withstand a motion to dismiss.
In determining whether any petition, including one purporting to state a *192cause of action for a declaratory judgment, states a claim, we accept as true all the facts pleaded and all the reasonable inferences drawn therefrom in order to determine whether the petition states any grounds for relief. Harness v. State Farm Mut. Auto. Ins. Co., 867 S.W.2d 591, 592 (Mo.App. E.D. 1993). A petition should be held sufficient if its averments invoke substantial principles of law which entitle the plaintiff to relief. Washington Univ. v. Royal Crown Bottling Co. of St. Louis, 801 S.W.2d 458, 463 (Mo.App.1990). The test for the sufficiency of a petition for declaratory judgment is not whether the plaintiff is entitled to the relief prayed for, but whether he is entitled to a declaration of rights or status on the facts pleaded. Cooper v. State, 818 S.W.2d 653, 655 (Mo.App.1991). If the averments are sufficient to show the propriety of declaratory relief, it is improper to dismiss the petition. Royal Crown, 801 S.W.2d at 463.
Rule 87.02 pertains to declaratory judgments and provides in pertinent part:
Any person interested under a ... written contract or other writings constituting a contract, or whose rights, status or other legal relations are affected by a ... contract ..., may have determined any question of construction or validity arising -under the instrument, ... [or] contract ... and obtain a declaration of rights, status or other legal relations thereunder.
In determining whether to sustain the insurers’ motion to dismiss in the present action, the trial court could consider only whether plaintiff was entitled to a declaratory judgment to interpret and construe the contracts of insurance on the facts pleaded and not whether plaintiff was entitled to judgment on the merits of the case. Clearly, plaintiff was a person whose rights were affected by the insurance policies; and plaintiff was entitled to a declaration of its rights under those contracts of insurance. See Harness, 867 S.W.2d at 592. Plaintiff’s petition pleaded facts which indicated that a declaratory judgment was appropriate to determine its rights under the policies. Having sufficiently pleaded the elements of a declaratory judgment action, plaintiff was entitled to win or lose after submission of the issues raised therein on the merits. See Id. The trial court therefore erred in granting insurers’ motion to dismiss in lieu of entering a judgment declaring plaintiffs rights under the contracts of insurance.
We are unable to consider the issues raised by the parties on appeal, because those issues were directed to the merits of the declaratory judgment action. The trial court did not decide those issues when it dismissed plaintiffs petition for failure to state a claim upon which relief could be granted; and thus we cannot review them on appeal.
Accordingly, we reverse the trial court’s dismissal of plaintiffs petition and remand the cause for a hearing on the merits of the declaratory judgment action.
KAROHL, J., concurs. CHARLES B. BLACKMAR, Senior Judge, concurs in result in opinion filed.. There is no indication that the trial court treated this motion for dismissal as one for summary judgment under Rules 55.27(a) and 74.04; and, therefore, only those matters appearing on the face of the petition may be considered. See Washington Univ. v. Royal Crown Bottling Co. of St. Louis, 801 S.W.2d 458, 463 n. 1 (Mo.App.1990).