book-openSearch to Order

Complete workflow from product search to order placement

This cookbook walks you through the complete workflow to search for products and place an order using the PartsSource API. By the end, you'll understand how data flows from user lookup through order creation.


Overview

Placing an order requires four API calls that build on each other:

Step
Endpoint
Purpose

1

User/Customer Lookup

Get user profile, companies, addresses

2

Catalog Search

Find products matching your criteria

3

Catalog Detail

Get pricing options and the priceOptionId

4

Create Order

Place order using the priceOptionId

circle-exclamation

Prerequisites

  • Valid OAuth 2.0 access token (see Authentication)

  • User ID or username for lookup

  • Understanding of which API to use (Customer API vs Internal API)

circle-info

Which API should I use?

  • Customer API (api.partssource.com/customer): For customer-facing integrations with tenant isolation

  • Internal API (api.partssource.com/internal): For internal/admin applications with cross-tenant access


Step 1: User/Customer Lookup

First, retrieve the user profile to get company information, facility IDs, and shipping/billing addresses needed for ordering.

circle-info

API Difference: The endpoint path differs between APIs:

  • Customer API: GET /users/lookup

  • Internal API: GET /customers/lookup

Customer API

Internal API

Response

Key Values to Capture

Field
Usage in Later Steps

contactId

requesterId for catalog detail and order creation

companies[].id

companyId for catalog detail and order (Internal API)

shippingAddresses[].id

shippingAddressId for order

billingAddresses[].id

billingAddressId for order


Search the product catalog using keywords, filters, and pagination.

Request (Both APIs)

circle-info

Pagination Limits:

  • Customer API: Maximum 200 results per page

  • Internal API: Maximum 1000 results per page

Response

Key Values to Capture

Field
Usage in Later Steps

items[].id

productId for catalog detail and order creation


Step 3: Get Catalog Detail (Critical)

This is the most important step. The catalog detail endpoint returns pricing options, each with a unique priceOptionId that acts as a 30-day quote.

circle-info

API Difference: The Internal API requires companyId, while the Customer API does not.

Customer API Request

Internal API Request

Response

Understanding the Options Array

Each option in the options array represents a different purchasing choice:

Field
Description

priceOptionId

Required for order - The quote ID, valid for 30 days

price

Unit price for this option

condition

Product condition (New OEM, Refurbished, Aftermarket, etc.)

warranty

Warranty period included

purchaseChoice

Type of purchase (Buy, Exchange, Loan, etc.)

customFields

Additional fields required by the vendor

circle-exclamation

About customFields (Internal API)

Some pricing options require additional information from the buyer. The customFields array defines what data you must provide when creating the order.

customField Property
Description

fieldId

Identifier to use in order request

prompt

User-facing label for the field

isRequired

Whether the field must be provided

formatRegex

Validation pattern for the value

errorMessage

Message shown if validation fails


Step 4: Create Order

Place the order using the priceOptionId from Step 3. Every order request requires an Idempotency-Key header.

circle-exclamation

Customer API Request

Internal API Request

circle-info

Internal API Difference: The Internal API requires companyId in the order request.

Response


Complete Flow Example

1

Authenticate and get access token

2

Look up user to get profile and addresses

Use the user ID or username to retrieve company information, facility IDs, and addresses.

3

Search catalog for desired product

Search using keywords or filters to find the product you want to order.

4

Get catalog detail with pricing options

Call /catalog/detail with the productId from search results. Capture the priceOptionId for the option you want.

5

Create order with priceOptionId

Submit the order with:

  • priceOptionId from Step 4

  • Address IDs from Step 2

  • A unique Idempotency-Key header

6

Verify order creation

Check the response for orderNumber and success: true. Store the order number for tracking.


Error Handling

Common Errors

Error
Cause
Solution

400 Bad Request

Missing required fields

Check required fields for your API

400 Bad Request

Missing Idempotency-Key

Add the header with a UUID

403 Forbidden

Tenant mismatch

Verify user belongs to the company

404 Not Found

Invalid priceOptionId

Get fresh catalog detail before ordering

409 Conflict

Idempotency key reused with different body

Use new key for different orders

422 Unprocessable Entity

Validation failed

Check error details in response

priceOptionId Expired

If your priceOptionId is older than 30 days, the order will fail validation. Call /catalog/detail again to get a fresh quote with updated pricing.


Next Steps

Last updated