---
updatedAt: 2026-05-27T08:00:07.000Z
agentTools:
  projectIndex: https://docs.d-id.com/llms.txt
---

# Create a new stream

Initiates the creation of a new WebRTC connection to a browser peer. The endpoint returns the necessary information to set up and manage the connection.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Realtime Endpoints",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://api.d-id.com/"
    }
  ],
  "paths": {
    "/agents/{agentId}/streams": {
      "post": {
        "operationId": "CreateStream",
        "responses": {
          "201": {
            "description": "Created stream",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitStreamResponse"
                }
              }
            }
          },
          "401": {
            "description": "AuthorizationError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "AuthorizationError",
                      "description": "user unauthenticated"
                    }
                  }
                }
              }
            }
          },
          "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": "Initiates the creation of a new WebRTC connection to a browser peer. The endpoint returns the necessary information to set up and manage the connection.",
        "summary": "Create a new stream",
        "tags": [
          "Agents Streams"
        ],
        "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/InitVideoStreamRequest"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JsonError": {
        "properties": {
          "kind": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "details": {},
          "internal": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "description"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "OfferJsep": {
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "offer"
            ],
            "nullable": false,
            "description": "The session description object describes the initial proposal in an offer/answer exchange."
          },
          "sdp": {
            "type": "string",
            "description": "Describe the media communication sessions to accept the session the is being negotiated"
          }
        },
        "required": [
          "type",
          "sdp"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "IceServer": {
        "properties": {
          "urls": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "string"
              }
            ],
            "description": "URL of the server - can be multiple addresses"
          },
          "username": {
            "type": "string",
            "description": "Username for authentication"
          },
          "credential": {
            "type": "string",
            "description": "Credintials for secure connection to the server"
          }
        },
        "required": [
          "urls"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "InitStreamResponse": {
        "properties": {
          "session_id": {
            "type": "string"
          },
          "id": {
            "type": "string",
            "description": "Id of the stream - should be returned as *path parameter* in all streaming request to the same stream"
          },
          "jsep": {
            "$ref": "#/components/schemas/OfferJsep",
            "description": "Jsep offer object used to create a peer connection"
          },
          "ice_servers": {
            "items": {
              "$ref": "#/components/schemas/IceServer"
            },
            "type": "array",
            "description": "ICE servers used to create a peer connection"
          }
        },
        "required": [
          "id",
          "jsep",
          "ice_servers"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "CompatibilityMode": {
        "type": "string",
        "enum": [
          "on",
          "off",
          "auto"
        ],
        "title": "Compatibility Mode"
      },
      "InitVideoStreamRequest": {
        "properties": {
          "fluent": {
            "type": "boolean",
            "description": "Whether to request a fluent stream.",
            "default": false
          },
          "session_timeout": {
            "type": "number",
            "format": "double",
            "description": "Maximum duration (in seconds) between messages before session times out.\nCan only be used with proper permissions",
            "example": 180,
            "maximum": 300
          },
          "stream_warmup": {
            "type": "boolean",
            "description": "Whether to stream wamrup video on the connection.\nIf set to true, will stream a warmup video when connection is established.\nAt the end of the warmup video, a message containing \"stream/ready\" will be sent on the data channel.",
            "default": false
          },
          "compatibility_mode": {
            "$ref": "#/components/schemas/CompatibilityMode",
            "description": "Defines the video codec to be used in the stream.\nWhen set to on: VP8 will be used.\nWhen set to off: H264 will be used\nWhen set to auto the codec will be selected according to the browser."
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "basic": {
        "type": "http",
        "scheme": "basic"
      }
    }
  },
  "x-readme": {
    "samples-languages": [
      "curl"
    ]
  }
}
```