tencent cloud

文档反馈

CreateSession

最后更新时间:2024-02-02 13:01:59

    1. API Description

    Domain name for API request: car.tencentcloudapi.com.

    This API is used to create a session. The timeout period of the API is 5 seconds.

    A maximum of 100 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: CreateSession.
    Version Yes String Common Params. The value used for this API: 2022-01-10.
    Region No String Common Params. This parameter is not required for this API.
    UserId Yes String The user’s unique ID. Tencent Cloud does not parse the ID. You need to manage your own user IDs. Based on your needs, you can either define unique IDs for users or use timestamps to generate random IDs. Make sure the same ID is used when a user reconnects to your application.
    UserIp Yes String Public IP of user’s application client, which is used for nearby scheduling.
    ClientSession No String The client-side session data, which is obtained from the SDK. If RunMode is RunWithoutClient, this parameter can be null.
    RunMode No String The on-cloud running mode.
    RunWithoutClient: Keep the application running on the cloud even when there are no client connections.
    Empty string (default): Keep the application running on the cloud only when there are client connections.
    ApplicationParameters No String Application startup parameter.
    If the user requests a multi-application project or a prelaunch-disabled single-application project, this parameter takes effect.

    If the user requests a prelaunch-enabled single-application project, this parameter is invalid.

    Note: When this parameter takes effect, the ApplicationParameters parameter will be appended to the end of the application startup parameter. The application startup parameter is set in the application or project configuration in the console.
    For example, for a prelaunch-disabled single-application project, if its application startup parameter bar is 0 and the ApplicationParameters parameter foo is 1, the actual application startup parameters will be bar=0 foo=1.
    HostUserId No String The user ID of the host in multi-person interaction scenarios, which is required.
    If the current user is the host, HostUserId must be the same as their UserId; otherwise, HostUserId should be the host's UserId.
    Role No String The role in multi-person interaction scenarios. Valid values:
    Player: A user who can operate an application by using a keyboard and mouse
    Viewer: A user who can only watch the video in the room but cannot operate the application

    3. Output Parameters

    Parameter Name Type Description
    ServerSession String The server-side session data, which is returned to the SDK.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Creating a session

    This example shows you how to create a session.

    Input Example

    POST / HTTP/1.1
    Host: car.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateSession
    <common request parameters>
    
    {
        "UserIp": "125.127.178.228",
        "ClientSession": "eyJhYmMiOjEyM30=",
        "UserId": "cg_user"
    }
    

    Output Example

    {
        "Response": {
            "ServerSession": "eyJ4dHoiOjc4OX0=",
            "RequestId": "fcf4146f-64d3-496c-88dc-d12f832de313"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation Operation failed.
    FailedOperation.LockTimeout Concurrency quota not requested or request timed out.
    FailedOperation.PathNotFound Failed to find the path.
    FailedOperation.ProcessTimeout Processing timed out.
    FailedOperation.SlowDown The request for the current UserId is being processed. Try again later.
    InternalError Internal error.
    InvalidParameter.JsonParseError JSON parsing error.
    InvalidParameterValue Invalid parameter value.
    LimitExceeded.Role The number of roles in a multi-person interaction scenario exceeds the limit.
    OperationDenied Operation denied.
    ResourceNotFound.NoIdle No available concurrency quota.
    ResourceNotFound.SessionNotFound Unable to find the session.
    ResourceUnavailable.Initialization The instance is being initialized.
    UnsupportedOperation.Stopping The session is being terminated.