# GetClaimRequestMergeDocumentUrl - Advanced Documentation ## Overview Returns a ready-to-fetch URL that generates a Word document from a claim request merge template, for one existing claim request. Use it when the user wants the letter or form for a request already recorded on a claim (for example, a records request to a provider). The URL has the caller's identity already embedded, so a plain GET with no cookies or headers returns the document. The document is generated when the URL is fetched, for the company and staff member who requested the URL. The template must be of the merge template type named `Request`. Find these templates with `SecureApi.GetMergeTemplatesByTypeName("Request")`. ## Parameters All three parameters are required. There is no Prompts parameter on this endpoint. | Parameter | Type | What it identifies | Where to get it | |-----------|------|--------------------|-----------------| | ClaimRequestID | number | The claim request to merge | `SecureApi.GetClaimRequestsForFirm()` or `SecureApi.GetClaimRequestsForGroup(...)` (each result has an ID); `SecureApi.GetClaimRequest(ClaimRequestID)` returns one in full | | ClaimID | number | The claim the request belongs to | The `Claim.ID` on the claim request returned by the calls above | | TemplateID | number | The request merge template | `SecureApi.GetMergeTemplatesByTypeName("Request")` (each result has an ID). The claim request also carries a `Template`; use it unless the user asks for a different one | ## Prompts and fields A request merge template can declare prompts (see `SecureApi.GetMergeTemplateByID(TemplateID)`, read `Prompts`; each has `Prefix`, `RecordType`, `RecordID`, `DisplayValue`, and for Staff prompts `CompanyStaffRole`). You do not answer them here. The answers were saved on the claim request when it was created, and this endpoint uses those saved values. `Fields` on the same template are the placeholders in the Word document. They are filled in automatically from the records: the claim request, the claim, the claimant, and the saved prompt values. Nothing in `Fields` needs to be sent by the caller. The endpoint also adds these itself, from the IDs you pass, exactly as the application does: - the claim request (Prefix `Request`, RecordType `Request`, RecordID = ClaimRequestID) - the claim (Prefix `Claim`, RecordType `Claim`, RecordID = ClaimID) - the claimant (Prefix `Claimant`, RecordType `Claimant`, RecordID = ClaimID) ## Example Claim request 77 on claim 303, using request template 101: ``` DocumentGenerationApi.GetClaimRequestMergeDocumentUrl( ClaimRequestID: 77, ClaimID: 303, TemplateID: 101 ) ``` ## Result A single URL string with authorization already embedded; there is no token to extract and no second call to make. Return the URL to the caller as the script result rather than fetching it yourself. The calling LLM downloads the document into its own environment. ## Limits The URL expires about 5 minutes (300 seconds) after it is issued. Request a fresh URL each time instead of caching, reusing, or retrying an old one. Use the URL exactly as returned - do not reorder, add to, or otherwise modify its query string. ## Errors This endpoint returns an error when you are not logged in or have no company selected. It does not check the template or records when it issues the URL. Those are checked when the URL is opened, so a bad ClaimRequestID, ClaimID, or TemplateID shows up as an error page at fetch time. If the fetched page is not a Word document, read it for the reason, fix the input, and request a new URL.