OAuth code examples
Working requests for the authorize, token, refresh and introspect calls.
Published ·Updated
For workspace-specific endpoints, use the x-workspace-id header to target a specific workspace. If omitted, the first authorized workspace is used. If you name a workspace the token cannot access, the call fails with 403 workspace_not_accessible.
Get Current User#
const response = await fetch("https://api.orshot.com/v1/me", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
const { data } = await response.json();
// { user_id: "...", email: "john@example.com", name: "John Doe",
// workspaces: [{ id: 50, name: "Acme", slug: "acme" }], plan: { ... } }List Templates#
const response = await fetch("https://api.orshot.com/v1/studio/templates", {
headers: {
Authorization: `Bearer ${accessToken}`,
"x-workspace-id": "50", // Optional: target specific workspace
},
});
const templates = await response.json();
// [{ id: "123", name: "Social Card", ... }, ...]Render Studio Template#
const response = await fetch("https://api.orshot.com/v1/studio/render", {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
"x-workspace-id": "50", // Optional: target specific workspace
},
body: JSON.stringify({
templateId: "123",
modifications: {
title: "Hello World",
logo: "https://example.com/logo.png",
},
response: {
type: "url",
format: "png",
},
}),
});
const { data } = await response.json();
// data.content is the image URL, for example
// "https://storage.orshot.com/..."Render Combined Multi-Page Video#
const response = await fetch("https://api.orshot.com/v1/studio/render", {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
"x-workspace-id": "50", // Optional: target specific workspace
},
body: JSON.stringify({
templateId: "123",
modifications: {
"page1@title": "Intro",
"page2@title": "Features",
"page3@title": "CTA",
},
response: {
type: "url",
format: "webm",
includePages: [1, 2, 3],
},
videoOptions: {
combinePages: true,
pageTransition: "fade",
pageTransitionDuration: 0.5,
muted: true,
},
}),
});
const data = await response.json();
// { data: { content: "https://.../combined.webm", ... } }Generate Image from a Library Template#
const response = await fetch("https://api.orshot.com/v1/generate/images", {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
"x-workspace-id": "50", // Optional: target specific workspace
},
body: JSON.stringify({
templateId: "open-graph-image-1",
modifications: {
title: "Hello World",
backgroundImageUrl: "https://example.com/photo.jpg",
},
response: { type: "url", format: "png" },
}),
});
const { data } = await response.json();
// data.content is the image URLGenerate with Base64 Response#
const response = await fetch("https://api.orshot.com/v1/generate/images", {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
"x-workspace-id": "50", // Optional: target specific workspace
},
body: JSON.stringify({
templateId: "open-graph-image-1",
modifications: { title: "Hello World" },
response: { type: "base64", format: "png" },
}),
});
const { data } = await response.json();
// data.content: "data:image/png;base64,iVBORw0KGgo..."Get Template Modifications#
const response = await fetch(
"https://api.orshot.com/v1/studio/123/modifications",
{
headers: {
Authorization: `Bearer ${accessToken}`,
"x-workspace-id": "50", // Optional: target specific workspace
},
},
);
const modifications = await response.json();
// [{ key: "title", id: "title", type: "text", description: "..." }, ...]Delete Template#
const response = await fetch(
"https://api.orshot.com/v1/studio/templates/123/delete",
{
method: "DELETE",
headers: {
Authorization: `Bearer ${accessToken}`,
"x-workspace-id": "50", // Optional: target specific workspace
},
},
);
const result = await response.json();
// { message: "Template successfully deleted", id: "123" }Was this page helpful?
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 40+ integrations
- White-label embed for your own app
- 100 free credits a month, no credit card required