Webhook Event Services
In the Webhook Event Service, you can publish and resend webhook requests. This service encompasses functionalities such as retrieving a list of webhooks and their details, as well as publishing and resending webhook requests from the OMS.
POST
Publish Event
This service is used to publish an event from OMS.
Path: /api/v1/oms/oms_hook_events/publish-event/
Payload
Parameter | Data Type | In | Description |
---|---|---|---|
hook | int | payload | Filters the event url |
instance | object | payload | Filters the event object content type |
Example Request
To run this service, a POST
request should be sent to /api/v1/oms/oms_hook_events/publish-event/
endpoint.
Here's an example of how to make the request in python:
import requests
url = "https://{oms_base_url}/api/v1/oms/oms_hook_events/publish-event/
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"
headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}
payload = {
'hook': "webhook.pk",
'instance': {
'pk': "package.pk",
'model': 'package'
}
}
response = requests.request("get", url, data=payload, headers=headers)
print(response.text)
Example Response (202 ACCEPTED)
In a successful response, API returns a response with a status code of 202 ACCEPTED
with an empty response body.
POST
Resend Event
This service is used to resend event from OMS.
Path: /api/v1/oms/oms_hook_events/resend-event/
Payload
Parameter | Data Type | In | Description |
---|---|---|---|
event | string | payload | uuid of the event |
Example Request
To run this service, a POST
request should be sent to /api/v1/oms/oms_hook_events/resend-event/
endpoint.
Here's an example of how to make the request in python:
import requests
url = "https://{oms_base_url}/api/v1/oms/oms_hook_events/publish-event/
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"
headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}
payload = {
'event': "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d",
}
response = requests.request("get", url, data=payload, headers=headers)
print(response.text)
Example Response (200 OK)
In a successful response, API returns a response with a status code of 200 OK
with an empty response body.
GET
List of Webhooks
This service is used to get a list of webhooks from OMS.
Path: /api/v1/oms/oms_hook_events/
Payload
No payload is required.
Example Request
To run this service, a GET
request should be sent to /api/v1/oms/oms_hook_events/
endpoint.
Here's an example of how to make the request in python:
import requests
url = "https://{oms_base_url}/api/v1/oms/oms_hook_events/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"
headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}
response = requests.request("get", url, headers=headers)
print(response.text)
Example Response (200 OK)
In a successful response with a status code of 200 OK
the response body contains list of webhook objects.
These parameters are described in the following table.
Parameter | Data Type | Description |
---|---|---|
id | int | Unique id of the webhook |
webhook | object | Details of the webhook |
created_date | datetime | Date and time of webhook created |
updated_date | datetime | Date and time of webhook updated |
uuid | string | Unique id of the webhook |
request_payload | object | Request payload of the webhook |
response_content | object | Response content of the webhook |
response_http_status | int | Response http status of the webhook |
delivered | boolean | Delivery status of the webhook |
request_datetimes | datetime | Date and time of webhook request |
retry_count | int | Retry count of the webhook |
object_id | int | Object id used in webhook |
content_type | string | Content type of the object |
This example response serves as a reference to understand the structure and data format returned from this API service.
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 3,
"webhook": {
"id": 1,
"retry_countdown_config": {
"choice": "exponential",
"kwargs": {
"base": 2
}
},
"created_date": "2024-02-19T08:12:18.591206Z",
"modified_date": "2024-02-19T08:12:18.591211Z",
"target_url": "http://www.zjdaxliadjwylwuqwicp.com/",
"is_active": true,
"secret_key": "esGmJGCSbxJUsYqsPFEeMiSpPqcqABPIGxFLNPDuFmKKQEVyecoHRTUAWyaphTep",
"event_type": "package.created",
"callback": null,
"additional_headers": {},
"config": {}
},
"created_date": "2024-02-19T08:12:18.793672Z",
"modified_date": "2024-02-19T08:12:18.793681Z",
"uuid": "d2a839f0-09cc-4755-a731-081d4cc1330a",
"request_payload": {
"event": {
"type": "package.created",
"uuid": "dfb06848cd3a48458e2f5c64006fd350"
},
"payload": {}
},
"response_content": {},
"response_http_status": 200,
"delivered": false,
"request_datetimes": [],
"retry_count": null,
"object_id": 1,
"content_type": 3
}
]
}
GET
Webhook Detail
This service is used to get webhook detail from OMS.
Path: /api/v1/oms/oms_hook_events/{pk}/
Payload
No payload is required.
Example Request
To run this service, a GET
request should be sent to /api/v1/oms/oms_hook_events/{pk}/
endpoint.
Here's an example of how to make the request in python:
import requests
url = "https://{oms_base_url}/api/v1/oms/oms_hook_events/1/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"
headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}
response = requests.request("get", url, headers=headers)
print(response.text)
Example Response (200 OK)
In a successful response with a status code of 200 OK
the response body contains webhook object.
These parameters are described in the following table.
Parameter | Data Type | Description |
---|---|---|
id | int | Unique id of the webhook |
webhook | object | Details of the webhook |
created_date | datetime | Date and time of webhook created |
updated_date | datetime | Date and time of webhook updated |
uuid | string | Unique id of the webhook |
request_payload | object | Request payload of the webhook |
response_content | object | Response content of the webhook |
response_http_status | int | Response http status of the webhook |
delivered | boolean | Delivery status of the webhook |
request_datetimes | datetime | Date and time of webhook request |
retry_count | int | Retry count of the webhook |
object_id | int | Object id used in webhook |
content_type | string | Content type of the object |
This example response serves as a reference to understand the structure and data format returned from this API service.
{
"id": 3,
"webhook": {
"id": 1,
"retry_countdown_config": {
"choice": "exponential",
"kwargs": {
"base": 2
}
},
"created_date": "2024-02-19T08:12:18.591206Z",
"modified_date": "2024-02-19T08:12:18.591211Z",
"target_url": "http://www.zjdaxliadjwylwuqwicp.com/",
"is_active": true,
"secret_key": "esGmJGCSbxJUsYqsPFEeMiSpPqcqABPIGxFLNPDuFmKKQEVyecoHRTUAWyaphTep",
"event_type": "package.created",
"callback": null,
"additional_headers": {},
"config": {}
},
"created_date": "2024-02-19T08:12:18.793672Z",
"modified_date": "2024-02-19T08:12:18.793681Z",
"uuid": "d2a839f0-09cc-4755-a731-081d4cc1330a",
"request_payload": {
"event": {
"type": "package.created",
"uuid": "dfb06848cd3a48458e2f5c64006fd350"
},
"payload": {}
},
"response_content": "false",
"response_http_status": 200,
"delivered": false,
"request_datetimes": [],
"retry_count": null,
"object_id": 1,
"content_type": 3
}