TryOnCloud
IntermediateSetup: 2–3 hoursREST API — direct HTTP calls from PHP

Virtual Try-On API for PHP Applications — Full Integration Guide

Integrate TryOnCloud's virtual try-on API into any PHP application — custom-built ecommerce platforms, Laravel stores, Symfony applications, or legacy PHP backends. Uses simple REST API calls with API key authentication. No SDK required.

Method

REST API — direct HTTP calls from PHP

Auth

API key in X-API-Key header

Language

PHP (vanilla, Laravel, Symfony, CodeIgniter)

Best for

Custom-built ecommerce platforms of any size

Why use TryOnCloud with Custom PHP

  • Works with any PHP framework or custom platform
  • Full control over UI — build the try-on experience to match your brand
  • Asynchronous API — submit job and poll for result, no blocking
  • Webhook support — receive result via callback instead of polling
  • Laravel and Symfony example code included

How to set up TryOnCloud on Custom PHP

Estimated setup time: 2–3 hours. Difficulty: Intermediate.

  1. 1

    Get your API key

    Log in to your TryOnCloud dashboard, go to API Keys, and generate a new key. Copy it — you will use it in every API request.

  2. 2

    Submit a try-on job

    POST to https://www.tryoncloud.com/api/tryon with your garment image URL and customer photo URL. The API returns a job ID immediately.

  3. 3

    Poll for or receive the result

    Either poll GET /api/result/{job_id} every 3 seconds, or provide a webhook_url in your POST body to receive the result automatically when processing completes (15–20 seconds).

  4. 4

    Display the result image

    The result is a URL pointing to the generated try-on image. Display it in a modal, lightbox, or inline on your product page.

  5. 5

    Handle errors gracefully

    Check for status: error in the result response. Common errors: unsupported image format, image too small (<400px), or garment not detected. Show a friendly fallback message.

Code example

PHP: Submit try-on job and poll for result

php
<?php
function submitTryOn(string $garmentUrl, string $personUrl): ?string {
    $apiKey = getenv('TRYONCLOUD_API_KEY');

    // Step 1: Submit job
    $ch = curl_init('https://www.tryoncloud.com/api/tryon');
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Content-Type: application/json',
            'X-API-Key: ' . $apiKey,
        ],
        CURLOPT_POSTFIELDS => json_encode([
            'garment_image_url' => $garmentUrl,
            'person_image_url'  => $personUrl,
        ]),
    ]);
    $response = json_decode(curl_exec($ch), true);
    curl_close($ch);

    $jobId = $response['job_id'] ?? null;
    if (!$jobId) return null;

    // Step 2: Poll for result (max 30s)
    for ($i = 0; $i < 10; $i++) {
        sleep(3);
        $ch = curl_init("https://www.tryoncloud.com/api/result/{$jobId}");
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HTTPHEADER => ['X-API-Key: ' . $apiKey],
        ]);
        $result = json_decode(curl_exec($ch), true);
        curl_close($ch);

        if (($result['status'] ?? '') === 'complete') {
            return $result['result_url'];
        }
    }
    return null;
}

Things to know

  • No pre-built UI — you build the frontend button and result display
  • Server must allow outbound HTTPS to api.tryoncloud.com
  • PHP cURL or Guzzle required for HTTP requests

Frequently asked questions

Does TryOnCloud provide a PHP SDK?

Not yet — a Composer package is on the roadmap. For now, the REST API is straightforward enough that a full SDK is not necessary. The code examples above cover the full integration.

Can I use Laravel's HTTP client instead of cURL?

Yes. Use Http::withHeaders(['X-API-Key' => config('services.tryoncloud.key')])->post('https://www.tryoncloud.com/api/tryon', [...]).

How do I handle the try-on result in a Laravel queue job?

Use the webhook_url option — pass your Laravel webhook route URL in the API request. TryOnCloud will POST the result to your endpoint when processing completes, eliminating the need to poll.

Ready to add virtual try-on to your Custom PHP store?

Join hundreds of fashion merchants reducing returns and boosting conversions with TryOnCloud. Start free — no credit card required.

Get started free

Other integrations