Chat API
This API allows you to send chat messages to specific users of the Woven City App.
Users will be notified via OS notifications only (not in-app notifications) when they receive a chat message.
Version Requirements
- MiniApp SDK Version: Not applicable (server-side HTTP API)
- MiniApp Runtime Engine Version:
>= 1.0.0
API Spec
{
"/mini-app-runtime/v1/chat/": {
"post": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"woven_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"project_id": {
"type": "string",
"format": "uuid"
}
},
"required": [
"message",
"woven_ids",
"project_id"
],
"additionalProperties": false
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"data": {
"type": "object",
"properties": {
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"user_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"reason": {
"type": "string"
}
},
"required": [
"user_ids",
"reason"
],
"additionalProperties": false
}
}
},
"required": [
"errors"
],
"additionalProperties": false
},
"info": {
"type": "string",
"minLength": 1
}
},
"required": [
"success",
"data",
"info"
],
"additionalProperties": false
}
}
}
}
}
}
}
}
Sending Chat Message
Prerequisites:
- You received a Server Side Client secret upon creation of your first MiniApp version.
caution
This API must be used on the backend only; please avoid using it on the frontend to not expose your client secret.
Steps (via Curl)
1 Get Access Token
curl -d 'client_id={YOUR_KEYCLOAK_CLIENT_ID}' \
-d 'client_secret={YOUR_KEYCLOAK_CLIENT_SECRET}' \
-d 'grant_type=client_credentials' \
'https://id.woven-city.toyota/auth/realms/woven/protocol/openid-connect/token'
2 Send Chat Message
Replace {ACCESS_TOKEN} with the obtained access token:
curl -X 'POST' \
'https://mini-app-api.lab.woven-city.toyota/mini-app-runtime/v1/chat' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-d '{
"project_id": "REPLACE_WITH_YOUR_PROJECT_ID",
"message":"REPLACE_WITH_YOUR_MESSAGE",
"woven_ids": [
"REPLACE_WITH_TARGET_WOVEN_ID_1",
"REPLACE_WITH_TARGET_WOVEN_ID_2",
"REPLACE_WITH_TARGET_WOVEN_ID_N"
]
}'
caution
- Project members cannot be included in the woven_ids field to receive chat messages. Because of this, you won't receive the chat messages if you are testing with a Project ID where you are a project member.