I can see that the invoices I have created are in the civicrm/custom map as invoiceID.pdf, but how can I link to them using Civicrm api?
Invoices can be send via email or can be downloaded. Both create an activity (of type "Emailed Invoice" or "Downloaded Invoice"). The invoice pdfs are attached to that activity.
When you first get the activity via the API and collect the Activity ID, you can get information about the attachment via the "Attachment-Get" API function, where "entity_table" then should be "civicrm_activity" and "entity_id" should be the activity id.
For example in php:
$result = civicrm_api3('Attachment', 'get', array( 'sequential' => 1, 'entity_table' => "civicrm_activity", 'entity_id' => #activity_id#, ));