Skip to main content

CPR Bulk Reset API

Overview

The CPR /delete-transaction-state/bulk API is designed to bulk delete CPR transaction states based on workflow versions and application status. This is an internal API used for resetting multiple transactions at once, typically when a workflow version needs to be deprecated.

Request details

note

This is an internal API. Access is restricted to authorized services only.

cURL example

curl --location --request DELETE 'https://ind-state.dev.hyperverge.co/v2/internal/delete-transaction-state/bulk' \
--header 'Content-Type: application/json' \
--header 'appId: ' \
--header 'appKey: ' \
--data-raw '{
"appId": "your_app_id",
"workflowId": "your_workflow_id",
"workflowVersions": ["1.0.0"],
"applicationStatusToReset": ["user_cancelled", "error", "auto_declined"],
"email": "your.email@hyperverge.com",
"clientId": "manual-test"
}'

Base URL: https://ind-state.idv.hyperverge.co URL: /api/v2/internal/delete-transaction-state/bulk Method: DELETE

Authentication

This API requires authentication headers.

HeaderRequired
appIdyes
appKeyyes
authorizationyes (if appKey not provided)

Request body

FieldTypeRequiredDescriptionExampleDefault
appIdStringYesThe application ID."55a3a6"
workflowIdStringYesThe workflow ID."user_main_onboarding"
workflowVersionsArray of StringsYesList of workflow versions to delete. Must follow semver format (x.y.z).["1.0.0", "1.1.0"]
applicationStatusToResetArray of StringsNoFilter deletion by transaction status. If empty, deletes all matching records regardless of status.["user_cancelled", "error"]["user_cancelled", "error", "auto_declined"]
emailStringYesEmail of the person initiating the bulk reset."user@hyperverge.co"
clientIdStringYesIdentifier of the client/system triggering the reset."HV"

Allowed status values

applicationStatusToReset accepts the following values:

StatusDescription
needs_reviewTransaction pending manual review.
auto_approvedTransaction automatically approved.
auto_declinedTransaction automatically declined.
user_cancelledTransaction cancelled by user.
errorTransaction encountered an error.
manually_approvedTransaction manually approved by reviewer.
manually_declinedTransaction manually declined by reviewer.

Behaviour notes:

  • If applicationStatusToReset is sent as an empty array (applicationStatusToReset: []), the API deletes all records matching appId, workflowId, and workflowVersions regardless of status.
  • If applicationStatusToReset is not sent, the API takes the default values: ["user_cancelled", "error", "auto_declined"].

Sample responses

Success — records deleted

{
"status": "success",
"statusCode": 200,
"result": {
"deletedRecords": [
{ "transactionId": "txn_abc123" },
{ "transactionId": "txn_def456" },
{ "transactionId": "txn_ghi789" }
],
"count": 3
}
}

Success — no records found

{
"status": "success",
"statusCode": 200,
"code": "resource_not_found_no_action_taken",
"result": {
"deletedRecords": [],
"count": 0
}
}

Error responses

Status codeError scenarioResponse structure
400Missing required field: appId{"status": "failure", "statusCode": 422, "error": "\"appId\" is required"}
400Missing required field: workflowId{"status": "failure", "statusCode": 422, "error": "\"workflowId\" is required"}
400Missing required field: workflowVersions{"status": "failure", "statusCode": 422, "error": "\"workflowVersions\" is required"}
400Empty workflowVersions array{"status": "failure", "statusCode": 422, "error": "\"workflowVersions\" must contain at least 1 items"}
400Invalid version format{"status": "failure", "statusCode": 422, "error": "\"workflowVersions[0]\" fails to match the required pattern"}
400Invalid status value{"status": "failure", "statusCode": 422, "error": "\"applicationStatusToReset[0]\" must be one of [needs_review, auto_approved, ...]"}
400Missing required field: email{"status": "failure", "statusCode": 422, "error": "\"email\" is required"}
400Invalid email format{"status": "failure", "statusCode": 422, "error": "\"email\" must be a valid email"}
400Missing required field: clientId{"status": "failure", "statusCode": 422, "error": "\"clientId\" is required"}

Deep dive — working of the API

Request validation

  1. All required fields (appId, workflowId, workflowVersions, email, clientId) must be present.
  2. workflowVersions must be a non-empty array with valid semver format (x.y.z).
  3. applicationStatusToReset values must be from the allowed status map.
  4. email must be a valid email format.

Deletion logic

The API builds a database query with the following conditions:

  1. appId equals the provided appId.
  2. workflowId equals the provided workflowId.
  3. workflowVersion is in the provided workflowVersions array.
  4. If applicationStatusToReset is provided and non-empty, additionally filters by status.

Status filtering behaviour

When applicationStatusToReset is provided:

  • Deletes records where transactionMetadata.status matches any value in the array.
  • Also deletes records where transactionMetadata is NULL.
  • Also deletes records where transactionMetadata.status is NULL or empty.
  • This ensures transactions without a status are also cleaned up.
  • If applicationStatusToReset is provided as empty, it takes the default values.

Flow diagram

flowchart TD
st([Start])
e([End])
op1[Validate Request Schema]
op2[Build Delete Query]
op3[Execute Delete with Filters]
op4[Return Deleted Records]
cond1{Valid Request?}
cond2{Records Found?}

st --> op1 --> cond1
cond1 -- Yes --> op2 --> op3 --> cond2
cond1 -- No --> e
cond2 -- Yes --> op4 --> e
cond2 -- No --> e

Analytics events

The API logs the following events to the cpr_analytics table:

Event nameWhen triggeredAdditional fields
delete-transaction-state-versions-startedRequest received.appId, workflowId, workflowVersions, status, email
delete-transaction-state-versions-no-records-foundNo matching records.appId, workflowId, workflowVersions, status, email
delete-transaction-state-versions-successRecords deleted.appId, workflowId, workflowVersions, status, email, deletedRowsCount
OwnerChitransh
Last reviewed onApr 22, 2026
Last updated onApr 25, 2026
Last updated bySrinija
Was this helpful?
Ask AI

Ask anything about the internal documentation

AI answers are based on internal documentation. Verify critical information.