Skip to content

API Fields

This page distills field-level details from the current DTO and route implementations, focusing on the common responses, event queries, event records, HTTP push parameters, and MQTT parameters that are most commonly used by public integrations. A complete OpenAPI schema can be generated from these DTOs later.

Common Response

FieldTypeDescription
resCodenumberCWAI response code; 1 = success, 0 = failure
resMsgobject[]Error or info message list
resMsg[].msgCodestringMessage code
resMsg[].msgTextstringMessage text
resMsg[].messageKeystringStable localization key; frontends should prefer it for translation
resMsg[].detailsobjectMachine-readable actual values, limits, required resources, and currently available resources
resMsg[].retryablebooleanWhether retrying can help after external conditions change
resMsg[].retryAfterSecondsnumberSuggested delay in seconds, returned only when applicable
resMsg[].recommendedActionstringSuggested next step, such as freeing storage, switching to chunks, or resizing an image
resultCodestringChinaMobile-compatible response code
resultMsgstringChinaMobile-compatible response text
resDataobjectBusiness response data

messageKey, details, recommendedAction, and retryAfterSeconds are returned only when applicable; retryable can also be omitted when false. Clients must treat an absent field as “no additional guidance,” not as another failure.

Chunk Upload Fields

See API Overview: Resource-Aware Transfers for the capability, chunk, and cancellation endpoints. uploadTemp uses multipart/form-data:

FieldTypeFirst ChunkLater ChunksDescription
fileblobrequiredrequiredCurrent chunk; the filename must remain unchanged
purposestringrequiredrequiredmodel-component, model-archive, video, face-import, audio, algorithm, upgrade, or image
chunkIndexdecimal string0requiredZero-based chunk index
totalChunksdecimal stringrequiredrequiredChunk count for the complete file
totalSizedecimal stringrequiredrequiredComplete file size in bytes
chunkSizedecimal stringrequiredrequiredCurrent chunk size; it must match the actual multipart file size
clientRequestIdstringrecommendedunchangedStable principal-scoped resume identity, up to 128 characters
uploadIdstringomittedrequiredOpaque server-issued session ID
sha256stringoptionalunchanged64-character hexadecimal SHA-256 of the complete file

contentLength, fileName, and filePath are generated by the server-side multipart parser from the current request. Client-supplied fields with those names are not trusted sources.

uploadTemp returns these fields under resData:

FieldTypeDescription
uploadIdstringServer session ID required by subsequent chunks and the business consumer
nextChunkIndexdecimal stringNext chunk required by the server; it can jump over confirmed chunks after an idempotent replay or restart recovery
completebooleanWhether the complete file has been received and verified
filePathstringR1-compatible opaque upload:// alias; it is not a server path and new clients must not use it

After upload completion, business APIs reference only the session ID:

Business EndpointField
/gtw/cwai/Camera/AddVideouploadId
/gtw/cwai/aihost/PTaskDetectPicuploadId, mutually exclusive with imageBase64/imageUrl
/gtw/cwai/Library/ModifyFacePicLibpictureUploadIds[]
/gtw/cwai/BodyLibrary/DetectPersonuploadId
/gtw/cwai/ThingsLibrary/AddLibThingsthingsList[].pictureUploadId

Model components, model archives, algorithm packages, upgrade packages, audio, and face imports likewise use the uploadId field in their respective DTOs. Legacy Base64 and compatibility fields remain readable, but large-file and high-resolution-image clients should use staged sessions and must not rely on server paths.

Pagination and Time Range

Event queries and similar interfaces reuse the pagination and time fields:

FieldTypeDefaultDescription
pageNumnumber1Page number
pageSizenumber10Page size
timeBeginnumber0Start time, millisecond timestamp
timeEndnumber0End time, millisecond timestamp

Event Query Conditions

Source: MsgConditionEvent.

FieldTypeDescription
algorithmCodesstring[]Algorithm code list
categorysstring[]Event category list (field name retained from the current implementation)
videoChannelNamestringChannel name
personNamestringPerson name
personCodestringPerson code
matchLibNamestringMatched gallery name
propColorstringTarget color, often vehicle color
propRelatedColorstringRelated target color, often plate color
propTypestringTarget type, often vehicle type
propDirectionstringTarget direction, often vehicle direction
reportStatusnumberReport status, default -1

Event Record

Source: MsgEventUnit.

FieldTypeDescription
idstringEvent record ID
videoChannelIdstringVideo channel ID
channelCodestringChannel code
channelNamestringChannel name
timestampnumberEvent time, millisecond timestamp
categorystringEvent category
algorithmCodestringAlgorithm code
algorithmNamestringAlgorithm name
areaIdstringArea ID
areaNamestringArea name
fullPicturestringFull-frame image URL
detectedPicturestringTarget detection image URL
videostringAlarm video URL
videostructuredstringStructured video file URL
reportStatusnumberReport status
propertystringAttribute JSON string; varies by algorithm type

