An autoinjector comprises a skin sensor 15 movably coupled to the autoinjectors housing 24 the skin sensor 15 being biased into a front position relative to the housing 24 and wherein it is further movable to a rear position relative to the housing 24 when the skin sensor element 15 is pressed against an injection site. A needle assembly comprising a needle 11 extending outside of the housing 24 when the device is in a needle insertion configuration - i.e. upon pressing the autoinjector against the skin of the injection site is also taught. A needle retraction mechanism coupled to the skin sensor 15 element is also provided. The retraction mechanism being provided to withdraw the needle 11 into the housing 24 when the sensor element 15 is moved from the rear position towards the front position i.e. upon moving the autoinjector away from the skin of the injection site - is also provided.