Write id to metadata