Creating a customer through the API - clarifications

ovaillancourtovaillancourt Member
in Help edited March 2012
Hi there!

Our business model requires the user to be registered and logged onto our website to be able to checkout an order.

So basically, our approach is to create a new foxycart customer through the API based on our site's user profile and linked the two through SSO.

I've been able to use the api no problem for other stuffs but I hit a snag when I try to create a new customer.

Basically, I'm doing a post request on the api, through a "customer_save" api_action, in which I specify the "customer_id", "customer_password_hash", "customer_password_salt".

In terms of Javascript code (using nodejs here), it translates to the following query code:
              var newCustomerData = {
                api_token: api_token,
                api_action: 'customer_save',
                customer_id: customer_id, 
                customer_password_hash: hashedPass,
                customer_password_salt: newSalt,

              //Save the new customer into foxycart
                console.log('Result here: ', res.text);

After sending this, the server responds with a "User not found" error:
<?xml version='1.0' encoding='UTF-8'?><foxydata><store_version>0.7.2</store_version><result>ERROR</result><messages><message>Customer Not Found (customer_email:, customer_id:[user id here, removed])</message></messages></foxydata>

I'm 100% convinced the actual way of querying the api is valid as I'm using the same query code for other queries which are working fine. Only the data sent through the "send" actually changes. I think the actual fields I'm passing or the way I'm trying to use the API for customer creation might be wrong.

I'm not exactly sure of the following thing:

Should I be passing the customer id? Or I should leave it blank to indicate a new user creation and collect it from somewhere else within foxycart (xml feed? server's response?) afterwards.


  • ovaillancourtovaillancourt Member
    edited March 2012
    Oops, created the thread completely in the wrong place :/. Should be moved to "Help - Advanced".

    Update: Ah! Moved it myself :D.

    First time user here :D sorry!
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Yeah, you don't want to be passing in the customer_id because then it looks for a customer to edit. If the customer_id is blank, it should create the new customer.
  • Ok perfect! Thanks for the info!
  • lukeluke FoxyCart Team
    Sorry if that wasn't clear.
  • ovaillancourtovaillancourt Member
    edited March 2012
    No worry Luke! I think there could be a note in the wiki concerning that, I don't recall seeing the info or being able to derive it from what's in there :).

    Another thing that could be interesting to put in there is the kind of content formatting the API is expecting in the post body.
  • lukeluke FoxyCart Team
    We're hard at work designing a completely new REST API which will come complete with documentation, so stay tuned. Awesomeness is coming. :)
  • Great news! :D Can't wait to see what you guys have coming up :D.
  • What do you mean by leaving customer_id blank? Not including it in the post? Or leaving customer_id there albeit with an empty value/string?
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Either way is fine.
  • SeanSean Member

    Does this mean that the external system has no way to assign or change the customer_id in foxy? We were hoping to make the customer_id something meaningful in our system.

  • fc_adamfc_adam FoxyCart Team

    That's right - you can't change the ID of the customer on FoxyCart's end.
Sign In or Register to comment.