Wali comes from a root cluster in Arabic meaning nearness, allegiance and protection, and the same root gives the words for a guardian, a legal next of kin and a governor. Applied to a person in relation to God it means one who is close to God and under God's protection, and the phrase awliya Allah, the friends of God, is scriptural: a verse of the Quran states that the friends of God have neither fear nor grief. Almost every later argument on the subject begins from that verse and from the question of who qualifies.
The classical Sufi literature answered it with a description rather than a procedure. There is no examination, no tribunal and no register. A person is a wali by the judgement of those who knew him, by the reputation that survives him, and very often by a chain of transmission: a Sufi order traces its teaching backwards from master to master, and the founders in that chain are its friends of God. Where wonders are attributed to such a person, the technical vocabulary is careful to keep them in a lower class than prophecy. A prophet's miracle, mujiza, authenticates a message; the wonder granted to a friend of God, karama, authenticates nothing and proves no doctrine. It is a favour, and the writers repeatedly warn that attachment to it is a distraction.
Because there is no court, the map of who counts is regional and plural. A figure of enormous standing in one country may be unheard of in the next, and the orders themselves disagree.