Attach a material to a session.

Open in ChatGPT Open in ChatGPT to ask questions about this page
Open in Claude Open in Claude to ask questions about this page
Copy as MarkdownCopy this page as markdown to use with AI assistants
View as Markdown Open this page as markdown in a new tab

Attaches one material to a course lesson or live workshop. Send sessionId and the keys of one source (library file, WorkDrive file, link, embed or recording). Supported types for a live session are presentation, video and PDF only. An on-demand lesson also supports image, document, spreadsheet, zip, audio, link and embed. The same create path is used when the trainer UI adds materials through Update Session.

Endpoint

post https://{TrainerCentral-API-Domain}/tc/api/v1/trainer/sessionMaterials.json

OAuth Scope

TrainerCentral.sessionapi.CREATECopied!

Headers

tc-orgIdstring(Required)

ID of the academy (orgId).

Example
51517414

Request Body

application/json
sessionMaterialJSON Object(Required)

The material to attach: sessionId and the keys of one source.

Hide Sub-Attributes
sessionIdlong(Required)

ID of the lesson or live session.

resourceTypeinteger(Optional)

Type of the material. For a live session only presentation, video and PDF are supported. For an on-demand lesson, link, embed, image, document, spreadsheet, zip and audio are also supported. Allowed: 1=Presentation, 5=PDF, 6=Video, 7=Link (on-demand), 9=Image (on-demand), 11=Document (on-demand), 12=Spreadsheet (on-demand), 13=ZIP (on-demand), 14=Audio (on-demand), 15=Embed (on-demand). Default 1.

viewTypeinteger(Optional)

Placement. Allowed: 0=Session content (default), 1=Handout.

materialIdlong(Optional)

Library file source. ID of a file in the academy library.

sessionMaterialIndexinteger(Optional)

Zero-based position of the material. Default: after the existing ones.

resourceIdstring(Optional)

WorkDrive file source. WorkDrive resource ID.

publicLinkIdstring(Optional)

WorkDrive file source. ID of the public link.

downloadUrlstring(Optional)

WorkDrive file source. Download URL of the file.

linkTitlestring(Optional)

Link and embed source (on-demand). Display title; required for a link or embed.

linkAddressstring(Optional)

Link source (on-demand). URL of the web page; required for a link.

embedCodestring(Optional)

Embed source (on-demand). Iframe HTML; required for an embed.

recordingPlayListIdlong(Optional)

Recording source. Recording playlist ID of a past live occurrence.

Request Example

cURL
cURL
Java
Python
Deluge
Copied!
curl --request POST \
  --url https://trainercentral.zoho.com/tc/api/v1/trainer/sessionMaterials.json \
  --header 'Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52' \
  --header 'content-type: application/json' \
  --header 'tc-orgId: 51517414' \
  --data '{"sessionMaterial":{"sessionId":3000000000050,"materialId":3000000000120,"resourceType":5,"viewType":0,"sessionMaterialIndex":0}}'

Body Parameters

Live session or on-demand: attach a library PDF (supported on live sessions).

Live session or on-demand: attach a library PDF (supported on live sessions).

Live session or on-demand: attach a presentation (supported on live sessions).

Live session or on-demand: attach a video (supported on live sessions).

Attach a WorkDrive PDF (supported on live sessions when resourceType is 5).

On-demand only: attach a link.

On-demand only: attach an embed.

On-demand only: attach a link as a handout.

On-demand: attach a recording from a past live occurrence.

