Skip to main content
PATCH
/
transactions
/
{id}
Update Transaction
curl --request PATCH \
  --url http://api.gu1.ai/transactions/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "metadata": {},
  "deviceDetails": {},
  "channel": {},
  "reason": "<string>"
}
'
import requests

url = "http://api.gu1.ai/transactions/{id}"

payload = {
"metadata": {},
"deviceDetails": {},
"channel": {},
"reason": "<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({metadata: {}, deviceDetails: {}, channel: {}, reason: '<string>'})
};

fetch('http://api.gu1.ai/transactions/{id}', 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}",
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([
'metadata' => [

],
'deviceDetails' => [

],
'channel' => [

],
'reason' => '<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}"

payload := strings.NewReader("{\n \"metadata\": {},\n \"deviceDetails\": {},\n \"channel\": {},\n \"reason\": \"<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}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {},\n \"deviceDetails\": {},\n \"channel\": {},\n \"reason\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("http://api.gu1.ai/transactions/{id}")

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 \"metadata\": {},\n \"deviceDetails\": {},\n \"channel\": {},\n \"reason\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body

Overview

Use this endpoint when you need to enrich or correct an existing transaction after creation: custom metadata, deviceDetails, channel, or reason. It does not change amount, status, parties, or other core fields (use Change status for status).
Shallow merge for metadata and deviceDetails: only keys you send are overwritten; omitted keys are preserved. Nested objects (e.g. metadata.tags) are replaced as a whole when you send that key. To clear channel, send "channel": null.

Endpoints

MethodEndpointUse when
By IDPATCH /transactions/{id}You have gu1’s transaction UUID
By external IDPATCH /transactions/external/{externalId}You only have your externalId from create
Both accept the same JSON body and return the same response shape.
PATCH https://api.gu1.ai/transactions/{id}
PATCH https://api.gu1.ai/transactions/external/{externalId}

Authentication

Requires transactions:edit (API key or session with equivalent permission):
Authorization: Bearer YOUR_API_KEY

Query Parameters

executeRules
boolean
default:"false"
When true, re-runs KYT rules with trigger transaction_updated after the patch (same mode as status change). Default: false.

Request Body

At least one field is required.
metadata
object
Shallow merge into existing metadata. Example: existing { "purpose": "payroll", "tags": { "a": 1 } } + body { "tags": { "b": 2 } }{ "purpose": "payroll", "tags": { "b": 2 } } (top-level tags is replaced as a whole).
deviceDetails
object
Shallow merge into existing deviceDetails (stored in device_details). Use this to add or correct device context after create — e.g. ipAddress, deviceId, osName, manufacturer, model, fraud flags (isVpn, isEmulator, …). Same field schema as Create transaction (deviceDetails). Rules evaluate paths like deviceDetails.ipAddress.
channel
string | null
Transaction channel (max 50 chars), e.g. web, mobile, api. Send null to clear.
reason
string
Outcome / decline reason enum. See Reason enum.

Example

{
  "metadata": {
    "clientReference": "INV-2026-0042",
    "tags": { "segment": "retail" }
  },
  "deviceDetails": {
    "ipAddress": "203.0.113.10",
    "deviceId": "dev-abc-123",
    "osName": "iOS",
    "osVersion": "17.0",
    "manufacturer": "Apple",
    "model": "iPhone"
  },
  "channel": "mobile",
  "reason": "FRAUD_SUSPECTED"
}

Response (200 OK)

{
  "success": true,
  "transaction": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "externalId": "tx_12345",
    "channel": "mobile",
    "reason": "FRAUD_SUSPECTED",
    "metadata": {
      "purpose": "payroll",
      "clientReference": "INV-2026-0042",
      "tags": { "segment": "retail" }
    },
    "deviceDetails": {
      "ipAddress": "203.0.113.10",
      "deviceId": "dev-abc-123",
      "osName": "iOS"
    },
    "updatedAt": "2026-05-29T12:00:00.000Z"
  }
}
When executeRules=true, rulesExecutionSummary is included (same shape as create / change status).

Errors

StatusCodeWhen
400VALIDATION_ERRORInvalid body or no effective change
400NO_CHANGESValues match what is already stored
404NOT_FOUNDTransaction not in your organization
403Missing transactions:edit

Side effects

  • Audit: transaction_updated event on the transaction timeline with changed fields (metadata, deviceDetails, channel, and/or reason in changes).
  • Webhook: transaction.updated (includes changes and current deviceDetails when applicable).
  • Rules: only when executeRules=true.

Examples

curl -X PATCH "https://api.gu1.ai/transactions/external/tx_12345" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": { "note": "Corrected after bank callback" },
    "channel": "api"
  }'

Get transaction

Read full transaction after update

Change status

Update lifecycle status and re-run rules

Create transaction

Initial metadata on create

Reason enum

Allowed reason values