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

# Renew stream lease

> Renew the stream lease and pay for elapsed streaming time. **Call every 10-20 seconds.** Streams expire after ~45 seconds without a keepalive.

Each call charges for time since the last keepalive. If credits are insufficient (402), the lease is NOT renewed and the stream will expire.

For native transport, the response includes a refreshed `livekit_token`.

## When to call

Streams expire 5 minutes after the last keepalive (or creation, if no keepalive has happened yet). Call `/keepalive` every \~2 minutes — clock skew is real and the cost of a missed renewal is the whole stream.

A keepalive on a stream that's already `ended` returns `404`. Streams cannot be revived; create a new one.

## What you get back

Every successful keepalive returns:

* A new **`expires_at_ms`** set to `now + ttl_seconds`.
* A **fresh LiveKit `publish.token`**. Save it — if your publisher disconnects from the room, you'll need a current token to rejoin without recreating the stream. Old tokens may stop working.
* The current **`stream_time_ms`** (matches `GET /streams/{id}`).


## OpenAPI

````yaml POST /streams/{stream_id}/keepalive
openapi: 3.0.3
info:
  title: Overshoot API
  version: 1.0.0-beta
  description: >
    Real-time video understanding API. Create a live video stream, push frames
    over

    WebRTC (LiveKit), then ask a vision-language model questions about what's
    happening

    using an OpenAI-compatible chat completions endpoint.


    Billing endpoints are mounted on the same host under `/billing`.
servers:
  - url: https://api.overshoot.ai/v1beta
security:
  - bearerAuth: []
tags:
  - name: Streams
    description: Create, inspect, keep alive, and delete live video streams.
  - name: Models
    description: List available vision-language models.
  - name: Chat
    description: Ask models questions about a stream's frames.
  - name: Billing
    description: Pricing, prepaid balance, and checkout.
paths:
  /streams/{stream_id}/keepalive:
    parameters:
      - $ref: '#/components/parameters/StreamId'
      - $ref: '#/components/parameters/RegionHeader'
    post:
      tags:
        - Streams
      summary: Renew stream lease
      description: >
        Renews the stream lease and returns a fresh publish token. Clients
        should renew

        before the 5-minute lease expires, for example every 4 minutes, and pass
        the

        returned token to the LiveKit SDK with `room.updateToken(...)`.
      operationId: keepaliveStream
      responses:
        '200':
          description: Lease renewed.
          headers:
            X-Overshoot-Region:
              $ref: '#/components/headers/RegionResponseHeader'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeepaliveResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Stream unknown, expired, deleted, or owned by a different user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Wrong region.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegionError'
components:
  parameters:
    StreamId:
      name: stream_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: UUID returned by `POST /streams`.
    RegionHeader:
      name: X-Overshoot-Region
      in: header
      required: false
      schema:
        type: string
        enum:
          - us-west1
          - us-central1
      description: >
        Optional hint to route the request to the region that owns the stream.
        If the

        request reaches the wrong region the API returns `409` with a
        `region_error` body.
  headers:
    RegionResponseHeader:
      description: The region that served this request.
      schema:
        type: string
        enum:
          - us-west1
          - us-central1
  schemas:
    KeepaliveResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        expires_at_ms:
          type: integer
        ttl_seconds:
          type: integer
          example: 300
        stream_time_ms:
          type: number
          description: Current stream-clock position in ms.
        publish:
          $ref: '#/components/schemas/PublishInfo'
      required:
        - id
        - expires_at_ms
        - ttl_seconds
        - publish
    Error:
      type: object
      description: Standard error body used by stream-lifecycle and billing endpoints.
      properties:
        detail:
          type: string
      required:
        - detail
    RegionError:
      type: object
      description: Returned on `409` when the request reaches the wrong region.
      properties:
        detail:
          type: object
          properties:
            error:
              type: string
              example: region_error
            expected_region:
              type: string
              example: us-west1
            requested_region:
              type: string
              nullable: true
              example: us-central1
    PublishInfo:
      type: object
      description: WebRTC publish target. Connect with the LiveKit client SDK.
      properties:
        type:
          type: string
          enum:
            - livekit
          default: livekit
        url:
          type: string
          description: LiveKit room URL (`wss://...`).
        token:
          type: string
          description: Short-lived publish JWT for the LiveKit client.
      required:
        - type
        - url
        - token
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key (e.g. `ovs_...`)
      description: >
        Every public HTTP request requires `Authorization: Bearer <api_key>`,
        except

        `GET /models` and the public `/billing/pricing` endpoints.


        - `401` means the key is missing, unknown, or revoked.

        - `403` means the key is valid but cannot access the requested resource.

        - The publish token returned by `POST /streams` is only for publishing
        media to
          LiveKit. It does not replace the API key for HTTP calls.

````