decode and encode apis