Fivexer

PHP

The PHP SDK (fivexer/sdk) requires PHP 8.1+ and covers all three credential planes — workspace, worker, and supervisor.

Install

bash
composer require fivexer/sdk

Quickstart

php
<?php
require 'vendor/autoload.php';

use Fivexer\SDK\Fivexer;
use Fivexer\SDK\Model\CreateTask;
use Fivexer\SDK\Model\UpsertWorker;

$client = new Fivexer('https://api.fivexer.com', 'sk_test_...');
$client->workers()->upsert((new UpsertWorker('agent_1'))->tags(['english', 'billing']));
$task = $client->tasks()->create((new CreateTask(['english', 'billing']))->priority(90));
echo $task->getId() . ' ' . $task->getStatus();

Hand work off and wait for the result

Give the task your own id so a retry cannot create a second one, say what a finished result must look like, and wait for it. outcome returns as soon as the task is done or the wait (up to 25 seconds) runs out; the SDK raises its own read timeout to cover the wait.

php
use Fivexer\SDK\Model\ResultContract;

$client->tasks()->create(
    (new CreateTask(['seo'], id: 'audit-2026-10-10', title: 'Audit the pricing page'))
        ->resultContract(
            (new ResultContract())
                ->schema(['type' => 'object', 'required' => ['url']])
                ->acceptanceCriteria('A link to the published report.'),
        ),
);

$outcome = $client->tasks()->outcome('audit-2026-10-10', 25000);
while (!$outcome->done) {
    $outcome = $client->tasks()->outcome('audit-2026-10-10', 25000);
}
echo $outcome->status . ' ' . $outcome->workerId;

A result that misses the schema is refused with result_invalid and stays with the worker to fix; a worker who cannot do the job completes with success: false, which always goes through. See the MCP agent toolset for the same flow over MCP.

What's covered

The workspace client exposes the full /v1 surface as resource accessors:

tasks(), workers(), skills(), decisions(), workflows(), runs(), learning(), notifications(), teams(), team(), joinLinks(), identities(), history(), breaks(), plus stats(), slaStats(), queueAudit() and portal() directly on the client. A task's sub-resources hang off tasks(): tasks()->context(), tasks()->comments(), tasks()->attachments().

Coverage is enforced, not claimed: ContractParityTest walks contract/operations.yaml and fails the build if the client is missing an operation the contract declares.

Worker portal

php
use Fivexer\SDK\FivexerWorker;
use Fivexer\SDK\Model\WorkerLogin;

$worker = new FivexerWorker('https://api.fivexer.com');
$worker->login(new WorkerLogin('ws_1', 'agent_1', '4821'));
$worker->accept($worker->queue()->getTaskIds()[0]);

Supervisor

php
use Fivexer\SDK\FivexerSupervisor;
use Fivexer\SDK\Model\AcceptSupervisorInvite;

$sv = new FivexerSupervisor('https://api.fivexer.com');
$sv->acceptInvite(new AcceptSupervisorInvite($tokenFromLink));

$board = $sv->overview();
$sv->assign($board->getParked()[0]->getId(), $board->getCrew()[0]->getWorkerId());

Supervisor actions are flat methods here (unpark, setPriority, assign, setAvailability) — only the TypeScript client groups them into namespaces. See the supervisor plane.

Errors and quotas

php
use Fivexer\SDK\Exception\FivexerApiException;

try {
    $client->tasks()->create(new CreateTask(['english']));
} catch (FivexerApiException $e) {
    echo $e->getStatusCode() . ' ' . $e->getCode();
    echo $e->getRetryAfterSeconds();
    echo $e->getQuota()->getTaskRateRemaining();
}

Only the workspace client parses quota headers; the worker and supervisor clients do not.

Webhooks

php
use Fivexer\SDK\Webhook\Webhook;

$event = Webhook::constructEvent($rawBody, $header, 'whsec_...');
echo $event->getEvent();

Pass the raw request body — parsing and re-encoding the JSON changes the bytes the signature was computed over.

Was this page helpful?