curl --request POST \
--url https://api.sapiom.ai/v1/transactions/{transactionId}/update \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"version": "<string>",
"checkout": {},
"purchase": {}
}
'import requests
url = "https://api.sapiom.ai/v1/transactions/{transactionId}/update"
payload = {
"version": "<string>",
"checkout": {},
"purchase": {}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({version: '<string>', checkout: {}, purchase: {}})
};
fetch('https://api.sapiom.ai/v1/transactions/{transactionId}/update', 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 => "https://api.sapiom.ai/v1/transactions/{transactionId}/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => '<string>',
'checkout' => [
],
'purchase' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$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 := "https://api.sapiom.ai/v1/transactions/{transactionId}/update"
payload := strings.NewReader("{\n \"version\": \"<string>\",\n \"checkout\": {},\n \"purchase\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
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.post("https://api.sapiom.ai/v1/transactions/{transactionId}/update")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"version\": \"<string>\",\n \"checkout\": {},\n \"purchase\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sapiom.ai/v1/transactions/{transactionId}/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": \"<string>\",\n \"checkout\": {},\n \"purchase\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"tenantId": "123e4567-e89b-12d3-a456-426614174000",
"serviceName": "openai",
"actionName": "completion",
"resourceName": "gpt-4",
"status": "authorized",
"requiresPayment": true,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"returnUrl": "<string>",
"nextAction": {},
"purchase": {
"type": "ucp_checkout",
"assertedBy": "merchant",
"merchant": {
"origin": "https://shop.example",
"name": "Example Shop",
"nameSource": "caller"
},
"total": {
"amount": "19.99",
"currency": "USD"
},
"lineItems": [
{
"title": "Mug",
"itemId": "item_123",
"quantity": 1,
"unitAmount": "19.99"
}
],
"revision": 1
},
"order": {
"outcome": "confirmed",
"id": "gid://shopify/Order/1",
"label": "#1008",
"permalinkUrl": "https://shop.example/orders/1",
"links": [
{
"type": "refund_policy",
"url": "https://shop.example/policies/refund-policy",
"title": "Refund policy"
}
]
},
"version": "<string>",
"approvals": {},
"serviceId": "123e4567-e89b-12d3-a456-426614174000",
"qualifiers": {
"model": "gpt-4",
"tokens": 1000
},
"metadata": {},
"authorizedAt": "2024-01-01T00:00:00.000Z",
"completedAt": "2024-01-01T00:00:00.000Z",
"outcome": "success",
"currentPaymentTransactionId": "123e4567-e89b-12d3-a456-426614174000",
"payment": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"transactionId": "123e4567-e89b-12d3-a456-426614174000",
"fiatAmount": "<string>",
"status": "authorized",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"fundingSource": "external_card",
"paymentCardId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"credentialRoute": "real_card_number",
"placeholder": {
"number": "4000123412341234",
"expMonth": 7,
"expYear": 2029,
"cvc": "123",
"brand": "visa",
"expiresAt": "2026-10-13T13:00:00.000Z",
"injectionRef": "<string>",
"transactionId": "<string>"
},
"billing": {
"country": "US",
"postalCode": "94105"
},
"reason": "sapiom_error",
"authorizedAt": "2024-01-01T00:00:00.000Z"
},
"trace": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"externalId": "checkout-session-abc123"
},
"agentId": "123e4567-e89b-12d3-a456-426614174000",
"agent": {
"id": "<string>",
"tenantId": "<string>",
"label": "<string>",
"name": "<string>",
"status": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"description": "<string>"
}
}Update a purchase
Replaces the whole purchase. Send the latest version from Get a transaction and one of two bodies: purchase for a browser_checkout, or checkout for a ucp_checkout. For a browser purchase, change the cart on the page first. The merchant, currency and card stay the same. Use a new Idempotency-Key for each change. If the response is lost, send the same body with the same key. Then follow the new nextAction. Sapiom can ask the user to approve the purchase again. Returns 409 after your agent enters the card. Requires a user key.
curl --request POST \
--url https://api.sapiom.ai/v1/transactions/{transactionId}/update \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"version": "<string>",
"checkout": {},
"purchase": {}
}
'import requests
url = "https://api.sapiom.ai/v1/transactions/{transactionId}/update"
payload = {
"version": "<string>",
"checkout": {},
"purchase": {}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({version: '<string>', checkout: {}, purchase: {}})
};
fetch('https://api.sapiom.ai/v1/transactions/{transactionId}/update', 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 => "https://api.sapiom.ai/v1/transactions/{transactionId}/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => '<string>',
'checkout' => [
],
'purchase' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$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 := "https://api.sapiom.ai/v1/transactions/{transactionId}/update"
payload := strings.NewReader("{\n \"version\": \"<string>\",\n \"checkout\": {},\n \"purchase\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
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.post("https://api.sapiom.ai/v1/transactions/{transactionId}/update")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"version\": \"<string>\",\n \"checkout\": {},\n \"purchase\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sapiom.ai/v1/transactions/{transactionId}/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": \"<string>\",\n \"checkout\": {},\n \"purchase\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"tenantId": "123e4567-e89b-12d3-a456-426614174000",
"serviceName": "openai",
"actionName": "completion",
"resourceName": "gpt-4",
"status": "authorized",
"requiresPayment": true,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"returnUrl": "<string>",
"nextAction": {},
"purchase": {
"type": "ucp_checkout",
"assertedBy": "merchant",
"merchant": {
"origin": "https://shop.example",
"name": "Example Shop",
"nameSource": "caller"
},
"total": {
"amount": "19.99",
"currency": "USD"
},
"lineItems": [
{
"title": "Mug",
"itemId": "item_123",
"quantity": 1,
"unitAmount": "19.99"
}
],
"revision": 1
},
"order": {
"outcome": "confirmed",
"id": "gid://shopify/Order/1",
"label": "#1008",
"permalinkUrl": "https://shop.example/orders/1",
"links": [
{
"type": "refund_policy",
"url": "https://shop.example/policies/refund-policy",
"title": "Refund policy"
}
]
},
"version": "<string>",
"approvals": {},
"serviceId": "123e4567-e89b-12d3-a456-426614174000",
"qualifiers": {
"model": "gpt-4",
"tokens": 1000
},
"metadata": {},
"authorizedAt": "2024-01-01T00:00:00.000Z",
"completedAt": "2024-01-01T00:00:00.000Z",
"outcome": "success",
"currentPaymentTransactionId": "123e4567-e89b-12d3-a456-426614174000",
"payment": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"transactionId": "123e4567-e89b-12d3-a456-426614174000",
"fiatAmount": "<string>",
"status": "authorized",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"fundingSource": "external_card",
"paymentCardId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"credentialRoute": "real_card_number",
"placeholder": {
"number": "4000123412341234",
"expMonth": 7,
"expYear": 2029,
"cvc": "123",
"brand": "visa",
"expiresAt": "2026-10-13T13:00:00.000Z",
"injectionRef": "<string>",
"transactionId": "<string>"
},
"billing": {
"country": "US",
"postalCode": "94105"
},
"reason": "sapiom_error",
"authorizedAt": "2024-01-01T00:00:00.000Z"
},
"trace": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"externalId": "checkout-session-abc123"
},
"agentId": "123e4567-e89b-12d3-a456-426614174000",
"agent": {
"id": "<string>",
"tenantId": "<string>",
"label": "<string>",
"name": "<string>",
"status": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"description": "<string>"
}
}Authorizations
Headers
Body
Response
The current transaction after acceptance; follow nextAction.
The purchase details and their source (assertedBy). UCP uses merchant throughout the purchase, including while checkout details are pending. Browser purchases use agent for the caller's statement. For a UCP purchase, a merchant.nameSource of caller identifies an optional display name supplied at create. The purchase is absent for a transaction that buys nothing.
{
"type": "ucp_checkout",
"assertedBy": "merchant",
"merchant": {
"origin": "https://shop.example",
"name": "Example Shop",
"nameSource": "caller"
},
"total": { "amount": "19.99", "currency": "USD" },
"lineItems": [
{
"title": "Mug",
"itemId": "item_123",
"quantity": 1,
"unitAmount": "19.99"
}
],
"revision": 1
}
For a purchase: the merchant-confirmed order outcome (confirmed, not_confirmed, unknown). With confirmed, the merchant's confirmation from its completed answer, for the platform to show the user: id, label (the order number the user sees), permalinkUrl (the order on the merchant's site) and links (its refund, shipping, terms, privacy and contact pages, { type, url, title? }), each null or empty when the merchant sent none. Null for a browser purchase, which has no order confirmation.
{
"outcome": "confirmed",
"id": "gid://shopify/Order/1",
"label": "#1008",
"permalinkUrl": "https://shop.example/orders/1",
"links": [
{
"type": "refund_policy",
"url": "https://shop.example/policies/refund-policy",
"title": "Refund policy"
}
]
}