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

# Create a livestream

> The only parameter you are required to set is the name of your stream,
but we also highly recommend that you define transcoding profiles
parameter that suits your specific broadcasting configuration.
\
\
If you do not define transcoding rendition profiles when creating the
stream, a default set of profiles will be used. These profiles include
240p,  360p, 480p and 720p.
\
\
The playback policy is set to public by default for new streams. It can
also be added upon the creation of a new stream by adding
`"playbackPolicy": {"type": "jwt"}`




## OpenAPI

````yaml POST /stream
openapi: 3.1.0
info:
  title: Livepeer API Reference
  description: |
    Welcome to the Livepeer API reference docs. Here you will find all the
    endpoints exposed on the standard Livepeer API, learn how to use them and
    what they return.
  version: 1.0.0
servers:
  - url: https://livepeer.studio/api
security:
  - apiKey: []
tags:
  - name: stream
    description: Operations related to livestream api
  - name: asset
    description: Operations related to asset/vod api
  - name: webhook
    description: Operations related to webhook api
  - name: multistream
    description: Operations related to multistream api
  - name: session
    description: Operations related to session api
  - name: room
    description: Operations related to rooms api
  - name: transcode
    description: Operations related to transcode api
  - name: metrics
    description: Operations related to metrics api
  - name: playback
    description: Operations related to playback api
  - name: accessControl
    description: Operations related to access control/signing keys api
  - name: task
    description: Operations related to tasks api
  - name: generate
    description: Operations related to AI generate api
