Change Transaction Status
curl --request PATCH \
--url http://api.gu1.ai/transactions/:id/changeStatus \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"status": "<string>"
}
'import requests
url = "http://api.gu1.ai/transactions/:id/changeStatus"
payload = { "status": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({status: '<string>'})
};
fetch('http://api.gu1.ai/transactions/:id/changeStatus', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://api.gu1.ai/transactions/:id/changeStatus",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'status' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://api.gu1.ai/transactions/:id/changeStatus"
payload := strings.NewReader("{\n \"status\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("http://api.gu1.ai/transactions/:id/changeStatus")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"status\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/transactions/:id/changeStatus")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"status\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"transaction": {},
"statusChanged": {},
"rulesExecutionSummary": {}
}API Reference
Change Transaction Status
Update transaction status and trigger update rules automatically β in the gu1 transaction monitoring product for fraud and AML, with examples for change status.
PATCH
/
transactions
/
:id
/
changeStatus
Change Transaction Status
curl --request PATCH \
--url http://api.gu1.ai/transactions/:id/changeStatus \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"status": "<string>"
}
'import requests
url = "http://api.gu1.ai/transactions/:id/changeStatus"
payload = { "status": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({status: '<string>'})
};
fetch('http://api.gu1.ai/transactions/:id/changeStatus', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://api.gu1.ai/transactions/:id/changeStatus",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'status' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://api.gu1.ai/transactions/:id/changeStatus"
payload := strings.NewReader("{\n \"status\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("http://api.gu1.ai/transactions/:id/changeStatus")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"status\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/transactions/:id/changeStatus")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"status\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"transaction": {},
"statusChanged": {},
"rulesExecutionSummary": {}
}Endpoint
Change Transaction Status
PATCH http://api.gu1.ai/transactions/:id/changeStatus
- Automatic validation of status transitions (prevents invalid state changes)
- State machine enforcement (open β closed state rules)
- Automatic execution of rules/matrices with
transaction_status_changedtrigger (nottransaction_updated) - Transaction integrity protection
- Comprehensive audit trail
Authentication
All requests must include an API key in theAuthorization header:
Authorization: Bearer YOUR_API_KEY
Required Headers
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Path Parameters
string
required
The UUID of the transaction to updateType:
string (uuid)Request Body
string
required
New transaction status. Must be a valid status enum value.Valid Statuses:
CREATED- Transaction created (open state)PROCESSING- Transaction being processed (open state)SUSPENDED- Transaction temporarily suspended (open state)SENT- Transaction sent/transmitted (closed state)EXPIRED- Transaction expired (closed state)DECLINED- Transaction declined/rejected (closed state)REFUNDED- Transaction refunded/reversed (closed state)SUCCESSFUL- Transaction completed successfully (closed state)
enum - 'CREATED' | 'PROCESSING' | 'SUSPENDED' | 'SENT' | 'EXPIRED' | 'DECLINED' | 'REFUNDED' | 'SUCCESSFUL'State Transition Rules
The endpoint enforces strict state transition rules to maintain transaction integrity:Open States
States that allow further transitions:CREATEDPROCESSINGSUSPENDEDSENT
Closed States
Final states that cannot transition to other states:EXPIREDDECLINEDREFUNDEDSUCCESSFUL
Transition Matrix
| From State | To State | Allowed? | Note |
|---|---|---|---|
| CREATED | PROCESSING | β Yes | Normal flow |
| CREATED | SUSPENDED | β Yes | Suspend for review |
| CREATED | SUCCESSFUL | β Yes | Quick approval |
| PROCESSING | SUSPENDED | β Yes | Suspend during processing |
| PROCESSING | SUCCESSFUL | β Yes | Normal completion |
| PROCESSING | DECLINED | β Yes | Reject during processing |
| SUSPENDED | PROCESSING | β Yes | Resume processing |
| SUSPENDED | SUCCESSFUL | β Yes | Approve suspended transaction |
| SUSPENDED | DECLINED | β Yes | Reject suspended transaction |
| SUCCESSFUL | PROCESSING | β No | Cannot reopen closed transaction |
| DECLINED | PROCESSING | β No | Cannot reopen closed transaction |
| EXPIRED | PROCESSING | β No | Cannot reopen closed transaction |
| REFUNDED | any | β No | Cannot change refunded transaction |
| SUCCESSFUL | DECLINED | β No | Cannot change between closed states |
- β Open β Open: Allowed (e.g., CREATED β PROCESSING)
- β Open β Closed: Allowed (e.g., PROCESSING β SUCCESSFUL)
- β Closed β Open: NOT Allowed (e.g., SUCCESSFUL β PROCESSING)
- β Closed β Closed: NOT Allowed (e.g., DECLINED β REFUNDED)
Update Rules Execution
When a transaction status is changed, the endpoint automatically:- Validates the transition - Ensures the new status is valid and transition is allowed
- Updates the status - Changes the transaction status in the database
- Executes status-change rules - Runs rules/matrices with trigger
status_changed(scope action or matrixtransaction_status_changed) - Updates risk score - Re-calculates risk based on rule results
- Returns updated transaction - Returns the complete transaction with new risk assessment
Distinct from field updates:
PATCH /transactions/{id} (metadata, deviceDetails, channel, reason) uses trigger updated. Only this changeStatus endpoint uses status_changed. Migrate rules that should run on status transitions to the new trigger.Rules Trigger
The endpoint usestrigger_transaction_status_changed, which executes rules configured with:
- Loose rules:
scope.triggers[].event.action = "status_changed" - Risk matrices:
triggers[].eventType = "transaction_status_changed"
{
"scope": {
"triggers": [
{
"type": "event",
"event": {
"entityType": "transaction",
"action": "status_changed",
"conditions": {}
}
}
],
"entityTypes": ["transaction"]
}
}
Complete Request Examples
Approve a Suspended Transaction
curl -X PATCH http://api.gu1.ai/transactions/550e8400-e29b-41d4-a716-446655440000/changeStatus \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "SUCCESSFUL"
}'
const transactionId = '550e8400-e29b-41d4-a716-446655440000';
const response = await fetch(`http://api.gu1.ai/transactions/${transactionId}/changeStatus`, {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'SUCCESSFUL'
})
});
const result = await response.json();
console.log(result);
import requests
transaction_id = "550e8400-e29b-41d4-a716-446655440000"
url = f"http://api.gu1.ai/transactions/{transaction_id}/changeStatus"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"status": "SUCCESSFUL"
}
response = requests.patch(url, json=payload, headers=headers)
result = response.json()
print(f"Transaction Status: {result['transaction']['status']}")
summary = result.get("rulesExecutionSummary") or {}
print(f"Matched rules: {summary.get('matchedRulesCount', 0)}")
Decline a Transaction Under Review
curl -X PATCH http://api.gu1.ai/transactions/550e8400-e29b-41d4-a716-446655440000/changeStatus \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "DECLINED"
}'
const transactionId = '550e8400-e29b-41d4-a716-446655440000';
const response = await fetch(`http://api.gu1.ai/transactions/${transactionId}/changeStatus`, {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'DECLINED'
})
});
const result = await response.json();
console.log(result);
import requests
transaction_id = "550e8400-e29b-41d4-a716-446655440000"
url = f"http://api.gu1.ai/transactions/{transaction_id}/changeStatus"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"status": "DECLINED"
}
response = requests.patch(url, json=payload, headers=headers)
result = response.json()
print(f"Status changed from {result['statusChanged']['from']} to {result['statusChanged']['to']}")
Suspend a Transaction for Manual Review
curl -X PATCH http://api.gu1.ai/transactions/550e8400-e29b-41d4-a716-446655440000/changeStatus \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "SUSPENDED"
}'
Response
Success Response (200 OK)
{
"success": true,
"transaction": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"externalId": "txn_12345",
"type": "PAYMENT",
"status": "SUCCESSFUL",
"amount": 1500.00,
"currency": "USD",
"amountInUsd": 1500.00,
"origin": {
"entityId": "customer_001",
"externalId": "EXT-001",
"name": "John Doe",
"country": "US",
"details": {},
"type": "person",
"riskScore": 15.50
},
"destination": {
"entityId": "merchant_002",
"externalId": "MER-002",
"name": "Electronics Store",
"country": "US",
"details": {},
"type": "company",
"riskScore": 8.20
},
"riskScore": 22.50,
"riskFactors": [
{
"factor": "status_change",
"score": 5,
"description": "Transaction status changed to SUCCESSFUL"
}
],
"flagged": false,
"description": "Laptop purchase",
"category": "electronics",
"metadata": {},
"transactedAt": "2024-12-23T14:30:00.000Z",
"createdAt": "2024-12-23T14:30:00.000Z",
"updatedAt": "2024-12-23T15:45:00.000Z"
},
"statusChanged": {
"from": "SUSPENDED",
"to": "SUCCESSFUL"
},
"rulesExecutionSummary": {
"rulesHit": [
{
"name": "High Value Transaction Check",
"score": 5,
"status": "active"
}
],
"rulesNoHit": [],
"totalScore": 22.5,
"matchedRulesCount": 3,
"executionTimeMs": 245,
"trigger": "status_change"
}
}
Response Fields
boolean
Whether the status change was successful
object
The updated transaction with all its data, including:
- id (string) - Transaction UUID
- status (string) - New transaction status
- origin (object) - Origin party information (nested structure)
- entityId (string) - Origin entity UUID
- name (string) - Origin party name
- country (string) - Origin country
- details (object) - Additional origin details
- type (string) - Origin entity type
- riskScore (number) - Origin entity risk score
- destination (object) - Destination party information (nested structure)
- entityId (string) - Destination entity UUID
- name (string) - Destination party name
- country (string) - Destination country
- details (object) - Additional destination details
- type (string) - Destination entity type
- riskScore (number) - Destination entity risk score
- riskScore (number) - Updated risk score after re-evaluation
- riskFactors (array) - Updated risk factors
- flagged (boolean) - Updated flag status
- updatedAt (string) - Timestamp of the update
object
Information about the status transition:
- from (string) - Previous status
- to (string) - New status
object
At the root of the response (aligned with Create transaction). Only present when rules ran. Summary of which rules matched (hit) vs did not match (no hit), executed actions, and total score.
- rulesHit (array) - Rules whose conditions were met. Each item: name, description, score, priority, category, status, conditions, actions.
- rulesNoHit (array) - Rules evaluated but conditions not met. Same structure as rulesHit.
- actionsExecuted (object) - Aggregated executed actions: alerts, suggestion, status, assignedUser, customKeys (array of strings, optional) β custom action keys from rules that matched; for integrations/workflows.
- totalScore (number) - Sum of score of all rules that hit (excluding shadow).
Error Responses
400 Bad Request - Invalid Status
{
"error": "Invalid status",
"validStatuses": [
"CREATED",
"PROCESSING",
"SUSPENDED",
"SENT",
"EXPIRED",
"DECLINED",
"REFUNDED",
"SUCCESSFUL"
]
}
400 Bad Request - Invalid Transition
{
"error": "Cannot transition from closed status to open status",
"currentStatus": "SUCCESSFUL",
"requestedStatus": "PROCESSING",
"message": "Transaction is in a closed state (SUCCESSFUL) and cannot be reopened"
}
404 Not Found
{
"error": "Transaction not found"
}
401 Unauthorized
{
"error": "Unauthorized",
"message": "Invalid or missing API key"
}
500 Internal Server Error
{
"error": "Failed to change transaction status",
"details": "Internal server error message"
}
Use Cases
1. Manual Review Workflow
// Step 1: Suspend suspicious transaction
await changeStatus(transactionId, 'SUSPENDED');
// Step 2: Analyst reviews transaction
// ... manual review process ...
// Step 3: Approve or decline based on review
if (approved) {
await changeStatus(transactionId, 'SUCCESSFUL');
} else {
await changeStatus(transactionId, 'DECLINED');
}
2. Automated Compliance Check
// Transaction created with CREATED status
const transaction = await createTransaction({...});
// Run additional compliance checks
const complianceResult = await runComplianceChecks(transaction.id);
if (complianceResult.passed) {
// Move to processing
await changeStatus(transaction.id, 'PROCESSING');
// Complete transaction
await changeStatus(transaction.id, 'SUCCESSFUL');
} else {
// Decline due to compliance issues
await changeStatus(transaction.id, 'DECLINED');
}
3. Fraud Detection Response
// Monitor transaction updates
if (fraudDetected) {
// Immediately suspend transaction
await changeStatus(transactionId, 'SUSPENDED');
// Create alert for investigation
await createAlert({
transactionId,
type: 'fraud_suspected',
severity: 'high'
});
// After investigation, take action
if (confirmed) {
await changeStatus(transactionId, 'DECLINED');
} else {
await changeStatus(transactionId, 'SUCCESSFUL');
}
}
4. Bulk Status Updates
// Update multiple transactions in parallel
const suspendedTransactions = await getTransactionsByStatus('SUSPENDED');
const results = await Promise.allSettled(
suspendedTransactions.map(async (txn) => {
if (shouldApprove(txn)) {
return await changeStatus(txn.id, 'SUCCESSFUL');
} else if (shouldDecline(txn)) {
return await changeStatus(txn.id, 'DECLINED');
}
})
);
console.log(`Updated ${results.filter(r => r.status === 'fulfilled').length} transactions`);
Best Practices
- Validate before changing - Always check the current status before attempting a status change to avoid unnecessary API calls
- Handle transition errors - Implement proper error handling for invalid transitions, as closed transactions cannot be reopened
- Use appropriate statuses - Choose the correct status that reflects the actual business state of the transaction
-
Monitor rule execution - Pay attention to
rulesExecutionSummaryto ensure update rules are triggering as expected and check execution details, warnings, and metadata - Implement audit logging - Track all status changes in your system for compliance and debugging purposes
- Bulk updates - When updating multiple transactions, use Promise.allSettled() to continue processing even if some updates fail
- Webhook integration - Consider setting up webhooks to receive notifications when status changes trigger important rules
- Testing state transitions - Test all possible state transitions in your development environment before deploying to production
Related Endpoints
Create Transaction
Create new transactions
Get Transaction
Retrieve transaction details
Rules Configuration
Configure update rules
Overview
Back to overview
Was this page helpful?