Foreigner Detention at immigration

Foreigner Detention at immigration :

Indonesian Immigration Law UU6-2011

Article 83

1. Immigration Officer shall be authorized to put
the Foreigner into the Immigration Detention
House or Immigration Detention Room in case of
such Foreigner:

a. Stays in the Indonesian Territory without
having legal Stay Permit or having no longer
valid Stay Permit;

b. Stays in the Indonesian Territory without
having any legal Travel Document;

c. Subjected to Immigration Administrative Action
in the form of his/her Stay Permit revoked due
to perpetrate act that contraries with
applicable laws and regulations or interferes
public security and orderliness;

d. Waiting for execution of Deportation;

or

e. Waiting for departure outside of the Indonesian
Territory provision of Entrance Sign is
rejected.

(2) Such Immigration Officer can put the Foreigner as
contemplated in paragraph (1) in other place in
case of such Foreigner gets sick, will gives
birth, or still children.

C boils down to breaking the law in any serious way, serious usually being defined as enough to get you prison time or maybe a large fine. You can end up there for not having a valid ID or travel document with you when asked, that including not having your KTP OA or SKTT handy when immigration raid a bar at closing time.
The latter can be an overnight stay in a cell but is treated as a minor offence pulling a small fine as long as you actually have one somewhere.

D - Deportation is generally preferred by most foreigners, but drug dealers are never offered the choice