logo
Use this method to create or overwrite a document in the extension document store.

Field
Type
Required
Description
method
String
Yes
"extensionSetDoc"
app_id
String
Conditional
The app the document belongs to. If omitted, the API's own chat id is used.
doc_type
String
Yes
Category of the document, e.g. "cart".
doc_id
String
Yes
Identifier of the document within that type.
doc
String
Yes
The document body. Serialize your own JSON into this string.
ref
String
Optional
Correlation id, echoed in the response.
πŸ’‘ Writing to an existing app_id + doc_type + doc_id overwrites the stored doc.

Response

extensionSetDocResponse

Field
Type
Returned
Description
method
String
Yes
"extensionSetDocResponse"
ack
Number
Yes
Number of rows written. 1 for an insert, 2 when an existing document was overwritten.
doc
String
Yes
The document body that was stored.
doc_id
String
Yes
Echoed from the request.
doc_type
String
Yes
Echoed from the request.
app_id
String
Yes
Echoed from the request.
ref
String
Optional
Echoed from the request.

SDK Mapping β€” extensionSetDoc

SDK
Response Callback
Java
onExtensionDocResponse(ExtensionDocResponse response) β€” type is insert
JavaScript
onExtensionDocResponse(response) β€” type is insert
Python
on_extension_doc_response(self, response) β€” type is insert

Example

Request

json
{ "method": "extensionSetDoc", "app_id": "90090684293000559", "doc_type": "cart", "doc_id": "user_9001", "doc": "{\"items\":[{\"sku\":\"A12\",\"qty\":2}]}", "ref": "111111148" }

Response

json
{ "method": "extensionSetDocResponse", "ack": 1, "doc": "{\"items\":[{\"sku\":\"A12\",\"qty\":2}]}", "doc_id": "user_9001", "doc_type": "cart", "app_id": "90090684293000559", "ref": "111111148" }