Overview
Creates or updates bank account information for a local authority. This endpoint forwards the request to the FSS (Financial Support System) API to store the bank details.
This endpoint requires specific authorization. Only users with the createBankDetails permission can create or update bank details. Unauthorized users will receive a 403 Forbidden response.
Authentication & Authorization
Required Permission: createBankDetails
Allowed Roles: CEO (Chief Executive Officer)
Authorization Check: The endpoint checks request.auth.isAuthorized and rejects requests from unauthorized users with a 403 Forbidden error.
Request
Body Parameters
The identifier for the local authority. Whitespace is trimmed.
The name on the bank account. Maximum length: 100 characters. Whitespace is trimmed.
The bank sort code. Hyphens and spaces are automatically removed during validation.Format: Can be provided as “12-34-56” or “123456” - both are accepted
The bank account number (typically 8 digits)
Email address of the person requesting the bank details creation. Whitespace is trimmed.
Job reference or JPP (Job Payment Proposal) identifier
The unique identifier for the organization
The validation includes stripUnknown: true, which means any additional fields not listed above will be automatically removed from the request.
Example Request
curl -X POST 'http://localhost:3001/bank-details' \
-H 'Authorization: Bearer YOUR_JWT_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"localAuthority": "LA12345",
"accountName": "City Council Finance",
"sortCode": "12-34-56",
"accountNumber": "12345678",
"requesterEmail": "[email protected]",
"jpp": "JPP-2024-001",
"organizationId": "ORG123"
}'
Response
Success Response (201 Created)
Returns the response from the FSS API after successfully creating the bank details.
Contains the result of the bank details creation operation from the FSS API
Status of the operation (typically “success”)
Confirmation message from the FSS API
{
"result": {
"status": "success",
"message": "Bank details created successfully",
"recordId": "BD-2024-001"
}
}
Error Responses
403 Forbidden
Returned when the user does not have permission to create bank details.
Error message indicating the user’s role is not allowed to create bank details
{
"statusCode": 403,
"error": "Forbidden",
"message": "Head of Finance not allowed to create bank details"
}
400 Bad Request
Returned when the request validation fails (missing required fields, invalid format, etc.).
{
"statusCode": 400,
"error": "Bad Request",
"message": "Invalid request payload input",
"validation": {
"source": "payload",
"keys": ["accountName"]
}
}
500 Internal Server Error
Returned when the FSS API request fails or a server error occurs.
Error type (“Internal Server Error”)
Error message (“Failed to create bank details”)
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "Failed to create bank details"
}
Implementation Details
Sort Code Processing
The sort code field has custom validation that automatically removes hyphens and spaces:
sortCode: Joi.string().custom((value) => {
return value.replaceAll('-', '').replaceAll(' ', '')
})
This means all these formats are valid and will be normalized:
"12-34-56" → "123456"
"12 34 56" → "123456"
"123456" → "123456"
Authorization Flow
- The request arrives with JWT authentication
- The
access-control plugin extracts the user’s role
- The role is checked against the
CREATE_BANK_DETAILS configuration
- If unauthorized, the handler returns 403 Forbidden (src/handler/bankDetails/post.js:14-17)
- If authorized, the request proceeds to the FSS API
External API Integration
The endpoint forwards requests to the FSS API:
- Base URL: Configured via
FSS_API_URL environment variable
- Endpoint:
/sn_gsm/bank_details/update_bank_details
- Method: POST
- Authentication: Uses
x-sn-apikey header with the API key from FSS_API_KEY
Audit Logging
All creation attempts are logged for audit purposes:
- Action:
BankDetailsCreated
- Recorded For: Only authorized users
- Includes: Request outcome (Success/Failure) and HTTP status code
The audit logging occurs at:
- Success: src/handler/bankDetails/post.js:55-60
- Failure: src/handler/bankDetails/post.js:42-47, 65
Environment Configuration
The following environment variables affect this endpoint:
FSS_API_URL: Base URL for the FSS API (default: http://localhost:3003/api)
FSS_API_KEY: API key for authenticating with FSS
CREATE_BANK_DETAILS: Comma-separated list of roles allowed to create bank details (default: ["CEO"])
Source Code References
- Route definition: src/routes/bankDetails.js:33-52
- Handler implementation: src/handler/bankDetails/post.js:11-68
- Access control: src/plugins/access-control.js:8
- Configuration: src/config.js:147-158, 184-189