- General scheme of interaction
- Registration and setting of the transport module
- Getting information about the transport module
- Work with Transport API
General scheme of registration of the transport module and channels
Module User System MessageGateway
--------------------------------------------------------------------------------------------------
| | | |
1. | Creating ------------------> | |
| an API key | |
| | | |
| | | |
2. | Clicks | |
| the “Connect” button -------------> | |
| in the Module card | |
| in the Marketplace | |
| | Redirecting |
3. | <--------------------------------------- the User |
| | to the form of configuring |
| | and enabling the Module |
4. | <-------------- Fills out a form | |
| | | |
5. Checking API key, | | |
rights for API key ------------------------------------> | |
and API version | | |
| | | |
6. Registration | Receiving |
of the transport module ---------------------------------> token ------------------> |
| | | |
| | Returning token |
7. | <----------------------------------- and url to access |
| | MessageGateway |
| | | |
| | | |
8. | Fills out the form with | |
| <------ transport channel | |
| settings | |
| | | |
9. Registration of | | |
transport -------------------------------------------------------------------> |
channels | | |
| | | |
10. Redirecting | | |
user --------------------------------------> | |
to the account | | |
of the system | | |
| | | |
----------------------------------------------------------------------------------------------
Registration and setting of the transport module
Registration of a new transport module, as well as changing the settings of an existing one, is performed using the method POST /api/v5/integration-modules/{code}/edit, to which it is mandatory to pass the parameter integrationModule[integrations][mgTransport]
. If the module with code code
already exists, the method changes its settings, otherwise a new module is created.
During registration it is necessary to specify the name integrationModule[name]
, code integrationModule[code]
, basic url integrationModule[baseUrl]
and a unique customer code integrationModule[clientId]
, which will subsequently pass the MessageGateway in the header ClientId
to identify the system account.
In the integrationModule[integrations][mgTransport][webhookUrl]
field you should specify the address to which MessageGateway will send requests to the transport module.
In case of successful registration, the response will contain URL MessageGateway (info[mgTransport][endpointUrl]
) and its access key (info[mgTransport][token]
).
Further configuration of the transport module and channel management must be performed in the MessageGateway via the Tranport API.
For successful registration of the transport module, the integration with MessageGateway must be active in the system account. When disabling the integration, all transport modules will be automatically disabled in MessageGateway.
Example of a request:
{
"code": "awesometransport-101",
"integrationCode": "awesometransport",
"active": true,
"name": "Awesome Transport",
"logo": "http://download.awesometransport.server.net/logos/robot.svg",
"clientId": "client-101",
"baseUrl": "https://awesometransport.server.net",
"accountUrl": "https://awesometransport.server.net/profile/client-101",
"actions": {
"activity": "/activity"
},
"integrations": {
"mgTransport": {
"webhookUrl": "https://awesometransport.server.net/wh/client-101"
}
}
}
Example of a response:
{
"success": true,
"info": {
"mgTransport": {
"endpointUrl": "http://127.0.0.1:8080",
"token": "5bbdfd67ed17486e32363c95d462a39a138b215ccd9f87ef4c23e8f89f18e10a5"
}
}
}
Getting information about the transport module
Getting information about the transport module is performed using the method GET /api/v5/integration-modules/{code}.
Example of a response:
{
"success": true,
"integrationModule": {
"code": "awesometransport-101",
"integrationCode": "awesometransport",
"active": true,
"freeze": false,
"name": "Awesome Transport",
"native": false,
"clientId": "client-101",
"baseUrl": "https://awesometransport.server.net",
"actions": {
"activity": "/activity"
},
"availableCountries": [],
"accountUrl": "https://awesometransport.server.net/profile/client-101",
"integrations": {
"mgTransport": {
"webhookUrl": "https://awesometransport.server.net/wh/client-101"
}
}
}
}
Work with Transport API
API Endpoint: https://mg-s1.retailcrm.pro/api/transport/v1/
Authorization is done using the token received when registering the transport module.
For each request you must pass this token in the header
X-Transport-Token:X2EDxEta9U3lcsSV0dwdF38UvtSCxIuGh
Important!
When requesting, there is a limit of 30 requests per second from one token. If the request frequency limits are exceeded, the API returns a response with the HTTP status
429 Too Many Requests
.
If you did not save the token when registering, you can get it along with the information about the transport module.
Below you can find links to documentation for the Transport API, as well as to ready-made API clients for a number of languages.