### Setup Next.js Project and Install Dependencies Source: https://orshot.com/docs/examples/instant-polaroid-app Use create-next-app to scaffold a new Next.js project and install necessary dependencies like framer-motion, lucide-react, jszip, clsx, and tailwind-merge. ```bash npx create-next-app@latest instant-polaroid cd instant-polaroid npm install framer-motion lucide-react jszip clsx tailwind-merge ``` -------------------------------- ### Quick Start Render Request Source: https://orshot.com/docs/api-reference/render-from-studio-template A minimal request example including template ID, dynamic modifications, and response format. ```javascript const res = await fetch("https://api.orshot.com/v1/studio/render", { method: "POST", headers: { "Content-Type": "application/json", Authorization: "Bearer ", }, body: JSON.stringify({ templateId: , modifications: { title: "Custom Title", imageUrl: "https://acme.com/cover.png", }, response: { type: "url", format: "png" }, }), }); const { data } = await res.json(); // data.content → the rendered image URL ``` -------------------------------- ### Install Node.js SDK Source: https://orshot.com/docs/sdks/node Use npm to install the SDK package. ```bash npm install @orshot/sdk ``` -------------------------------- ### Dynamic URL Examples Source: https://orshot.com/docs/integrations/dynamic-urls Basic usage examples for generating images with text replacements and smart resizing. ```markdown https://api.orshot.com/v1/studio/dynamic-url/hello-world.png?templateId=123&title=Hello%20World&subtitle=Welcome&sign=abc123def456 ``` ```markdown https://api.orshot.com/v1/studio/dynamic-url/story.png?templateId=123&title=Hello%20World&sign=abc123def456&size=instagram-story ``` -------------------------------- ### Install Skill Globally Source: https://orshot.com/docs/integrations/agent-skill Make the skill available across all projects by installing it globally. ```bash npx skills add orshot-hq/orshot-agent-skills -g ``` -------------------------------- ### Start Development Server (Bash) Source: https://orshot.com/docs/examples/instant-polaroid-app Run this command in your terminal to start the Next.js development server. ```bash npm run dev ``` -------------------------------- ### Install Orshot SDK Source: https://orshot.com/docs/sdks/node Choose the package manager command to install the Orshot SDK. ```bash npm install --save orshot ``` ```bash yarn add orshot ``` ```bash pnpm install orshot ``` -------------------------------- ### React component setup Source: https://orshot.com/docs/orshot-embed/custom-asset-picker Initial setup for handling the embed within a React component. ```jsx import { useEffect, useRef, useState } from "react"; function EmbedWithAssetPicker() { const iframeRef = useRef(null); const [pickerState, setPickerState] = useState(null); ``` -------------------------------- ### Configure All PDF Options Source: https://orshot.com/docs/pdf-generation/pdf-options A comprehensive example showing the structure of the pdfOptions object. ```json { "pdfOptions": { "margin": "20px", "dpi": 300, "colorMode": "rgb", "rangeFrom": 1, "rangeTo": 5 } } ``` -------------------------------- ### Install Orshot CLI Source: https://orshot.com/docs/integrations/orshot-cli Install the CLI globally using npm. ```bash npm install -g orshot-cli ``` -------------------------------- ### Non-Interactive Installation Source: https://orshot.com/docs/integrations/agent-skill Perform an automated installation suitable for CI/CD pipelines or scripting. ```bash npx skills add orshot-hq/orshot-agent-skills -g -y -a cursor ``` -------------------------------- ### Install Orshot SDK Source: https://orshot.com/docs/sdks/node Use npm to install the Orshot package. ```bash npm ``` -------------------------------- ### List Installed Skills Source: https://orshot.com/docs/integrations/agent-skill Displays all currently installed agent skills. ```bash npx skills list ``` -------------------------------- ### Search Brand Assets with JavaScript Source: https://orshot.com/docs/api-reference/brand-assets-search Examples of performing GET requests to search for assets, filter by type, or list all assets of a specific type. ```javascript await fetch("https://api.orshot.com/v1/brand-assets/search?query=logo", { method: "GET", headers: { "Content-Type": "application/json", Authorization: "Bearer ", }, }); ``` ```javascript await fetch( "https://api.orshot.com/v1/brand-assets/search?query=primary&types=color,font", { method: "GET", headers: { "Content-Type": "application/json", Authorization: "Bearer ", }, } ); ``` ```javascript // Omit query to list all assets of the given type await fetch("https://api.orshot.com/v1/brand-assets/search?types=font", { method: "GET", headers: { "Content-Type": "application/json", Authorization: "Bearer ", }, }); ``` -------------------------------- ### Initialize Orshot Client Source: https://orshot.com/docs/sdks/ruby Setup the client instance using your API key. ```ruby require 'orshot' client = Orshot::Client.new('') ``` -------------------------------- ### Publishing Configuration Examples Source: https://orshot.com/docs/publish/publish-from-api Configure the publish object for instant posts, drafts, or scheduled content. ```js publish: { accounts: [1, 3], content: "Just shipped a new feature! 🚀" } // → [{ platform: "twitter", username: "acmehq", status: "published" }, // { platform: "linkedin", username: "acmehq", status: "published" }] ``` ```js publish: { accounts: [1, 2], content: "Draft post — review before publishing", isDraft: true } // → [{ platform: "twitter", username: "acmehq", status: "drafted" }, // { platform: "instagram", username: "acmeinsta", status: "drafted" }] ``` ```js publish: { accounts: [1, 2], content: "Launching next week!", schedule: { scheduledFor: "2030-01-15T14:00:00Z" }, timezone: "America/New_York" } // → [{ platform: "twitter", username: "acmehq", status: "scheduled" }, // { platform: "instagram", username: "acmeinsta", status: "scheduled" }] ``` -------------------------------- ### Real-World Implementation Examples Source: https://orshot.com/docs/dynamic-parameters/link Practical use cases for marketing flyers, product catalogs, and reports. ```json { "modifications": { "headline": "Limited Time Offer!", "cta_text": "Shop Now", "cta_text.href": "https://store.example.com/sale", "cta_text.fontSize": "28px", "cta_text.color": "#ffffff", "cta_text.backgroundColor": "#ff6600" }, "response": { "format": "pdf", "type": "url" } } ``` ```json { "modifications": { "product1_image.href": "https://shop.com/products/item-1", "product1_name": "Wireless Headphones", "product1_name.href": "https://shop.com/products/item-1", "product2_image.href": "https://shop.com/products/item-2", "product2_name": "Smart Watch", "product2_name.href": "https://shop.com/products/item-2" }, "response": { "format": "pdf" } } ``` ```json { "modifications": { "page1@source1.href": "https://research.com/paper/123", "page1@source1": "[1] Latest AI Research", ``` -------------------------------- ### Full Example (Node.js) Source: https://orshot.com/docs/developers/authorization-code This example demonstrates the complete Authorization Code flow using Node.js and Express. It handles redirecting the user to Orshot for authorization, storing the code verifier, and exchanging the authorization code for tokens. ```javascript import crypto from "crypto"; import express from "express"; const app = express(); const CLIENT_ID = process.env.ORSHOT_CLIENT_ID; const CLIENT_SECRET = process.env.ORSHOT_CLIENT_SECRET; const REDIRECT_URI = "http://localhost:3000/callback"; // Store verifiers by state (use a proper session store in production) const pendingAuth = new Map(); app.get("/login", (req, res) => { const state = crypto.randomBytes(16).toString("hex"); const codeVerifier = crypto.randomBytes(32).toString("base64url"); const codeChallenge = crypto .createHash("sha256") .update(codeVerifier) .digest("base64url"); pendingAuth.set(state, codeVerifier); const url = new URL("https://orshot.com/oauth/authorize"); url.searchParams.set("client_id", CLIENT_ID); url.searchParams.set("redirect_uri", REDIRECT_URI); url.searchParams.set("response_type", "code"); url.searchParams.set("code_challenge", codeChallenge); url.searchParams.set("code_challenge_method", "S256"); url.searchParams.set("scope", "workspace:read render:generate"); url.searchParams.set("state", state); res.redirect(url.toString()); }); app.get("/callback", async (req, res) => { const { code, state } = req.query; const codeVerifier = pendingAuth.get(state); if (!codeVerifier) { return res.status(400).send("Invalid state"); } pendingAuth.delete(state); const response = await fetch("https://api.orshot.com/v1/oauth/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ grant_type: "authorization_code", client_id: CLIENT_ID, client_secret: CLIENT_SECRET, code, redirect_uri: REDIRECT_URI, code_verifier: codeVerifier, }), }); const tokens = await response.json(); // Store tokens securely — tokens.access_token, tokens.refresh_token res.json({ success: true, workspace_ids: tokens.workspace_ids }); }); app.listen(3000); ``` -------------------------------- ### Install Orshot PHP SDK Source: https://orshot.com/docs/sdks/php Use Composer to install the Orshot package in your project. ```bash composer require rishimohan/orshot ``` -------------------------------- ### URL Validation Examples Source: https://orshot.com/docs/dynamic-parameters/link Examples of valid and invalid URL formats for the .href parameter. ```json { "link.href": "https://example.com", "link.href": "http://example.com", "link.href": "https://example.com/path/to/page", "link.href": "https://example.com?param=value", "link.href": "https://subdomain.example.com" } ``` ```json { "link.href": "", // Empty string "link.href": " ", // Whitespace only "link.href": "not-a-url", // Missing protocol "link.href": "ftp://example.com" // Unsupported protocol } ``` -------------------------------- ### Install Orshot Ruby SDK Source: https://orshot.com/docs/sdks/ruby Installation methods for the Orshot gem via Gemfile or command line. ```ruby gem 'orshot' ``` ```bash bundle install ``` ```bash gem install orshot ``` -------------------------------- ### Combine All Video Parameters Source: https://orshot.com/docs/dynamic-parameters/video Example showing multiple video parameters applied to a single template. ```json { "templateId": "your-template-id", "modifications": { "bgVideo": "https://example.com/product-demo.mp4", "bgVideo.trimStart": 0, "bgVideo.trimEnd": 10, "bgVideo.muted": false, "bgVideo.loop": false, "title": "Product Launch", "title.fontSize": "48px" }, "response": { "type": "url", "format": "mp4" } } ``` -------------------------------- ### REST API Integration Example Source: https://orshot.com/docs/dynamic-parameters/content-type This example demonstrates how to use the Orshot REST API to render a template with dynamic modifications, including setting content types for elements. ```bash curl -X POST https://api.orshot.com/v1/studio/render \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "templateId": "your-template-id", "modifications": { "slot": "https://example.com/image.png", "slot.contentType": "image", "slot.objectFit": "contain" }, "response": { "format": "png", "type": "url" } }' ``` -------------------------------- ### GET /templates/all Source: https://orshot.com/docs/api-reference/studio-templates-list Retrieves a list of all studio templates available to the authenticated workspace. ```APIDOC ## GET /templates/all ### Description Retrieves a list of all studio templates. Each template includes details such as dimensions, tags, thumbnail URLs, and arrays for page data and available modifications. ### Method GET ### Endpoint /templates/all ### Response #### Success Response (200) - **id** (Integer) - Unique identifier for the template - **created_at** (String) - Timestamp when the template was created - **workspace_id** (String) - ID of the workspace the template belongs to - **user_id** (String) - ID of the user who created the template - **canvas_width** (Number) - Width of the template canvas in pixels - **canvas_height** (Number) - Height of the template canvas in pixels - **updated_at** (String) - Timestamp when the template was last updated - **name** (String) - Name of the template - **description** (String) - Description of the template - **tags** (Array) - Array of tag strings assigned to the template - **thumbnail_url** (String) - URL to the template's thumbnail image - **embed_user_id** (String) - Internal ID of the embed user - **pages_data** (Array) - Array of page objects - **modifications** (Array) - Array of available modification objects ### Error Handling - **400**: Invalid page/limit parameters - **403**: Missing or invalid API key or no studio templates found in workspace ### Rate Limits - **Limit**: 30 requests per minute per API key. ``` -------------------------------- ### GET /v1/studio/templates Source: https://orshot.com/docs/developers/oauth-endpoints Retrieves a list of available studio templates. ```APIDOC ## GET /v1/studio/templates ### Description Retrieves a list of available studio templates. ### Method GET ### Endpoint /v1/studio/templates ### Parameters #### Required Scope - workspace:templates:read ``` -------------------------------- ### Loading State Implementation Source: https://orshot.com/docs/orshot-embed/integration React example showing how to display a loading indicator while the iframe initializes. ```jsx function DesignEditor() { const [isLoading, setIsLoading] = useState(true); return (
{isLoading && (
Loading design editor...
)}