# Twitch

Go live on a Twitch channel with Live Publish. The title is set and the stream key is read automatically.


## Overview

Twitch is a **live-only** platform in Relaycast. You use it as a [Live Publish](/docs/live) destination, not as a target for `POST /v1/posts`. Adding a Twitch account to a post returns a `validation_error`.

When a stream starts, Relaycast:

1. sets the channel title to the stream `title` (up to 140 characters; if this fails the stream still starts),
2. reads the channel's stream key with the Helix API, and
3. streams to Twitch's ingest at `rtmp://live.twitch.tv/app`.

The destination's `watchUrl` is `https://www.twitch.tv/<login>`. The channel goes offline when the stream stops.

## Connect the account

In **[Integrations](https://social-publish-kappa.vercel.app/dashboard/integrations)**, choose **Twitch** and authorize with the account that owns the channel.

### App setup (self-hosted)

1. In the [Twitch developer console](https://dev.twitch.tv/console/apps), register an application. The category is up to you; the client type is **Confidential**.
2. Add the OAuth redirect URL `https://social-publish-kappa.vercel.app/api/integrations/twitch/callback`.
3. Set `TWITCH_CLIENT_ID` and `TWITCH_CLIENT_SECRET` (or add them as a [BYOK OAuth app](/docs/oauth-apps)).

Scopes requested: `channel:read:stream_key` and `channel:manage:broadcast`. Tokens are refreshed automatically. If the refresh is rejected, the account is marked `reconnect_required`.

## Without connecting

You can also stream to Twitch with a key instead of connecting the account. Add a Custom RTMP destination with `"preset": "twitch_manual"`, server `rtmp://live.twitch.tv/app`, and the primary stream key from **Creator Dashboard → Settings → Stream**. The title isn't changed in that case.

## Recommended video

Twitch accepts H.264 up to 1080p60 at 6 Mbps and AAC audio. With `video: "auto"` such sources are passed through unchanged. Anything else is re-encoded to 720p. See [Video and audio](/docs/live#video-and-audio).
