Catalog Image Upload

I am trying to export items from my php site to square. Can you pls share the code in curl in php to upload catalog images.


To be honest, it’s nearly impossible (I’ve never gotten it to work) to do it in PHP cURL. Strongly recommend using our PHP SDK to handle this, or a third-party HTTP library like Guzzle.

I was using this code and it was working fine. But when i tested yesterday, it was breaking.

$client = new \GuzzleHttp\Client([
// Use for sandbox
‘base_uri’ => ‘
$request_data = json_encode([
‘idempotency_key’ => ‘some unique key’,
‘object_id’ => “CatalogItem ID”,
‘image’ => [
‘id’ => ‘#TEMP_ID’,
‘type’ => ‘IMAGE’,
‘image_data’ => [
‘name’ => ‘My picture’,
‘caption’ => ‘A picture of a cup of coffee’

        $response = $client->request('POST', '/v2/catalog/images', [
                                     'headers' => [
                                     'Accept' => 'application/json',
                                     'Authorization' => 'Bearer ACCESS_TOKEN',
                                     'Square-Version' => '2020-04-22'
                                     'multipart' => [
                                     'name' => 'request',
                                     'contents' => $request_data
                                     'name' => 'file',
                                     'contents' => fopen('/path/to/file', 'r')
        Can you pls let me know what the issue is

As far as I can tell the above code works (tested it), except you need https in (we don’t allow non-https requests). If it’s still not working, can you provide the error?