Webhook Setup

Technical Documentation for Webhook Setup

This documentation provides guidance for establishing a messaging channel for various types of messages from the SDK to the application. The client must configure a webhook on their servers to receive these messages. Once the service is operational, the SDK connection parameters to your server hosting the webhook need to be set, including the endpoint and access parameters if authorization is used. It is crucial that the webhook designed to receive messages adheres to the request and response models described in this documentation. To view the current settings for sending messages to the webhook, an access token is required. For instructions on generating an access token, refer to the Access Token Generation sections. Methods for viewing and modifying the webhook connection settings are detailed in the Viewing Webhook Settings and Modifying Webhook Settings sections. The expected request and response models from your constructed webhook on your servers are described in the Webhook Description section

Viewing Webhook Settings

This method will display the current settings in the SDK system for sending messages to the webhook located on your server

URL https://api.infocus.company

GET /sdk/v1/settings/

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <BackendAccessToken>

Response

{
  "user_name": "access_developer",
  "webhook_url": "https://your.company/sdkwebhook/",
  "webhook_max_num_delivery": 6,
  "webhook_basic_auth_enable": false,
  "webhook_basic_auth_username": "user",
  "webhook_basic_auth_password": "password"

}

Response Fields

  • user_name: Your login.

  • webhook_url: The address of the webhook on your servers.

  • webhook_max_num_delivery: Maximum number of delivery attempts if the webhook is unavailable (retry interval: 30 seconds).

  • webhook_basic_auth_enable: Indicates if Basic Authentication is enabled.

  • webhook_basic_auth_username: Username for Basic Authentication (if enabled).

  • webhook_basic_auth_password: Password for Basic Authentication (if enabled).

Modifying Webhook Settings

This method allows you to change the settings in the SDK system related to sending messages to the webhook located on your server

URL https://api.infocus.company

POST /sdk/v1/settings/

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <BackendAccessToken>

Body

Name
Type
Description
webhook_url

String

The address of the webhook on your servers

webhook_max_num_delivery

Integer

Maximum number of delivery attempts if the webhook is unavailable (retry interval: 30 seconds).

webhook_basic_auth_enable

Boolean

Indicates if Basic Authentication is enabled

webhook_basic_auth_username

String

Username for Basic Authentication (if enabled).

webhook_basic_auth_password

String

Password for Basic Authentication (if enabled).

Response

{
  "user_name": "access_developer",
  "webhook_url": "https://your.company/sdkwebhook/",
  "webhook_max_num_delivery": 6,
  "webhook_basic_auth_enable": false,
  "webhook_basic_auth_username": "user",
  "webhook_basic_auth_password": "password"
}

Webhook Description

This section describes the model that the webhook on your server should follow to receive messages from the SDK.

Endpoint The endpoint you specified in the webhook settings

POST /The path you specified in the webhook settings

Headers

Name
Value

Content-Type

application/json

Authorization

Optional if Basic Authentication is used

Body

Name
Type
Description

type

String

Type of message (e.g., SMS, PUSH).

phone_number_list

Array of String

Array of phone numbers to receive notifications

data

Objects

Contains details related to the notification, including either SMS or Push notification formats

SMS Notification Example

{
    "type": "SMS",
    "phone_number_list": ["380671111111", "380672222222"],
    "data": {
        "message_text": "You have received a new message"
    }
}

Push Notification Example

{
    "type": "PUSH",
    "phone_number_list": ["380671111111", "380672222222"],
    "data": {
        "push_type": "CHAT_NEW_MESSAGE",
        "push_data": {
            "chat_uid": "1b6e09b0-fe6f-43bf-918e-40437bdf85f9",
            "msg_uid": "1b6e09b0-fe6f-43bf-918e-40437bdf85f9",
            "msg_text": "Hello, World!",
            "date": "2022-01-01T00:00:00Z",
            "is_system": false,
            "sender": "MANAGER_CS",
            "sender_name": "John Doe"
        }
    }
}

Response

{
  "status_code": "000",
  "status_desc": "The request was completed successfully",
  "error_message": "string",
  "delivery_id": "d4b087cd-347d-4a81-817e-161ee319e323"
}

Response Fields

  • status_code: If the status code is 000, the request is executed successfully.

  • status_desc: Description of the request status.

  • error_message: Error message if the request fails.

  • delivery_id: Webhook delivery identifier

Status Codes Reference

The following status codes are used in the response to indicate the outcome of the request

Status Code
Description

000

The request was completed successfully

001

Delivery has been queued

900

The delivery was not successful

999

A critical error occurred while executing the request

901

Request parameters turned out to be incorrect

Webhook Message Types

The types of messages that can be sent via the webhook are defined as follows

Type
Description

SMS

Represents an SMS message type.

PUSH

Represents a Push notification type.

Conclusion

This documentation provides a comprehensive guide for setting up a webhook on the client's servers to receive messages from the SDK. Ensure that the webhook is configured correctly to facilitate seamless communication and notification delivery.

Last updated