Trade Reporting Extracts (TRE) is a backend service that receives report requests from the frontend, persists them in the TRE data store, and manages notifications about report availability and status. It enables users to request, track, and download trade reports efficiently.
You can run the service locally in two ways:
After cloning the repository, run the following command in the root directory:
sbt run
To use the service manager CLI (sm2), please refer to the official setup guide for instructions on how to install and configure it locally.
Once set up:
- To start the service:
sm2 --start TRE_ALL
- To stop the service:
sm2 --stop TRE_ALL
The service's endpoints (that need Enrolment to access) can be accessed by using the enrolments below:
| Enrolment Key | Identifier Name | Identifier Value |
|---|---|---|
| HMRC-CUS-ORG | EORINumber | GB123456789012 |
| HMRC-CUS-ORG | EORINumber | GB123456789014 |
The minimum requirement for test coverage is 90%. Builds will fail when the project drops below this threshold.
| Command | Description |
|---|---|
sbt test |
Runs unit tests locally |
sbt "test/testOnly *TEST_FILE_NAME*" |
Runs tests for a single file |
| Command | Description |
|---|---|
sbt clean coverage test coverageReport |
Generates a unit test coverage report. The report can be found at target/scala-3.3.4/scoverage-report/index.html |
| Name | Endpoint | Description |
|---|---|---|
| ReportRequest API | POST /trade-reporting-extracts/create-report-request |
Submit a request for a trade report. |
| Available Reports API | GET /trade-reporting-extracts/api/available-reports |
Retrieve a list of available trade reports for the authenticated user or EORI. |
| Available Reports Count API | GET /trade-reporting-extracts/api/available-reports-count |
Get the total number of available trade reports for the authenticated user or EORI. |
| Requested Reports API | GET /trade-reporting-extracts/requested-reports |
Retrieve a list of trade reports that have been requested by the user or EORI. |
| Setup User API | GET /trade-reporting-extracts/eori/setup-user |
Initialize or set up a user in the system by EORI. |
| Authorised EORIs API | GET /trade-reporting-extracts/user/:eori/authorised-eoris |
Retrieve a list of EORI numbers the user is authorized to access. |
| Notify Report Available API | POST /trade-reporting-extracts/notify-report-available |
SDES notifies this system when a report file is available for download. |
| Report Status Notification API | PUT /tre/reportstatusnotification/v1 |
EIS notifies this system about the status of a report request. |
The ReportRequest API allows clients to request trade reports by submitting a JSON payload. The API endpoint is:
- POST
/trade-reporting-extracts/create-report-request
The request should be a JSON object with the following fields:
eori: String, the EORI number of the requester.reportStartDate: String (YYYY-MM-DD), the start date for the report.reportEndDate: String (YYYY-MM-DD), the end date for the report.whichEori: String, the EORI number for which the report is requested.reportName: String, a name for the report.eoriRole: Array of Strings, roles associated with the EORI (e.g.,["declarant"]).reportType: Array of Strings, types of reports requested (e.g.,["importHeader"]).dataType: String, type of data (e.g.,import).additionalEmail: Array of Strings, additional email addresses for notifications.
{
"eori": "GB123456789014",
"reportStartDate": "2025-04-16",
"reportEndDate": "2025-05-16",
"whichEori": "GB123456789014",
"reportName": "MyReport",
"eoriRole": ["declarant"],
"reportType": ["importHeader"],
"dataType": "import",
"additionalEmail": ["email1@gmail.com"]
}| Status Code | Description |
|---|---|
| 200 OK | Report request(s) created successfully. Returns references to the created requests. |
| 400 Bad Request | The request body is invalid or missing required fields. |
The Available Reports API allows clients to retrieve a list of available trade reports for the authenticated user or EORI.
- GET
/trade-reporting-extracts/api/available-reports
The request must be a JSON object containing the EORI:
{
"eori": "GB123456789012"
}Returns a list of available trade reports that can be downloaded or accessed by the user. This endpoint is typically used to display available reports in a user interface or to automate report retrieval.
The response is a JSON array, where each object represents an available report with details such as report name, type, date range, and download link.
[
{
"reportId": "12345",
"reportName": "Import Report April 2025",
"reportType": "importHeader",
"reportStartDate": "2025-04-01",
"reportEndDate": "2025-04-30",
"downloadUrl": "/trade-reporting-extracts/download/12345"
},
{
"reportId": "67890",
"reportName": "Export Report May 2025",
"reportType": "exportHeader",
"reportStartDate": "2025-05-01",
"reportEndDate": "2025-05-31",
"downloadUrl": "/trade-reporting-extracts/download/67890"
}
]| Status Code | Description |
|---|---|
| 200 OK | List of available reports returned successfully. |
| 400 Bad Request | The request body is missing or contains an invalid EORI. |
The Available Reports Count API allows clients to retrieve the total number of available trade reports for the authenticated user or EORI.
- GET
/trade-reporting-extracts/api/available-reports-count
The request must be a JSON object containing the EORI:
{
"eori": "GB123456789012"
}Returns a JSON object containing the count of available trade reports. This endpoint is useful for displaying summary information or for pagination purposes in a user interface.
The response is a JSON object with a single field count indicating the number of available reports.
{
"count": 2
}| Status Code | Description |
|---|---|
| 200 OK | Count of available reports returned successfully. |
| 400 Bad Request | The request body is missing or contains an invalid EORI. |
The Requested Reports API allows clients to retrieve a list of trade reports that have been requested by the user or EORI.
- GET
/trade-reporting-extracts/requested-reports
The request must be a JSON object containing the EORI:
{
"eori": "GB123456789012"
}Returns a list of trade report requests made by the user. This endpoint is typically used to display the status or history of report requests in a user interface.
The response is a JSON array, where each object represents a requested report with details such as request ID, report name, type, date range, status, and submission date.
[
{
"requestId": "req-12345",
"reportName": "Import Report April 2025",
"reportType": "importHeader",
"reportStartDate": "2025-04-01",
"reportEndDate": "2025-04-30",
"status": "Completed",
"submittedAt": "2025-05-01T10:00:00Z"
},
{
"requestId": "req-67890",
"reportName": "Export Report May 2025",
"reportType": "exportHeader",
"reportStartDate": "2025-05-01",
"reportEndDate": "2025-05-31",
"status": "Processing",
"submittedAt": "2025-06-01T09:30:00Z"
}
]| Status Code | Description |
|---|---|
| 200 OK | List of requested reports returned successfully. |
| 204 No Content | No reports found for the given EORI. |
| 400 Bad Request | The request body is missing or contains an invalid EORI. |
| 500 Internal Server Error | An error occurred while fetching reports. |
The Setup User API allows clients to initialize or set up a user in the system, typically by providing an EORI (Economic Operators Registration and Identification) number.
- POST
/trade-reporting-extracts/eori/setup-user
The request must be a JSON object containing the EORI to set up:
{
"eori": "GB123456789014"
}Initializes a user profile or environment for the given EORI. This endpoint is generally used during onboarding or when a new user needs to be registered in the system.
Returns a JSON object with the user details. Responds with HTTP status 201 (Created) on success.
{
"eori": "GB123456789014",
"additionalEmails": [
"user1@example.com",
"user2@example.com"
],
"authorisedUsers": [
{
"name": "John Doe",
"email": "john.doe@example.com"
}
],
"companyInformation": {
"companyName": "Example Ltd",
"address": "123 Example Street, London, UK"
},
"notificationEmail": {
"address": "notify@example.com",
"verified": true
}
}| Status Code | Description |
|---|---|
| 201 Created | User setup completed successfully. |
The Authorised EORIs API allows clients to retrieve a list of EORI numbers that the user is authorized to access or act on behalf of.
- GET
/trade-reporting-extracts/user/:eori/authorised-eoris
Returns a list of EORI numbers associated with the user, indicating which EORIs the user is authorized to use for report requests or other actions.
The response is a JSON array of EORI numbers or objects containing EORI details.
[
"GB123456789014",
"GB987654321000"
]| Status Code | Description |
|---|---|
| 200 OK | List of authorised EORIs returned successfully. |
| 500 Internal Server Error | An error occurred while fetching authorised EORIs. |
The Notify Report Available API is consumed by the SDES service to notify this system when a report file is available for download.
- POST
/trade-reporting-extracts/notify-report-available
This endpoint receives notifications from SDES when a new report file is available. It is typically called by SDES, not by end users.
The request should be a JSON object containing details about the available file, such as file name, location, and metadata.
{
"fileName": "import_report_2025_04.csv",
"location": "/sdes/files/import_report_2025_04.csv",
"eori": "GB123456789014",
"reportType": "importHeader",
"availableAt": "2025-05-01T10:00:00Z"
}Returns a JSON object indicating success or failure of the notification processing.
{
"status": "success",
"message": "Notification received and processed."
}| Status Code | Description |
|---|---|
| 200 OK | Notification processed successfully. |
| 400 Bad Request | The request body is missing or invalid. |
- This endpoint is intended for SDES integration.
The Report Status Notification API is consumed by the EIS service to notify this system about the status of a report request.
- PUT
/tre/reportstatusnotification/v1
This endpoint receives status updates from EIS regarding report requests, such as when a report is being processed, completed, or failed.
The request should be a JSON object containing the report request ID, status, and any relevant details or error messages.
{
"requestId": "req-12345",
"status": "Completed",
"completedAt": "2025-05-01T10:00:00Z",
"details": "Report successfully generated."
}Returns a JSON object indicating the result of the status update processing.
{
"status": "success",
"message": "Status update received."
}| Status Code | Description |
|---|---|
| 201 Created | Report status notification processed successfully. |
| 400 Bad Request | The request body is missing, invalid, or required headers are missing. |
| 403 Forbidden | Authorization failed. |
- This endpoint is intended for EIS integration.
| Command | Description |
|---|---|
| sbt run | Runs the service locally |
| sbt clean | Cleans code |
| sbt compile | Compiles the code |
| sbt coverage | Prints code coverage |
| sbt test | Runs unit tests |
| sbt it/test | Runs integration tests |
| sbt scalafmtCheckAll | Runs code formatting checks based on .scalafmt.conf |
| sbt scalafmtAll | Formats all the necessary files based on .scalafmt.conf |
| sbt "test/testOnly TEST_FILE_NAME" | Runs tests for a single file |
| sbt clean coverage test coverageReport | Generates a unit test coverage report that you can find here target/scala-3.3.5/scoverage-report/index.html |