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));
{
  "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}"

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