Tracepos Developer HubTracepos Developer Hub
Home
Guide
POS & Integrations
API Reference
Webhooks
Home
Guide
POS & Integrations
API Reference
Webhooks
  • Core Catalog & Outlets

    • Products API
    • Categories & Brands API
    • Warehouses & Outlets API
  • Parties & CRM

    • Customers & Suppliers API
  • Operations & Stock

    • Sales & Transactions API
    • Purchases & Procurement API
    • Inventory & Price Adjustments API
    • Returns & Reversals API
  • Financial Ledger & Expenses

    • Payments & Settlements API
    • Expense Management API
    • Double-Entry Accounting Architecture
  • Real-Time Sync

    • Webhooks & Real-Time Sync

Purchases & Procurement API

The Purchases API manages the procurement of goods from suppliers and manufacturers. When stock arrives at a warehouse, recording a purchase through this endpoint:

  1. Increments Physical Stock: Updates current_stock for each product line in the receiving warehouse.
  2. Creates Inventory Batches: Logs batch details for FIFO expiry and costing tracking.
  3. Posts Accounts Payable (A/P): Enters the liability into double-entry accounting (Debiting Inventory Asset 11700, Crediting Accounts Payable 21100).
  4. Dispatches Supplier Disbursements: If all_payments are provided, records outward payments from the designated bank account or petty cash drawer.

1. List Purchases

Retrieve a paginated history of procurement orders for the authorized warehouse.

GET/api/v1/public/purchases

Query Parameters

ParameterTypeDefaultDescription
datesString-Date range filter in YYYY-MM-DD,YYYY-MM-DD format
limitInteger20Results per page
pageInteger1Page number

Code Examples

:::: code-group ::: code-group-item cURL

curl -X GET "https://api.tracepos.com/api/v1/public/purchases?limit=20&page=1" \
  -H "X-Tracepos-Public-Key: tp_pub_live_7f8a9c2d1e" \
  -H "X-Tracepos-Secret-Key: tp_sec_live_9b3e1f7a4c" \
  -H "Accept: application/json"

::: ::: code-group-item Node.js (Axios)

const axios = require('axios');

async function listPurchases() {
  const response = await axios.get('https://api.tracepos.com/api/v1/public/purchases', {
    headers: {
      'X-Tracepos-Public-Key': process.env.TRACEPOS_PUBLIC_KEY,
      'X-Tracepos-Secret-Key': process.env.TRACEPOS_SECRET_KEY,
      'Accept': 'application/json'
    }
  });

  return response.data.data;
}

::: ::: code-group-item Python (Requests)

import os
import requests

headers = {
    "X-Tracepos-Public-Key": os.getenv("TRACEPOS_PUBLIC_KEY"),
    "X-Tracepos-Secret-Key": os.getenv("TRACEPOS_SECRET_KEY"),
    "Accept": "application/json"
}

response = requests.get("https://api.tracepos.com/api/v1/public/purchases", headers=headers)
purchases = response.json().get("data", {})

::: ::: code-group-item PHP (Guzzle)

use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://api.tracepos.com/api/v1/public/']);

$response = $client->get('purchases', [
    'headers' => [
        'X-Tracepos-Public-Key' => getenv('TRACEPOS_PUBLIC_KEY'),
        'X-Tracepos-Secret-Key' => getenv('TRACEPOS_SECRET_KEY'),
        'Accept'                => 'application/json'
    ]
]);

$purchases = json_decode($response->getBody()->getContents(), true)['data'];

::: ::::

Response (200 OK)

{
  "status": "success",
  "data": {
    "current_page": 1,
    "data": [
      {
        "id": 94,
        "unique_id": "ord_pur_18374ab90",
        "invoice_number": "PUR-00102",
        "order_type": "purchases",
        "order_date": "2026-09-28",
        "subtotal": "250000.00",
        "total": "250000.00",
        "paid_amount": "250000.00",
        "due_amount": "0.00",
        "payment_status": "paid",
        "user": {
          "id": 201,
          "name": "Dangote Sugar Refinery Plc"
        },
        "staff_member": {
          "id": 2,
          "name": "Procurement Officer"
        }
      }
    ],
    "total": 35
  }
}

2. Get Single Purchase Order

Retrieve purchase details including received quantities, line item costs, and attached supplier payments.

GET/api/v1/public/purchases/{id}

Response (200 OK)

{
  "status": "success",
  "data": {
    "id": 94,
    "invoice_number": "PUR-00102",
    "order_date": "2026-09-28",
    "total": "250000.00",
    "paid_amount": "250000.00",
    "due_amount": "0.00",
    "user": {
      "id": 201,
      "name": "Dangote Sugar Refinery Plc",
      "phone": "+23412700000"
    },
    "items": [
      {
        "id": 142,
        "product_id": 12,
        "quantity": 100,
        "unit_price": "2500.00",
        "subtotal": "250000.00",
        "product": {
          "id": 12,
          "name": "Granulated White Sugar 50kg",
          "item_code": "SUG-50KG-WHT"
        }
      }
    ],
    "payments": [
      {
        "id": 88,
        "amount": "250000.00",
        "payment_type": "out",
        "date": "2026-09-28"
      }
    ]
  }
}

