---
title: "Process a message"
method: POST
path: "/$process-message"
tags: ["Message"]
---

# Process a message

`POST /$process-message`

### Using $process-message
The inherent flexibility of the various workflows supported by BaRS is facilitated by the $process-message endpoint. The example in the "Try this API" feature for this endpoint is a referral request.

### Function
| Function| API Call|Description
| ----                              | ----                   | ----                 |
| Making a referral request         | POST /$process-message | The sender will POST a FHIR Bundle, including the FHIR resources defined in MessageDefinition requested previously, the 'focus' being a ServiceRequest resource, supported by Encounter, Observation, Flag etc. The MessageHeader resource will indicate the activity required through use of 'event', 'reason' and 'focus' data elements.<cr> The MessageHeader resource will indicate the activity required. An example of this can be found [here.](https://simplifier.net/NHSBookingandReferrals/79120f41-a431-4f08-bcc5-1e67006fcae0/~json)|
| Respond to a referral             | POST /$process-message | A receiver wanting to respond to a request will direct their response to the Sender's $process-message endpoint, reversing the previous request/response roles. All implementers (senders or receivers) of BaRS must build a $process-message endpoint to be able to support the asynchronous workflows which involve such feedback responses. An example of this can be found [here.](https://simplifier.net/nhsbookingandreferrals/bc040878-cf51-4acf-9ede-7448fbb5be7c-duplicate-2)|
| Cancelling a referral             | POST /$process-message | An updated payload request ensuring the status of the service request is set to 'revoked', as a minimum.An example of this can be found [here.](https://simplifier.net/nhsbookingandreferrals/a961e68a-50e9-4988-9b14-4bfa4629d761)|
| Making a booking                  | POST /$process-message | Once a slot has been identified, the sender makes a request to book through the $process-message endpoint. The receivers MessageDefinition defines the required FHIR resources and must including reference to the service request, if applicable. The MessageHeader resource will indicate the activity required.An example of this can be found [here.](https://simplifier.net/nhsbookingandreferrals/777a156c-af3c-4748-a8a3-7e95e4b0df9a)|
| Respond to a booking              | POST /$process-message | A sender may receive a response to a booking they've made, for example, where a patient fails to attend. The original receiver (now the sender, in effect) will respond to the original sender (now the receiver) with an updated payload to reflect the current state of the booking e.g. DNA.|
| Cancelling a booking (and rebook) | POST /$process-message | An updated payload request ensuring the status of the appointment is set to 'cancelled', as a minimum.|

for more information on processing requests, please see the guidance within our [End-to-End Workflow](https://simplifier.net/guide/nhsbookingandreferralstandard/Home/Design/Design--Core#End-to-end-workflow) documentation.

## Response `200`

Success

## Other responses

- `4XX` — Below are examples of potential HTTP status codes and their associated error codes, which could be returned in the event of a fault. Guidance on error handling within BaRS can be found [here](https://simplifier.net/guide/nhsbookingandreferralstandard/Home/Design/Design--Core#Error-handling). | HTTP status | Error code | Description | | ----------- | -------------------------- | --------------------------------------------- | | 400 | SEND_BAD_REQUEST | The API was unable to process the request. | | 400 | REC_BAD_REQUEST | The Receiver has responded stating the message was malformed. | | 401 | SEND_UNAUTHORIZED | The API deemed you unauthorized to make this request. | | 401 | REC_UNAUTHORIZED | The receiver deemed you unauthorized to make request. | | 403 | SEND_FORBIDDEN | Missing or Expired Token. | | 404 | PROXY_NOT_FOUND | No related people exist for given NHS number. | | 404 | REC_NOT_FOUND | Patient record for given NHS number has been invalidated and not superseded by another NHS number. | | 405 | SEND_METHOD_NOT_ALLOWED | HTTP Verb is not correct for this scenario.| | 405 | REC_METHOD_NOT_ALLOWED | Receiver does not allow this.| | 405 | PROXY_METHOD_NOT_ALLOWED | Proxy does not allow this.| | 406 | SEND_NOT_ACCEPTABLE | Senders message had an incorrect content type defined for a response.| | 408 | REC_TIMEOUT | The downstream domain processing has not completed within the configured timeout period. | | 409 | SEND_CONFLICT | | | 409 | REC_CONFLICT | | | 409 | PROXY_CONFLICT | | | 422 | SEND_UNPROCESSABLE_ENTITY | Message was not malformed but deemed unprocessable. | | 422 | REC_UNPROCESSABLE_ENTITY | Message was not malformed but deemed unprocessable. | | 422 | PROXY_UNPROCESSABLE_ENTITY | Message was not malformed but deemed unprocessable. | | 429 | SEND_TOO_MANY_REQUESTS | The user has sent too many requests in a given amount of time| | 429 | REC_TOO_MANY_REQUESTS | The user has sent too many requests in a given amount of time|
- `5XX` — Below are examples of potential HTTP status codes and their associated error codes, which could be returned in the event of a fault. Guidance on error handling within BaRS can be found [here](https://simplifier.net/guide/nhsbookingandreferralstandard/Home/Design/Design--Core#Error-handling). | HTTP status | Error code | Description | | ----------- | -------------------------- | --------------------------------------------- | | 500 | REC_SERVER_ERROR | The receiver server has encountered an Error processing the request. | | 500 | PROXY_SERVER_ERROR | Proxy Error. | | 501 | SEND_NOT_IMPLEMENTED | The Request was not recognized. | | 501 | REC_NOT_IMPLEMENTED | The Receiver did not recognize the request. | | 501 | PROXY_NOT_IMPLEMENTED | The Proxy did not recognize the request. | | 503 | REC_UNAVAILABLE | The Receiver was unavailable to service the request.| | 503 | PROXY_UNAVAILABLE | The Proxy was unavailable to service the request. |

---

[API](https://skmtc.net/nhs/apis/booking-and-referral-api.md) · [All operations](https://skmtc.net/nhs/apis/booking-and-referral-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nhs/booking-and-referral-api/revisions/62e13e4e1370/schema)
