XMPP messages or any other XMPP stanza can be sent using this API by sending an HTTP POST request to (by default) http://localhost:8080/rest/stream/?api-key=API_KEY
with serialized XMPP stanza as a content, where API_KEY
is the API key for HTTP API.
This key is set in etc/config.tdsl.
Also, each request needs to be authorized by sending a valid administrator JID and password as user and password of BASIC HTTP authorization method.
Content of HTTP request should be encoded in UTF-8
and Content-Type
should be set to application/xml
.
If the sent XMPP stanza does not contain a from
attribute, then the HTTP API component will provide it’s own JID.
If iq
stanza is being sent, and no from
attribute is set then the received response will be returned as the content of the HTTP response.
Successful requests will return HTTP response code 200.
Sending an XMPP message with from set to HTTP API component to full JID. Data needs to be sent as a HTTP POST request content to /rest/stream/?api-key=API_KEY
URL of the HTTP API component to deliver the message Example message 1 to test@example.com/resource-1.
<message xmlns="jabber:client" type="chat" to="test@example.com/resource-1"> <body>Example message 1</body> </message>
Sending an XMPP message with from
set to HTTP API component to a bare JID. Data needs to be sent as a HTTP POST request content to /rest/stream/?api-key=API_KEY
URL of the HTTP API component to deliver message Example message 2 to test@example.com.
<message xmlns="jabber:client" type="chat" to="test@example.com"> <body>Example message 2</body> </message>
Sending an XMPP message with from
set to specified JID and to a recipients' full JID. Data needs to be sent as a HTTP POST request content to /rest/stream/?api-key=API_KEY
URL of the HTTP API component to deliver message Example message 3 to test@example.com/resource-1 with sender of message set to sender@example.com.
<message xmlns="jabber:client" type="chat" from="sender@example.com" to="test@example.com/resource-1"> <body>Example message 1</body> </message>