Cap comprising a cavity for hosting the device