> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akool.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Close Session

> Close an active streaming avatar session

<Note>
  Both the avatar\_id and voice\_id can be easily obtained by copying them directly from the web interface. You can also create and manage your streaming avatars using our intuitive web platform.

  Create and manage your avatars at: [https://akool.com/apps/upload/avatar?from=%2Fapps%2Fstreaming-avatar%2Fedit](https://akool.com/apps/upload/avatar?from=%2Fapps%2Fstreaming-avatar%2Fedit)
</Note>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST --location "https://openapi.akool.com/api/open/v4/liveAvatar/session/close" \
      -H "Authorization: Bearer your_token_here" \
      -H "Content-Type: application/json" \
      -d '{
            "session_id": "session_123456789"
          }'
  ```

  ```java Java theme={null}
  OkHttpClient client = new OkHttpClient().newBuilder()
    .build();
  MediaType mediaType = MediaType.parse("application/json");
  RequestBody body = RequestBody.create(mediaType, "{\n  \"session_id\": \"session_123456789\"\n}");
  Request request = new Request.Builder()
    .url("https://openapi.akool.com/api/open/v4/liveAvatar/session/close")
    .method("POST", body)
    .addHeader("Authorization", "Bearer your_token_here")
    .addHeader("Content-Type", "application/json")
    .build();
  Response response = client.newCall(request).execute();
  ```

  ```js Javascript theme={null}
  const myHeaders = new Headers();
  myHeaders.append("Authorization", "Bearer your_token_here");
  myHeaders.append("Content-Type", "application/json");

  const raw = JSON.stringify({
    "session_id": "session_123456789"
  });

  fetch("https://openapi.akool.com/api/open/v4/liveAvatar/session/close", {
    method: "POST",
    headers: myHeaders,
    body: raw
  })
  .then(response => response.text())
  .then(result => console.log(result));
  ```

  ```php PHP theme={null}
  <?php
  $client = new Client();
  $headers = [
    'Authorization' => 'Bearer your_token_here',
    'Content-Type' => 'application/json'
  ];
  $body = '{
    "session_id": "session_123456789"
  }';
  $request = new Request('POST', 'https://openapi.akool.com/api/open/v4/liveAvatar/session/close', $headers, $body);
  $res = $client->sendAsync($request)->wait();
  echo $res->getBody();
  ?>
  ```

  ```python Python theme={null}
  import requests
  import json

  url = "https://openapi.akool.com/api/open/v4/liveAvatar/session/close"
  payload = json.dumps({
    "session_id": "session_123456789"
  })
  headers = {
    'Authorization': 'Bearer your_token_here',
    'Content-Type': 'application/json'
  }

  response = requests.request("POST", url, headers=headers, data=payload)
  print(response.text)
  ```
</CodeGroup>

## Response Example

```json theme={null}
{
  "code": 1000,
  "msg": "ok",
  "data": {
    "session_id": "session_123456789",
    "status": "closed",
    "closed_at": 1700788730000
  }
}
```


## OpenAPI

````yaml POST /api/open/v4/liveAvatar/session/close
openapi: 3.0.3
info:
  title: Live Avatar API
  description: API for managing streaming avatars and sessions
  version: 1.0.0
servers:
  - url: https://openapi.akool.com
    description: Production server
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /api/open/v4/liveAvatar/session/close:
    post:
      tags:
        - Session Management
      summary: Close Session
      description: Close an active streaming session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: Session ID from the _id field returned by Create Session
            example:
              id: 6698c9d69cf7b0d61d1b6420
      responses:
        '200':
          description: Session closed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
components:
  schemas:
    ApiResponse:
      type: object
      required:
        - code
        - msg
      properties:
        code:
          type: integer
          description: 'Interface returns business status code (1000: success)'
          example: 1000
        msg:
          type: string
          description: Interface returns status information
          example: OK
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your API Key used for request authorization. If both Authorization and
        x-api-key have values, Authorization will be used first and x-api-key
        will be discarded.
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your API Key used for request authorization. Get Token from
        authentication/usage#get-the-token

````