Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Android
iOS
Web
Electron

Classroom REST API

This page provides detailed help for the Flexible Classroom RESTful APIs.

Basic information

Server

All requests are sent to the host api.agora.io. See Ensure service reliability for alternate domain names.

Data format

The Content-Type of all requests is application/json.

Authentication

Flexible Classroom Cloud Service uses tokens for authentication. You need to put the corresponding information into the Authorization: agora token= field when sending your HTTP request. For details, see Secure authentication with tokens.

Create a classroom

Description

Call this method to create a classroom. After it is created, the classroom is reserved for five days.

Prototype

  • Method: POST
  • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUuid}

Request parameters

URL parameters

Pass the following parameters in the URL:

ParameterTypeDescription
regionString(Required) The region for connection. Flexible Classroom supports the following regions:
  • cn: Mainland China.
  • ap: Asia Pacific.
  • eu: Europe.
  • na: North America.
appIdString(Required) Agora App ID.
roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins an RTC or RTM channel. The string length must be less than 64 characters. The following characters are supported:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • The numbers 0 to 9.
  • The space character.
  • The following special characters: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Request body parameters

Pass in the following parameters in the request body:

ParameterTypeDescription
roomTypeString(Required) The type of the classroom. You can set the value to :
  • 0: One-to-one classroom.
  • 2: Lecture hall.
  • 4: Small classroom.
  • 10: Small cloud classroom.