3. Create Purchase (Stock Inward)

Record new inventory intake from a supplier.

POST/api/v1/public/purchases

Request Parameters

ParameterTypeRequiredDescription
user_idInteger / StringYesSupplier party ID (e.g. 201)
order_dateDate (YYYY-MM-DD)YesReceipt date
product_itemsArrayYesArray of received products
product_items[].xidString / IntegerYesProduct hashed ID (xid) or numeric ID
product_items[].quantityNumericYesUnits received into stock
product_items[].unit_priceNumericYesPurchase/landing unit cost price
product_items[].selected_unit_idString / IntegerNoUnit of measure hash ID
invoice_numberStringNoSupplier's delivery note or tax invoice number
all_paymentsArrayNoOutward payments made at time of intake
all_payments[].amountNumericYes (if payment)Amount disbursed to supplier
all_payments[].payment_mode_idInteger / StringYes (if payment)Payment mode ID (e.g. bank transfer)

Request Payload Example

{
  "user_id": 201,
  "order_date": "2026-09-30",
  "invoice_number": "DANGOTE-INV-99382",
  "product_items": [
    {
      "xid": "J1rA2l6xN4",
      "quantity": 50,
      "unit_price": 2200.00
    }
  ],
  "all_payments": [
    {
      "amount": 110000.00,
      "payment_mode_id": 3
    }
  ]
}

Code Examples

:::: code-group ::: code-group-item cURL

curl -X POST "https://api.tracepos.com/api/v1/public/purchases" \
  -H "X-Tracepos-Public-Key: tp_pub_live_7f8a9c2d1e" \
  -H "X-Tracepos-Secret-Key: tp_sec_live_9b3e1f7a4c" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "user_id": 201,
    "order_date": "2026-09-30",
    "invoice_number": "DANGOTE-INV-99382",
    "product_items": [
      {
        "xid": "J1rA2l6xN4",
        "quantity": 50,
        "unit_price": 2200.00
      }
    ],
    "all_payments": [
      {
        "amount": 110000.00,
        "payment_mode_id": 3
      }
    ]
  }'

::: ::: code-group-item Node.js (Axios)

const axios = require('axios');

async function createPurchase(purchasePayload) {
  const response = await axios.post(
    'https://api.tracepos.com/api/v1/public/purchases',
    purchasePayload,
    {
      headers: {
        'X-Tracepos-Public-Key': process.env.TRACEPOS_PUBLIC_KEY,
        'X-Tracepos-Secret-Key': process.env.TRACEPOS_SECRET_KEY,
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      }
    }
  );

  return response.data;
}

::: ::: code-group-item Python (Requests)

import os
import requests

headers = {
    "X-Tracepos-Public-Key": os.getenv("TRACEPOS_PUBLIC_KEY"),
    "X-Tracepos-Secret-Key": os.getenv("TRACEPOS_SECRET_KEY"),
    "Content-Type": "application/json",
    "Accept": "application/json"
}

payload = {
    "user_id": 201,
    "order_date": "2026-09-30",
    "invoice_number": "DANGOTE-INV-99382",
    "product_items": [
        {"xid": "J1rA2l6xN4", "quantity": 50, "unit_price": 2200.00}
    ],
    "all_payments": [
        {"amount": 110000.00, "payment_mode_id": 3}
    ]
}

response = requests.post("https://api.tracepos.com/api/v1/public/purchases", json=payload, headers=headers)
result = response.json()

::: ::: code-group-item PHP (Guzzle)

use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://api.tracepos.com/api/v1/public/']);

$response = $client->post('purchases', [
    'headers' => [
        'X-Tracepos-Public-Key' => getenv('TRACEPOS_PUBLIC_KEY'),
        'X-Tracepos-Secret-Key' => getenv('TRACEPOS_SECRET_KEY'),
        'Content-Type'          => 'application/json',
        'Accept'                => 'application/json'
    ],
    'json' => [
        'user_id'        => 201,
        'order_date'     => '2026-09-30',
        'invoice_number' => 'DANGOTE-INV-99382',
        'product_items'  => [
            ['xid' => 'J1rA2l6xN4', 'quantity' => 50, 'unit_price' => 2200.00]
        ],
        'all_payments'   => [
            ['amount' => 110000.00, 'payment_mode_id' => 3]
        ]
    ]
]);

$result = json_decode($response->getBody()->getContents(), true);

::: ::::

Response (200 OK)

{
  "status": "success",
  "purchase_id": 95,
  "invoice_number": "DANGOTE-INV-99382",
  "current_status": "Stock updated and entry recorded"
}
Prev
Sales & Transactions API
Next
Inventory & Price Adjustments API