Remove Audit subscription
This endpoint will remove the existing audit subscription record from the database and stop the current streaming process. Please note, to restart the subscription, call the subscribe endpoint again.
URL : http://34.122.70.8/api/v1/audit/unsubscribe
Method : DELETE
Auth required : YES
| Headers | Type | Description |
|---|---|---|
| api-key | string | Unique api key provided to each customer |
Permissions required : None
Data constraints
Provide info including where the service should forward the Audit Records, the maximum number of records in each payload, and the frequency for sending them.
Response Body:
| Field | Type | Description |
|---|---|---|
| status | Boolean | Status of the request |
| msg | string | Response message from the server |
| data | Data Object |
Data Object:
| Field | Type | Description |
|---|---|---|
| id | string | ID of the audit subscription table record |
| start_time | Date | Date and time from when Audit Records should be fetched |
| last_read_at | Data Object | Time of the last Audit Record sent via the subscription |
| endpoint_url | string | Client webhook URL where data is being sent |
| fetch_limit | string | Max number of Audit Records to be sent to the client in each message |
| read_interval | Number | Interval, in seconds, between messages sent to the client |
| status | string | Status of the subscription. For new subscription, the status will be 'active'. |
| createdAt | Date | Date and time subscription was created |
| updatedAt | Data Object | Date and time subscription was last updated |
Success Response
Condition : If everything is OK and and the subscription does not already exist.
Code : 200 OK
Content example
{
"status": true,
"msg": "Audit record unsubscribed successfully",
"data": [
{
"id": 1,
"start_time": "2022-12-25T07:03:30.000Z",
"last_read_at": null,
"endpoint_url": "http://localhost:3000/hook",
"fetch_limit": 100,
"read_interval": 60,
"status": "active",
"createdAt": "2023-07-12T17:51:58.439Z",
"updatedAt": "2023-07-12T17:51:58.439Z"
}
]
}
Error Responses
Condition : If no subscription exists.
Code : 200 OK
Content :
{
"status": true,
"msg": "Audit record unsubscribed successfully",
"data": []
}
Or
Condition : If api-key is not passed in request header or is wrong.
Code : 401 Unauthorized
Content example
{
"status": false,
"error_code": "AUDIT_UNAUTHORIZED",
"error_msg": "Missing/MisMatch API KEY"
}
- Nodejs
- React
const fetch = require('node-fetch');
let url = 'http://34.122.70.8/api/v1/audit/unsubscribe';
let options = {method: 'DELETE', headers: {'api-key': '<API_KEY>'}};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
let headersList = {
"api-key": "<API_KEY>"
}
let response = await fetch("http://34.122.70.8/api/v1/audit/unsubscribe", {
method: "DELETE",
headers: headersList
});
let data = await response.text();
console.log(data);