Transactions

A transaction groups several changes so they are applied together, or not at all.

Commit a transaction

PUT /transactions/commit

Commit transaction

Applies every change made since the transaction was started.

This change is staged. Send PUT /services/apply to apply it.

curl
curl -X PUT "https://appliance.example.com/api/v1/transactions/commit" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/transactions/commit';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.put("https://appliance.example.com/api/v1/transactions/commit", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/transactions/commit', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Transaction committed"
}

Roll back a transaction

PUT /transactions/rollback

Rollback transaction

Discards every change made since the transaction was started.

This change is staged. Send PUT /services/apply to apply it.

curl
curl -X PUT "https://appliance.example.com/api/v1/transactions/rollback" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/transactions/rollback';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.put("https://appliance.example.com/api/v1/transactions/rollback", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/transactions/rollback', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Transaction rolled back"
}

Start a transaction

PUT /transactions/start

Opens a transaction on this connection. Changes made while it is open are held until you commit them.

This change is staged. Send PUT /services/apply to apply it.

Body parameters
ignoreError boolean default: "true"

If ignoreError=false, the transaction lock will be removed on error and transaction will be rolled back automatically. The transaction will then need to be restarted.

curl
curl -X PUT "https://appliance.example.com/api/v1/transactions/start" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "ignoreError": "true"
}'
PHP
<?php

$url = 'https://appliance.example.com/api/v1/transactions/start';
$headers = [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
];

$payload = [
    'ignoreError' => 'true',
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}
payload = {
    "ignoreError": "true"
}

response = requests.put("https://appliance.example.com/api/v1/transactions/start", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/transactions/start', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "ignoreError": "true"
}),
});

const data = await response.json();
Response
{
  "status": "success",
  "message": "Transaction Started",
  "data": [
    {
      "id": "5f6b57069d184"
    }
  ]
}