Distru icon

Distru

Interact with the Distru API

Overview

The node interacts with the Distru API to manage purchase records by creating or updating ("upsert") purchases. This operation is useful for inventory and procurement workflows where you need to record incoming purchases, update existing purchase details, or synchronize purchase data between Distru and other systems.

Typical use cases include:

  • Automatically recording new purchase orders received from suppliers.
  • Updating purchase information such as items, charges, or due dates when changes occur.
  • Integrating purchase data into broader inventory management or accounting workflows.

For example, a user can create a purchase with multiple items and associated charges, specifying the location where inventory will be received, and optionally link it to a company or billing location.

Properties

Name Meaning
ID Unique identifier of the purchase (used to update an existing purchase if provided).
Location ID The location where the inventory from this purchase will be received. (Required)
Company ID Identifier of the company associated with the purchase.
Billing Location ID Identifier of the billing location related to the purchase.
Due Datetime The due date and time for the purchase payment or completion.
Order Datetime The date and time when the purchase order was made.
Items A collection of purchase items, each including: Product ID, Quantity, Price, Location ID, Batch ID, and Item ID (for updates).
Charges A collection of charges related to the purchase, each including: Name, Type (CHARGE, DISCOUNT, TAX), Price, Percent, Unit Type (PERCENT or PRICE), and Charge ID (for updates).
Items (JSON) JSON string representing the entire array of purchase items. Overrides the form-based "Items" input if set.
Charges (JSON) JSON string representing the entire array of charges. Overrides the form-based "Charges" input if set.

Output

The node outputs an array of JSON objects representing the created or updated purchase(s) as returned by the Distru API. Each output item contains the full purchase data structure, including all fields and nested items/charges as stored in Distru.

No binary data output is produced by this operation.

Dependencies

  • Requires an API token credential for authenticating requests to the Distru API.
  • The node uses the Distru API endpoint, either production (https://app.distru.com/public/v1) or staging (https://staging.distru.com/public/v1), depending on configuration.
  • Proper network access to the Distru API is necessary.
  • The user must configure the API token credential in n8n before using this node.

Troubleshooting

  • Missing API Token: If the API token is not set or invalid, the node throws an error: "Distru API token is not set!" Ensure the API token credential is configured correctly.
  • Missing Required Fields: For example, "Location ID" is required; omitting it will cause the API request to fail. Always provide required fields.
  • Invalid UUIDs: IDs are normalized to UUID format internally. Providing invalid or malformed IDs may cause errors.
  • API Errors: Any errors returned by the Distru API (e.g., validation errors, permission issues) will be surfaced as node errors. Review the error message for details.
  • Continue On Fail: If enabled, the node will continue processing subsequent items even if one fails, returning error details in the output JSON.

Links and References

Discussion