Hi there,
The GetTicketAttachment API command can be used for this: https://developers.whmcs.com/api-reference/getticketattachment/