Skip to main content
GET
/
v1
/
purchases
/
{purchase_id}
/
versions
Version History
const options = {
  method: 'GET',
  headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/purchases/{purchase_id}/versions', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://api.dcycle.io/v1/purchases/{purchase_id}/versions"

headers = {
    "x-api-key": "<x-api-key>",
    "x-organization-id": "<x-organization-id>"
}

response = requests.get(url, headers=headers)

print(response.text)
curl --request GET \
  --url https://api.dcycle.io/v1/purchases/{purchase_id}/versions \
  --header 'x-api-key: <x-api-key>' \
  --header 'x-organization-id: <x-organization-id>'
{
  "items": {},
  "total": 123,
  "page": 123,
  "size": 123
}

Version History

Returns a paginated list of all changes made to a purchase over time, including who made the change, when, and which fields were modified.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Path Parameters

purchase_id
string
required
UUID of the purchase

Query Parameters

page
integer
default:"1"
Page number (1-based)
size
integer
default:"50"
Items per page (max 100)

Response

items
array[object]
Version entries:
FieldTypeDescription
indexintegerVersion number (0 = creation)
changesetobjectMap of field names to [old_value, new_value] pairs
user_idstring | nullUUID of the user who made the change
created_atstringISO 8601 timestamp
total
integer
Total number of versions
page
integer
Current page number
size
integer
Page size

Example

curl -X GET "https://api.dcycle.io/v1/purchases/${PURCHASE_ID}/versions" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"
import requests
import os

headers = {
    "x-api-key": os.getenv("DCYCLE_API_KEY"),
    "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
}

purchase_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

response = requests.get(
    f"https://api.dcycle.io/v1/purchases/{purchase_id}/versions",
    headers=headers,
)

data = response.json()
print(f"{data['total']} versions")
for v in data["items"]:
    fields = ", ".join(v["changeset"].keys()) if v["changeset"] else "created"
    print(f"  v{v['index']}: {fields} ({v['created_at']})")
const axios = require('axios');

const headers = {
  'x-api-key': process.env.DCYCLE_API_KEY,
  'x-organization-id': process.env.DCYCLE_ORG_ID,
};

const purchaseId = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890';

axios.get(`https://api.dcycle.io/v1/purchases/${purchaseId}/versions`, { headers })
.then(response => {
  const { items, total } = response.data;
  console.log(`${total} versions`);
  items.forEach(v => {
    const fields = Object.keys(v.changeset).join(', ') || 'created';
    console.log(`  v${v.index}: ${fields}`);
  });
});

Successful Response

{
  "items": [
    {
      "index": 0,
      "changeset": {},
      "user_id": "user-uuid-here",
      "created_at": "2025-03-10T14:22:00Z"
    },
    {
      "index": 1,
      "changeset": {
        "quantity": [100.0, 150.0],
        "description": ["Office supplies", "Office supplies Q1"]
      },
      "user_id": "user-uuid-here",
      "created_at": "2025-03-15T09:10:00Z"
    }
  ],
  "total": 2,
  "page": 1,
  "size": 50
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

404 Not Found

Cause: The purchase does not exist or belongs to another organization
{"detail": "Purchase not found"}

Get Purchase

View current purchase details

Update Purchase

Modify a purchase record