Skip to main content

Update Audit subscription status

This endpoint allows the end user to update the subscription status to one of two possible states: pause or resume.

URL : http://34.122.70.8/api/v1/audit/subscription/:status

Method : PUT

Auth required : YES

HeadersTypeDescription
api-keystringUnique api key provided to each customer

Permissions required : None

Params 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.

Path Parameters:

KeyTypeDescription
statusstringUpdate status to pause or resume

Response Body:

FieldTypeDescription
statusBooleanStatus of the request
msgstringResponse message from server
dataData Object

Data Object:

FieldTypeDescription
idstringID of the audit subscription table record
start_timeDateDate and time from when Audit Records should be fetched
last_read_atData ObjectTime of the last Audit Record sent via the subscription
endpoint_urlstringClient webhook URL where data is being sent
fetch_limitstringMax number of Audit Records to be sent to client in each message
read_intervalNumberInterval, in seconds, between messages sent to client
statusstringStatus of the subscription. For new subscription, the status will be 'active'.
createdAtDateDate and time subscription was created
updatedAtData ObjectDate and time Subscription was last updated

Request Example All fields must be sent.

http://34.122.70.8/api/v1/audit/subscription/pause
http://34.122.70.8/api/v1/audit/subscription/resume

Success Response

Condition : If subscription is successfully paused.

Code : 200 OK

Content example

{
"status": true,
"msg": "Subscription status updated 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": "pause",
"createdAt": "2023-07-12T18:18:26.136Z",
"updatedAt": "2023-07-12T18:18:26.136Z"
}
]
}

Or

Condition : If subscription is successfully resumed.

Code : 200 OK

Content example

{
"status": true,
"msg": "Subscription status updated 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-12T18:18:26.136Z",
"updatedAt": "2023-07-12T18:18:26.136Z"
}
]
}

Error Responses

Condition : If param other than pause or resume is passed.

Code : 400 Bad Request

Content :

{
"status": false,
"error_code": "BAD_DATA",
"error_msg": "Subscription status not found or invalid"
}

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"
}
const fetch = require('node-fetch');

let url = 'http://34.122.70.8/api/v1/audit/subscription/resume';

let options = {method: 'PUT', headers: {'api-key': '<API_KEY>'}};

fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));