Event Report Payload

HTTP webhook and some internal event messages use CMsgOnEventsReq semantics:

FieldTypeDescription
messageIdstringMessage ID
devIdstringDevice ID
taskIdstringTask ID
videoChannelIdstringChannel ID
channelNamestringChannel name
timestampstringUTC millisecond timestamp string
itimestampnumberUTC millisecond timestamp (defined in the DTO; the current outbound to_json does not output this field, only inbound deserialization reads it)
algorithmIdstringAlgorithm ID
algorithmCodestringAlgorithm code
algorithmNamestringAlgorithm name
areaIdstringArea ID
areaNamestringArea name
orignalPicturestringOriginal image: Base64 in HTTP webhooks and a URL in internal messages (field name retained from the current implementation)
fullPicturestringFull-frame image: Base64 in HTTP webhooks and a URL in internal messages
detectedPicturestringTarget image: Base64 in HTTP webhooks and a URL in internal messages
videostringAlarm video: an absolute device-local path in standalone HTTP webhooks and a web URL in browser/query responses. The file may take a few seconds to finish after the event is pushed
videostructuredstringStructured video file path or URL; may be empty
overviewFilestringStructured overview file path or URL; may be empty
recordIdstringAlarm record ID
filesstring[]Related file list (defined in the DTO; the current outbound to_json does not output this field, only inbound deserialization reads it)
isRetryMessagebooleanWhether this is a retry message
targetsobject[]Detection targets that triggered the event, with label, confidence, optional trackId, and pixel-coordinate box
propertyobjectAttribute object; varies by algorithm type
categorystringEvent category

Property Field Types

Event properties are differentiated via OnEventsPropertyType (see the enum in src/util/MsgBaseTypes.h, and the outbound serialization in src/util/dto/ClientMsgEvent.cc). Each type outputs its corresponding JSON key:

Type (OnEventsPropertyType)Output KeyMain Fields
facefacequality, age, gender, wearMask, wearGlasses, featureUrl, image
body (Body / BodyFeature)bodytopLength, topColor, bottomLength, bottomColor, featureUrl, image
vehiclevehicleplateColor, vehicleColor, vehicleClass, orientation, plate, plateSrc, attrs
behaviorbehaviorcount, duration, targetId
machineMaterialmachineMaterialmatchId, matchDegree, groupId, groupName, baseImageUrl, runningStatus
peoplepeopleenterNumber, leaveNumber, enterOrgNum, leaveOrgNum, time
carcarenterNumber, leaveNumber, enterOrgNum, leaveOrgNum, time
workClothesRecognitionworkClothesRecognitionmatchId, matchDegree, groupId, groupName, baseImageUrl
personCount (PersonCount)personCount + personsArea person-count statistics; also outputs the persons list (fields below)
countNumber (CountNumber)countNumberCounting-type events

The following are additional sub-objects (not independent OnEventsPropertyType enum values, but emitted alongside the main type):

Sub-objectEmitted WhenMain Fields
recognitionEmitted alongside the face typematchDegree, matchLibName, matchId, LibImage, matchName, personCode, personId
personsEmitted alongside the personCount typeorignalPicture, fullPicture, targetPicture, box
targetAny type, appended when bHaveTarget is trueinAreaTime, inAreaFullImageUrl, outAreaTime, outAreaFullImageUrl

HTTP Push Parameters

Routes:

text
/gtw/cwai/System/QueryHttpInterfaceParam
/gtw/cwai/System/SetHttpInterfaceParam
FieldTypeDescription
switchbooleanWhether HTTP push is enabled; the set interface only recognizes this field
enablebooleanOnly output by the query response (same value as switch); the set interface does not read this field
urlstringHTTP URL that receives events

MQTT Parameters

Routes:

text
/gtw/cwai/System/QueryMqttAdapterParam
/gtw/cwai/System/SetMqttAdapterParam
FieldTypeDefaultDescription
switchbooleantrueWhether MQTT is enabled; the set interface only recognizes this field
enablebooleantrueOnly output by the query response (same value as switch); the set interface does not read this field
urlstringemptyMQTT broker address
portnumber1883MQTT broker port
statusbooleantrueCurrent MQTT registration/connection status; a query-result field
authModenumber00 uses built-in IoT auth; non-0 uses a normal username/password
clientIdstringemptyClient ID under normal auth mode
userNamestringemptyUsername under normal auth mode
passwdstringemptyPassword under normal auth mode

IoT Network Mode Parameters

Routes:

text
/gtw/cwai/System/QueryIotNetworkParam
/gtw/cwai/System/ModifyIotNetworkParam
FieldTypeDefaultDescription
mqttIpstringemptyMQTT address under IoT network mode
mqttPortnumber1883MQTT port under IoT network mode
httpUrlstringemptyHTTP address under IoT network mode
statusbooleantrueWhether MQTT is currently enabled; a query-result field

Released under the Apache 2.0 License.