If is a small category (or even a topological category), one can define a -torsor (or torsor with structure category ) which generalizes the torsor (principal bundle) with structure group(oid).
If is a sheaf over , denote by its stalk over (cf. etale space).
A -torsor over a space is given by a functor such that
(surjectivity) every ‘total stalk’ , where , is nonempty;
(transitivity) for any two germs ‘in the same total stalk’, , there is a span , and such that and ;
(freeness) a parallel pair of morphisms in , may induce coalescence for some only if there is a morphism and such that and .
The classifying space of a category classifies -torsors.
Literature: I. Moerdijk, Classifying spaces and classifying topoi, Springer Lec. Notes Math. 1616 (1995)