---
updatedAt: 2026-08-28T22:30:18.000Z
agentTools:
  projectIndex: https://developer.wafeq.com/llms.txt
---

# Purchase to pay

Create purchase orders and supplier bills, then record payment with a complete payables trail.

# Purchase to pay

A purchase-to-pay integration connects procurement activity to accounts payable and the final cash movement.

## Workflow

| Step                    | Endpoint                                                                 | Result                        |
| ----------------------- | ------------------------------------------------------------------------ | ----------------------------- |
| 1. Resolve the supplier | [Contacts](/reference/contacts)                                          | Supplier contact ID           |
| 2. Create the order     | [Create purchase order](/reference/purchase_orders_create)               | Purchase order ID             |
| 3. Create the payable   | [Convert purchase order to bill](/reference/purchase_orders_bill_create) | Draft bill ID                 |
| 4. Record settlement    | [Create payment](/reference/payments_create)                             | Payment allocated to the bill |
| 5. Verify               | [Retrieve bill](/reference/bills_retrieve)                               | Current balance and status    |

## Create a purchase order

```bash
curl --request POST "https://api.wafeq.com/v1/purchase-orders/" \
  --header "Authorization: Api-Key <API_KEY>" \
  --header "Content-Type: application/json" \
  --header "X-Wafeq-Idempotency-Key: po-<SOURCE_ID>" \
  --data '{
    "contact": "<SUPPLIER_CONTACT_ID>",
    "currency": "AED",
    "purchase_order_date": "2026-08-29",
    "purchase_order_number": "PO-701",
    "reference": "PROC-701",
    "external_id": "proc_701",
    "line_items": [
      {
        "description": "Office equipment",
        "account": "<ASSET_OR_EXPENSE_ACCOUNT_ID>",
        "quantity": 2,
        "unit_amount": 1800,
        "tax_rate": "<TAX_RATE_ID>",
        "cost_center": "<COST_CENTER_ID>"
      }
    ]
  }'
```

Line items can also be managed with the [Purchase order line items](/reference/purchase-order-line-items) endpoints.

## Convert the order to a bill

When the supplier invoice is accepted:

```bash
curl --request POST "https://api.wafeq.com/v1/purchase-orders/<PURCHASE_ORDER_ID>/bill/" \
  --header "Authorization: Api-Key <API_KEY>" \
  --header "Content-Type: application/json"
```

Store the returned bill ID. The purchase order remains the procurement record; the bill becomes the accounts-payable document.

If your workflow has no purchase order, create the payable directly with [Create bill](/reference/bills_create).

## Record supplier payment

```bash
curl --request POST "https://api.wafeq.com/v1/payments/" \
  --header "Authorization: Api-Key <API_KEY>" \
  --header "Content-Type: application/json" \
  --header "X-Wafeq-Idempotency-Key: supplier-payment-<PAYMENT_ID>" \
  --data '{
    "amount": 3780,
    "currency": "AED",
    "date": "2026-09-15",
    "paid_through_account": "<BANK_ACCOUNT_ID>",
    "contact": "<SUPPLIER_CONTACT_ID>",
    "external_id": "supplier_pay_701",
    "bill_payments": [
      {
        "bill": "<BILL_ID>",
        "amount": 3780,
        "amount_to_pcy": 3780
      }
    ]
  }'
```

## Handle exceptions explicitly

* Use a debit note for supplier-side reductions or returns rather than rewriting the original bill.
* Keep partial payments as separate payment records or allocations.
* For foreign currency, follow the payment schema and preserve the exchange-rate context.
* Keep the supplier, currency, project, branch, cost center, and custom-field values consistent from order to bill.

For card purchases and operational spend that should not enter accounts payable, see [Record expenses and receipts](/docs/record-expenses-and-receipts).