paths:
  /stream:
    post:
      tags:
        - stream
      summary: Create a stream
      description: |
        The only parameter you are required to set is the name of your stream,
        but we also highly recommend that you define transcoding profiles
        parameter that suits your specific broadcasting configuration.
        \
        \
        If you do not define transcoding rendition profiles when creating the
        stream, a default set of profiles will be used. These profiles include
        240p,  360p, 480p and 720p.
        \
        \
        The playback policy is set to public by default for new streams. It can
        also be added upon the creation of a new stream by adding
        `"playbackPolicy": {"type": "jwt"}`
      operationId: createStream
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/new-stream-payload'
              type: object
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stream'
                x-speakeasy-name-override: data
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      x-codeSamples:
        - lang: typescript
          label: createStream
          source: >-
            import { Livepeer } from "livepeer";

            import { Profile, TranscodeProfileEncoder, TranscodeProfileProfile,
            Type } from "livepeer/models/components";


            const livepeer = new Livepeer({
              apiKey: "<YOUR_BEARER_TOKEN_HERE>",
            });


            async function run() {
              const result = await livepeer.stream.create({
                name: "test_stream",
                pull: {
                  source: "https://myservice.com/live/stream.flv",
                  headers: {
                    "Authorization": "Bearer 123",
                  },
                  location: {
                    lat: 39.739,
                    lon: -104.988,
                  },
                },
                playbackPolicy: {
                  type: Type.Webhook,
                  webhookId: "1bde4o2i6xycudoy",
                  webhookContext: {
                    "streamerId": "my-custom-id",
                  },
                  refreshInterval: 600,
                },
                profiles: [
                  {
                    width: 1280,
                    name: "720p",
                    height: 720,
                    bitrate: 3000000,
                    fps: 30,
                    fpsDen: 1,
                    quality: 23,
                    gop: "2",
                    profile: Profile.H264Baseline,
                  },
                ],
                record: false,
                recordingSpec: {
                  profiles: [
                    {
                      width: 1280,
                      name: "720p",
                      height: 720,
                      bitrate: 3000000,
                      quality: 23,
                      fps: 30,
                      fpsDen: 1,
                      gop: "2",
                      profile: TranscodeProfileProfile.H264Baseline,
                      encoder: TranscodeProfileEncoder.H264,
                    },
                    {
                      width: 1280,
                      name: "720p",
                      height: 720,
                      bitrate: 3000000,
                      quality: 23,
                      fps: 30,
                      fpsDen: 1,
                      gop: "2",
                      profile: TranscodeProfileProfile.H264Baseline,
                      encoder: TranscodeProfileEncoder.H264,
                    },
                  ],
                },
                multistream: {
                  targets: [
                    {
                      profile: "720p0",
                      videoOnly: false,
                      id: "PUSH123",
                      spec: {
                        name: "My target",
                        url: "rtmps://live.my-service.tv/channel/secretKey",
                      },
                    },
                  ],
                },
              });

              // Handle the result
              console.log(result);
            }


            run();
        - lang: go
          label: createStream
          source: "package main\n\nimport(\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"context\"\n\t\"github.com/livepeer/livepeer-go/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    s := livepeergo.New(\n        livepeergo.WithSecurity(\"<YOUR_BEARER_TOKEN_HERE>\"),\n    )\n\n    ctx := context.Background()\n    res, err := s.Stream.Create(ctx, components.NewStreamPayload{\n        Name: \"test_stream\",\n        Pull: &components.Pull{\n            Source: \"https://myservice.com/live/stream.flv\",\n            Headers: map[string]string{\n                \"Authorization\": \"Bearer 123\",\n            },\n            Location: &components.Location{\n                Lat: 39.739,\n                Lon: -104.988,\n            },\n        },\n        PlaybackPolicy: &components.PlaybackPolicy{\n            Type: components.TypeWebhook,\n            WebhookID: livepeergo.String(\"1bde4o2i6xycudoy\"),\n            WebhookContext: map[string]any{\n                \"streamerId\": \"my-custom-id\",\n            },\n            RefreshInterval: livepeergo.Float64(600),\n        },\n        Profiles: []components.FfmpegProfile{\n            components.FfmpegProfile{\n                Width: 1280,\n                Name: \"720p\",\n                Height: 720,\n                Bitrate: 3000000,\n                Fps: 30,\n                FpsDen: livepeergo.Int64(1),\n                Quality: livepeergo.Int64(23),\n                Gop: livepeergo.String(\"2\"),\n                Profile: components.ProfileH264Baseline.ToPointer(),\n            },\n        },\n        Record: livepeergo.Bool(false),\n        RecordingSpec: &components.NewStreamPayloadRecordingSpec{\n            Profiles: []components.TranscodeProfile{\n                components.TranscodeProfile{\n                    Width: livepeergo.Int64(1280),\n                    Name: livepeergo.String(\"720p\"),\n                    Height: livepeergo.Int64(720),\n                    Bitrate: 3000000,\n                    Quality: livepeergo.Int64(23),\n                    Fps: livepeergo.Int64(30),\n                    FpsDen: livepeergo.Int64(1),\n                    Gop: livepeergo.String(\"2\"),\n                    Profile: components.TranscodeProfileProfileH264Baseline.ToPointer(),\n                    Encoder: components.TranscodeProfileEncoderH264.ToPointer(),\n                },\n            },\n        },\n        Multistream: &components.Multistream{\n            Targets: []components.Target{\n                components.Target{\n                    Profile: \"720p\",\n                    VideoOnly: livepeergo.Bool(false),\n                    ID: livepeergo.String(\"PUSH123\"),\n                    Spec: &components.TargetSpec{\n                        Name: livepeergo.String(\"My target\"),\n                        URL: \"rtmps://live.my-service.tv/channel/secretKey\",\n                    },\n                },\n            },\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.Stream != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: createStream
          source: |-
            from livepeer import Livepeer
            from livepeer.models import components

            s = Livepeer(
                api_key="<YOUR_BEARER_TOKEN_HERE>",
            )

            res = s.stream.create(request={
                "name": "test_stream",
                "pull": {
                    "source": "https://myservice.com/live/stream.flv",
                    "headers": {
                        "Authorization": "Bearer 123",
                    },
                    "location": {
                        "lat": 39.739,
                        "lon": -104.988,
                    },
                },
                "playback_policy": {
                    "type": components.Type.WEBHOOK,
                    "webhook_id": "1bde4o2i6xycudoy",
                    "webhook_context": {
                        "streamerId": "my-custom-id",
                    },
                    "refresh_interval": 600,
                },
                "profiles": [
                    {
                        "width": 1280,
                        "name": "720p",
                        "height": 720,
                        "bitrate": 3000000,
                        "fps": 30,
                        "fps_den": 1,
                        "quality": 23,
                        "gop": "2",
                        "profile": components.Profile.H264_BASELINE,
                    },
                ],
                "record": False,
                "recording_spec": {
                    "profiles": [
                        {
                            "width": 1280,
                            "name": "720p",
                            "height": 720,
                            "bitrate": 3000000,
                            "quality": 23,
                            "fps": 30,
                            "fps_den": 1,
                            "gop": "2",
                            "profile": components.TranscodeProfileProfile.H264_BASELINE,
                            "encoder": components.TranscodeProfileEncoder.H_264,
                        },
                    ],
                },
                "multistream": {
                    "targets": [
                        {
                            "profile": "720p",
                            "video_only": False,
                            "id": "PUSH123",
                            "spec": {
                                "name": "My target",
                                "url": "rtmps://live.my-service.tv/channel/secretKey",
                            },
                        },
                    ],
                },
            })

            if res.stream is not None:
                # handle response
                pass
