Can I delete old Messages threads automatically?

I would like to remove old Messages threads. Is there any way to do this, manually or automatically, other than deleting them one-by-one?

Is there an API for deleting them?


Solution 1:

It's in Messages Prefs, though it doesn't have much in the way of granularity…

enter image description here

Drop menu artificially floated away for clarity.