As always the question is “what are you trying to do / achieve”? e.g. where are you starting from - are you trying to find a particular filing? Are you trying to get all the documents for a particular company? etc.
You don’t really need to worry about document IDs. The API is based on following URIs. You look up the Filing History List for a company. Each entry in this has a links member including a URI to get the “document metadata” for the document. That in turn has a link to the actual file data - see details later on exactly how to do that).
As far as I know the whole design of the API is essentially mirroring the flow of the Companies House search website e.g. the assumption is you’ll start from a given company number (or a search, which will then give you a link to the company profile). You then follow the links in the Company Profile e.g. to the filing history (or just make the appropriate URI for the filing history for the company yourself using the company number). Finally the links to the documents are available from the Filing History list.
See my post e.g. here:
https://forum.aws.chdev.org/t/document-api-implementation/1927/5
Also one here covering similar ground:
https://forum.aws.chdev.org/t/how-to-get-document-id/2706/5
Beware that the document metadata is on Companies House servers but the actual document data is hosted elsewhere, so you may need care with authorization as described in the thread posts above.