### Get Orders using OrderDesk API v2 in PHP Source: https://apidocs.orderdesk.com/index This PHP script utilizes the OrderDeskApiClient to fetch orders based on specified criteria like source name, start date, and sorting. It requires the 'order-desk-api-client.php' file and store/API credentials. The output is the raw result of the API call. ```php "FoxyCart", "search_start_date" => "2015-04-15 12:05:06", "order_by" => "shipping_last_name", ); $result = $od->get("orders", $args); echo "
" . print_r($result, 1) . ""; ?> ``` -------------------------------- ### GET /api/v2/test Source: https://apidocs.orderdesk.com/index This endpoint allows you to test your API connection and verify that the system time can be successfully retrieved. ```APIDOC ## GET /api/v2/test ### Description Make sure the connection is successful and return the system time ### Method GET ### Endpoint `/api/v2/test` ### Parameters #### Query Parameters None #### Request Body None ### Request Example #### PHP cURL ```php get("test"); echo "
" . print_r($result, 1) . ""; ?> ``` #### cURL ```bash curl "https://app.orderdesk.me/api/v2/test" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request (e.g., "success"). - **message** (string) - A message confirming the connection status (e.g., "Connection Successful"). - **current_date_time** (string) - The current date and time on the server. #### Response Example ```json { "status": "success", "message": "Connection Successful", "current_date_time": "2015-04-14 22:00:10" } ``` ``` -------------------------------- ### Get All Order Items via OrderDesk API Client and cURL Source: https://apidocs.orderdesk.com/index This snippet demonstrates how to retrieve all items associated with a specific order using the OrderDesk API. It includes examples for both a PHP client library and a cURL command. Requires valid `$storeid` and `$apikey`. ```php get("orders/736745/order-items"); echo "
" . print_r($result, 1) . ""; ?> ``` ```curl curl "https://app.orderdesk.me/api/v2/orders/736745/order-items" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### GET /api/v2/inventory-items Source: https://apidocs.orderdesk.com/index Retrieves a list of all inventory items. This endpoint is useful for getting an overview of all products in the inventory. ```APIDOC ## Get All Inventory Items ### Description Retrieves a list of all inventory items. This endpoint is useful for getting an overview of all products in the inventory. ### Method GET ### Endpoint /api/v2/inventory-items ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl "https://app.orderdesk.me/api/v2/inventory-items" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request. - **execution_time** (string) - The time taken for the request to execute. - **records_returned** (integer) - The number of records returned. - **total_records** (string) - The total number of records available. - **inventory_items** (array) - A list of inventory item objects. - **id** (integer) - Unique identifier for the inventory item. - **name** (string) - Name of the inventory item. - **code** (string) - Unique code for the inventory item. - **price** (integer) - Price of the inventory item. - **cost** (integer) - Cost of the inventory item. - **weight** (float) - Weight of the inventory item. - **stock** (integer) - Current stock level. - **update_source** (string) - Source from which the item was updated. - **manufacturer_sku** (string|null) - Manufacturer's SKU for the item. - **location** (string) - Storage location of the item. - **date_added** (string) - Date and time when the item was added. - **date_updated** (string) - Date and time when the item was last updated. #### Response Example ```json { "status": "success", "execution_time": "0.6651 seconds", "records_returned": 5, "total_records": "5", "inventory_items": [ { "id": 2510, "name": "Three Wolf T-Shirt, X-Large / Black", "code": "3wolf-11", "price": 10, "cost": 8, "weight": 0.8, "stock": 48, "update_source": "Shopify", "manufacturer_sku": null, "location": "", "date_added": "2014-08-09 09:06:53", "date_updated": "2014-08-09 09:06:53" } ] } ``` ``` -------------------------------- ### PHP: Query Testing Endpoint Source: https://apidocs.orderdesk.com/index This PHP snippet demonstrates how to connect to the Order Desk API's testing endpoint using the provided client library. It authenticates using store ID and API key, sends a GET request, and displays the result, which includes the system time upon successful connection. Ensure the `order-desk-api-client.php` is included and `$storeid` and `$apikey` are defined. ```php get("test"); echo "
" . print_r($result, 1) . ""; ?> ``` -------------------------------- ### Get Single Order Item via OrderDesk API Client and cURL Source: https://apidocs.orderdesk.com/index Provides code examples for fetching a specific order item from an order using the OrderDesk API. Both PHP client and cURL implementations are shown. This requires the order ID and the order item ID, along with authentication credentials. ```php get("orders/736745/order-items/47986"); echo "
" . print_r($result, 1) . ""; ?> ``` ```curl curl "https://app.orderdesk.me/api/v2/orders/736745/order-items/47986" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### Get Store Information using cURL Source: https://apidocs.orderdesk.com/index This snippet shows how to retrieve store information using a cURL command. It makes a GET request to the OrderDesk API endpoint for store details and requires the Store ID and API Key to be provided in the request headers. The output is the JSON response from the API. ```bash curl "https://app.orderdesk.me/api/v2/store" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### Get Store Information using PHP OrderDesk API Client Source: https://apidocs.orderdesk.com/index This snippet demonstrates how to fetch store details using the OrderDeskApiClient in PHP. It requires the 'order-desk-api-client.php' file and authentication credentials (store ID and API key). The output is the raw result of the API call, presented in a preformatted text block. ```php get("store"); echo "
" . print_r($result, 1) . ""; ?> ``` -------------------------------- ### cURL: Query Testing Endpoint Source: https://apidocs.orderdesk.com/index This cURL command shows how to interact with the Order Desk API's testing endpoint. It sends a GET request to the specified URL and includes the necessary `ORDERDESK-STORE-ID` and `ORDERDESK-API-KEY` headers for authentication. This is useful for verifying API connectivity and retrieving the current server time. ```bash curl "https://app.orderdesk.me/api/v2/test" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### GET /api/v2/store Source: https://apidocs.orderdesk.com/index Retrieves details about the OrderDesk store, including its ID, name, settings, and associated folders. ```APIDOC ## GET /api/v2/store ### Description Retrieves details about the OrderDesk store, including its ID, name, settings, and associated folders. ### Method GET ### Endpoint https://app.orderdesk.me/api/v2/store ### Parameters #### Headers - **ORDERDESK-STORE-ID** (string) - Required - The ID of your OrderDesk store. - **ORDERDESK-API-KEY** (string) - Required - Your OrderDesk API key. ### Request Example ```bash curl "https://app.orderdesk.me/api/v2/store" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request (e.g., "success"). - **execution_time** (string) - The time taken to execute the request. - **store** (object) - An object containing the store's details. - **id** (string) - The unique identifier for the store. - **name** (string) - The name of the store. - **settings** (object) - An object containing various store settings. - **folders** (object) - An object mapping folder IDs to folder names. ``` -------------------------------- ### GET /api/v2/orders Source: https://apidocs.orderdesk.com/index Retrieves a list of orders from the OrderDesk system. This endpoint supports filtering by source name, start date, and sorting by shipping last name. It requires authentication via ORDERDESK-STORE-ID and ORDERDESK-API-KEY headers. ```APIDOC ## GET /api/v2/orders ### Description Retrieves a list of orders based on specified criteria. ### Method GET ### Endpoint https://app.orderdesk.me/api/v2/orders ### Parameters #### Query Parameters - **source_name** (string) - Optional - Filters orders by the source name (e.g., "FoxyCart"). - **search_start_date** (string) - Optional - Filters orders added on or after this date and time (YYYY-MM-DD HH:MM:SS). - **order_by** (string) - Optional - Specifies the field to sort the results by (e.g., "shipping_last_name"). ### Request Headers - **ORDERDESK-STORE-ID** (string) - Required - Your OrderDesk store ID. - **ORDERDESK-API-KEY** (string) - Required - Your OrderDesk API key. ### Request Example ```bash curl "https://app.orderdesk.me/api/v2/orders?source_name=FoxyCart&search_start_date=2015-04-15%2012:05:06&order_by=shipping_last_name" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" ``` ### Response #### Success Response (200) - **status** (string) - The status of the API request (e.g., "success"). - **message** (string) - A message describing the result of the request. - **total_records** (integer) - The total number of records matching the query. - **records_returned** (integer) - The number of records returned in this response. - **offset** (integer) - The offset used for pagination. - **limit** (integer) - The limit of records per page. - **orders** (array) - An array of order objects. - Each order object contains fields like `id`, `email`, `shipping_method`, `quantity_total`, `order_total`, `payment_status`, `date_added`, `shipping` (object), `customer` (object), `order_items` (array), etc. #### Response Example ```json { "status": "success", "message": "Execution took 0.0208 seconds", "total_records": 1, "records_returned": 1, "offset": 0, "limit": 50, "orders": [ { "id": "925086", "email": "myemail@server.com", "shipping_method": "", "quantity_total": 1, "weight_total": 2.375, "product_total": 19, "shipping_total": 0, "handling_total": 0, "tax_total": 0, "discount_total": 0, "order_total": 19, "cc_number_masked": "xxxxxxxxxxxx4242", "cc_exp": "02/2016", "processor_response": "Authorize.net Transaction ID:2231994036", "payment_type": "Visa", "payment_status": "Approved", "processor_balance": 19, "refund_total": 0, "customer_id": "8173875", "email_count": "3", "ip_address": "181.16.150.12", "tag_color": "", "source_name": "FoxyCart", "source_id": "648714418", "fulfillment_name": "", "fulfillment_id": "", "tag_name": "", "folder_id": 64, "date_added": "2015-04-15 12:12:10", "date_updated": "2015-04-15 15:32:04", "shipping": { "first_name": "Jimmy", "last_name": "Dean", "company": "", "address1": "800 Emmet St", "address2": "", "address3": "", "address4": "", "city": "Nashville", "state": "TN", "postal_code": "55555", "country": "US", "phone": "208-555-5555" }, "customer": { "first_name": "Bingo", "last_name": "Little", "company": "", "address1": "900 Lord Business Ave", "address2": "", "city": "Knoxville", "state": "TN", "postal_code": "77777", "country": "US", "phone": "208-555-5555" }, "return_address": { "title": "Acme", "name": "Doug Jones", "company": "Acme Manufacturing", "address1": "817 E Maple Ln", "address2": "", "city": "Knoxville", "state": "TN", "postal_code": "55555", "country": "US", "phone": "" }, "checkout_data": { "Order Notes": "Please leave by back door" }, "order_metadata": { "fraud_protection_score": 0 }, "discount_list": [], "order_notes": [], "order_items": [ { "id": "1670028", "name": "Subscription Product", "price": 19, "quantity": 1, "weight": 2.375, "code": "126478", "delivery_type": "ship", "category_code": "DEFAULT", "variation_list": [], "metadata": { "image": "http://img1.wikia.nocookie.net/__cb20130318151721/epicrapbattlesofhistory/images/6/6d/Rick-astley.jpg" } } ] } ] } ``` ``` -------------------------------- ### GET /api/inventory-items Source: https://apidocs.orderdesk.com/index Retrieves all inventory items for the store. Supports filtering and searching based on various item attributes. ```APIDOC ## GET /api/inventory-items ### Description Get all the store's inventory items. You can search for which inventory items you'd like to return by passing the following values as query parameters. ### Method GET ### Endpoint /api/inventory-items ### Parameters #### Query Parameters - **id** (string) - Order Desk's ID for the inventory item. - **search** (string) - Search metadata, name, and code for this value. - **name** (string) - The name of the inventory item. - **code** (string) - The inventory item's unique SKU. - **metadata** (string) - A value that must be found somewhere in the list of the metadata keys and values. - **manufacturer_sku** (string) - The SKU used by the manufacturer. Can be used as print_sku. - **location** (string) - The warehouse or fulfillment method responsible for this item. - **update_source_not** (string) - The item must not have been updated by this integration (use the integration slug). - **updated_start_date** (datetime) - The earliest date this item was updated in UTC format. ### Response (Response structure not provided in the input text) ``` -------------------------------- ### Create Order History Item via OrderDesk API Client and cURL Source: https://apidocs.orderdesk.com/index Shows how to add an entry to an order's history using the OrderDesk API. Examples are provided for both a PHP client and cURL. The `source_name` parameter is optional. Requires `$storeid` and `$apikey`. ```php "My New Note", "source_name" => "API", ); $result = $od->post("orders/736745/order-history", $args); echo "
" . print_r($result, 1) . ""; ?> ``` ```curl curl "https://app.orderdesk.me/api/v2/orders/736745/order-history" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" \ -H "Content-Type: application/json" \ -X POST \ -d '{"note": "My New Note", "source_name": "API"}' ``` -------------------------------- ### Fetch All Inventory Items using PHP and cURL Source: https://apidocs.orderdesk.com/index This snippet demonstrates how to fetch a list of all inventory items from the OrderDesk API. It includes examples for using a PHP client library and a direct cURL request. Both methods require authentication credentials (store ID and API key). The output is a JSON response containing inventory item details. ```php get("inventory-items"); echo "
" . print_r($result, 1) . ""; ?> ``` ```bash curl "https://app.orderdesk.me/api/v2/inventory-items" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### GET /websites/apidocs_orderdesk Source: https://apidocs.orderdesk.com/index Retrieves a list of orders with various filtering and sorting options. You can filter by folder, source, dates, customer details, shipping details, and more. The results can be ordered and paginated. ```APIDOC ## GET /websites/apidocs_orderdesk ### Description Retrieves a list of orders with various filtering and sorting options. You can filter by folder, source, dates, customer details, shipping details, and more. The results can be ordered and paginated. ### Method GET ### Endpoint /websites/apidocs_orderdesk ### Parameters #### Query Parameters - **folder_id** (string) - Optional - Search for orders from a particular folder. For multiple folders, enter multiple IDs separated by a comma: `1004,1009,1010` - **folder_name** (string) - Optional - Search for orders from a particular folder. Enter the folder's exact name instead of its ID. - **source_id** (string) - Optional - The source ID. - **source_name** (string) - Optional - The source name. - **search_start_date_local** (string) - Optional - Start date from when an order was added. Search in local store time. - **search_end_date_local** (string) - Optional - End date from when an order was added. Search in local store time. - **search_start_date** (string) - Optional - Start date from when an order was added. Search in UTC time. - **search_end_date** (string) - Optional - End date from when an order was added. Search in UTC time. - **modified_start_date** (string) - Optional - Start date from when an order was modified. Search in UTC time. - **modified_end_date** (string) - Optional - End date from when an order was modified. Search in UTC time. - **email** (string) - Optional - Search for orders with a particular email address. - **customer_id** (string) - Optional - Search for orders with a particular customer ID. - **customer_first_name** (string) - Optional - Search the customer first name field. - **customer_last_name** (string) - Optional - Search the customer first name field. - **customer_company** (string) - Optional - Search the customer company field. - **customer_address1** (string) - Optional - Search the customer address1 field. - **shipping_first_name** (string) - Optional - Search the shipping first name field. - **shipping_last_name** (string) - Optional - Search the shipping first name field. - **shipping_company** (string) - Optional - Search the shipping company field. - **shipping_address1** (string) - Optional - Search the shipping address1 field. - **customer_phone** (string) - Optional - Search the customer phone field. - **shipping_phone** (string) - Optional - Search the shipping phone field. - **get_order_history** (boolean) - Optional - Set this to `1` to include order history. This slows down the results considerably so use carefully. - **order_by** (string) - Optional - Order the query by an order field. Defaults to `date_added`. - **order** (string) - Optional - `ASC` or `DESC`, defaults to `DESC`. - **limit** (integer) - Optional - How many orders to return, defaults to `50`, limit of `500`. - **offset** (integer) - Optional - The number of records to offset. ### Response #### Success Response (200) - **orders** (array) - A list of order objects. - **pagination** (object) - Pagination details. #### Response Example ```json { "orders": [ { "order_id": "12345", "customer_name": "John Doe", "order_date": "2023-10-27T10:00:00Z" } ], "pagination": { "total_records": 100, "limit": 50, "offset": 0 } } ``` ``` -------------------------------- ### Create Inventory Item using PHP and cURL Source: https://apidocs.orderdesk.com/index This section shows how to create a new inventory item via the OrderDesk API. It provides examples in PHP and cURL. The PHP code uses a client to send a POST request with item details. The cURL command illustrates the equivalent HTTP request, including headers and the JSON payload. ```php "Three Wolves T-Shirt", "code" => "3wolf-XX", "price" => 11.00, "stock" => 52, "variation_list" => array( "Color" => "Red", "Size" => "Large", ), "metadata" => array( "image" => "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg", "print_url" => "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg", "print_sku" => "x533", ), "manufacturer_sku" => "GT5000", ); $result = $od->post("inventory-items", $args); echo "
" . print_r($result, 1) . ""; ?> ``` ```curl curl "https://app.orderdesk.me/api/v2/inventory-items" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" -H "Content-Type: application/json" -X POST -d '{"name": "Three Wolves T-Shirt", "code" => "3wolf-11", "price" => 11.00, "stock" => 52, "variation_list": { "Color": "Red", "Size": "Large"}, "metadata": {"image": "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg", "print_url": "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg","print_sku": "x533"}}' ``` -------------------------------- ### Get All Order Shipments Source: https://apidocs.orderdesk.com/index Retrieves all shipment information for a given order using the Order Desk API. Requires store ID, API key, and order ID. Returns a list of shipment objects. ```php get("orders/29491/shipments"); echo "
" . print_r($result, 1) . ""; ?> ``` -------------------------------- ### Get Orders using OrderDesk API v2 with cURL Source: https://apidocs.orderdesk.com/index This cURL command demonstrates how to retrieve orders from the OrderDesk API v2. It includes query parameters for filtering and sorting, as well as essential headers for authentication (ORDERDESK-STORE-ID and ORDERDESK-API-KEY). ```bash curl "https://app.orderdesk.me/api/v2/orders?source_name=FoxyCart&search_start_date=2015-04-15%2012:05:06&order_by=shipping_last_name" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### Get Single Order using PHP Source: https://apidocs.orderdesk.com/index Retrieves a single order by its ID using the OrderDesk API client in PHP. This snippet requires the `order-desk-api-client.php` file and valid store ID and API key. It outputs the order details in a preformatted string. ```php get("orders/736745"); echo "
" . print_r($result, 1) . ""; ?> ``` -------------------------------- ### Get All Order Shipments (cURL) Source: https://apidocs.orderdesk.com/index Retrieves all shipment information for a given order using a cURL request to the Order Desk API. Requires store ID, API key, and order ID. Returns a list of shipment objects. ```bash curl "https://app.orderdesk.me/api/v2/orders/29491/shipments" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" ``` -------------------------------- ### Delete Order via OrderDesk API Client and cURL Source: https://apidocs.orderdesk.com/index Demonstrates how to delete an order using the OrderDesk API. It shows examples using a PHP client library and a cURL command. Ensure you have the `order-desk-api-client.php` included and valid `$storeid` and `$apikey`. ```php delete("orders/736745"); echo "
" . print_r($result, 1) . ""; ?> ``` ```curl curl "https://app.orderdesk.me/api/v2/orders/736745" \ -H "ORDERDESK-STORE-ID: storeid" \ -H "ORDERDESK-API-KEY: apikey" \ -X DELETE ``` -------------------------------- ### Update Inventory Item using PHP and cURL Source: https://apidocs.orderdesk.com/index This snippet demonstrates how to update an existing inventory item using the OrderDesk API. It includes both a PHP client example and a cURL command. The PHP code uses a client library to send a PUT request with updated item details. The cURL command shows the equivalent HTTP request with necessary headers and payload. ```php "Three Wolves T-Shirt", "code" => "3wolf-11", "price" => 11.00, "stock" => 52, "variation_list" => array( "Color" => "Red", "Size" => "Large", ), "metadata" => array( "image" => "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg", "print_url" => "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg", "print_sku" => "x533", ), "manufacturer_sku" => "GT5000", ); $result = $od->put("inventory-items/2510", $args); echo "
" . print_r($result, 1) . ""; ?> ``` ```curl curl "https://app.orderdesk.me/api/v2/inventory-items/2510" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" -H "Content-Type: application/json" -H "X-HTTP-Method-Override: PUT" -X POST -d '{"name": "Three Wolves T-Shirt", "code" => "3wolf-11", "price" => 11.00, "stock" => 52, "variation_list": { "Color": "Red", "Size": "Large"}, "metadata": {"image": "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg", "print_url": "https://images-na.ssl-images-amazon.com/images/I/81sUY6YDp5L._UX522_.jpg","print_sku": "x533"}}' ``` -------------------------------- ### Create Order via PHP Client Source: https://apidocs.orderdesk.com/index This snippet demonstrates how to create a new order using the OrderDesk API Client in PHP. It requires authentication with store ID and API key, and constructs an order payload including customer, shipping, and item details. The result of the API call is then printed. ```php "6487172454", "email" => "myemail@server.com", "shipping_method" => "UPS Ground", "shipping_total" => 9.50, "handling_total" => 0, "tax_total" => 1.25, "date_added" => "2019-01-15 12:12:10", "date_updated" => "2019-01-15 15:32:04", "shipping" => array( "first_name" => "Jimmy", "last_name" => "Dean", "company" => "", "address1" => "800 Emmet St", "address2" => "", "city" => "Nashville", "state" => "TN", "postal_code" => "55555", "country" => "US", "phone" => "555-555-5555" ), "customer" => array( "first_name" => "Bingo", "last_name" => "Little", "company" => "", "address1" => "900 Lord Business Ave", "address2" => "", "city" => "Knoxville", "state" => "TN", "postal_code" => "77777", "country" => "US", "phone" => "555-555-5555" ), "return_address" => array( "title" => "Acme", "name" => "Doug Jones", "company" => "Acme Manufacturing", "address1" => "817 E Maple Ln", "address2" => "", "city" => "Knoxville", "state" => "TN", "postal_code" => "55555", "country" => "US", "phone" => "555-555-5555" ), "checkout_data" => array( "PackingSlip" => "Link To Packing Slip" ), "order_metadata" => array( "ship_notify_url" => "link to your site for notification" ), "order_items" => array( array( "name" => "My Product", "price" => 9.99, "quantity" => 1, "weight" => 1.1, "code" => "my-sku", "variation_list" => array( "Size" => "Large", "Color" => "Red" ), "metadata" => array( "image" => "preview thumbnail url", "print_sku" => "printer-sku", "print_url" => "url of hi-res artwork", ), ), ), ); $result = $od->post("orders", $args); echo "
" . print_r($result, 1) . ""; ?> ``` -------------------------------- ### Create an Order API Source: https://apidocs.orderdesk.com/index This endpoint allows for the creation of a new order within the OrderDesk system. ```APIDOC ## POST /websites/apidocs_orderdesk/orders ### Description This endpoint allows for the creation of a new order within the OrderDesk system. ### Method POST ### Endpoint /websites/apidocs_orderdesk/orders ### Parameters #### Request Body - **customer_details** (object) - Required - Details about the customer. - **first_name** (string) - Required - **last_name** (string) - Required - **email** (string) - Required - **shipping_details** (object) - Required - Details about the shipping address. - **address1** (string) - Required - **city** (string) - Required - **state** (string) - Required - **zip_code** (string) - Required - **country** (string) - Required - **items** (array) - Required - List of items in the order. - **sku** (string) - Required - **quantity** (integer) - Required ### Request Example ```json { "customer_details": { "first_name": "Jane", "last_name": "Doe", "email": "jane.doe@example.com" }, "shipping_details": { "address1": "123 Main St", "city": "Anytown", "state": "CA", "zip_code": "90210", "country": "USA" }, "items": [ { "sku": "ITEM001", "quantity": 2 } ] } ``` ### Response #### Success Response (201) - **order_id** (string) - The ID of the newly created order. - **status** (string) - The status of the created order. #### Response Example ```json { "order_id": "67890", "status": "Processing" } ``` ``` -------------------------------- ### Create Order via cURL Source: https://apidocs.orderdesk.com/index This snippet shows how to create a new order using a cURL command. It includes necessary headers for authentication and content type, specifies the POST request method, and provides a JSON payload with comprehensive order details, including shipping, customer, and item information. ```bash curl "https://app.orderdesk.me/api/v2/orders" -H "ORDERDESK-STORE-ID: storeid" -H "ORDERDESK-API-KEY: apikey" -H "Content-Type: application/json" -X POST -d '{ "source_id": "6487172454", "email": "myemail@server.com", "shipping_method": "UPS Ground", "shipping_total": 9.50, "handling_total": 0, "tax_total": 1.25, "date_added": "2019-01-15 12:12:10", "date_updated": "2019-01-15 15:32:04", "shipping": { "first_name": "Jimmy", "last_name": "Dean", "company": "", "address1": "800 Emmet St", "address2": "", "city": "Nashville", "state": "TN", "postal_code": "55555", "country": "US", "phone": "555-555-5555" }, "customer": { "first_name": "Bingo", "last_name": "Little", "company": "", "address1": "900 Lord Business Ave", "address2": "", "city": "Knoxville", "state": "TN", "postal_code": "77777", "country": "US", "phone": "555-555-5555" }, "return_address": { "title": "Acme", "name": "Doug Jones", "company": "Acme Manufacturing", "address1": "817 E Maple Ln", "address2": "", "city": "Knoxville", "state": "TN", "postal_code": "55555", "country": "US", "phone": "555-555-5555" }, "checkout_data": { "PackingSlip": "Link To Packing Slip" }, "order_metadata": { "ship_notify_url": "link to your site for notification" }, "order_items": [ { "name": "My Product", "price": 9.99, "quantity": 1, "weight": 1.1, "code": "my-sku", "variation_list": { "Size": "Large", "Color": "Red" }, "metadata": { "image": "preview thumbnail url", "print_sku": "printer-sku", "print_url": "location of hi-res artwork", } } ] }' ```