PHP SDK createCustomerResponse is string?

According to the tech docs for the PHP SDK, the createCustomer function should return an object of createCustomerResponse but I get a json string.

Here’s an excerpt of my code

    $customerRequest = new Square\Models\CreateCustomerRequest;

    $client = new Square\SquareClient([
        'accessToken' => SQUARE_TOKEN,
        'environment' => Square\Environment::SANDBOX,

    $customersApi = $client->getCustomersApi();
    $apiResponse = $customersApi->createCustomer($customerRequest);
    if ($apiResponse->isSuccess()) {
        $createCustomerResponse = $apiResponse->getBody();
        return json_decode($createCustomerResponse);    //I have to decode the json to access the attributes.
    } else {
        $errors = $apiResponse->getErrors();
        return $errors;

Given that I’ve brand new to this SDK, perhaps I am not doing something right?

Hi @frank welcome to the forums!

I believe getBody() is the raw body (a string, in other words). If you want a PHP object, you should use getResult() instead, which in your above case, would actually return a CreateCustomerResponse object.

Brilliant! Thank you!

I’m looking at the docs at this url :

The doc there links to each of the APIs like Customer and so forth but how do I find all the different methods and functions for each object? Other than the examples I can’t seem to find a reference.

This is more of a how to read the docs question than anything else.
Apologies for the basicness.

Thanks in advance!

No worries at all. Once you click on one of the APIs (like Customer), you will be directed to a new doc page with all of the endpoints available. If you go to a specific endpoint, like CreateCustomer, you will see that the Parameters takes a CreateCustomerRequest and the response is a CreateCustomerResponse. You can click either of these objects to be taken to their details page which shows all of the fields and functions to access or set the fields.

Note, you can also just click the doc link in the root Github repo and navigate from there. On the next page, you’ll see apis and models, so if you click models, every model that exists will be there. (like