API Reference

Orders

Here are examples for working with the Orders collection through the REST API.

Creating Orders

const createOrder = async (token, customerId) => {
  const response = await fetch('https://api.picoshealth.com/v1/orders', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      customer: customerId,
      line_items: [
        {
          product: 'prod-uuid-1',
          quantity: 2,
          price: 49.99,
        },
      ],
      subtotal: 99.98,
      tax: 8.00,
      total: 107.98,
      currency: 'USD',
      status: 'pending',
      shipping_address: {
        street: '123 Main St',
        city: 'New York',
        state: 'NY',
        zip: '10001',
        country: 'USA',
      },
    }),
  });
  return response.json();
};

Managing Order Status

Approve an Order

const approveOrder = async (token, orderId) => {
  const response = await fetch(
    `https://api.picoshealth.com/v1/orders/${orderId}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        status: 'approved',
      }),
    }
  );
  return response.json();
};

Cancel an Order

const cancelOrder = async (token, orderId) => {
  const response = await fetch(
    `https://api.picoshealth.com/v1/orders/${orderId}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        status: 'cancelled',
      }),
    }
  );
  return response.json();
};

Ship an Order

const shipOrder = async (token, orderId, trackingNumber) => {
  const response = await fetch(
    `https://api.picoshealth.com/v1/orders/${orderId}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        status: 'shipped',
        metadata: {
          trackingNumber: trackingNumber,
        },
      }),
    }
  );
  return response.json();
};

Querying Orders

Get Pending Orders

const getPendingOrders = async (token) => {
  const response = await fetch(
    'https://api.picoshealth.com/v1/orders?where={"status":{"equals":"pending"}}&sort=-createdAt',
    {
      headers: { 'Authorization': `Bearer ${token}` },
    }
  );
  return response.json();
};

Get Customer Orders

const getCustomerOrders = async (token, customerId) => {
  const response = await fetch(
    `https://api.picoshealth.com/v1/orders?where={"customer":{"equals":"${customerId}"}}&sort=-createdAt`,
    {
      headers: { 'Authorization': `Bearer ${token}` },
    }
  );
  return response.json();
};

Get High-Value Orders

const getHighValueOrders = async (token, minAmount) => {
  const response = await fetch(
    `https://api.picoshealth.com/v1/orders?where={"total":{"greater_than":${minAmount}}}&limit=50`,
    {
      headers: { 'Authorization': `Bearer ${token}` },
    }
  );
  return response.json();
};

Get Orders from Date Range

const getOrdersByDateRange = async (token, startDate, endDate) => {
  const response = await fetch(
    `https://api.picoshealth.com/v1/orders?where={"and":[{"createdAt":{"greater_than":"${startDate}"}},{"createdAt":{"less_than":"${endDate}"}}]}&sort=-createdAt`,
    {
      headers: { 'Authorization': `Bearer ${token}` },
    }
  );
  return response.json();
};

Last Updated: June 22, 2026

Previous
Products