# Create streaming key (/en/api-reference/api-ref/rtmp-gateway/create-streaming-key)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Creates a streaming key for Media Gateway ingress streaming.

- OpenAPI: /openapi/media-gateway/media-gateway.en.yaml
- Operation ID: create-media-gateway-streaming-key
- Method: POST
- Path: /{region}/v1/projects/{appId}/rtls/ingress/streamkeys

## Servers

- https://api.agora.io

## Parameters

- `region` (path, required) - Region for the streaming key or stream. Supported values are `na` for North America, `eu` for Europe, `ap` for Asia except mainland China, and `cn` for mainland China.
- `appId` (path, required) - The app ID provided by Agora to each developer. After creating a project in Agora Console, you can get an app ID. The app ID is a unique identifier for a project.
- `X-Request-ID` (header, optional) - The UUID (Universally Unique Identifier) of the request. After you pass in this field, the Agora server returns this field in the response header. It is recommended to assign `X-Request-ID` a value. If omitted, the Agora server automatically generates a UUID and returns it.

## Request body

- `settings` (object, required)
  - `settings.channel` (string, required) - Agora channel name. The string length must be less than 64 bytes. You can leave this field empty and Agora uses a random integer UID to enter the channel in the `GR-xxxx` format. The `channel` and `uid` parameters cannot be empty or `0` at the same time.
No schema.
  - `settings.uid` (string, required) - Host user UID in the Agora channel. Numeric IDs can range from 1 to 4294967295. String IDs cannot exceed 255 bytes or be empty. If this field is empty or `0`, Agora uses a random integer UID. The `channel` and `uid` parameters cannot be empty or `0` at the same time.
No schema.
  - `settings.expiresAfter` (integer, required) - Validity period of the streaming key in seconds from creation. If set to `0`, the streaming key is always valid. Do not leave this field empty or set it to null.
No schema.
  - `settings.templateId` (string) - Associated flow configuration template ID. Omit this field if you have not created a configuration template. If omitted, the default configuration is used.
No schema.

## Responses

### 200

The request succeeded and returned the created streaming key.

- `status` (string) - Request status. `success` means the request succeeds.
No schema.
- `data` (object)
  - `data.streamKey` (string) - The streaming key.
No schema.
  - `data.channel` (string) - Agora channel name associated with the streaming key.
No schema.
  - `data.uid` (string) - User UID associated with the streaming key.
No schema.
  - `data.expiresAfter` (integer) - Validity period of the streaming key in seconds.
No schema.
  - `data.createdAt` (string) - Unix timestamp, in seconds, when the streaming key was created.
No schema.
### 401

The request failed. A `401 (Unauthorized)` response status code means the request is not authorized.

- `status` (string) - Request status.
No schema.
- `message` (string) - Description of why the request failed.
No schema.
### default

The request failed. A `401 (Unauthorized)` response status code means the request is not authorized.

- `status` (string) - Request status.
No schema.
- `message` (string) - Description of why the request failed.
No schema.
