Repository navigation
CCM-20500: Return mail API documentation #1113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| summary: Returned mail | ||
| description: |- | ||
| The returned mail callback sends a POST request to your service when NHS Notify is informed that a letter has been returned. | ||
|
|
||
| If you're onboarding with NHS Notify and need to use the returned mail callback, contact the onboarding team to tell them you want to subscribe to returned mail events. | ||
|
|
||
| If you're live with NHS Notify and need to use the returned mail callback, [raise a Service Now ticket](https://nhsdigitallive.service-now.com/csm). | ||
|
|
||
| ### About returned mail | ||
|
|
||
| When NHS Notify receives information that a letter has been returned, it sends a callback to your service with the details of the return. | ||
|
|
||
| The callback includes the return reason code and text, the message it relates to, and the time the callback event was processed. | ||
|
|
||
| Callbacks can arrive more than once or out of order. Use `meta.idempotencyKey` to identify duplicate events. See the callback guidance above for retries and rate limiting. | ||
|
|
||
| ### Authentication | ||
|
|
||
| This callback uses mutual TLS (mTLS) for authentication instead of HMAC signatures or API keys. NHS Notify presents a client certificate when connecting to your endpoint. Your service must validate the inbound client certificate against the NHS Notify CA to authenticate the request. | ||
| operationId: post-v1-returned-mail-callbacks | ||
| security: [] | ||
| requestBody: | ||
| content: | ||
| application/vnd.api+json: | ||
| schema: | ||
| type: object | ||
| required: | ||
| - data | ||
| properties: | ||
| data: | ||
| type: array | ||
| minItems: 1 | ||
| items: | ||
| $ref: ../schemas/components/ReturnedMailCallback.yaml | ||
| responses: | ||
| '202': | ||
| description: Accepted | ||
| '401': | ||
| description: Unauthorized | ||
| '403': | ||
| description: Forbidden | ||
| '429': | ||
| $ref: ../responses/4xx/callbacks/429_TooManyRequests_Callbacks.yaml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
specification/schemas/components/ReturnedMailCallback.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| type: object | ||
| title: CallbackRequest | ||
| required: | ||
| - type | ||
| - attributes | ||
| - links | ||
| - meta | ||
| properties: | ||
| type: | ||
| type: string | ||
| enum: | ||
| - ReturnedMail | ||
| example: ReturnedMail | ||
| attributes: | ||
| type: object | ||
| required: | ||
| - messageId | ||
| - messageReference | ||
| - channel | ||
| - reason | ||
| - reasonText | ||
| - timestamp | ||
| properties: | ||
| messageId: | ||
| $ref: ../types/KSUID.yaml | ||
| messageReference: | ||
| $ref: ../../snippets/MessageReferenceSnippet.yaml | ||
| channel: | ||
| type: string | ||
| description: The channel used for the returned message. | ||
| enum: | ||
| - letter | ||
| example: letter | ||
| reason: | ||
| type: string | ||
| description: Code indicating why the letter was returned. | ||
| example: UNDELIVERABLE | ||
| reasonText: | ||
| type: string | ||
| description: Text describing why the letter was returned. | ||
| example: 'Unable to deliver: address not found' | ||
| timestamp: | ||
| type: string | ||
| description: Date and time NHS Notify processed this callback event. | ||
| format: date-time | ||
| example: '2026-07-01T10:00:00.000Z' | ||
| links: | ||
| type: object | ||
| required: | ||
| - message | ||
| properties: | ||
| message: | ||
| type: string | ||
| description: URL to retrieve the related message. | ||
| format: uri | ||
| example: 'https://api.service.nhs.uk/comms/v1/messages/2WL3qFTEFM0qMY8xjRbt1LIKCzM' | ||
| meta: | ||
| type: object | ||
| required: | ||
| - idempotencyKey | ||
| properties: | ||
| idempotencyKey: | ||
| type: string | ||
| description: Value to use to identify duplicate callback events, even if their timestamps differ. | ||
| example: '2515ae6b3a08339fba3534f3b17cd57cd573c57d25b25b9aae08e42dc9f0a445' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.