On 2008 January 9.56 UT, SN 2008D was discovered while following up an unusually bright X-ray transient (XT) in the nearby spiral galaxy NGC 2770. We present early optical spectra (obtained 1.75 days after the XT) which allowed the first identification of the object as a supernova (SN) at redshift z=0.007. These spectra were acquired during the initial declining phase of the light curve, likely produced in the stellar envelope cooling after shock breakout, and rarely observed. They exhibit a rather flat spectral energy distribution with broad undulations, and a strong, W-shaped feature with minima at 3980 and 4190{AA} (rest frame). We also present extensive spectroscopy and photometry of the SN during the subsequent photospheric phase. Unlike SNe associated with gamma-ray bursts, SN 2008D displayed prominent He features and is therefore of Type Ib.