cURL Examples
Replace
pk_your_api_key with your actual API key in all examples.
Products
List Products
curl "https://api.getdemi.co/api/v1/products?limit=10" \
-H "X-API-Key: pk_your_api_key"
Get Product by ID
curl "https://api.getdemi.co/api/v1/products/42" \
-H "X-API-Key: pk_your_api_key"
Search Products
curl "https://api.getdemi.co/api/v1/products?search=chicken" \
-H "X-API-Key: pk_your_api_key"
Customers
List Customers
curl "https://api.getdemi.co/api/v1/customers" \
-H "X-API-Key: pk_your_api_key"
Create Customer
curl -X POST "https://api.getdemi.co/api/v1/customers" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"email": "orders@acme.com",
"phone": "+1-555-123-4567",
"contactName": "John Doe",
"paymentTerms": "Net 30"
}'
Payment Terms: Valid values are
Due on receipt (default), Net 15, Net 30, Net 60.
Update Customer (Partial Update)
Both PUT and PATCH support partial updates - only include the fields you want to change:
curl -X PATCH "https://api.getdemi.co/api/v1/customers/123" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"email": "new-email@acme.com"
}'
Clear Field Value
To clear/unset a field value, set it to null:
curl -X PATCH "https://api.getdemi.co/api/v1/customers/123" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"phone": null
}'
Manage Customer Locations
Create, update, and delete locations in a single request:
curl -X PATCH "https://api.getdemi.co/api/v1/customers/123" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"locations": [
{ "name": "New Location", "address": { "address1": "123 Main St", "city": "Vancouver", "countryDivision": "BC", "country": "CA", "postalCode": "V5K 0A1" } },
{ "id": 456, "name": "Updated Location Name" },
{ "id": 789, "_delete": true }
]
}'
Location Operations:
- Create: Include object without
id - Update: Include object with
id - Delete: Include object with
idand"_delete": true
Delete Customer
curl -X DELETE "https://api.getdemi.co/api/v1/customers/123" \
-H "X-API-Key: pk_your_api_key"
Orders
List Orders
curl "https://api.getdemi.co/api/v1/orders?limit=20" \
-H "X-API-Key: pk_your_api_key"
Filter Orders by Customer
curl "https://api.getdemi.co/api/v1/orders?customerId=123" \
-H "X-API-Key: pk_your_api_key"
Filter Orders by Date Range
curl "https://api.getdemi.co/api/v1/orders?fromDate=2024-01-01&toDate=2024-01-31" \
-H "X-API-Key: pk_your_api_key"
Create Order
curl -X POST "https://api.getdemi.co/api/v1/orders" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"customerId": 123,
"deliveryDate": "2024-01-15",
"poNumber": "PO-2024-001",
"items": [
{ "productId": 42, "quantity": 10 },
{ "productId": 43, "quantity": 5 }
]
}'
Update Order (Partial Update)
Only Draft orders can be updated. Both PUT and PATCH support partial updates:
curl -X PATCH "https://api.getdemi.co/api/v1/orders/456" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"poNumber": "PO-2024-002",
"orderNotes": "Please deliver before noon"
}'
Update Order Items
When updating items, provide the complete list - it replaces all existing items:
curl -X PATCH "https://api.getdemi.co/api/v1/orders/456" \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "productId": 42, "quantity": 15 },
{ "productId": 44, "quantity": 8 }
]
}'
Cancel Order
Only Draft and Pending orders can be cancelled:
curl -X DELETE "https://api.getdemi.co/api/v1/orders/456" \
-H "X-API-Key: pk_your_api_key"
Pagination
First Page
curl "https://api.getdemi.co/api/v1/products?limit=20&offset=0" \
-H "X-API-Key: pk_your_api_key"
Next Page
curl "https://api.getdemi.co/api/v1/products?limit=20&offset=20" \
-H "X-API-Key: pk_your_api_key"
Other Languages
See also: