Skip to main content

Hooks - Update Status

Endpoint​

/i/hook/status

Overview​

Updates enabled/disabled status for one or more hooks in a single request.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

Requires hooks Update permission.

Request Parameters​

ParameterTypeRequiredDescription
statusJSON String (Object)YesJSON-stringified map of hook IDs to boolean enabled state.
app_idStringConditionalRequired for non-global-admin users.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

status Object Structure​

FieldTypeRequiredDescription
{hookId}BooleanYesKey is hook ObjectID string; value is target enabled state (true or false).

Decoded payload example:

{
"65f0cbf8bca6b8e8fbf7f901": true,
"65f0cc6ebca6b8e8fbf7f902": false
}

Examples​

Disable one hook​

/i/hook/status?
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY&
status={"65f0cbf8bca6b8e8fbf7f901":false}

Mixed enable/disable batch​

/i/hook/status?
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY&
status={"65f0cbf8bca6b8e8fbf7f901":true,"65f0cc6ebca6b8e8fbf7f902":false}

Response​

Success Response​

true

Response Fields​

FieldTypeDescription
(root value)Booleantrue when the batch update promise resolves successfully.

Error Responses​

  • 400
{
"result": "Missing parameter \"api_key\" or \"auth_token\""
}
  • 400
{
"result": "Token not valid"
}
  • 400
{
"result": "Invalid status list"
}
  • 401
{
"result": "No app_id provided"
}
  • 401
{
"result": "User does not exist"
}
  • 401
{
"result": "User does not have right"
}
  • 401
{
"result": "User is locked"
}
  • 401
{
"result": "App does not exist"
}
  • 401
{
"result": "Token is invalid"
}
  • 500
{
"result": "Failed to update hook statuses: MongoServerError: write conflict"
}

Behavior​

Behavior Modes​

ModeConditionResult
Batch status updateValid status mapUpdates enabled field for each listed hook and returns true.
JSON parse failureInvalid or missing status JSON stringReturns 400 with Invalid status list.

Impact on Other Data​

  • Updates enabled values in countly.hooks.
  • Writes audit event to system logs on successful batch update.

Operational Considerations​

  • Large status payloads create many parallel DB operations in one request.
  • Invalid hook ID strings can fail ObjectID conversion and fail the request.
Implementation details

Configuration Impact

refreshRulesPeriod controls how quickly the updated enabled state is reflected in runtime rule cache after this endpoint returns.

Audit & System Logs

Successful updates dispatch /systemlogs with action:

  • hook_status_updated

Database Collections

CollectionUsed forData touched by this endpoint
countly.membersAuthentication and permission checksReads member account and access metadata.
countly.appsApp validation for non-global-admin usersReads app context during permission validation.
countly.hooksHook status updatesUpdates enabled field for each hook ID in status.