Insert keyframe on an object's custom property with Python
Keyframes on custom properties use Python's getitem/setitem syntax rather then getattr/setattr.

This matches python api, where you would access object.location as an attribute and object["prop"] for a custom property.

So you would need to write it like this:

object.keyframe_insert(data_path='["prop"]')


Note that you have to use " quotes, not ','["prop"]' can be written as "[\"prop\"]" too of course.

I think we have this documented, I'll have to double check though.