class_type 'DateTime'; subtype 'DT' => as 'Maybe[DateTime]'; coerce 'DT', from 'Str', via { DateTime::Format::DateParse->parse_datetime($_) }; coerce 'DT', from 'Int', via { DateTime->from_epoch( epoch => $_ ) }; ... has created_time => ( is => 'rw', isa => 'DT', required => 0, coerce => 1, ); # and then in the subroutine I posted earlier: ... for my $post_id ( keys %$post_response ) { # changed to unblessed ...