use Espo\ApiClient\Client; $client = new Client('https://your-espocrm-site'); $client->setApiKey('API_KEY'); $response = $client->request(Client::METHOD_POST, 'Lead', [ 'firstName' => 'Test', 'lastName' => 'Hello', ]); $response = $client->request(Client::METHOD_GET, 'Opportunity', [ 'maxSize' => 10, 'select' => 'id,name,assignedUserId', 'orderBy' => 'createdAt', 'order' => 'desc', 'primaryFilter' => 'open', ]); $parsedBody = $response->getParsedBody(); $fileContentsResponse = $client->request(Client::METHOD_GET, "Attachment/file/{$attachmentId}") ->getBodyPart();