Copied!
  {
    "sessionMaterial": {
      "sessionId": 3000000000050,
      "materialId": 3000000000120,
      "resourceType": 5,
      "viewType": 0,
      "sessionMaterialIndex": 0
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000050,
      "materialId": 3000000000125,
      "resourceType": 1,
      "viewType": 0
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000050,
      "materialId": 3000000000126,
      "resourceType": 6,
      "viewType": 0
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000040,
      "resourceId": "abcdefghijklmnopqrstuvwxyz01234567890",
      "publicLink": "https://workdrive.example.com/file/abcde12345",
      "publicLinkId": "linkabcde12345",
      "downloadUrl": "https://workdrive.example.com/download/abcde12345",
      "resourceType": 5,
      "viewType": 0
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000040,
      "resourceType": 7,
      "linkTitle": "Reference Article",
      "linkAddress": "https://www.example.com/article",
      "viewType": 0
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000040,
      "resourceType": 15,
      "linkTitle": "Interactive Demo",
      "embedCode": "<iframe src=\"https://www.example.com/embed\" width=\"600\" height=\"400\"></iframe>",
      "viewType": 0
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000040,
      "resourceType": 7,
      "linkTitle": "First link",
      "linkAddress": "https://www.example.com/handout",
      "viewType": 1
    }
  }
                
  {
    "sessionMaterial": {
      "sessionId": 3000000000040,
      "recordingPlayListId": 3000000000090,
      "viewType": 0
    }
  }
                
▼ Show full

Response Parameters

sessionMaterialJSON Object

One attachment. Returned for a get, a link or embed update, or a text material update.

Hide Sub-Attributes
sessionMaterialIdstring

ID of the attachment (sessionMaterialId).

idstring

Same as sessionMaterialId.

sessionIdstring

ID of the lesson or live session.

sessionstring

Same as sessionId.

materialIdstring

ID of the file record (materials[].id). Absent for links and embeds.

materialstring

Same as materialId.

resourceIdstring

ID of the stored file or, for a test (resourceType 20), the test form UUID.

resourceTypestring

Type of the material. Live sessions use presentation, video and PDF only; on-demand lessons may also use link, embed, image, document, spreadsheet, zip, audio, rich text, recorded video and test. Allowed: 1=Presentation, 5=PDF, 6=Video, 7=Link, 8=Recorded video, 9=Image, 10=Rich text, 11=Document, 12=Spreadsheet, 13=ZIP, 14=Audio, 15=Embed (iframe), 20=Test.

viewTypestring

Placement of the material. Allowed: 0=Session content, 1=Handout, 2=Assessment (tests), 4=Instruction (assignment lessons).

sessionMaterialIndexstring

Zero-based position of the material in the session.

topicstring

Display name of the material: the file name or the link title.

linkTitlestring

Title of a link (resourceType 7) or embed (resourceType 15).

linkAddressstring

URL of a link material (resourceType 7).

embedCodestring

Iframe HTML of an embed material (resourceType 15).

isDeletedstring

true when the file was deleted from the library.

timestring

Time attached, in epoch milliseconds.

materialJSON Object

File record of sessionMaterial. Absent for links and embeds.

Hide Sub-Attributes
idstring

ID of the file record.

namestring

File name of the material.

materialTypestring

Type of the file. Allowed: 1=Presentation, 5=PDF, 6=Video, 8=Recorded video, 9=Image, 10=Rich text, 11=Document, 12=Spreadsheet, 13=ZIP, 14=Audio, 15=Subtitle.

sizestring

File size in bytes.

statusstring

Processing status. Allowed: -1=Scheduled, 0=Processing, 1=Uploaded, 2=Failed, 3=Converting, 4=Ready, 5=No preview.

renderingServicestring

Internal rendering service code.

storageServicestring

Internal storage service code.

sessionMaterialsJSON Array

Attachments of the session. Returned after an add, a reorder or a new text material.

Hide Sub-Attributes
JSON Object
Show Sub-Attributes
sessionMaterialIdstring

ID of the attachment (sessionMaterialId).

idstring

Same as sessionMaterialId.

sessionIdstring

ID of the lesson or live session.

sessionstring

Same as sessionId.

materialIdstring

ID of the file record (materials[].id). Absent for links and embeds.

materialstring

Same as materialId.

resourceIdstring

ID of the stored file or, for a test (resourceType 20), the test form UUID.

resourceTypestring

