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('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": {},
  "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

Response

201
application/json

Material uploaded successfully

The response is of type object.