PHP

Get started with Orshot PHP SDK


Installation#

composer require rishimohan/orshot

Initialise#

<?php
require 'vendor/autoload.php';
use Orshot\Client;

$client = new Client("<ORSHOT_API_KEY>");

renderFromStudioTemplate#

Render from a custom Studio template. Supports image, PDF, video generation and publishing to social accounts.

Generate Image#

$response = $client->renderFromStudioTemplate([
  'templateId' => 1234,
  'modifications' => [
    'title' => 'Orshot Studio',
    'description' => 'Generate images from custom templates',
  ],
  'response' => [ 'type' => 'url', 'format' => 'png', 'scale' => 2 ],
]);

Generate PDF#

$response = $client->renderFromStudioTemplate([
  'templateId' => 1234,
  'modifications' => [ 'title' => 'Invoice #1234' ],
  'response' => [ 'type' => 'url', 'format' => 'pdf' ],
  'pdfOptions' => [
    'margin' => '20px',
    'rangeFrom' => 1,
    'rangeTo' => 2,
    'colorMode' => 'rgb',
    'dpi' => 300,
  ],
]);

Generate Video#

$response = $client->renderFromStudioTemplate([
  'templateId' => 1234,
  'modifications' => [
    'videoElement' => 'https://example.com/custom-video.mp4',
    'videoElement.trimStart' => 0,
    'videoElement.trimEnd' => 10,
  ],
  'response' => [ 'type' => 'url', 'format' => 'mp4' ],
  'videoOptions' => [
    'trimStart' => 0,
    'trimEnd' => 20,
    'muted' => false,
    'loop' => true,
    'fps' => 30,
    'audioSource' => 'https://example.com/audio.mp3',
  ],
]);

Publish to Social Accounts#

$response = $client->renderFromStudioTemplate([
  'templateId' => 1234,
  'modifications' => [ 'title' => 'Check out our latest update!' ],
  'response' => [ 'type' => 'url', 'format' => 'png' ],
  'publish' => [
    'accounts' => [1, 2],
    'content' => 'Check out our latest design!',
  ],
]);
// $response['publish'] => [[ 'platform' => 'twitter', 'username' => 'acmehq', 'status' => 'published' ], ...]

Schedule a Post#

$response = $client->renderFromStudioTemplate([
  'templateId' => 1234,
  'modifications' => [ 'title' => 'Scheduled post' ],
  'response' => [ 'type' => 'url', 'format' => 'png' ],
  'publish' => [
    'accounts' => [1],
    'content' => 'This will be posted later!',
    'schedule' => [ 'scheduledFor' => '2026-04-01T10:00:00Z' ],
    'timezone' => 'America/New_York',
  ],
]);

Parameters#

keyrequireddescription
templateIdYesID of the Studio template.
modificationsNoArray of dynamic modifications for the template.
response.typeNobase64, binary, url (Defaults to url).
response.formatNopng, webp, jpg, jpeg, avif, pdf, mp4, webm, gif (Defaults to png).
response.scaleNoScale of the output (1 = original, 2 = double). Defaults to 1.
response.includePagesNoPage numbers to render for multi-page templates (e.g. [1, 3]).
response.fileNameNoCustom file name (without extension). Works with url and binary types.
pdfOptions.marginNoCSS margin value (e.g. "20px").
pdfOptions.rangeFromNoStart page number for PDF output.
pdfOptions.rangeToNoEnd page number for PDF output.
pdfOptions.colorModeNorgb or cmyk.
pdfOptions.dpiNoDPI for print quality (e.g. 300).
videoOptions.trimStartNoTrim start time in seconds.
videoOptions.trimEndNoTrim end time in seconds.
videoOptions.mutedNoMute audio track.
videoOptions.loopNoLoop the video.
videoOptions.durationNoTotal video duration in seconds.
videoOptions.fpsNoFrames per second (1-30).
videoOptions.qualityNoVideo quality (1-100).
videoOptions.audioSourceNoExternal audio URL or array of per-page audio sources.
videoOptions.subtitleSourceNoSubtitle file URL.
videoOptions.combinePagesNoCombine multi-page templates into a single video.
videoOptions.pageTransitionNoTransition effect between pages (e.g. "fade", "dissolve", "wipe", "slide").
videoOptions.pageTransitionDurationNoTransition duration in seconds (0.1-2).
publish.accountsNoArray of social account IDs from your workspace.
publish.contentNoCaption/text for the social post.
publish.isDraftNotrue to save as draft instead of publishing.
publish.schedule.scheduledForNoISO date string to schedule the post.
publish.timezoneNoTimezone string (e.g. "America/New_York").
publish.platformOptionsNoPer-account options keyed by account ID.

renderFromTemplate#

Render from a pre-built Orshot template.

$response = $client->renderFromTemplate([
  'templateId' => 'open-graph-image-1',
  'modifications' => [
    'title' => 'Orshot',
    'description' => 'Create Visuals and Automate Image Generation',
  ],
  'responseType' => 'url',
  'responseFormat' => 'png',
]);
keyrequireddescription
templateIdYesID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...)
modificationsYesModifications for the selected template.
responseTypeNobase64, binary, url (Defaults to url).
responseFormatNopng, webp, pdf, jpg, jpeg, avif (Defaults to png).

For available templates and their modifications refer Orshot Templates Page


generateSignedUrl#

Generate a signed URL for a template.

$response = $client->generateSignedUrl([
  'templateId' => 'open-graph-image-1',
  'modifications' => [ 'title' => 'Hello World' ],
  'expiresAt' => 1744276943,
  'renderType' => 'images',
  'responseFormat' => 'png',
]);
keyrequireddescription
templateIdYesID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...)
modificationsYesModifications for the selected template.
expiresAtYesExpires at in unix timestamp (Number).
renderTypeNoimages, pdfs (Defaults to images).
responseFormatNopng, webp, pdf, jpg, jpeg, avif (Defaults to png).

Ready to automate?

Start rendering images, PDFs and videos from your templates in under 2 minutes. Free plan, no credit card.

Get your API key
  • Image, PDF and video generation via API
  • Visual editor with AI and smart layouts
  • Zapier, Make, MCP and 50+ integrations
  • White-label embed for your own app
  • 30 free credits — no credit card required