Purchase API
Overview
The Purchase API allows partners to manage purchase orders for inventory procurement, including creating purchases, retrieving purchase details, and managing approval workflows.
Base URL
- Production:
https://open.bebaskirim.com/api/partner/v1
Authentication
All API requests require authentication using API key and tenant identification:
- Authorization: Bearer token authentication
- X-Tenant-Id: Your tenant identifier
curl -H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Tenant-Id: YOUR_TENANT_ID" \
https://open.bebaskirim.com/api/partner/v1/purchasesEndpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/partner/v1/purchases/create | Create new purchase |
| GET | /api/engine/v1/purchases | Get purchase list |
| GET | /api/engine/v1/purchases/:id/detail | Get purchase detail |
| POST | /api/partner/v1/purchases/:id/approve | Approve purchase |
| POST | /api/partner/v1/purchases/:id/reject | Reject purchase |
| PUT | /api/partner/v1/purchases/:id/update | Update purchase |
1. Create Purchase
Create a new purchase order for inventory procurement.
Endpoint: POST /api/partner/v1/purchases/create
Headers:
Authorization: {token}(required)X-Tenant-Id: {tenant_id}(required)
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | Yes | Purchase order code |
| purchase_date | date | Yes | Purchase order date (YYYY-MM-DD hh:mm:ss) |
| estimate_arrival_date | date | Yes | Purchase order date (YYYY-MM-DD hh:mm:ss) |
| external_reference | string | No | External reference number |
| tracking_number | string | No | Tracking number |
| type | string | Yes | Purchase type (purchase, return) |
| location_id | integer | Yes | Destination location ID |
| supplier_id | integer | No | Supplier ID |
| details | array | Yes | Array of purchase items |
| details[].product_id | string | Yes | Product identifier |
| details[].quantity | number | Yes | Quantity to purchase |
| details[].price | number | Yes | Unit price per item |
| details[].discount | number | No | Discount percentage (0-100) |
Request Body:
{
"code": "PURCHASECODE1",
"purchase_date": "2025-09-29 10:00:00",
"estimate_arrival_date": "2025-09-30 10:00:00",
"external_reference": "EXTERNAL TESTER 1",
"tracking_number": "TRACKKING",
"type": "purchase",
"location_id": 1,
"supplier_id": "",
"details": [
{
"product_id" : 1,
"quantity" : 1,
"price" : "18000",
"discount" : ""
},
{
"product_id" : 2,
"quantity" : 5,
"price" : "2000",
"discount" : ""
}
]
}Response:
Created 201 with no content and purchase status is pending2. Get Purchase List
Retrieve a paginated list of purchases with filtering options.
Endpoint: GET /api/engine/v1/purchases
Headers:
Authorization: {token}(required)X-Tenant-Id: {tenant_id}(required)
Query Parameters:
page(integer, required): Page number for pagination (default: 1)size(integer, required): Number of items per page (default: 10, max: 100)sort(integer, required): Sort data (asc, desc)status(string, optional): Filter by status:pending,approved,rejected,receivedtype(string, optional): Filter by type:purchase,returnlocation_id(integer, optional): Filter by location IDsupplier_id(integer, optional): Filter by supplier IDcreate_from(date, optional): Filter purchases from date (YYYY-MM-DD)create_to(date, optional): Filter purchases to date (YYYY-MM-DD)
Request Body:
{
"page": 1,
"size": 10,
"sort" : "ASC"
}Response:
{
"status": "ok",
"data": {
"purchase": [
{
"id": "purchase_123",
"purchase_number": "PO-2024-001",
"supplier_id": 1,
"location_id": 1,
"type": "purchase",
"purchase_date": "2024-01-15",
"expected_delivery_date": "2024-01-20",
"external_reference_number": "PO-2024-001",
"tracking_number": "123456789",
"status": "pending",
"total_amount": 6525000,
"item_count": 2,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"current_page": 1,
"per_page": 10,
"total": 45,
"last_page": 5
}
},
"errors": null,
"request_id": "request-id"
}3. Get Purchase Detail
Retrieve detailed information about a specific purchase order.
Endpoint: GET /api/engine/v1/purchases/:id/detail
Headers:
Authorization: {token}(required)X-Tenant-Id: {tenant_id}(required)
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Purchase ID |
Request:
curl -X GET https://sandbox-api.bebaskirim.com/api/engine/v1/purchases/1/detail \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Tenant-Id: YOUR_TENANT_ID"Response:
{
"status": "ok",
"data": {
"purchase" : {
"id": "purchase_123",
"purchase_number": "PO-2024-001",
"supplier": {
"id": 1,
"name": "PT Supplier Indonesia",
"contact_person": "John Doe",
"phone": "+62-21-12345678",
"email": "contact@supplier.co.id",
"address": "Jl. Supplier No. 123, Jakarta"
},
"location": {
"id": 1,
"code": "location_123",
"name": "Warehouse A",
"address": "Jl. Warehouse No. 456, Jakarta"
},
"type": "purchase",
"purchase_date": "2024-01-15",
"expected_delivery_date": "2024-01-20",
"external_reference_number": "PO-2024-001",
"tracking_number": "123456789",
"status": "pending",
"subtotal": 6750000,
"total_discount": 225000,
"total_amount": 6525000,
"notes": "Urgent restock for high-demand items",
"items": [
{
"item_id": "item_123",
"product_name": "Product A",
"sku": "SKU-001",
"quantity": 100,
"unit_price": 45000,
"discount_percent": 5,
"discount_amount": 225000,
"total_price": 4275000,
"notes": "Bulk purchase discount"
},
{
"id": 2,
"item_id": "item_456",
"product_name": "Product B",
"sku": "SKU-002",
"quantity": 50,
"unit_price": 75000,
"discount_percent": 0,
"discount_amount": 0,
"total_price": 3750000,
"notes": "Regular price"
}
],
"created_by": "abed",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z",
"approved_at": null,
"approved_by": null,
"rejected_at": null,
"rejected_by": null,
"rejection_reason": null,
"received_at": null,
"received_by": null
}
},
"errors": null,
"request_id": "request-id"
}4. Approve Purchase
Approve a pending purchase order.
Endpoint: PATCH /api/partner/v1/purchases/:id/approve
Headers:
Authorization: {token}(required)X-Tenant-Id: {tenant_id}(required)
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Purchase ID |
Request Body:
{}Example Request:
curl -X PATCH https://sandbox-api.bebaskirim.com/api/partner/v1/purchases/PUR-2024-001/approve \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Tenant-Id: YOUR_TENANT_ID" \
-H "Content-Type: application/json" \
-d '{}'Example Response:
{
"status": "ok",
"data": null,
"errors": null,
"request_id": "request-id"
}5. Reject Purchase
Reject a pending purchase order.
Endpoint: PATCH /api/partner/v1/purchases/:id/reject
Headers:
Authorization: {token}(required)X-Tenant-Id: {tenant_id}(required)
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Purchase ID |
Request Body:
{
"reason": "Insufficient budget for this purchase"
}Example Request:
curl -X PATCH https://sandbox-api.bebaskirim.com/api/partner/v1/purchases/PUR-2024-001/reject \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Tenant-Id: YOUR_TENANT_ID" \
-H "Content-Type: application/json" \
-d '{
"reason": "Insufficient budget for this purchase"
}'Example Response:
{
"status": "ok",
"data": null,
"errors": null,
"request_id": "request-id"
}6. Update Purchase
Update an information of purchase order.
Endpoint: PUT /api/partner/v1/purchases/{id}/update
Headers:
Authorization: {token}(required)X-Tenant-Id: {tenant_id}(required)
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | Conditional | Purchase order code (max 255 characters) |
| purchase_date | date | Conditional | Purchase date (YYYY-MM-DD HH:mm:ss). Cannot be in the future. |
| estimate_arrival_date | date | Conditional | Estimated arrival date (YYYY-MM-DD HH:mm:ss). Must be greater than or equal to purchase_date. |
| external_reference | string | No | External reference number (max 255 characters) |
| tracking_number | string | No | Tracking number (max 255 characters) |
| type | string | Conditional | Purchase type (purchase, return) |
| location_id | integer | Conditional | Destination location ID |
| supplier_id | integer | No | Supplier ID |
| details | array | Conditional | Array of purchase items (minimum 1 item) |
| details[].product_id | integer | Yes | Product identifier |
| details[].quantity | integer | Yes | Quantity (minimum 1) |
| details[].price | number | Yes | Unit price per item (minimum 0) |
| details[].discount | number | No | Discount percentage (0–100) |
| details[].purchase_detail_id | integer | No | Existing purchase detail ID (used for updating specific item) |
| replace_details | boolean | No | If true, replace all existing purchase details with provided details |
| updated_by | string | No | User who performed the update (max 255 characters) |
Request Body:
{
"code": "PURCHASECODE1",
"purchase_date": "2025-09-29 10:00:00",
"estimate_arrival_date": "2025-09-30 10:00:00",
"external_reference": "EXTERNAL TESTER 1",
"tracking_number": "TRACKKING",
"type": "purchase",
"location_id": 1,
"supplier_id": "",
"details": [
{
"product_id" : 2,
"quantity" : 5,
"price" : "349000",
"discount" : ""
}
]
}Response:
{
"status": 200,
"message": "Ok",
"data": {
"purchase_id": 23,
"purchase_number": "PURCHASECODE1",
"supplier": {
"id": null,
"name": null,
"contact_person": null,
"phone": null,
"email": null,
"address": null
},
"location_id": 1,
"type": "return",
"purchase_date": "2025-09-29T10:00:00.000000Z",
"expected_arrival_date": "2025-09-30T10:00:00.000000Z",
"external_reference_number": "EXTERNAL TESTER 1",
"tracking_number": "TRACKKING",
"status": "pending",
"subtotal": "1745000.00",
"total_discount": "0.00",
"total_amount": 1745000,
"notes": null,
"items": [
{
"item_id": 1,
"product_name": "Off Mercy",
"sku": "MASKIV",
"quantity": 2,
"price": "200000.00",
"discount": "0.00",
"total": 400000
},
{
"item_id": 2,
"product_name": "THE LESSER TIME",
"sku": "ROLTRAP",
"quantity": 5,
"price": "349000.00",
"discount": "0.00",
"total": 1745000
}
],
"created_at": "2026-01-22T20:36:25.000000Z",
"updated_at": "2026-02-12T21:29:17.000000Z",
"created_by": "maternal",
"updated_by": "maternal"
},
"errors": null,
"request_id": "6704ac86-3e2b-4fc1-833d-3a57e27eb14d"
}