Skip to main content
POST
/
api
/
v1
/
materials
/
upload
Upload a material file
const url = 'https://studyfetchapi.com/api/v1/materials/upload';
const form = new FormData();
form.append('name', '<string>');
form.append('folderId', '<string>');
form.append('extractImages', 'true');
form.append('references', '<string>');
form.append('file', '{
  "fileName": "example-file"
}');

const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};

options.body = form;

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
{
  "_id": "<string>",
  "name": "<string>",
  "organizationId": "<string>",
  "folderId": "<string>",
  "contentType": "text",
  "content": {
    "text": "<string>",
    "url": "<string>",
    "s3Key": "<string>",
    "s3Url": "<string>",
    "filename": "<string>",
    "fileSize": 123,
    "mimeType": "<string>"
  },
  "metadata": {},
  "status": "active",
  "usage": {},
  "references": [
    {
      "title": "Understanding Photosynthesis",
      "url": "https://example.com/article"
    }
  ],
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z"
}

Authorizations

x-api-key
string
header
required

API Key for authentication

Body

multipart/form-data
file
file
required
name
string
required

Material name

folderId
string

Folder ID (optional)

extractImages
string
default:true

Whether to extract images from files (true/false, default: true)

references
string

JSON string of references array (optional)

Response

Material uploaded successfully

_id
string
required

Material ID

name
string
required

Material name

organizationId
string
required

Organization ID

folderId
string | null
required

Folder ID

contentType
enum<string>
required

Content type

Available options:
text,
pdf,
video,
audio,
image,
epub
content
object
required

Material content

status
enum<string>
required

Material status

Available options:
active,
processing,
pending_upload,
error,
deleted
createdAt
string<date-time>
required

Creation timestamp

updatedAt
string<date-time>
required

Last update timestamp

metadata
object

Material metadata

usage
object

Usage information

references
object[]

References that this material cites

I