How to save an order to Keap with the PHP SDK?

I have a use case for Infusionsoft/Keap similar to this thread, but simpler. I just want to send orders, including lists of line items, to Keap and have them saved there. Payment will be taken care of elsewhere. There is no need for two-way communications. However, I’m working in the constraints of an application that is a couple of years old and uses the Infusionsoft PHP-SDK. I’d prefer to keep everything consistent and not deal with the problem of having two different ways of accessing Keap in the same application. However, the only documentation I can find online is for the REST APIs, which don’t help when I’m using the SDK. I’ve looked for code I can use as a model for doing this, but found nothing. How do I save an order to Keap through the PHP SDK? What function(s) do I call, and what parameters do I need to send?

To create an order with the Infusionsoft PHP SDK you use orders()->create() and pass the order details along with one or more line items. For example:

$order = $infusionsoft->orders()->create([
    'contact_id'   => 4064,
    'order_date'   => '2025-08-18T12:52:10.000Z',
    'order_title'  => 'Sample order',
    'order_type'   => 'Online',
    'order_items'  => [
        [
            'product_id'  => 4,
            'quantity'    => 8,
            'price'       => 29.99,
            'description' => 'Product description',
            'item_type'   => 'PRODUCT'
        ]
    ]
]);

The required fields are:

  • contact_id (integer)
  • order_date (date-time string)
  • order_title (string)
  • order_type (string: “Online” or “Offline”)
  • order_items (array of item objects)

You can find the full schema, including optional fields in the documentation.

Keep in mind that the Infusionsoft PHP SDK is deprecated. While it may still work, we recommend planning a move to the REST API for better long-term support.

I’m reactivating this old thread because the solution provided is not working for me. A necessary preliminary step to creating the order is to make sure that there are product records for all the products in the order. My code checks for whether a keap product exists, and if it doesn’t, the code tries to create one by building an object called $keap_product which contains the necessary data elements (name, price, SKU) and then calling $infusionsoft->products()->create($keap_product). When I do this, I get a CannotCreate error, which is apparently being thrown on my end in the SDK ProductService class. How can I fix this?

Hi Sean,

Here’s an example of how you can create a product using the infusionsoft PHP SDK:

$product = $infusionsoft->products()->create([
    'product_name' => 'Sample product',
    'sku' => 'smp-prd'
]);

You can find the full documentation here.

If that still doesn’t work, could you share more details about the exact error message or stack trace you’re getting?

Whenever I try to use $infusionsoft→products()→create(), I get an exception with this error message:

“Infusionsoft\Api\Rest\ProductService cannot use create function.”

Is this connected to the CannotCreate trait that is in the SDK’s ProductService class? In my version of it, that class has this in the header:

use Infusionsoft\Api\Rest\Traits\CannotCreate;

use Infusionsoft\Api\Rest\Traits\CannotDelete;

use Infusionsoft\Api\Rest\Traits\CannotModel;

use Infusionsoft\Api\Rest\Traits\CannotSave;

class ProductService extends RestModel {

use CannotCreate, CannotSave, CannotModel;

Yes, the CannotCreate trait in the ProductService class is what’s causing that exception. To be able to use create(), you can remove the CannotCreate trait from the class in your local SDK copy.

After removing it, the create() method should work as expected.