Once set, this parameter value cannot be changed.
roomNameString(Required) The name of the classroom. The maximum length of this parameter is 64 characters.
roomPropertiesObject(Optional) The properties of the classroom. It includes the name of the room, room number whiteboard plug-in configuration, chat plug-in configuration, room opening, end time, duration, configuration of the number of people who raise their hands to connect to the microphone, the maximum number of people to connect to the microphone, and the switch status configuration of the device for students to join the room by default, etc.
roomProperties.scheduleObject(Optional) The schedule of the classroom.
roomProperties.schedule.startTimeInteger(Optional) The start timestamp (ms) of the class. Once set, this parameter value cannot be changed.
roomProperties.schedule.durationInteger(Optional) The duration of the class (s).The maximum value is 86,400 seconds, and it is recommended to set it according to the actual duration of the class. If you set the class duration and dragging duration, when recording is turned on, the maximum recording time maxRecordingHour parameter will be set based on the sum of the two and rounded up. See Set the recording state.
roomProperties.schedule.closeDelayInteger(Optional) The delay of the class end time (s). in seconds. When the class duration ends, the class will enter the "End" state (state= 2). At this time, users can still enter and stay in the classroom normally. When the dragging time ends, the class will enter the "closed" state (state= 3) and all users will be kicked out.
roomProperties.processesObject(Optional) The process of inviting students to go "on the stage".
roomProperties.processes.handsUpObject(Optional) The settings of "on the stage".
roomProperties.processes.handsUp.maxAcceptInteger(Optional) The maximum number of students "on the stage".
roomProperties.processes.handsUp.defaultAcceptRoleString(Optional) The default user on the stage. If you hope to set the student on the stage, set it as "audience". If not, set is as "" or do not set this parameter. In the cloud classroom scenario, default is "".
roomProperties.flexPropsObject(Optional) The initial properties of the classroom.The user's backend can pass customized parameters to the room through this parameter.Users can set custom attributes for any classroom based on their own business needs. Flexible Classroom will synchronize changes in this attribute to all clients in the classroom to realize your own business expansion.
roomProperties.widgetsObject(Optional) Settings of the widgets in the classroom.
roomProperties.widgets.netlessBoardObject(Optional) Settings of the whiteboard widget in the classroom.
roomProperties.widgets.netlessBoard.stateInteger(Optional) The state of the whiteboard widget in the classroom:
  • 0: Disabled.
  • 1: Enabled.
  • roomProperties.widgets.easemobIMObject(Optional) Settings of the chat widget in the classroom.
    roomProperties.widgets.easemobIM.stateInteger(Optional) The state of the chat widget in the classroom:
  • 0: Disabled.
  • 1: Enabled.
  • roleConfigObject(Optional) The role configuration.
    roleConfig.2Object(Optional) The configuration of the student role.
    roleConfig.2.limitInteger(Optional) The limit of the number of students.
    roleConfig.2.defaultStreamObject(Optional) The default stream type of the student.
    roleConfig.2.defaultStream.stateInteger(Optional) The state of the default stream type of the student:
  • 0: Disabled.
  • 1: Enabled.
  • roleConfig.2.defaultStream.videoStateInteger(Optional) The video state of the default stream of the student:
  • 0: Disabled.
  • 1: Enabled.
  • roleConfig.2.defaultStream.audioStateInteger(Optional) The audio state of the default stream of the student:
  • 0: Disabled.
  • 1: Enabled.
  • To create a small cloud classroom, the following are the required parameters:


    _16
    {
    _16
    ...
    _16
    "roomName":"{roomName}",
    _16
    "roomType":10,
    _16
    "roleConfig":{
    _16
    "2":{
    _16
    "defaultStream":{
    _16
    "audioState":1,
    _16
    "state":1,
    _16
    "videoState":1
    _16
    },
    _16
    "limit":49
    _16
    }
    _16
    },
    _16
    ...
    _16
    }

    Request example


    _42
    curl -X POST 'https://api.agora.io/{region}/edu/apps/{YourAppId}/v2/rooms/test_room' \
    _42
    -H 'Content-Type: application/json;charset=UTF-8' \
    _42
    -H 'Authorization: agora token={educationToken}' \
    _42
    --data-raw '{
    _42
    "roomName": "test_class",
    _42
    "roomType": 4,
    _42
    "roleConfig": { // The audio and video permissions of students joining the room are turned on or off by default.(Optional)
    _42
    "2": {
    _42
    "limit": 50,
    _42
    "defaultStream": {
    _42
    "state": 1,
    _42
    "videoState": 1,
    _42
    "audioState": 1
    _42
    }
    _42
    }
    _42
    },
    _42
    "roomProperties": {
    _42
    "schedule": {
    _42
    "startTime": 1655452800000,
    _42
    "duration": 600,
    _42
    "closeDelay": 300
    _42
    },
    _42
    "processes": {
    _42
    "handsUp": {
    _42
    "maxAccept": 10, //The maximum number of students "on the stage".
    _42
    "defaultAcceptRole": "" //(Optional) The default user on the stage. If you hope to set the student on the stage, set it as "audience". If not, set is as "" or do not set this parameter.In cloud classroom Scenario default is ""
    _42
    }
    _42
    },
    _42
    //The user's backend can pass customized parameters to the room through this parameter.Users can set custom attributes for any classroom based on their own business needs. Flexible Classroom will synchronize changes in this attribute to all clients in the classroom to realize your own business expansion.
    _42
    "flexProps": {
    _42
    "exampleKey": "exampleValue"
    _42
    },
    _42
    "widgets": {//The state of the widgets in the classroom : on or off
    _42
    "netlessBoard": {
    _42
    "state": 0
    _42
    },
    _42
    "easemobIM": {
    _42
    "state": 1
    _42
    }
    _42
    }
    _42
    }
    _42
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerRequest status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringDetailed information about the code.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Note that you can just call the API to create a room, the server will respond with the 200 or 409. 200 means the room is created, 409 means the room has already been created and you can join the classroom.

    Query a classroom

    Description

    Returns all information about the room object.

    Prototype

    • Method: GET
    • Endpoint: {region}/edu/apps/{appId}/v2/rooms/{roomUuid}

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins an RTC or RTM channel. The string length must be less than 64 characters. The following characters are supported:
    • All lowercase English letters: a to z.
    • All uppercase English letters: A to Z.
    • The numbers 0 to 9.
    • The space character.
    • The following special characters: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request example


    _3
    curl -X GET 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class' \
    _3
    -H 'Content-Type: application/json;charset=UTF-8' \
    _3
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    ParameterTypeDescription
    codeIntegerRequest status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringDetailed information about the code.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.
    dataObjectThe returned object, which contains the following data:
    • roomUuid: String, room ID.
    • roomName: String, room name.
    • createTime: Integer, room creation timestamp.
    • roomProperties: Object, room attributes.
      • roomType: Integer, room type.
        • 0: 1 to 1.
        • 2: Large classroom.
        • 4: Small classroom.
        • 10: Small cloud classroom.
      • schedule: Object, lesson plan.
        • state: Integer, room state.
          • 0: Not started.
          • 1: Started.
          • 2: Ended.
          • 3: Closed.
        • startTime: Integer, starting time.
        • endTime: Integer, end time.
        • closeTime: Integer, closing time.
      • widgets: Object, component collection.
        • netlessBoard: Object, whiteboard component.
          • extra: Object, extended information.
            • boardAppId: String, whiteboard App ID.
            • boardId: String, whiteboard room ID.
            • boardToken: String, whiteboard room Token.
            • boardRegion: String, whiteboard area.
          • state: Integer, component state.
            • 0: Integer, not activated.
            • 1: Integer, activated.
        • easemobIM: Object, chat room component.
          • extra: Object, extended information.
            • orgName: String, organization name.
            • appName: String, app name.
            • chatRoomId: String, chat room ID.
            • appKey: String, app Key.
          • state: Integer, component state.
            • 0: Integer, not activated.
            • 1: Integer, activated.

    Response example


    _83
    {
    _83
    "msg": "Success",
    _83
    "code": 0,
    _83
    "ts": 1684231543281,
    _83
    "data": {
    _83
    "roomName": "jasoncai's Room",
    _83
    "roomUuid": "3579768dd1e1eec8522d3ed76992afd04",
    _83
    "scenario": "education",
    _83
    "roleConfig": {
    _83
    ...
    _83
    },
    _83
    "roomProperties": {
    _83
    "reward": {
    _83
    ...
    _83
    },
    _83
    "processes": {
    _83
    "handsUp": {
    _83
    ...
    _83
    },
    _83
    "openCamera": {
    _83
    ...
    _83
    },
    _83
    "remoteControl": {
    _83
    ...
    _83
    },
    _83
    "waveArm": {
    _83
    ...
    _83
    }
    _83
    },
    _83
    "im": {
    _83
    "huanxin": {
    _83
    ...
    _83
    }
    _83
    },
    _83
    "screen": {
    _83
    ...
    _83
    },
    _83
    "groups": {
    _83
    ...
    _83
    },
    _83
    "carousel": {
    _83
    ...
    _83
    },
    _83
    "widgets": {
    _83
    "netlessBoard": {
    _83
    "extra": {
    _83
    ...
    _83
    },
    _83
    "state": 1
    _83
    },
    _83
    "easemobIM": {
    _83
    "extra": {
    _83
    ...
    _83
    }
    _83
    }
    _83
    },
    _83
    "schedule": {
    _83
    "closeDelay": 600,
    _83
    "duration": 1800
    _83
    },
    _83
    "webhookConfig": {
    _83
    ...
    _83
    },
    _83
    "record": {
    _83
    ...
    _83
    },
    _83
    "state": 0,
    _83
    "board": {
    _83
    "info": {
    _83
    ...
    _83
    }
    _83
    },
    _83
    "roomType": 4
    _83
    },
    _83
    "roomTemplate": "edu_medium_v1",
    _83
    "muteChat": {},
    _83
    "muteVideo": {},
    _83
    "muteAudio": {},
    _83
    "state": 0,
    _83
    "checkState": false,
    _83
    "createTime": 1683884683422
    _83
    }
    _83
    }

    Set the classroom state

    Description

    Call this method to set the classroom state: Not started, Started, Ended.

    Prototype

    • Method: PUT
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/states/{state}

    Request parameters

    URL parameters

    Pass the following parameter in the URL.

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z
    • All uppercase English letters: A to Z
    • All numeric characters: 0-9
    • The space character
    • "!", 1"#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    stateInteger(Required) The classroom state:
    • 0: Not started.
    • 1: Started.
    • 2: Ended.
    • 3: The room is closed and users can no longer join the room.

    Request example


    _2
    curl -X PUT 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/states/1' \
    _2
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _7
    "status": 200,
    _7
    "body":
    _7
    {
    _7
    "code": 0,
    _7
    "msg": "Success",
    _7
    "ts": 1610450153520
    _7
    }

    Update custom classroom properties

    Description

    Add or update the custom properties of a specified classroom.

    Prototype

    • Method: PUT
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/properties

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    propertiesObjectClassroom properties.
    roomProperties.examinationUrlString(Optional) The URL of the exam papers used in proctoring exam scenarios.
    causeObjectThe update reason.

    Request example


    _10
    curl -X PUT 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/properties' \
    _10
    -H 'Content-Type: application/json;charset=UTF-8' \
    _10
    -H 'Authorization: agora token={educationToken}' \
    _10
    --data-raw '{
    _10
    "properties": {
    _10
    "key1": "value1",
    _10
    "key2": "value2"
    _10
    },
    _10
    "cause": {}
    _10
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Delete custom classroom properties

    Description

    Delete the custom properties of a specified classroom.

    Prototype

    • Method: DELETE
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/properties

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    propertiesString arrayClassroom properties.
    causeObjectReason for deletion.

    Request example

    Request Body


    _7
    curl -X DELETE 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/properties' \
    _7
    -H 'Content-Type: application/json;charset=UTF-8' \
    _7
    -H 'Authorization: agora token={educationToken}' \
    _7
    --data-raw '{
    _7
    "properties": ["key1", "key2"],
    _7
    "cause": {}
    _7
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Create or remove breakout classrooms

    Description

    Create or remove breakout rooms. Breakout rooms are sessions that are split off from a classroom that allow students to discuss classwork in smaller groups.

    Prototype

    • Method: PUT
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/groups/states/{state}

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) The Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    stateIntegerWhether to enable breakout rooms:
    • 1: Enabled. Set as this value if you want to create breakout rooms.
    • 0: Disabled. Set as this value if you want to remove breakout rooms.

    Request body parameters

    • To create breakout rooms, you need to set state to 1 and pass in the following parameters in the request body.
    • To remove all breakout rooms, you need to set state to 0 and leave the request body blank.
    ParameterTypeDescription
    groupsArray(Required) The breakout rooms to be created. This parameter consists of the following parameters:
    • groupUuid: (Optional) The ID of the breakout room, string type. If you do not provide an ID, an ID is automatically assigned to the breakout room.
    • groupName: (Optional) The name of the breakout room, string type.
    • users: (Required) The user list in the breakout room, array type. This parameter consists of the following parameters:
      • userUuid: (Required) The user ID. This is the unique identifier of the user when logging in to Signaling. The string length must be less than 64 characters. Supported character scopes are the following:
          • All lowercase English letters: a to z.
          • All numeric characters: 0-9
          • The space character.
          • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request example


    _13
    curl -X PUT 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/states/1' \
    _13
    -H 'Authorization: agora token={educationToken}' \
    _13
    --data-raw '{
    _13
    "groups":[
    _13
    {
    _13
    "groupUuid": "group1",
    _13
    "groupName":"Group 01",
    _13
    "users":[{
    _13
    "userUuid": "user1"
    _13
    }]
    _13
    }
    _13
    ]
    _13
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Set the recording state

    Description

    Call this method to start or stop recording a specified classroom.

    Prototype

    • Method: PUT
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/records/states/{state}

    Request parameters

    URL parameters

    Pass the following parameter in the URL.

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    stateInteger(Required) The recording state:
    • 0: Stop recoding.
    • 1: Started.

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    modeString(Optional) The recording mode:
    • Set this parameter as web to enable web page recording mode. The format of recorded files is MP4. When the length of the recorded file reaches around two hours, or when the size of the file exceeds around 2 GB, the recording service automatically creates another MP4 file.
    • If you do not set this parameter, Flexible Classroom records the audio and video of the teachers in composite recording mode by default. The format of recorded files is M3U8 and TS.
    webRecordConfigObject(Optional) When the mode is set as web, you need to set the detailed configuration of the web page recording through webRecordConfig, including the following fields:
    • rootUrl: (Required) String, the root address of the web page to be recorded. During the recording, Agora Edu Cloud Service automatically gets the full address of the web page to be recorded by putting rootUrl, roomUuid, roomType, and other parameters together. If you set both url and rootUrl, url overrides rootUrl.
    • publishRtmp: (Optional) Whether to push the recorded webpage to CDN:
      • true: Yes.
      • false: No.
    • onhold: (Required) Boolean. You can set this parameter as:
      • true: Pauses recording immediately after the web page recording task is enabled. The recording service opens and renders the web page to be recorded, but does not generate a slice file.
      • false: (Default) Enables the web page recording task and starts recording.
    • videoBitrate: (Optional) Number. The bitrate of the video (Kbps). The value range is [50, 8000]. The default value of videoBitrate varies according to the resolution of the output video:
      • If the resolution of the output video is less than 1280 × 720, the default value of videoBitrate is 1500.
      • If the resolution of the output video is greater than or equal to 1280 × 720, the default value of videoBitrate is 2000.
    • videoFps: (Optional) Number. The frame rate of the video (fps). The value range is [5, 60]. The default value is 15.
    • audioProfile: (Optional) Number. The sample rate, encoding mode, number of audio channels, and bitrate.
      • 0: (Default) Sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 48 Kbps.
      • 1: Sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 128 Kbps.
      • 2: Sample rate of 48 kHz, music encoding, stereo, and a bitrate of up to 192 Kbps.
    • videoWidth: Number. The width of the video (pixels). The value range is [480, 1280]. The default value is 1280. The product of videoWidth and videoHeight should not exceed 921,600 (1280 × 720).
    • videoHeight: Number. The height of the video (pixels). The value range is [480, 1280]. The default value is 720. The product of videoWidth and videoHeight should not exceed 921,600 (1280 × 720).
    • maxRecordingHour: Number, the maximum recording length (hours). The value range is [1,720]. If you set the class duration, Agora Edu Cloud Service gets the maximum recording length by rounding up the class duration. For example, if the class duration is 1800 seconds, maxRecordingHour is one hour. If you do not set the class duration, the default value of maxRecordingHour is two hours. If the limit set by maxRecordingHour is exceeded, the recording stops automatically.
    retryTimeoutNumberThe amount of time (seconds) that the Flexible Classroom cloud service waits between tries. The Flexible Classroom cloud service reties twice at most.

    Request example


    _12
    curl -X PUT 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/records/states/1' \
    _12
    -H 'Content-Type: application/json;charset=UTF-8' \
    _12
    -H 'Authorization: agora token={educationToken}' \
    _12
    --data-raw '{
    _12
    "mode": "web",
    _12
    "webRecordConfig": {
    _12
    "url": "https://webdemo.agora.io/xxxxx/?userUuid={recorder_id}&roomUuid={room_id_to_be_recorded}&roleType=0&roomType=4&pretest=false&rtmToken={recorder_token}&language=en&appId={your_app_id}",
    _12
    "rootUrl": "https://xxx.yyy.zzz",
    _12
    "publishRtmp": "true"
    _12
    },
    _12
    "retryTimeout": 60
    _12
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.
    dataObjectThe returned object, which contains the following data:
    • recordId: String. The unique identifier of the recording.
    • sid: String. The sid of cloud recording.
    • resourceId: String. The resourceId of cloud recording.
    • state: Integer. The recording state: 0: The recording ends. 1: The recording begins.
    • startTime: Integer. The timestamp (ms) when the recording begins.
    • streamingUrl: Object. The URL address of pulling the CDN stream: rtmp: String. The URL of the RTMP streaming. flv: String. The URL of the FLV streaming. hls: String. The URL of the HLS streaming.

    Response example


    _11
    "status": 200,
    _11
    "body":
    _11
    {
    _11
    "code": 0,
    _11
    "ts": 1610450153520,
    _11
    "streamingUrl": {
    _11
    "rtmp": "",
    _11
    "flv": "",
    _11
    "hls": ""
    _11
    }
    _11
    }

    Update the recording configurations

    Description

    Call this method during the recording to update the recording configurations. Every time this method is called, the previous configurations are overwritten.

    Prototype

    • Method: PATCH
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/records/states/{state}

    Request parameters

    URL parameters

    Pass the following parameter in the URL.

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    webRecordConfigObject(Optional) Recording configurations:
    • onhold: (Required) Boolean. You can set this parameter as:
      • true: Pauses the web page recording. The recording service no longer generates any slice file.
      • false: (Default) Continues the web page recording. After the recording is paused, you can call this method and set the onhold parameter as false to continue the web page recording.

    Request example


    _8
    curl -X PATCH 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/records/states/1' \
    _8
    -H 'Content-Type: application/json;charset=UTF-8' \
    _8
    -H 'Authorization: agora token={educationToken}' \
    _8
    --data-raw '{
    _8
    "webRecordConfig": {
    _8
    "onhold": false
    _8
    }
    _8
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _6
    "status": 200,
    _6
    "body":
    _6
    {
    _6
    "code": 0,
    _6
    "ts": 1610450153520
    _6
    }

    Get the recording list

    Description

    Get the recording list in a specified classroom.

    You can fetch data in batches with the nextId parameter. You can get up to 100 pieces of data for each batch.

    Prototype

    • Method: GET
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/records

    Request parameters

    URL parameters

    Pass the following parameter in the URL.

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Query parameters

    ParameterTypeDescription
    nextIdString(Optional) The starting ID of the next batch of data. When you call this method to get the data for the first time, leave this parameter empty or set it as null. Afterward, you can set this parameter as the nextId that you get in the response of the previous method call.

    Request example


    _8
    curl -X PATCH 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/records/states/1' \
    _8
    -H 'Content-Type: application/json;charset=UTF-8' \
    _8
    -H 'Authorization: agora token={educationToken}' \
    _8
    --data-raw '{
    _8
    "webRecordConfig": {
    _8
    "onhold": false
    _8
    }
    _8
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.
    dataObjectInclude the following parameters:
    • count: Integer, the number of pieces of data in this batch.
    • list: JSONArray. An array of the recording list. A JSON object includes the following parameters:
      • appId: Your Agora App ID.
      • roomUuid: The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel.
      • recordId: The unique identifier of a recording session. A recording session starts when you call a method to start recording and ends when you call this method to stop recording.
      • startTime: The UTC timestamp when a recording session starts, in milliseconds.
      • endTime: The UTC timestamp when a recording session ends, in milliseconds.
      • resourceId: The resourceId of the Agora Cloud Recording service.
      • sid: The sid of the Agora Cloud Recording service.
      • recordUid: The UID used by the Agora Cloud Recording service in the channel.
      • boardAppId: The App Identifier of the Agora Interactive Whiteboard service.
      • boardToken: The SDK Token of the Agora Interactive Whiteboard service.
      • boardId: The unique identifier of a whiteboard session.
      • type: Integer, the recording type:
        • 3: Web Page Recording
      • status: Integer, the recording state:
        • 1: In recording.
        • 2: Recording has ended.
      • url: String, the URL address of the recorded files in composite recording mode.
      • recordDetails: JSONArray. The JSON object contains the following fields:
        • url: String, the URL address of the recorded files in web page recording mode.
      • nextId: String, the starting ID of the next batch of data. If it is null, there is no next batch of data. If it is not null, use this nextId to continue the query until null is reported.
      • total: Integer, the total number of pieces of data.
      • unready: Boolean. true means that recording fails.
    • webRecordingUrlQuery: String. Same as query in webpage recording.

    Response example


    _30
    {
    _30
    "msg":"Success",
    _30
    "code":0,
    _30
    "ts":1706091167911,
    _30
    "data":{
    _30
    "total":1,
    _30
    "list":[
    _30
    {
    _30
    "recordId":"sssssssssss",
    _30
    "appId":"sssssssssss",
    _30
    "roomUuid":"sssssssssss",
    _30
    "startTime":1706079930586,
    _30
    "endTime":1706081355989,
    _30
    "resourceId":"443322222",
    _30
    "sid":"sssssssssss",
    _30
    "recordUid":"sssssssssss",
    _30
    "type":3,
    _30
    "status":2,
    _30
    "url":"https://xxxxxxxx.m3u8",
    _30
    "recordDetails":[
    _30
    {
    _30
    "url":"xxxxxxxxx.mp4"
    _30
    }
    _30
    ],
    _30
    "webRecordUrlQuery":"xxxxxxx"
    _30
    }
    _30
    ],
    _30
    "count":1
    _30
    }
    _30
    }

    Query a specific user

    Prototype

    • Method: GET
    • Endpoint: /{region}/edu/polling/apps/{appId}/v2/rooms/{roomUUid}/users/{userUuid}

    Request parameters

    URL parameters

    Pass the following parameter in the URL.

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
  • cn: Mainland China.
  • ap: Asia Pacific.
  • eu: Europe.
  • na: North America.
  • appIdString(Required) Agora App ID.
    roomUUidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins an RTC or RTM channel. The string length must be less than 64 characters. The following characters are supported:
    • All lowercase English letters: a to z.
    • All uppercase English letters: A to Z.
    • The numbers 0 to 9.
    • The space character.
    • The following special characters: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    userUuidString(Required) The user ID. This is the unique identifier of the user and also the user ID used when logging in to Signaling. The string length must be less than 64 characters. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All numeric characters.
  • 0-9
  • The space character.
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
  • Request example


    _2
    curl -X GET 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/users/test_user' \
    _2
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
  • 0: The request succeeds.
  • Non-zero: The request fails.
  • msgStringThe detailed information.
    dataObjectInclude the following parameters:
    • userUuid: String, the user ID.
    • userName: String, the user name.
    • role: Integer. The user role. This parameter can be set as one of the following values:
      • 1: Teacher.
      • 2: Student.
      • 3: Teaching assistant.
    • streamUuid: String. The ID of the stream, which is also the uid used when joining an Video SDK channel.
    • state: Whether the user is online:
      • 0: Offline.
      • 1: Online.
    • userProperties: Object. The user property.
    • updateTime: Number. The time when the user status is updated, Unix timestamp (in milliseconds), UTC time.

    Response example


    _14
    {
    _14
    "msg": "Success",
    _14
    "code": 0,
    _14
    "ts": 1658126805245,
    _14
    "data": {
    _14
    "userName": "jasoncai",
    _14
    "userUuid": "681d9aca4924e9a84ad301e8cca438a71",
    _14
    "role": "1",
    _14
    "userProperties": {},
    _14
    "updateTime": 1658126782174,
    _14
    "streamUuid": "1417753684",
    _14
    "state": 1
    _14
    }
    _14
    }

    Update custom user properties

    Description

    Add or update the custom properties of a specified user.

    Prototype

    • Method: PUT
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/users/{userUuid}/properties

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    userUuidString(Required) The user ID. This is the unique identifier of the user when logging in to Signaling. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    propertiesObjectThe user properties.
    causeObjectThe update reason.

    Request example


    _10
    curl -X PUT 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/users/test_user/properties' \
    _10
    -H 'Content-Type: application/json;charset=UTF-8' \
    _10
    -H 'Authorization: agora token={educationToken}' \
    _10
    --data-raw '{
    _10
    "properties": {
    _10
    "key1": "value1",
    _10
    "key2": "value2"
    _10
    },
    _10
    "cause": {}
    _10
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Delete custom user properties

    Description

    Delete the custom properties of a specified user.

    Prototype

    • Method: DELETE
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/users/{userUuid}/properties

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    userUuidString(Required) The user ID. This is the unique identifier of the user when logging in to Signaling. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    propertiesString arrayThe user properties.
    causeObjectReason for deletion.

    Request example


    _7
    curl -X DELETE 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/users/test_user/properties' \
    _7
    -H 'Content-Type: application/json;charset=UTF-8' \
    _7
    -H 'Authorization: agora token={educationToken}' \
    _7
    --data-raw '{
    _7
    "properties": ["key1", "key2"],
    _7
    "cause": {}
    _7
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Kick a user out of a classroom

    Description

    Call this method to kick a specified user out of a classroom. After a successful method call, the server triggers an event indicating a user leaves the classroom. You can use the dirty parameter to determine whether the user can enter the classroom afterwards.

    Prototype

    • Method: POST
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/users/{userUuid}/exit

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
    userUuidString(Required) The user ID. This is the unique identifier of the user when logging in to Signaling. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Request body parameters

    Pass in the following parameters in the request body.

    ParameterTypeDescription
    dirtyObject(Optional) The user privilege:
    • state: Boolean, whether the user is dirty:
      • 1: Dirty. A dirty user cannot enter the classroom.
      • 0: Not dirty.
    • duration: Number, the duration of the dirty state (seconds), starting from the time when the user is kicked out of the classroom.

    Request example


    _9
    curl -X POST 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/users/test_user/exit' \
    _9
    -H 'Content-Type: application/json;charset=UTF-8' \
    _9
    -H 'Authorization: agora token={educationToken}' \
    _9
    --data-raw '{
    _9
    "dirty": {
    _9
    "state": 1,
    _9
    "duration": 600
    _9
    }
    _9
    }'

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.

    Response example


    _5
    {
    _5
    "msg": "Success",
    _5
    "code": 0,
    _5
    "ts": 1610167740309
    _5
    }

    Query a specified event

    Description

    Query a specified type of event in a specified classroom.

    You can fetch data in batches with the nextId parameter. You can get up to 100 pieces of data for each batch.

  • You can query the same event repeatedly.
  • You cannot query events in a destroyed classroom. A classroom is destroyed automatically one hour after it is ended.
  • Prototype

    • Method: GET
    • Endpoint: /{region}/edu/apps/{appId}/v2/rooms/{roomUUid}/sequences

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters. The following character sets are supported:
    • All lowercase English letters: a to z.
    • All numeric characters: 0-9
    • The space character.
    • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

    Query parameters

    ParameterTypeDescription
    nextIdString(Optional) The starting ID of the next batch of data. When you call this method to get the data for the first time, leave this parameter empty or set it as null. Afterward, you can set this parameter as the nextId that you get in the response of the previous method call.
    cmdInteger(Optional) Event type. For details, see Flexible Classroom Cloud Service Events.

    Request example


    _2
    curl -X GET 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/sequences?cmd=20' \
    _2
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.
    dataObjectInclude the following parameters:
    • total: Integer, the total number of pieces of data.
    • count: Integer, the number of pieces of data in this batch.
    • list: JSONArray. An array of the recording list. A JSON object includes the following parameters:
        • roomUuid: String, the classroom ID.
        • cmd: Integer, the event type. For details, see Flexible Classroom Cloud Service Events.
        • sequence: Integer. The event ID. This is the unique identifier of an event, which is automatically generated to ensure the order of events.
        • version: Integer, the service version.
        • data: Object, the detailed data of the event. The data varies depending on the event type. For details, see Flexible Classroom Cloud Service Events.
    • nextId: String, the starting ID of the next batch of data. If it is null, there is no next batch of data. If it is not null, use this nextId to continue the query until null is reported.

    Response example


    _19
    {
    _19
    "msg": "Success",
    _19
    "code": 0,
    _19
    "ts": 1610433913533,
    _19
    "data": {
    _19
    "total": 1,
    _19
    "list": [
    _19
    {
    _19
    "roomUuid": "",
    _19
    "cmd": 20,
    _19
    "sequence": 1,
    _19
    "version": 1,
    _19
    "data": {}
    _19
    }
    _19
    ],
    _19
    "nextId": null,
    _19
    "count": 1
    _19
    }
    _19
    }

    Get all classroom events

    Description

    Get all events in the classrooms associated with a specified App ID.

    You can call this method at regular intervals to listen for all the events that occur in the flexible classrooms.

  • Each event can only be obtained once.
  • Note: You cannot get events one hour after a classroom is destroyed.
  • Prototype

    • Method: GET
    • Endpoint: /{region}/edu/polling/apps/{appId}/v2/rooms/sequences

    Request parameters

    URL parameters

    Pass the following parameter in the URL.

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.

    Request example


    _2
    curl -X GET 'https://api.sd-rtn.com/{region}/edu/polling/apps/{yourAppId}/v2/rooms/sequences' \
    _2
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    ParameterTypeDescription
    codeIntegerBusiness status code:
    • 0: The request succeeds.
    • Non-zero: The request fails.
    msgStringThe detailed information.
    tsNumberThe current Unix timestamp (in milliseconds) of the server in UTC.
    dataObjectInclude the following parameters:
    • roomUuid: String, the classroom ID.
    • cmd: Integer, the event type. For details, see Flexible Classroom Cloud Service Events.
    • sequence: Integer. The event ID. This is the unique identifier of an event, which is automatically generated to ensure the order of events.
    • version: Integer, the service version.
    • data: Object, the detailed data of the event. The data varies depending on the event type. For details, see Flexible Classroom Cloud Service Events.

    Response example


    _16
    "status": 200,
    _16
    "body":
    _16
    {
    _16
    "msg": "Success",
    _16
    "code": 0,
    _16
    "ts": 1610167740309,
    _16
    "data":[
    _16
    {
    _16
    "roomUuid": "xxxxxx",
    _16
    "cmd": 20,
    _16
    "sequence": 1,
    _16
    "version": 1,
    _16
    "data":{}
    _16
    }
    _16
    ]
    _16
    }

    Get data for pop-up quizzes

    Prototype

    • Method: GET
    • Request path: /edu/apps/{appId}/v2/rooms/{roomUUid}/widgets/popupQuiz/sequences

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters.

    Query parameters

    ParameterTypeDescription
    nextIdString(Optional) The starting ID of the next batch of data. When you call this method to get the data for the first time, leave this parameter empty or set it as null. Afterward, you can set this parameter as the nextId that you get in the response of the previous method call.
    countInteger(Optional) The number of pieces of data in this batch. The default value is 100.

    Request example


    _2
    curl -X GET 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/widgets/popupQuiz/sequences' \
    _2
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    The fields returned in data vary in different situations.

    • After the teacher clicks the Start button to start a quiz, the summarized data of the Pop-up Quiz widget updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.correctItemsObject[]The correct choice
      changeProperties.extra.correctCountIntegerThe number of students who have made the correct choice
      changeProperties.extra.answerStateIntegerThe status of this quiz:
      • 1 : In progress
      • 0: Ended
      changeProperties.extra.receiveQuestionTimeLongThe time when the students receive the question
      changeProperties.extra.popupQuizIdStringThe question ID
      changeProperties.extra.averageAccuracyFloatThe rate at which the correct choice is made for this question
      changeProperties.extra.totalCountIntegerThe total number of students who have submitted their answers to this question
      changeProperties.extra.itemsObject[]The options of this question
      changeProperties.stateIntegerThe state of the Pop-up Quiz widget:
      • 0: Inactive
      • 1: Active
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
    • After a student submits the answer, the student's data updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.lastCommitTimeLongThe last submit time
      changeProperties.popupQuizIdStringThe question ID
      changeProperties.selectedItemsObject[]The answer submitted by this student
      changeProperties.isCorrectBooleanWhether the answer submitted by the student is correct
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
      fromUserObjectThe user who starts this quiz
      fromUser.userUuidStringThe ID of the user who starts this quiz
      fromUser.userNameStringThe name of the user who starts this quiz
      fromUser.roleStringThe role of the user who starts this quiz
    • After a student submits the answer, the summarized data of the Pop-up Quiz widget updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.selectedCountIntegerThe number of students who have submitted their answers
      changeProperties.extra.correctCountIntegerThe number of students who have made the correct choice
      changeProperties.extra.averageAccuracyFloatThe rate at which the correct choice is made for this question
      changeProperties.extra.totalCountIntegerThe total number of students who have submitted their answers to this question
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
    • After the teacher ends the quiz, the summarized data of the Pop-up Quiz widget updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.selectedCountIntegerThe number of students who have submitted their answers
      changeProperties.extra.correctCountIntegerThe number of students who have made the correct choice
      changeProperties.extra.answerStateIntegerThe status of this quiz:
      • 1 : In progress
      • 0: Ended
      changeProperties.extra.averageAccuracyFloatThe rate at which the correct choice is made for this question
      changeProperties.extra.totalCountIntegerThe total number of students who have submitted their answers to this question
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator

    Response example

    • After the teacher clicks the Start button to start a quiz, the summarized data of the Pop-up Quiz widget updates:


      _25
      "action": NumberInt("1"),
      _25
      "changeProperties": {
      _25
      "extra.correctItems": [
      _25
      "A",
      _25
      "B",
      _25
      "D"
      _25
      ],
      _25
      "extra.totalCount": NumberInt("1"),
      _25
      "extra.answerState": NumberInt("1"),
      _25
      "state": NumberInt("1"),
      _25
      "extra.popupQuizId": "ab5b183238a74d5a9c955dc87c6397e0",
      _25
      "extra.averageAccuracy": 0,
      _25
      "extra.correctCount": NumberInt("0"),
      _25
      "extra.items": [
      _25
      "A",
      _25
      "C",
      _25
      "B"
      _25
      ],
      _25
      "extra.receiveQuestionTime": NumberLong("1652413962895")
      _25
      },
      _25
      "operator": {
      _25
      "userName": "server",
      _25
      "userUuid": "server",
      _25
      "role": "server"
      _25
      }

    • After a student submits the answer, the student's data updates:


      _16
      "action": NumberInt("1"),
      _16
      "changeProperties": {
      _16
      "selectedItems": [
      _16
      "A",
      _16
      "B",
      _16
      "D"
      _16
      ],
      _16
      "isCorrect": true,
      _16
      "popupQuizId": "ab5b183238a74d5a9c955dc87c6397e0",
      _16
      "lastCommitTime": NumberLong("1652413989997")
      _16
      },
      _16
      "fromUser": {
      _16
      "userName": "yerongzhe2",
      _16
      "userUuid": "yerongzhe22",
      _16
      "role": "audience"
      _16
      }

    • After the teacher ends the quiz, the summarized data of the Pop-up Quiz widget updates:


      _13
      "action": NumberInt("1"),
      _13
      "changeProperties": {
      _13
      "extra.totalCount": NumberInt("1"),
      _13
      "extra.answerState": NumberInt("0"),
      _13
      "extra.selectedCount": NumberInt("1"),
      _13
      "extra.averageAccuracy": 1,
      _13
      "extra.correctCount": NumberInt("1")
      _13
      },
      _13
      "operator": {
      _13
      "userName": "server",
      _13
      "userUuid": "server",
      _13
      "role": "server"
      _13
      }

    Get data for polls

    Prototype

    • Method: GET
    • Request path: /edu/apps/{appId}/v2/rooms/{roomUUid}/widgets/poll/sequences

    Request parameters

    URL parameters

    Pass the following parameters in the URL:

    ParameterTypeDescription
    regionString(Required) The region for connection. For details, see Network geofencing. Flexible Classroom supports the following regions:
    • cn: Mainland China.
    • ap: Asia Pacific.
    • eu: Europe.
    • na: North America.
    appIdString(Required) Agora App ID.
    roomUuidString(Required) The classroom ID. This is the globally unique identifier of a classroom. It is also used as the channel name when a user joins a channel. The string length must be less than 64 characters.

    Query parameters

    ParameterTypeDescription
    nextIdString(Optional) The starting ID of the next batch of data. When you call this method to get the data for the first time, leave this parameter empty or set it as null. Afterward, you can set this parameter as the nextId that you get in the response of the previous method call.
    countInteger(Optional) The number of pieces of data in this batch. The default value is 100.

    Request example


    _2
    curl -X GET 'https://api.sd-rtn.com/{region}/edu/apps/{yourAppId}/v2/rooms/test_class/widgets/popupQuiz/sequences' \
    _2
    -H 'Authorization: agora token={educationToken}' \

    Response parameters

    The fields returned in data vary in different situations.

    • After the teacher clicks the Start button to start a poll, the summarized data of the Polling widget updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.modeIntegerThe polling mode:
      • 1: Single-choice
      • 2: Multiple-choice
      changeProperties.extra.pollingStateIntegerThe status of this poll:
      • 1 : In progress
      • 0: Ended
      changeProperties.extra.pollDetailsMap<String, Object>The polling results. key is the option index, starting from 0.
      changeProperties.extra.pollDetails.numIntegerThe number of students who have selected this option
      changeProperties.extra.pollDetails.percentageFloatThe percentage of students who have selected this option in students who have submitted their choices
      changeProperties.extra.pollIdStringThe poll ID
      changeProperties.extra.pollItemsObjectThe option content
      changeProperties.stateIntegerThe state of the Polling widget:
      • 0: Inactive
      • 1: Active
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
    • After a student submits the choice, the student's data updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.pollIdStringThe poll ID
      changeProperties.extra.selectIndexObject[]The index of the option selected by this student
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
      fromUserObjectThe user who starts this poll
      fromUser.userUuidStringThe ID of the user who starts this poll
      fromUser.userNameStringThe name of the user who starts this poll
      fromUser.roleStringThe role of the user who starts this poll
    • After a student submits the answer, the summarized data of the Polling widget updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.pollDetailsMap<String, Object>The polling results. key is the option index, starting from 0.
      changeProperties.extra.pollDetails.numIntegerThe number of students who have selected this option
      changeProperties.extra.pollDetails.percentageFloatThe percentage of students who have selected this option in students who have submitted their choices
      changeProperties.extra.pollIdStringThe poll ID
      causeStringThe reason for the property change
      cause.popQuizIdStringThe Pop-up Quiz ID
      cause.actionIntegerThe action type:
      • 1: The teacher starts taking the quiz
      • 2: The teacher finishes taking the quiz
      • 3: The student hands over the answer
      • 4: The information is updated
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
      fromUserObjectThe user who starts this poll
      fromUser.userUuidStringThe ID of the user who starts this poll
      fromUser.userNameStringThe name of the user who starts this poll
      fromUser.roleStringThe role of the user who starts this poll
    • After the teacher ends the poll, the summarized data of the Polling widget updates. data contains the following fields:

      Field nameTypeDescription
      actionIntegerThe action type
      widgetUuidStringThe widget ID
      changePropertiesObjectThe changed properties
      changeProperties.extraObjectThe extra information of the changed properties
      changeProperties.extra.pollingStateIntegerThe status of this poll:
      • 1 : In progress
      • 0: Ended
      changeProperties.extra.pollDetailsMap<String, Object>The polling results. key is the option index, starting from 0.
      changeProperties.extra.pollDetails.numIntegerThe number of students who have selected this option
      changeProperties.extra.pollDetails.percentageFloatThe percentage of students who have selected this option in students who have submitted their choices
      changeProperties.extra.pollIdStringThe poll ID
      causeStringThe reason for the property change
      operatorObjectThe operator of the property change
      operator.userUuidStringThe ID of the operator
      operator.userNameStringThe name of the operator
      operator.roleStringThe role of the operator
      fromUserObjectThe user who starts this poll
      fromUser.userUuidStringThe ID of the user who starts this poll
      fromUser.userNameStringThe name of the user who starts this poll
      fromUser.roleStringThe role of the user who starts this poll

    Response example

    • After the teacher clicks the Start button to start a poll, the summarized data of the Polling widget updates:


      _41
      "action": NumberInt("1"),
      _41
      "changeProperties": {
      _41
      "extra.pollId": "e556ce3df5cd4c23941b03bf54d29ba3",
      _41
      "extra.pollState": NumberInt("1"),
      _41
      "extra.pollItems": [
      _41
      "aaa",
      _41
      "bbb",
      _41
      "ccc",
      _41
      "ddd",
      _41
      "eee"
      _41
      ],
      _41
      "extra.mode": NumberInt("2"),
      _41
      "state": NumberInt("1"),
      _41
      "extra.pollDetails": {
      _41
      "0": {
      _41
      "num": NumberInt("0"),
      _41
      "percentage": 0
      _41
      },
      _41
      "1": {
      _41
      "num": NumberInt("0"),
      _41
      "percentage": 0
      _41
      },
      _41
      "2": {
      _41
      "num": NumberInt("0"),
      _41
      "percentage": 0
      _41
      },
      _41
      "3": {
      _41
      "num": NumberInt("0"),
      _41
      "percentage": 0
      _41
      },
      _41
      "4": {
      _41
      "num": NumberInt("0"),
      _41
      "percentage": 0
      _41
      }
      _41
      }
      _41
      },
      _41
      "operator": {
      _41
      "userName": "server",
      _41
      "userUuid": "server",
      _41
      "role": "server"
      _41
      }

    • After a student submits the choice, the student's data updates:


      _19
      "action": NumberInt("1"),
      _19
      "changeProperties": {
      _19
      "pollId": "e556ce3df5cd4c23941b03bf54d29ba3",
      _19
      "selectIndex": [
      _19
      NumberInt("1"),
      _19
      NumberInt("2"),
      _19
      NumberInt("4")
      _19
      ]
      _19
      },
      _19
      "fromUser": {
      _19
      "userName": "yerongzhe2",
      _19
      "userUuid": "yerongzhe22",
      _19
      "role": "audience"
      _19
      },
      _19
      "operator": {
      _19
      "userName": "server",
      _19
      "userUuid": "server",
      _19
      "role": "server"
      _19
      }

    • After a student submits the choice, the summarized data of the Polling widget updates:


      _31
      "action": NumberInt("1"),
      _31
      "changeProperties": {
      _31
      "extra.pollId": "2f38e6de32064713adf135de41c963df",
      _31
      "extra.pollDetails": {
      _31
      "0": {
      _31
      "num": NumberInt("1"),
      _31
      "percentage": 0.33333334
      _31
      },
      _31
      "1": {
      _31
      "num": NumberInt("3"),
      _31
      "percentage": 1
      _31
      },
      _31
      "2": {
      _31
      "num": NumberInt("3"),
      _31
      "percentage": 1
      _31
      },
      _31
      "3": {
      _31
      "num": NumberInt("0"),
      _31
      "percentage": 0
      _31
      },
      _31
      "4": {
      _31
      "num": NumberInt("2"),
      _31
      "percentage": 0.6666667
      _31
      }
      _31
      }
      _31
      },
      _31
      "operator": {
      _31
      "userName": "server",
      _31
      "userUuid": "server",
      _31
      "role": "server"
      _31
      }

    • After the teacher ends the poll, the summarized data of the Polling widget updates:


      _31
      "action": NumberInt("1"),
      _31
      "changeProperties": {
      _31
      "extra.pollId": "2f38e6de32064713adf135de41c963df",
      _31
      "extra.pollDetails": {
      _31
      "0": {
      _31
      "num": NumberInt("1"),
      _31
      "percentage": 0.33333334
      _31
      },
      _31
      "1": {
      _31
      "num": NumberInt("3"),
      _31
      "percentage": 1
      _31
      },
      _31
      "2": {
      _31
      "num": NumberInt("3"),
      _31
      "percentage": 1
      _31
      },
      _31
      "3": {
      _31
      "num": NumberInt("0"),
      _31
      "percentage": 0
      _31
      },
      _31
      "4": {
      _31
      "num": NumberInt("2"),
      _31
      "percentage": 0.6666667
      _31
      }
      _31
      }
      _31
      },
      _31
      "operator": {
      _31
      "userName": "server",
      _31
      "userUuid": "server",
      _31
      "role": "server"
      _31
      }

    Status code

    Response status codeBusiness status codeDescription
    2000The request succeeds.
    400400The request parameter is incorrect.
    401N/APossible reasons:
    • The App ID is invalid.
    • Unauthorized. Incorrect x-agora-uid or x-agora-token.
    40330403200The classroom is muted globally. Users cannot send chat messages.
    404N/AThe server cannot find the requested resource.
    40420404100The classroom does not exist.
    40420404200The user does not exist.
    40930409410The recording has not been started.
    40930409411The recording has not been ended.
    40930409100The class has been started.
    40930409101The class has been ended.
    500500The server has an internal error and cannot process the request.
    503N/AInternal server error. The gateway or proxy server does not receive a timely response from the upstream server.

    Events

    This section lists all types of events that you can get through the Get classroom events method.

    The classroom state changes

    When the cmd property of an event is 1, the event indicates the classroom state changes, and the data property contains the following fields:

    ParameterTypeDescription
    startTimeNumberThe Unix timestamp (in milliseconds) when the class starts, in UTC. This property is available after the state of the classroom changes to 1".
    stateIntegerThe current state of the classroom:
    • 0: Not started.
    • 1: In progress.
    • 2: Ended.
    • 3: After the run-late time of a class, the room is closed and users can no longer enter the room.
    endTimeNumberThe Unix timestamp (in milliseconds) when the class ends, in UTC. This property is available after the state of the classroom changes to 2.
    closeTimeNumberThe Unix timestamp (in milliseconds) when the classroom closes, in UTC. This property is available after the state of the classroom changes to 3.

    Example


    _4
    {
    _4
    "startTime": 1611561776588,
    _4
    "state": 1
    _4
    }

    Receives a room chat message

    When the cmd property of an event is 3, the event indicates the server receives a room chat message, and the data contains the following fields:

    ParameterTypeDescription
    fromUserObjectThe user who sends this message. This object contains the following fields:
    • userUuid: String. The user ID.
    • userName: String. The user name.
    • role: Integer. The user role. This parameter can be set as one of the following values:
      • 1: Teacher.
      • 2: Student.
    messageStringThe message.
    typeIntegerThe type of the message. Temporarily, you can only set this parameter as 1(text messages).

    Example


    _9
    {
    _9
    "fromUser": {
    _9
    "role": "host",
    _9
    "userName": "jason",
    _9
    "userUuid": "jason1"
    _9
    },
    _9
    "message": "aa",
    _9
    "type": 1
    _9
    }

    Users enter or leave the classroom

    When the cmd property of an event is 20, the event indicates that users have entered or left the classroom. data includes the following fields:

    ParameterTypeDescription
    totalIntegerThe total number of users in the classroom after this event.
    onlineUsersObject ArrayThe new users who entered the classroom at the time of this event. This object contains the following fields:
    • userName: String. The user name.
    • userUuid: String. The user ID.
    • role: Integer. The user role. This parameter can be set as one of the following values:
      • 1: Teacher.
      • 2: Student.
    • userProperties: Object. The user property.
    • streamUuid: String. The ID of the stream, which is also the uid used when joining an Video SDK channel.
    • type: Integer. The reasons why the user enters the room:
      • 1: The user enters the classroom in a normal way.
      • 2: The user re-enters the classroom.
    • updateTime: Number. The time when the user enters the classroom, Unix timestamp (milliseconds), UTC time.
    offlineUsersObject ArrayThe new users who have left the classroom at the time of this event. This object contains the following fields:
    • userName: String. The user name.
    • userUuid: String. The user ID.
    • role: Integer. The user role. This parameter can be set as one of the following values:
      • 1: Teacher.
      • 2: Student.
    • userProperties: Object. The user property.
    • streamUuid: String. The ID of the stream, which is also the uid used when joining an Video SDK channel.
    • type: Integer. The reasons why the user leaves the classroom:
      • 1: The user leaves the classroom on the client, such as leaving the class normally, the application is forcibly closed, or the user is disconnected due to poor network conditions.
      • 2: The user is kicked out of the classroom.
    • updateTime: Number. The time when the user enters or leaves the classroom, Unix timestamp (in milliseconds), UTC time.

    Example


    _25
    {
    _25
    "total": 3,
    _25
    "onlineUsers": [
    _25
    {
    _25
    "userName": "",
    _25
    "userUuid": "",
    _25
    "role": "0",
    _25
    "userProperties": {},
    _25
    "streamUuid": "",
    _25
    "type": 1,
    _25
    "updateTime": 1611561776588
    _25
    }
    _25
    ],
    _25
    "offlineUsers": [
    _25
    {
    _25
    "userName": "",
    _25
    "userUuid": "",
    _25
    "role": "0",
    _25
    "userProperties": {},
    _25
    "streamUuid": "",
    _25
    "type": 1,
    _25
    "updateTime": 1611561776588
    _25
    }
    _25
    ]
    _25
    }

    The recording state changes

    When the cmd property of an event is 1001, the event indicates the recording state changes, and the data property contains the following fields:

    ParameterTypeDescription
    recordIdStringThis is the unique identifier of a recording session. A recording session starts when you call a method to start recording and ends when you call this method to stop recording. This field is available only when state is 1.
    sidStringThe sid of the Agora Cloud Recording service. This field is available only when state is 1.
    resourceIdStringThe resourceId of the Agora Cloud Recording service. This field is available only when state is 1.
    stateIntegerThe current recording state:
    • 2: Recording has ended.
    • 1: In recording.
    startTimeNumberThe Unix timestamp (in milliseconds) when the recording starts, in UTC. This property is available after the recording state changes to "Started".
    streamingUrlObjectThe URL address for the webpage after being pushed to the CDN. Students can use this URL to watch the teaching online.

    Example


    _7
    {
    _7
    "recordId": "xxx",
    _7
    "sid": "xxx",
    _7
    "resourceId": "xxx",
    _7
    "state": 1,
    _7
    "startTime": 1611564500488
    _7
    }

    The number of rewards changes

    When the cmd property of an event is 1101, the event indicates the number of rewards changes, and the data property contains the following fields:

    ParameterTypeDescription
    rewardDetailsObject ArrayEach object represents the rewards of a user and contains the following fields:
    • userUuid: String. The user ID.
    • changedReward: Integer. The number of changed rewards.
    • total: Integer. The total number of rewards after the change.
    updateTimeNumberThe Unix timestamp (in milliseconds) when the rewards change, in UTC.

    Example


    _10
    {
    _10
    "rewardDetails": [
    _10
    {
    _10
    "userUuid": "",
    _10
    "changedReward": 1,
    _10
    "totalReward": 10
    _10
    }
    _10
    ],
    _10
    "updateTime": 1611564500488
    _10
    }

    The resources in the classroom change

    When the cmd property of an event is 1003, the event indicates the resources in the classroom change, and the data property contains the following fields:

    ParameterTypeDescription
    ParameterTypeDescription
    resourcesObject ArrayEach object represents a public resource and contains the following fields:
    • resourceUuid: String. The resource ID.
    • resourceName: String. The resource name.
    • size: Number. The resourc size (bytes).
    • url: String. The URL address of the resource.
    • taskUuid: String. The ID of the file conversion task.
    • taskToken: String. The token used for the file conversion task.
    • taskProgress: Object. The progress of a file conversion task.
    operatorObjectIt contains the following fields:
    • userUuid: String. The user ID.
    • userName: String. The user name.
    • role: Integer. Th user role.
    actionIntegerThe resource change type:
    • 1: The resource is added or updated.
    • 2: The resource is deleted.

    Example


    _19
    {
    _19
    "resources": [
    _19
    {
    _19
    "resourceUuid": "",
    _19
    "resourceName": "1",
    _19
    "size": 1024,
    _19
    "url": "http://xxx.com/ooo",
    _19
    "taskUuid": "",
    _19
    "taskToken": "",
    _19
    "taskProgress": {}
    _19
    }
    _19
    ],
    _19
    "operator": {
    _19
    "role": "1",
    _19
    "userName": "jason",
    _19
    "userUuid": "jason1"
    _19
    },
    _19
    "action": 1
    _19
    }

    The users "on the stage" change

    When the cmd property of an event is 1501, the event indicates the users "on the stage" change, and the data property contains the following fields:

    ParameterTypeDescription
    acceptedUsersObject ArrayThe list of users who are now "on the stage". The object contains the following fields:
    • userUuid: String. The user ID.
    addAcceptedUsersObject ArrayThe list of users who have just "gone onto the stage". The object contains the following fields:
    • userUuid: String. The user ID.
    removeAcceptedUsersObject ArrayThe list of users who have just "left the stage". The object contains the following fields:
    • userUuid: String. The user ID.

    Example


    _17
    {
    _17
    "acceptedUsers": [
    _17
    {
    _17
    "userUuid": ""
    _17
    }
    _17
    ],
    _17
    "addAcceptedUsers": [
    _17
    {
    _17
    "userUuid": ""
    _17
    }
    _17
    ],
    _17
    "removeAcceptedUsers": [
    _17
    {
    _17
    "userUuid": ""
    _17
    }
    _17
    ]
    _17
    }

    The users who wave their hands change

    When the cmd property of an event is 1502, the event indicates the users who wave their hands change, and the data property contains the following fields:

    ParameterTypeDescription
    progressUsersObject ArrayThe list of users who are waving their hands. The object contains the following fields:
    • userUuid: String. The user ID.
    • payload: Object.
    addProgressUsersObject ArrayThe list of users who have just started waving their hands. The object contains the following fields:
    • userUuid: String. The user ID.
    • payload: Object.
    removeProgressUsersObject ArrayThe list of users who have just stopped waving their hands. The object contains the following fields:
    • userUuid: String. The user ID.
    • payload: Object.

    Example


    _20
    {
    _20
    "progressUsers": [
    _20
    {
    _20
    "userUuid": "",
    _20
    "payload": {}
    _20
    }
    _20
    ],
    _20
    "addProgressUsers": [
    _20
    {
    _20
    "userUuid": "",
    _20
    "payload": {}
    _20
    }
    _20
    ],
    _20
    "removeProgressUsers": [
    _20
    {
    _20
    "userUuid": "",
    _20
    "payload": {}
    _20
    }
    _20
    ]
    _20
    }

    Ensure service reliability

    This section presents the overall strategy you use to ensure high availability of REST services.

    Switch the domain name

    To ensure high availability of REST services, Agora enables you to switch domain names when you experience service outage due to regional network failures. Take the following steps to set up and switch your domain name:

    1. Set the primary domain name based on the location of your service server:

      • If the DNS address of the service server is located in a country or region other than mainland China, set the primary domain name to api.agora.io.
      • If the DNS address of the service server is in mainland China, set the primary domain name to api.sd-rtn.com.
    2. If your attempt to initiate a RESTful API request using the primary domain fails, set up your retry strategy as follows:

      1. Primary domain retry: Retry using the same primary domain name.

      2. Alternate domain retry:

        • If the current primary domain name is api.sd-rtn.com, use api.agora.io as the alternate domain name.
        • If the current primary domain name is api.agora.io, use api.sd-rtn.com as the alternate domain name.
      3. Adjacent domain retry: If alternate domain retry fails, retry using the domain name adjacent to the current region.

        For example, suppose your business server is located in Europe. You set the primary domain name to api.agora.io, and the business server resolves the primary domain name to Germany. Germany is located in central Europe (api-eu-central-1.agora.io). The domain name table shows that the adjacent area is West Europe. Use the api-eu-west-1.agora.io or api-eu-west-1.sd-rtn.com domain name to retry.

    Precautions

    Take the following precautions when setting up your retry strategy:

    • To avoid exceeding the QPS limit with retry requests, best practice is to use a back-off strategy. For example, wait 1 second before you retry for the first time, wait 3 seconds before retrying the second time, and wait 6 seconds before retry a third time.

    • If the request fails because of a network problem rather than a DNS domain name resolution problem, skip alternate domain retry and proceed to adjacent domain retry.

    • Before switching to the region domain name, ensure that the REST services you wish to use, for example, cloud recording or channel management, are deployed in that region.

    Domain name table

    The following table shows the primary and region domain names for various regions.

    Primary domain nameRegion domain nameRegion
    api.sd-rtn.comapi-us-west-1.sd-rtn.comWestern United States
    api-us-east-1.sd-rtn.comEastern United States
    api-ap-southeast-1.sd-rtn.comSoutheast Asia Pacific
    api-ap-northeast-1.sd-rtn.comNortheast Asia Pacific
    api-eu-west-1.sd-rtn.comWestern Europe
    api-eu-central-1.sd-rtn.comCentral Europe
    api-cn-east-1.sd-rtn.comEast China
    api-cn-north-1.sd-rtn.comNorth China
    api.agora.ioapi-us-west-1.agora.ioWestern United States
    api-us-east-1.agora.ioEastern United States
    api-ap-southeast-1.agora.ioSoutheast Asia Pacific
    api-ap-northeast-1.agora.ioNortheast Asia Pacific
    api-eu-west-1.agora.ioWestern Europe
    api-eu-central-1.agora.ioCentral Europe
    api-cn-east-1.agora.ioEast China
    api-cn-north-1.agora.ioNorth China
    vundefined