components:
  schemas:
    new-stream-payload:
      type: object
      required:
        - name
      additionalProperties: false
      properties:
        name: 838548a5-c1e0-4b46-a1f4-7d2ae249ad0d
        pull: a9d0e340-cdf9-4266-a28f-c0e09b5d6ab7
        creatorId:
          $ref: '#/components/schemas/input-creator-id'
        playbackPolicy:
          $ref: '#/components/schemas/playback-policy'
        profiles:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ffmpeg-profile'
          default:
            $ref: '#/components/schemas/stream/properties/profiles/default'
        record: efda6da5-8ee5-45f5-9faf-e5d1953c6b4b
        recordingSpec:
          type: object
          additionalProperties: false
          properties:
            profiles:
              type:
                - array
                - 'null'
              items:
                $ref: '#/components/schemas/transcode-profile'
        multistream: 807e7de9-fe04-41b4-9a6f-4f2a442957df
        userTags: ad5fb4e2-ed71-47b2-950c-35b8f5628767
    stream:
      type: object
      required:
        - name
      additionalProperties: false
      properties:
        id:
          type: string
          readOnly: true
          example: de7818e7-610a-4057-8f6f-b785dc1e6f88
        name:
          type: string
          example: test_stream
        kind:
          type: string
          example: stream
          deprecated: true
        creatorId:
          $ref: '#/components/schemas/creator-id'
        userTags:
          type: object
          description: User input tags associated with the stream
          additionalProperties:
            oneOf:
              - type: string
              - type: number
              - type: array
                items:
                  oneOf:
                    - type: string
                    - type: number
        lastSeen:
          type: number
          example: 1587667174725
        sourceSegments:
          type: number
          example: 1
        transcodedSegments:
          type: number
          example: 2
        sourceSegmentsDuration:
          type: number
          example: 1
          description: Duration of all the source segments, sec
        transcodedSegmentsDuration:
          type: number
          example: 2
          description: Duration of all the transcoded segments, sec
        sourceBytes:
          type: number
          example: 1
        transcodedBytes:
          type: number
          example: 2
        ingestRate:
          type: number
          example: 1
          description: Rate at which sourceBytes increases (bytes/second)
        outgoingRate:
          type: number
          example: 2
          description: Rate at which transcodedBytes increases (bytes/second)
        isActive:
          type: boolean
          description: If currently active
          example: true
        isHealthy: aed8c1c2-f270-495b-97a2-11b76dddbbd6
        issues: f5adca63-bbd5-4bcf-a306-2f02a53089f6
        createdByTokenName:
          type: string
          readOnly: true
          description: Name of the token used to create this object
          example: abc-123-xyz-456
        createdAt:
          type: number
          readOnly: true
          description: Timestamp (in milliseconds) at which stream object was created
          example: 1587667174725
        parentId:
          type: string
          example: de7818e7-610a-4057-8f6f-b785dc1e6f88
          description: Points to parent stream object
        streamKey:
          type: string
          example: hgebdhhigq
          description: Used to form RTMP ingest URL
        pull:
          type: object
          description: |-
            Configuration for a stream that should be actively pulled from an
            external source, rather than pushed to Livepeer. If specified, the
            stream will not have a streamKey.
          additionalProperties: false
          required:
            - source
          properties:
            source:
              type: string
              description: URL from which to pull from.
              example: https://myservice.com/live/stream.flv
            headers:
              type: object
              description: Headers to be sent with the request to the pull source.
              additionalProperties:
                type: string
              example:
                Authorization: Bearer 123
            isMobile:
              oneOf:
                - type: integer
                  enum:
                    - 0
                    - 1
                    - 2
                  description: '0: not mobile, 1: mobile screen share, 2: mobile camera.'
                - type: boolean
                  description: If true, the stream will be pulled from a mobile source.
              description: >-
                Indicates whether the stream will be pulled from a mobile
                source.
              default: 0
            location:
              type: object
              description: |-
                Approximate location of the pull source. The location is used to
                determine the closest Livepeer region to pull the stream from.
              additionalProperties: false
              required:
                - lat
                - lon
              properties:
                lat:
                  type: number
                  description: |-
                    Latitude of the pull source in degrees. North is positive,
                    south is negative.
                  example: 39.739
                lon:
                  type: number
                  description: |-
                    Longitude of the pull source in degrees. East is positive,
                    west is negative.
                  example: -104.988
        playbackId:
          type: string
          example: eaw4nk06ts2d0mzb
          description: >-
            The playback ID to use with the Playback Info endpoint to retrieve
            playback URLs.
        playbackPolicy:
          $ref: '#/components/schemas/playback-policy'
        profiles:
          type: array
          description: |
            Profiles to transcode the stream into. If not specified, a default
            set of profiles will be used with 240p, 360p, 480p and 720p
            resolutions. Keep in mind that the source rendition is always kept.
          default:
            - name: 240p0
              fps: 0
              bitrate: 250000
              width: 426
              height: 240
            - name: 360p0
              fps: 0
              bitrate: 800000
              width: 640
              height: 360
            - name: 480p0
              fps: 0
              bitrate: 1600000
              width: 854
              height: 480
            - name: 720p0
              fps: 0
              bitrate: 3000000
              width: 1280
              height: 720
          items:
            $ref: '#/components/schemas/ffmpeg-profile'
        projectId:
          type: string
          description: The ID of the project
          example: aac12556-4d65-4d34-9fb6-d1f0985eb0a9
        record:
          description: |
            Should this stream be recorded? Uses default settings. For more
            customization, create and configure an object store.
          type: boolean
          example: false
        recordingSpec:
          type: object
          description: |
            Configuration for recording the stream. This can only be set if
            `record` is true.
          additionalProperties: false
          properties:
            profiles:
              type: array
              items:
                $ref: '#/components/schemas/transcode-profile'
              description: |
                Profiles to process the recording of this stream into. If not
                specified, default profiles will be derived based on the stream
                input. Keep in mind that the source rendition is always kept.
        multistream:
          type: object
          additionalProperties: false
          properties:
            targets:
              type: array
              example:
                - id: PUSH123
                  profile: 720p
              description: |
                References to targets where this stream will be simultaneously
                streamed to
              items:
                $ref: '#/components/schemas/target'
        suspended:
          type: boolean
          description: If currently suspended
        lastTerminatedAt:
          type:
            - number
            - 'null'
          example: 1713281212993
          description: Timestamp (in milliseconds) when the stream was last terminated
        userId:
          type: string
          readOnly: true
          example: we7818e7-610a-4057-8f6f-b785dc1e6f88
          deprecated: true
        renditions:
          type: object
    error:
      type: object
      properties:
        errors:
          type: array
          minItems: 1
          items:
            type: string
            example:
              - id not provided
              - Account not found
    input-creator-id:
      oneOf:
        - type: object
          additionalProperties: false
          required:
            - type
            - value
          properties:
            type:
              type: string
              enum:
                - unverified
            value:
              type: string
        - type: string
          description: >-
            Helper syntax to specify an unverified creator ID, fully managed by
            the developer.
    playback-policy:
      type:
        - object
        - 'null'
      description: Whether the playback policy for an asset or stream is public or signed
      additionalProperties: false
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - public
            - jwt
            - webhook
          example: webhook
        webhookId:
          type: string
          description: ID of the webhook to use for playback policy
          example: 1bde4o2i6xycudoy
        webhookContext:
          type: object
          description: User-defined webhook context
          additionalProperties: true
          example:
            streamerId: my-custom-id
        refreshInterval:
          type: number
          description: |
            Interval (in seconds) at which the playback policy should be
            refreshed (default 600 seconds)
          example: 600
        allowedOrigins:
          type: array
          description: >-
            List of allowed origins for CORS playback
            (<scheme>://<hostname>:<port>, <scheme>://<hostname>)
          items:
            type: string
    ffmpeg-profile:
      type: object
      description: Transcode profile
      additionalProperties: false
      required:
        - width
        - name
        - height
        - bitrate
        - fps
      properties:
        width:
          type: integer
          minimum: 128
          example: 1280
        name:
          type: string
          minLength: 1
          maxLength: 500
          example: 720p
        height:
          type: integer
          minimum: 128
          example: 720
        bitrate:
          type: integer
          minimum: 400
          example: 3000000
        fps:
          type: integer
          minimum: 0
          example: 30
        fpsDen:
          type: integer
          minimum: 1
          example: 1
        quality:
          type: integer
          description: >
            Restricts the size of the output video using the constant quality
            feature. Increasing this value will result in a lower quality video.
            Note that this parameter might not work if the transcoder lacks
            support for it.
          minimum: 0
          maximum: 44
          example: 23
        gop:
          type: string
          example: 2
        profile:
          type: string
          enum:
            - H264Baseline
            - H264Main
            - H264High
            - H264ConstrainedHigh
          example: H264Baseline
        encoder:
          type: string
          enum:
            - H.264
    transcode-profile:
      type: object
      description: Transcode API profile
      additionalProperties: false
      required:
        - bitrate
      properties:
        width:
          type: integer
          minimum: 128
          example: 1280
        name:
          type: string
          minLength: 1
          maxLength: 500
          example: 720p
        height:
          type: integer
          minimum: 128
          example: 720
        bitrate:
          type: integer
          minimum: 400
          example: 3000000
        quality:
          type: integer
          description: >
            Restricts the size of the output video using the constant quality
            feature. Increasing this value will result in a lower quality video.
            Note that this parameter might not work if the transcoder lacks
            support for it.
          minimum: 0
          maximum: 44
          example: 23
        fps:
          type: integer
          minimum: 0
          example: 30
        fpsDen:
          type: integer
          minimum: 1
          example: 1
        gop:
          type: string
          example: 2
        profile:
          type: string
          enum:
            - H264Baseline
            - H264Main
            - H264High
            - H264ConstrainedHigh
          example: H264Baseline
        encoder:
          type: string
          enum:
            - H.264
            - HEVC
            - VP8
            - VP9
          example: H.264
    creator-id:
      oneOf:
        - type: object
          additionalProperties: false
          required:
            - type
            - value
          properties:
            type:
              type: string
              enum:
                - unverified
              example: unverified
            value:
              type: string
              description: Developer-managed ID of the user who created the resource.
              example: user123
    target:
      type: object
      required:
        - profile
      additionalProperties: false
      properties:
        profile:
          type: string
          description: |
            Name of transcoding profile that should be sent. Use
            "source" for pushing source stream data
          minLength: 1
          maxLength: 500
          example: 720p0
        videoOnly:
          type: boolean
          description: |
            If true, the stream audio will be muted and only silent
            video will be pushed to the target.
          default: false
          example: false
        id:
          type: string
          description: ID of multistream target object where to push this stream
          example: PUSH123
        spec:
          type: object
          writeOnly: true
          description: |
            Inline multistream target object. Will automatically
            create the target resource to be used by the created
            stream.
          required:
            - url
          additionalProperties: false
          properties:
            name:
              type: string
              example: My target
            url: 2d40d583-52db-44b0-a09b-18e2f8dab8de
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````