Overview
Callback endpoints allow services to register webhooks that GOV.UK Notify will call when specific events occur (delivery receipts, inbound SMS, returned letters). Base URL:/service/{service_id}/callback-api
Callback Types
delivery_status- Delivery receipt callbacksinbound_sms- Inbound SMS callbacksreturned_letter- Returned letter callbackscomplaint- Email complaint callbacks
Create Callback
Endpoint:POST /service/{service_id}/callback-api
Register a new callback URL for a service.
Path Parameters
service_id(UUID, required) - Service identifier
Request Body
url(string, required) - HTTPS callback URLbearer_token(string, required) - Bearer token (minimum 10 characters)updated_by_id(UUID, required) - User who created the callbackcallback_type(string, optional) - Type of callback
Response
Status:201 Created
Error Responses
Status:400 Bad Request
404 Not Found
Update Callback
Endpoint:POST /service/{service_id}/callback-api/{callback_api_id}
Update an existing callback configuration.
Path Parameters
service_id(UUID, required) - Service identifiercallback_api_id(UUID, required) - Callback API identifier
Request Body
updated_by_id(UUID, required) - User making the updatecallback_type(string, required) - Type of callbackurl(string, optional) - New callback URLbearer_token(string, optional) - New bearer token
Response
Status:200 OK
Get Callback
Endpoint:GET /service/{service_id}/callback-api/{callback_api_id}
Retrieve a callback configuration.
Path Parameters
service_id(UUID, required) - Service identifiercallback_api_id(UUID, required) - Callback API identifier
Query Parameters
callback_type(string, optional) - Type of callback to retrieve
Response
Status:200 OK
Delete Callback
Endpoint:DELETE /service/{service_id}/callback-api/{callback_api_id}
Delete a callback configuration.
Path Parameters
service_id(UUID, required) - Service identifiercallback_api_id(UUID, required) - Callback API identifier
Query Parameters
callback_type(string, optional) - Type of callback to delete
Response
Status:204 No Content
No response body on successful deletion.
Error Responses
Status:404 Not Found
delivery_status: “Service delivery receipt API not found”inbound_sms: “Service inbound API not found”returned_letter: “Service returned letter API not found”
Implementation Notes
Security
- Bearer tokens are encrypted before storage (see
/home/daytona/workspace/source/app/models.py:886) - All callback URLs must use HTTPS
- Bearer token minimum length is 10 characters
Constraints
- Each service can only have one callback URL per callback type
- The
service_idandcallback_typecombination must be unique - Database constraint:
uix_service_callback_type
Source Code References
- Endpoints:
/home/daytona/workspace/source/app/service/callback_rest.py - Schema validation:
/home/daytona/workspace/source/app/service/service_callback_api_schema.py - Model:
/home/daytona/workspace/source/app/models.py:886 - DAO operations:
/home/daytona/workspace/source/app/dao/service_callback_api_dao.py