Skip to main content
POST
/
api
/
v1
/
components
/
{id}
/
embed
Generate embed code for component
const url = 'https://studyfetchapi.com/api/v1/components/{id}/embed';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
  body: '{"userId":"<string>","groupIds":["class-101","class-102"],"sessionId":"<string>","theme":{"primaryColor":"<string>","secondaryColor":"<string>","backgroundColor":"<string>","textColor":"<string>","fontFamily":"<string>","fontSize":"<string>","borderRadius":"<string>","padding":"<string>","logoUrl":"<string>","hideBranding":true},"features":{"enableWebSearch":true,"enableHistory":true,"enableVoice":true,"enableFollowUps":true,"enableComponentCreation":true,"placeholderText":"<string>","enableWebSearchSources":true,"enableImageSources":true,"enableTranscript":true,"enableOutline":true,"enableBadWordsFilter":true,"enableGuardrails":true,"enablePromptingScore":true,"enableResponsibilityScore":true,"enableReferenceMode":true},"width":"<string>","height":"<string>","expiryHours":1}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
{
  "embedUrl": "<string>",
  "token": "<string>",
  "expiresAt": "2023-11-07T05:31:56Z",
  "componentId": "<string>",
  "componentType": "<string>",
  "options": {
    "width": "<string>",
    "height": "<string>"
  }
}

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

id
string
required

Component ID

Body

application/json
userId
string

User ID for tracking

groupIds
string[]

Group IDs for collaboration

Example:
["class-101", "class-102"]
sessionId
string

Session ID for continuity

theme
object

Theme customization

features
object

Feature toggles

width
string

Embed width (e.g., "100%", "600px")

height
string

Embed height (e.g., "400px", "100vh")

expiryHours
number
default:1

Token expiry time in hours

Response

200 - application/json

Embed code generated successfully

embedUrl
string
required

The embed URL for iframe integration

token
string
required

JWT token for authentication

expiresAt
string<date-time>
required

Token expiration timestamp

componentId
string
required

Component ID

componentType
string
required

Component type

options
object
required

Embed options

I