---
updatedAt: 2026-05-24T12:18:34.000Z
agentTools:
  projectIndex: https://docs.d-id.com/llms.txt
---

# Create a new session

Creates a new streaming session for an Expressive Agent and returns the credentials needed to connect to the room.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Realtime Endpoints",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://api.d-id.com/"
    }
  ],
  "paths": {
    "/v2/agents/{agentId}/sessions": {
      "post": {
        "operationId": "CreateSession",
        "responses": {
          "201": {
            "description": "Created session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitSessionV2Response"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "BadRequest",
                      "description": "Invalid request parameters"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AuthorizationError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "AuthorizationError",
                      "description": "user unauthenticated"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "Forbidden",
                      "description": "echo sessions require a secret credential"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "NotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "NotFound",
                      "description": "Agent not found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "NotReadyError | ConflictError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "NotReadyError",
                      "description": "This agent is being built. Please try again in a minute or two."
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Creates a new streaming session for an Expressive Agent and returns the credentials needed to connect to the room.",
        "summary": "Create a new session",
        "tags": [
          "Agents Sessions V2"
        ],
        "security": [
          {
            "basic": []
          },
          {
            "bearer": []
          },
          {
            "client-key": []
          }
        ],
        "parameters": [
          {
            "description": "Agent Id",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InitSessionV2Request"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JsonError": {
        "properties": {
          "kind": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "details": {},
          "internal": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "description"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "InitSessionV2Response": {
        "properties": {
          "id": {
            "type": "string",
            "description": "Session ID for the session"
          },
          "session_url": {
            "type": "string",
            "description": "Session URL for connecting to the session"
          },
          "session_token": {
            "type": "string",
            "description": "Session token for authentication"
          },
          "interrupt_enabled": {
            "type": "boolean",
            "description": "Whether interrupt is enabled for this session"
          },
          "echo_token": {
            "type": "string",
            "description": "LiveKit token for the caller's backend to join the room and stream audio into the session.\nReturned only for `echo` sessions, which require a secret credential."
          }
        },
        "required": [
          "id",
          "session_url",
          "session_token",
          "interrupt_enabled"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "SessionRequestType": {
        "enum": [
          "interactive",
          "echo"
        ],
        "type": "string"
      },
      "InitSessionV2Request": {
        "properties": {
          "session_type": {
            "$ref": "#/components/schemas/SessionRequestType",
            "description": "Type of session to create; defaults to `interactive`.\n`echo` also returns a `echo_token` and requires a secret credential (API key or bearer token)."
          },
          "chat_persist": {
            "type": "boolean",
            "description": "whether to persist the chat",
            "default": false
          }
        },
        "type": "object",
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "basic": {
        "type": "http",
        "scheme": "basic"
      }
    }
  },
  "x-readme": {
    "samples-languages": [
      "curl"
    ]
  }
}
```