## Table of Contents

* [Introduction](#introduction)
* [Status Publisher endpoints](#endpoints)
  - [Publish dataset details](#publishDataset)
  - [Publish status](#publishStatus)
* [API specs](#api-specs)


## Introduction 

The Status Publisher service provides APIs for publishing dataset details and status messages to the `statuschangedtopic`.

* **Dataset details** - A dataset can be anything that contains data. A file is one type of dataset that contains data inside. A file collection is another type of dataset that contains a set of files.
* **Status** - Holds the overall status of the dataflow.


## Status Publisher endpoints 

The Status Publisher service supports the operations listed below from different endpoints:

### Publish dataset details 

You can use the POST /dataset-details endpoint to publish the dataset details message to the `statuschangedtopic`.
The endpoint accepts a list of dataset details.

#### Sample dataset details publish request

```
[
  {
    "correlationId": "1cc462e9-9a39-48b9-84c3-9d53b18b8089",
    "datasetId": "opendes:dataset--File.Generic:332b55d5-0cf2-4474-a3e5-d3cff0c5746a",
    "datasetVersionId": "opendes:dataset--File.Generic:332b55d5-0cf2-4474-a3e5-d3cff0c5746a:23423432",
    "datasetType": "FILE",
    "recordCount": 1
  }
]
```

### Publish status 

You can use the POST /status endpoint to publish the status message to the `statuschangedtopic`.
The endpoint accepts a list of statuses.

#### Sample status publish request

```
[
  {
    "correlationId": "1cc462e9-9a39-48b9-84c3-9d53b18b8089",
    "recordId": "opendes:wellbore:osdudemo-ATVMxMDEzTVMxMDQ",
    "recordIdVersion": "opendes:wellbore:osdudemo-ATVMxMDEzTVMxMDQ:23423432",
    "stage": "FILE_SYNC",
    "status": "SUCCESS",
    "message": "File metadata stored successfully",
    "errorCode": 0
  }
]
```

```
[
  {
    "correlationId": "1cc462e9-9a39-48b9-84c3-9d53b18b8089",
    "recordId": "opendes:wellbore:5noUsKs81vWsu0w3",
    "stage": "WKS_SYNC",
    "status": "FAILED",
    "message": "Raw record not present",
    "errorCode": 400
  }
]
```

#### Sample status publish request with additionalProperties

Additional properties ('additionalProperties') is a map of key-value pairs that provides additional information for the status.

It accepts a key-value pair at the 1st level only.

The supported data type for the keys is `String` and any string value can be a key. Examples: inputRecordId, version, and timestamp.

Supported data types for the values are `String, Integer, Long, Double,` and `Boolean`. Examples: opendes:wellbore:osdudemo-5noUsKs81vWsu0w3, true, and 1234567.

```
[
  {
    "kind": "status",
    "properties": {
      "correlationId": "1cc462e9-9a39-48b9-84c3-9d53b18b8089",
      "recordId": "opendes:wellbore:wks-35b7eecfa2c35145053b150f47461bea630a.osdu.wks.wellbore.2",
      "recordIdVersion": "opendes:wellbore:wks-35b7eecfa2c35145053b150f47461bea630a.osdu.wks.wellbore.2",
      "stage": "WKS_SYNC",
      "status": "SUCCESS",
      "errorCode": 0,
      "userEmail": "test@email.com",
      "timestamp": 1625221800,
      "additionalProperties": {
        "inputRecordId": "opendes:wellbore:osdudemo-5noUsKs81vWsu0w3",
        "inputRecordIdVersion": "opendes:wellbore:osdudemo-5noUsKs81vWsu0w3:23423432"
      }
    }
  }
]
```

You can find more details about supported stages and statuses in [Global Status Monitoring tutorial](/solutions/data-workspace/tutorial/global-status-monitoring) in the `Supported Stages and Statuses` section.

## API Specs 

All available Status Publisher service APIs are in the [API Reference](/solutions/data-workspace/apis/osdu-status-publisher-service).