they most certainly cannot detain you without a cause. in the context of what you wrote, if you do not have your id, which is not mandatory to carry, they can detain you for 48 hours in order to establish your identity, but if they fail they have to let you go.