PHP API throwing some sort of validation error for sandbox and production environment

Here is the code I’m using to trim the video:

require 'vendor/autoload-2.php';

use Shotstack\Client\Api\EditApi;
use Shotstack\Client\Configuration;
use Shotstack\Client\Model\Edit;
use Shotstack\Client\Model\Output;
use Shotstack\Client\Model\Timeline;
use Shotstack\Client\Model\Track;
use Shotstack\Client\Model\Clip;
use Shotstack\Client\Model\VideoAsset;

$stime = $_POST['stime'];
$etime = $_POST['etime'];
$userID = $_POST['userID'];
$videoURL = $_POST['videoURL'];
$videoKey = $_POST['videoKey'];

$source = str_replace(' ', '%20', $videoURL);

$vidLength = $etime - $stime;

class TrimDemo
    protected $apiKey;
    protected $apiUrl = '';

    public function __construct()

        $this->apiKey = 'MY API KEY';

    public function render()
        $config = Configuration::getDefaultConfiguration()
            ->setApiKey('x-api-key', $this->apiKey);

            echo $this->apiUrl.'<br>';
            echo $this->apiKey.'<br><br>';

        $client = new EditApi(null, $config);

        $videoAsset = new VideoAsset();

        $videoClip = new Clip();

        $track = new Track();

        $timeline = new Timeline();

        $output = new Output();

        $edit = new Edit();

        try {
            $response = $client->postRender($edit)->getResponse();
        } catch (Exception $e) {
            die('Request failed: ' . $e->getMessage());

        $video = $client->getRender($response->getId())->getResponse();
        if ($video->getStatus() === 'done') {
            echo $video->getUrl().'<br>';

        global $videoID;
        $videoID = $response->getId();

$editor = new TrimDemo();

$finalID = $videoID;


I’m getting the following error thrown at me:
Request failed: [400] Client error: POST resulted in a 400 Bad Request response: {“success”:true,“message”:“Bad Request”,“response”:{“error”:{“name”:“ValidationError”,“details”:[{“message”:"“trim” mu (truncated…)

Can anyone please help?

Hi @soohaibster,

There appears to be an issue with one of the variables you’re passing to the API, specifically in relation to the trim property. Are you using the right type? The trim method only accepts a float.

If you can share what you are sending through to your PHP script and their types this may help solve the problem.

1 Like

Thanks a lot @dazzatron . That was the real problem there. I was sending the value as a string. I have changed it now and everything is working properly.

Thanks again!

1 Like