Type of the material. Live sessions use presentation, video and PDF only; on-demand lessons may also use link, embed, image, document, spreadsheet, zip, audio, rich text, recorded video and test. Allowed: 1=Presentation, 5=PDF, 6=Video, 7=Link, 8=Recorded video, 9=Image, 10=Rich text, 11=Document, 12=Spreadsheet, 13=ZIP, 14=Audio, 15=Embed (iframe), 20=Test.

viewTypestring

Placement of the material. Allowed: 0=Session content, 1=Handout, 2=Assessment (tests), 4=Instruction (assignment lessons).

sessionMaterialIndexstring

Zero-based position of the material in the session.

topicstring

Display name of the material: the file name or the link title.

linkTitlestring

Title of a link (resourceType 7) or embed (resourceType 15).

linkAddressstring

URL of a link material (resourceType 7).

embedCodestring

Iframe HTML of an embed material (resourceType 15).

isDeletedstring

true when the file was deleted from the library.

timestring

Time attached, in epoch milliseconds.

materialsJSON Array

File records of the file-based entries.

Hide Sub-Attributes
JSON Object
Show Sub-Attributes
idstring

ID of the file record.

namestring

File name of the material.

materialTypestring

Type of the file. Allowed: 1=Presentation, 5=PDF, 6=Video, 8=Recorded video, 9=Image, 10=Rich text, 11=Document, 12=Spreadsheet, 13=ZIP, 14=Audio, 15=Subtitle.

sizestring

File size in bytes.

statusstring

Processing status. Allowed: -1=Scheduled, 0=Processing, 1=Uploaded, 2=Failed, 3=Converting, 4=Ready, 5=No preview.

renderingServicestring

Internal rendering service code.

storageServicestring

Internal storage service code.

errorJSON Object

Error details.

Hide Sub-Attributes
codestring

Deprecated numeric error code (for example ST_202). Prefer codeStr; omitted from doc samples.

codeStrstring

Error code name (ShowtimeErrorCode / err_code_str), for example MISSING_PARAMETER.

messagestring

Error message.

Possible Error Codes

HTTP CodeError CodeDescription
500ST_81

CREATE_SESSION_MATERIAL_FAILED - A link needs linkTitle and linkAddress, an embed needs linkTitle and embedCode, or materialId does not exist. Send the required keys. Do not retry unchanged.

ST_406

FEATURE_NOT_AVAILABLE - Handouts (viewType 1) for live sessions are not on the academy plan. Upgrade the plan or send viewType 0. Do not retry unchanged.

ST_30

UNAUTHORIZED_RESOURCE_ACCESS - The user cannot read the WorkDrive file or recording. Share it with the user or pick another. Do not retry unchanged.

ST_79

INVALID_SESSION - sessionId in the body does not match a session in this academy. Pass a valid sessionId. Do not retry unchanged.

ST_401

SESSION_DELETED - The session was deleted. Use a session that is not deleted. Do not retry unchanged.

ST_102

UNAUTHORISED_ACCESS - The user is not an academy owner or admin, the primary trainer of the workshop, or, for a lesson, a course admin or trainer. Call with one of these roles; do not retry unchanged.

Response Example

Response after attaching a library PDF.

200
200
400
500
Copied!
  {
    "sessionMaterials": [
      {
        "sessionMaterialId": "3000000000110",
        "id": "3000000000110",
        "sessionId": "3000000000040",
        "session": "3000000000040",
        "materialId": "3000000000120",
        "material": "3000000000120",
        "resourceType": "5",
        "viewType": "0",
        "sessionMaterialIndex": "0",
        "topic": "Module 1 Slides.pdf",
        "time": "1782727715513"
      }
    ],
    "materials": [
      {
        "id": "3000000000120",
        "name": "Module 1 Slides.pdf",
        "materialType": "5",
        "size": "204800",
        "status": "4"
      }
    ]
  }
                
  {
    "error": {
      "code": "string",
      "codeStr": "string",
      "message": "string"
    }
  }
                
500 Request failed; see the error code.
▼ Show full