File attachments to eRS advice and guidance requests, fail with 400 error

I’m trying to attach an upload to an A&G request, using https://digital.nhs.uk/developer/api-catalogue/e-referral-service-fhir#post-/STU3/CommunicationRequest/-ubrn-/$ers.sendCommunicationToRequester

I’ve got an an id back from the main upload API, against ‘NHSD-eRS-Referral-ID’ being the A&G UBRN

From the docs, it looks like I just add a guidanceAttachmentFile to the parameter array, right ?

My request is

 {"meta":{"profile":["https://fhir.nhs.uk/STU3/StructureDefinition/eRS-SendCommunicationToRequester-Request-Parameters-1"]},"resourceType":"Parameters","parameter":[{"name":"guidanceOutcome","valueCoding":{"system":"https://fhir.nhs.uk/STU3/CodeSystem/eRS-GuidanceResponseOutcome-1","code":"REQUIRE_FURTHER_INFORMATION"}},{"name":"guidance","valueString":"with"},{"name":"updatedPriority","valueCoding":{"system":"https://fhir.nhs.uk/STU3/CodeSystem/eRS-Priority-1","code":"ROUTINE"}},{"name":"guidanceAttachmentFile","resource":{"meta":{"profile":["https://fhir.nhs.uk/STU3/StructureDefinition/eRS-DocumentReference-1"]},"resourceType":"DocumentReference","type":{"coding":[{"system":"https://fhir.nhs.uk/STU3/CodeSystem/eRS-AttachmentType-1","code":"GUIDANCE_RESPONSE"}]},"status":"current","indexed":"2026-8-21T15:53:38.335000+00:00","description":"Uploaded file","content":[{"attachment":{"url":"Binary/d0dcc538-2fbd-4a53-93b3-1c654b886fd3"}}]}}]}

but this errors with a 400 code, being a non-specific “bad request”. If I leave out the extra parameter element, the message saves fine.

Either I don’t understand, and files can’t be attached to A&G, only referrals, or I’ve mucked up some thing in the JSON. It formats OK and looks like the example to me !

Any hints ?

Hi,

Yeah A&G responses can include attachments, using 1 or more guidanceAttachmentFile parameters.

One possible issue could be the indexed value in the JSON you gave, which may be an invalid date-time because the month and day should generally be zero padded as following RFC 3339 (which requires two digit months and days). RFC 3339 doesn’t specify a number of digits for seconds, so that shouldn’t matter either way.

For example, rather than:“indexed”:“2026-8-21T15:53:38.335000+00:00”, use: “indexed”: “2026-08-21T15:53:38.335Z”.

Let me know if still doesn’t work after that, and I can take another look.

Ah ha !

We changed that and it’s attached, thanks.

The schema in the docs just says “indexed: date-time” rather than being that specific :slight_smile: