[SalesForce] Accessing a pdf as content document via URL

I have a problem when accesing a pdf stored as salesforce file via URL. At some point in time I was able to load a pdf (stored as note and attachment) in my browser using the following link :

 [server url]/servlet/servlet.FileDownload?file=00P2............

But on this instance of my environment, even if I am using notes and attachment or salesforce files, I noticed that the prefix is 069…… and not 00P. I found that this prefix is the prefix for content document. But how can I access a content document via URL ?

My requirement is not to get the base64 data from the pdf, I just need a URL to the pdf, because i will need this URL for a webservice call, let say via twilio.

Doest anybody know how to get it ? Or even better, if I can generate the public link via apex code, an then used that link will be even better.

Best Answer

Try this URL format - note the "document" instead of "version" in the path:

/sfc/servlet.shepherd/document/download/[DOCID]