Skip to main content
POST
/
api
/
v1
/
components
Create a new component
const options = {
  method: 'POST',
  headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    type: 'chat',
    name: 'My Study Component',
    config: {
      model: 'gpt-4o-mini-2024-07-18',
      materials: ['<string>'],
      folders: ['<string>'],
      systemPrompt: '<string>',
      temperature: 1,
      maxTokens: 123,
      enableWebSearch: true,
      enableRAGSearch: true,
      enableHistory: true,
      enableVoice: true,
      enableFollowUps: true,
      enableComponentCreation: true,
      maxSteps: 123,
      enableGuardrails: true,
      enableMessageGrading: true,
      guardrailRules: [
        {
          id: 'rule-1',
          description: 'No direct homework answers',
          condition: 'The AI response provides direct answers to homework',
          action: 'block',
          message: 'I cannot provide direct answers to homework questions.'
        }
      ],
      enableReferenceMode: true
    },
    description: 'A component for studying biology',
    metadata: {}
  })
};

fetch('https://studyfetchapi.com/api/v1/components', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "_id": "<string>",
  "componentId": "<string>",
  "type": "chat",
  "name": "<string>",
  "organization": "<string>",
  "config": {},
  "status": "active",
  "usage": {},
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "description": "<string>"
}

Authorizations

x-api-key
string
header
required

API Key for authentication

Body

application/json
type
enum<string>
required

Type of component to create

Available options:
chat,
data_analyst,
flashcards,
scenarios,
practice_test,
audio_recap,
tutor_me,
explainers,
uploads,
chat_analytics
name
string
required

Name of the component

Example:

"My Study Component"

config
object
required

Component-specific configuration

  • Option 1
  • Option 2
  • Option 3
  • Option 4
  • Option 5
  • Option 6
  • Option 7
  • Option 8
  • Option 9
  • Option 10
description
string

Component description

Example:

"A component for studying biology"

metadata
object

Additional metadata

Response

201 - application/json

Component created successfully

_id
string
required

Component ID (MongoDB ObjectId)

componentId
string
required

Unique component identifier

type
enum<string>
required

Component type

Available options:
chat,
data_analyst,
flashcards,
scenarios,
practice_test,
audio_recap,
tutor_me,
explainers,
uploads,
chat_analytics
name
string
required

Component name

organization
string
required

Organization ID

config
object
required

Component configuration

status
enum<string>
required

Component status

Available options:
active,
inactive,
draft
usage
object
required

Usage statistics

createdAt
string<date-time>
required

Creation timestamp

updatedAt
string<date-time>
required

Last update timestamp

description
string

Component description