Function ping

Description

Health check for external KSeF Service. Checks if the service is running and returns its version and log.

Important notes

  • This endpoint checks connectivity to the KSeF Service (external microservice for KSeF integration)
  • Requires KsefService configuration in userDBConfig:
    $tc['api']['KsefService'] = [
        'serverUrl' => 'http://localhost:8080',
        'apiKey' => 'your-api-key',
    ];
  • The ping endpoint on KSeF Service does not require API key authentication

Arguments

None - this function takes no parameters.

Returns

Success response

{
  "status": "OK",
  "version": "1.0.0.0",
  "log": "12:30:45 Server started\n12:30:46 KSeF initialized",
  "message": null
}

Error response

{
  "status": "ERROR",
  "version": null,
  "log": null,
  "message": "Nie można połączyć z serwisem KSeF",
  "curlError": "Connection refused",
  "curlErrno": 7
}

Possible error messages

  • Brak konfiguracji serwisu KSeF - missing serverUrl in config
  • Nie można połączyć z serwisem KSeF - connection error (service not running)
  • Serwis KSeF zwrócił błąd HTTP: XXX - HTTP error from service
  • Nieprawidłowa odpowiedź JSON - invalid response format

Example

require_once('classUddsOx.php');

$udds = new classUddsOx;
$udds->customerCode = [your_customerCode];
$udds->login = [your_login];
$udds->password = [your_password];
$udds->serverUrl = 'http://api.dlaoperatora.pl/udds/';

$ret = $udds->ping();

if ($ret['status'] == 'OK') {
    echo "KSeF Service version: " . $ret['version'];
    echo "Service is running correctly";
} else {
    echo "Error: " . $ret['message'];
}

Related endpoints