---
title: "Generate patient letter (A019, FHIR STU3)"
method: POST
path: "/STU3/ReferralRequest/{ubrn}/$ers.generatePatientLetter"
tags: ["Refer patient", "Arrange appointment", "Arrange triage"]
---

# Generate patient letter (A019, FHIR STU3)

`POST /STU3/ReferralRequest/{ubrn}/$ers.generatePatientLetter`

## Request

- Base URL: `https://sandbox.api.service.nhs.uk/referrals/FHIR`
- URL: `https://sandbox.api.service.nhs.uk/referrals/FHIR/STU3/ReferralRequest/{ubrn}/$ers.generatePatientLetter`
- Auth: HTTP bearer

## Overview

Use this endpoint to download a PDF format letter for the patient summarising the current state of their referral and any steps the patient may need to follow.

## Supported security patterns
- Healthcare worker, user-restricted access

## Pre-requisites
In order to use this endpoint you must be an authenticated e-RS user and use one of the following e-RS roles:
  - `REFERRING_CLINICIAN`
  - `REFERRING_CLINICIAN_ADMIN`

You need to use the `Unique Booking Reference Number` (UBRN) of a referral request in order to use this endpoint.

## Use case

As an authenticated user

I need to generate the patient letter including up-to-date details about their referral and any steps the patient may need to follow

So that I can pass it to the patient.

## Parameters

- `#/paths/~1STU3~1Task/get/parameters/0` (unresolved $ref)
- `#/paths/~1STU3~1Task/get/parameters/1` (unresolved $ref)
- `#/paths/~1STU3~1Slot/get/parameters/2` (unresolved $ref)
- `#/paths/~1STU3~1Task/get/parameters/4` (unresolved $ref)
- `#/paths/~1STU3~1ReferralRequest~1%7Bubrn%7D/get/parameters/0` (unresolved $ref)

## Response `200`

Response contains the binary stream of the generated patient letter.

## Other responses

- `401` (unresolved $ref)
- `403` (unresolved $ref)
- `404` (unresolved $ref)
- `406` (unresolved $ref)
- `422`: Where status code 422 (Unprocessable Entity) is returned then an eRS-OperationOutcome-1 will be included in the body, as detailed below. Check diagnostics property for specific information regarding the error. | Error code | Description | | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | INVALID_REQUEST_TYPE | The `UBRN` provided exists in e-RS but does not correspond to an active request. | | NO_ACCESS_CODE | The patient does not have an access code/password to log onto the patient portal. | | INVALID_REQUEST_STATE | The Request, while otherwise valid, is not in the correct state for the specific action being performed. | | NO_RELATIONSHIP | The user does not have a legitimate relationship with the request. |
- `429` (unresolved $ref)
- `500` (unresolved $ref)
- `503` (unresolved $ref)

---

[API](https://skmtc.dev/nhs/apis/e-referrals-service-api.md) - [All operations](https://skmtc.dev/nhs/apis/e-referrals-service-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nhs/apis/e-referrals-service-api/revisions/916969ea472f?raw)
