URL: /api/1.0/xmppdomains/<fqdn>/gateway/messages/<username>
This API endpoint is used when a message needs to be sent directly to any user and appear to be from any user. It is authenticated using the normal API authentication username and API password.
If a message is being sent as myuser@example1.chatwith.it then use this example url:
https://manager.chatmongers.com/api/1.0/xmppdomains/example1.chatwith.it/gateway/messages/myuser
URL: /api/1.0/xmppdomains/<fqdn>/gateway/messages
This API endpoint is used to send a message as a specific user. The authentication to use is Basic HTTP authentication with the XMPP user’s username and password. In order to use this API endpoint the user needs the ‘xmppgateway’ permission.
If a message is being sent as myuser@example1.chatwith.it then use this example url:
https://myuser:mypassword@manager.chatmongers.com/api/1.0/xmppdomains/example1.chatwith.it/gateway/messages
To send an XML formatted message post the message with Content-type: application/xml.
This API endpoint accepts an XMPP <message/> stanza. The same rules apply as when acting as an XMPP client. The message must contain a to= attribute and can accept any other valid options for XMPP stanzas. The from will automatically be assigned as the authorized API user that is sending the message.
Example XML post data:
<message to="user@host.chatwith.it" xmlns="jabber:client" type="chat">
<body>Hello, this is a test message</body>
</message>
Warning: Without type=’chat’ and xmlns=’jabber:client’ your messages may be discarded by the chatmongers server or other federated servers.
To send a JSON formatted message post the message with Content-type: application/json.
JSON messages have some standard fields that are used to construct a message stanza.
| Field | Required | Description |
|---|---|---|
| to | required | XMPP jid |
| body | optional | Text to insert into <message><body/></message> |
| message_attributes | optional | Key value list of attributes to be added to the message. The attributes type=”chat” and xmlns=”jabber:client” are set by default. |
| body_attributes | optional | Key value list of attributes to be added to the body element |
| extra_elements | optional | XML stanzas to be added after the <body/> element. |
Example JSON post data:
{"to": "user@host.chatwith.it",
"message_attributes": {"id": "1234"},
"body": "Hello, this is a test message.",
"extra_elements": "<subject>This is a message subject</subject>"
}
This will result in the following XMPP Message being sent:
<message to="user@host.chatwith.it" id="1234" xmlns="jabber:client" type="chat">
<body>Hello, this is a test message.</body>
<subject>This is a message subject</subject>
</message>