Real-time (synchronous) coding
Single record and small batch coding.
Single record coding
The coding service has been designed to apply a classification code and title to a free text entry. The synchronous single record coding feature will enable public facing webforms and other points of data collection to have codes and titles suggested in real time (~1 second).
- The service will provide multiple responses within a classification category, as long as at least one response has a confidence level above the threshold.
- It may only provide one response - for example, if there is only one six-digit code in the relevant category.
- If no responses are above the confidence threshold, the service will not return any results.
Small batch coding
A small JSON file of up to 300 text records can also be coded synchronously.
Note: when you are running a synchronous small batch, the whole packet needs to be syntactically correct. If the syntax fails, the whole batch will fail. As the operation is combined for the whole group of records, none of the records will be able to be coded if there is an error in any record.
When to use synchronous or asynchronous coding
Synchronous coding should only be used for single record coding or small batches of data. If you are coding 900 records, for example, it will be possible to run them in three small batch submissions.
Asynchronous large batch coding is recommended if you need to code or recode a large volume of data. (Large batch coding can be used to code from 1 record to millions of records.)
Coding against the latest model for a topic
This endpoint is used to code a single or small batch of free text records against the specified coding topic, using the latest model for that topic.
Request syntax
Depending on whether you are coding a single record or a small batch of records, your request will follow one of the following formats:
1. Coding a single free text record
POST /v1/topics/{topic}/code HTTP/1.1
Host: string
Content-type: application/json
Authorization: string
{
"record": {
"occp_text": "string",
"tasks_text": "string"
},
"numberOfSuggestions": number
}2. Coding a small batch of free text records
POST /v1/topics/{topic}/code HTTP/1.1
Host: string
Content-type: application/json
Authorization: string
{
"records": [
{
"recordId": "string",
"occp_text": "string",
"tasks_text": "string"
},
],
"numberOfSuggestions": number
}See Integration script examples for example PowerShell single record and small batch coding scripts.
| topic | The uriName of the topic against which the record is coded. This can be acquired by listing the available topics. Required: Yes |
|---|
| record | The free text record to be coded. Type: Record object, following the input format specified by the model. Required: No, but either record or records must be provided. |
|---|---|
| records | The free text records to be coded. Type: Array of Record objects, following the input format specified by the model. Each item may optionally specify an additional string value recordId. Length Constraints: Minimum length of 1. Maximum length of 300. Required: No, but either record or records must be provided. |
| numberOfSuggestions | The number of suggested codes to be provided if the record cannot be coded successfully. The maximum value of this field is 16. Type: Number Required: No |
Response syntax
The response of this endpoint will depend on whether your input request contained a single record or a small batch of records.
1. Coding a single free text record
HTTP/1.1 200 OK
Content-type: application/json
{
"codeStatus": "string",
"input": {
"occp_text": "string",
"tasks_text": "string"
},
"result": [
{
"codeCategory": "string",
"codeLabel": "string",
"codeConfidence": number
}
],
}2. Coding a small batch of free text records
HTTP/1.1 200 OK
Content-type: application/json
[
{
"recordId": "string",
"codeStatus": "string",
"input": {
"occp_text": "string",
"tasks_text": "string"
},
"result": [
{
"codeCategory": "string",
"codeLabel": "string",
"codeConfidence": number
}
],
}
]Response elements
If the action is successful, the service sends back an HTTP 200 response. The API returns either a SynchronousCodeResponse object or an array of SynchronousCodeResponse objects corresponding to the input records.
Errors
For information about synchronous coding errors, see Errors and suggested actions.
Examples
(Also see Integration script examples for example PowerShell single record and small batch coding scripts.)
| Successfully coded a single record using only one free text field: | |
|---|---|
| Sample request | |
| Sample response | |
| Successfully coded a single record using all free text fields: | |
|---|---|
| Sample request | |
| Sample response | |
| Unsuccessfully coded a single record using only one free text field: | |
|---|---|
| Sample request | |
| Sample response | |
| Coding a small batch of records: | |
|---|---|
| Sample request | |
| Sample response | |
Coding against a specific model
This endpoint is used to code a single or small batch of free text records against the specified coding topic, using the specified model.
Request syntax
Depending on whether you are coding a single record or a small batch of records, your request will follow one of the following formats:
1. Coding a single free text record against a specific model
POST /v1/topics/{topic}/models/{model}/code HTTP/1.1
Host: string
Content-type: application/json
Authorization: string
{
"record": {
"occp_text": "string",
"tasks_text": "string"
}
"numberOfSuggestions": number
}
2. Coding records against a specific model
POST /v1/topics/{topic}/models/{model}/code HTTP/1.1
Host: string
Content-type: application/json
Authorization: string
{
"records": [
{
"recordId": "string",
"occp_text": "string",
"tasks_text": "string"
}
],
"numberOfSuggestions": number
}| topic | The uriName of the topic against which the record is coded. This can be acquired by listing the available topics. Required: Yes |
|---|---|
| model | The model GUID for the model you would like to use to code records. This can be acquired by listing the available models for your topic. Required: Yes |
| record | The free text record to be coded. Type: Record object, following the input format specified by the model. Required: No, but either record or records must be provided. |
|---|---|
| records | The free text records to be coded. Type: Array of Record objects, following the input format specified by the model. Each item may optionally specify an additional string value recordId. Length Constraints: Minimum length of 1. Maximum length of 300. Required: No, but either record or records must be provided. |
| numberOfSuggestions | The number of suggested codes to be provided if the record cannot be coded successfully. The maximum value of this field is 16. Type: Number Required: No |
Response syntax
The response of this endpoint will depend on whether your input request contained a single record or a small batch of records.
1. Coding a single free text record
HTTP/1.1 200 OK
Content-type: application/json
{
"codeStatus": "string",
"input": {
"occp_text": "string",
"tasks_text": "string"
},
"result": [
{
"codeCategory": "string",
"codeLabel": "string",
"codeConfidence": number
}
],
}2. Coding a small batch of free text records
HTTP/1.1 200 OK
Content-type: application/json
[
{
"recordId": "string",
"codeStatus": "string",
"input": {
"occp_text": "string",
"tasks_text": "string"
},
"result": [
{
"codeCategory": "string",
"codeLabel": "string",
"codeConfidence": number
}
],
}
]Response elements
If the action is successful, the service sends back an HTTP 200 response. The API returns either a SynchronousCodeResponse object or an array of SynchronousCodeResponse objects corresponding to the input records.
Errors
For information about synchronous coding errors, see Errors and suggested actions.
Examples
(Also see Integration script examples for example PowerShell single record and small batch coding scripts.)
| Successfully coded a single record against a specific model: | |
|---|---|
| Sample request | |
| Sample response | |
| Coding a small batch of records against a specific model: | |
|---|---|
| Sample request | |
| Sample response | |