# Create and manage stream targets You can use the Wowza Streaming Engineā„¢ media server software REST API to identify and manage stream targets in a Wowza Streaming Engine instance. > **Notes:** - Wowza Streaming Engine 4.3.0 or later is required. - PHP examples for the tasks in this article are available in the **tests** folder of the [PHP REST Library for Wowza Streaming Engine on GitHub](https://github.com/WowzaMediaSystems/wse-rest-library-php). ## Enable push publishing in the Wowza Streaming Engine REST API Before you can create or use stream targets with the Wowza Streaming Engine REST API, you must enable the push publishing module. To do so, you need to add an advanced property to the application's configuration and add the push publish module to the application. Start by retrieving the details of the application's advanced settings and a list of the modules the application is using. Retrieve the information by sending a GET call to the endpoint `/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv`. > **Note**: Wowza Streaming Engine REST API requests must include three headers: **Accept:application/json, Content-Type:application/json**, and **charset=utf-8**. For more information, see [Query the Wowza Streaming Engine REST API](https://www.wowza.com/docs/how-to-query-the-wowza-streaming-engine-rest-api). Example request: ```bash curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv" ``` The request returns an object (**advancedSettings**) that shows the application's advanced settings and a modules list of the **modules** in use. The response looks something like this: ```json { "version": "1543353224014", "serverName": "serverName", "advancedSettings": [ { "enabled": false, "canRemove": true, "name": "debugAACTimecodes", "value": "false", "defaultValue": "false", "type": "Boolean", "sectionName": "cupertinostreamingpacketizer", "section": "/Root/Application/LiveStreamPacketizer", "documented": true }, { "enabled": false, "canRemove": true, "name": "debugMP3Timecodes", "value": "false", "defaultValue": "false", "type": "Boolean", "sectionName": "cupertinostreamingpacketizer", "section": "/Root/Application/LiveStreamPacketizer", "documented": true }, ... ], "modules": [ { "order": 0, "name": "base", "description": "Base", "class": "com.wowza.wms.module.ModuleCore" }, { "order": 1, "name": "logging", "description": "Client Logging", "class": "com.wowza.wms.module.ModuleClientLogging" }, { "order": 2, "name": "flvplayback", "description": "FLVPlayback", "class": "com.wowza.wms.module.ModuleFLVPlayback" }, { "order": 3, "name": "ModuleCoreSecurity", "description": "Core Security Module for Applications", "class": "com.wowza.wms.security.ModuleCoreSecurity" } ] } ``` > **Note**: During GET requests to the `/v2/servers/{serverName}/vhosts/(vhostName}/applications/{appName}/adv` endpoint, the **wowzaVideoApiToken** used for Wowza Video stream targets is obfuscated. When you run a PUT or POST request for this same endpoint, the **wowzaVideoApiToken** is encrypted when stored. Now, execute a PUT command to accomplish two tasks: Add the pushPublishMapPath property to the application's configuration. Append the ModulePushPublish to the complete list of modules in use. > **Note**: The PUT command must include all of the existing modules in use by the application as well as the push publish module; use the response from the GET call to enumerate the modules that precede **ModulePushPublish** in the PUT call. The command calls the same endpoint, `/v2/servers/{serverName}/vhosts/(vhostName}/applications/{appName}/adv`, and looks like this: ```bash curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv" { "version": "1543353224014", "serverName": "serverName", "advancedSettings": [ { "enabled": true, "canRemove": false, "name": "pushPublishMapPath", "value": "${com.wowza.wms.context.VHostConfigHome}/conf/${com.wowza.wms.context.Application}/PushPublishMap.txt", "defaultValue": null, "type": "String", "sectionName": "Application", "section": "/Root/Application", "documented": false } ], "modules": [ { "order": 0, "name": "base", "description": "Base", "class": "com.wowza.wms.module.ModuleCore" }, { "order": 1, "name": "logging", "description": "Client Logging", "class": "com.wowza.wms.module.ModuleClientLogging" }, { "order": 2, "name": "flvplayback", "description": "FLVPlayback", "class": "com.wowza.wms.module.ModuleFLVPlayback" }, { "order": 3, "name": "ModuleCoreSecurity", "description": "Core Security Module for Applications", "class": "com.wowza.wms.security.ModuleCoreSecurity" }, { "order": 4, "name": "ModulePushPublish", "description": "ModulePushPublish", "class": "com.wowza.wms.pushpublish.module.ModulePushPublish" } ] } ``` Finally, restart the application, and then you can create and edit stream targets using the Wowza Streaming Engine REST API. ```bash curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/actions/restart" ``` ## Get a list of stream targets View a list of stream targets for an application: ```bash curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries ``` View a list of stream targets for an application named **testlive**: ```bash curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/pushpublish/mapentries ``` ## Get a stream target Run the following cURL request to retrieve a stream target for the Wowza Streaming Engine **live** application with an **entryName** of **my-rtmp-stream-target**. This is a Wowza Streaming Engine stream target that uses an RTMP destination to deliver the stream to viewers: ```bash curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/live/pushpublish/mapentries/my-rtmp-stream-target ``` A sample response looks similar to this: ```json { "serverName": "_defaultServer_", "entryName": "my-rtmp-stream-target", "sessionStatus": "NotFound", "enabled": true, "autoStartTranscoder": false, "sourceStreamName": "myStream", "profile": "rtmp", "streamName": "myStream", "application": "my-application", "host": "wowza.myserver.com", "port": 1935, "userName": "myUser", "password": "myPassword", "adaptiveStreaming": false, "sendFCPublish": true, "sendReleaseStream": true, "sendStreamCloseCommands": true, "removeDefaultAppInstance": true, "sendOriginalTimecodes": true, "originalTimecodeThreshold": "0x100000", ... "extraOptions": { "destinationName": "rtmp" } } ``` ## Create a stream target Create a stream target for the Wowza Streaming Engine **testlive** application (an RTMP destination) with an **entryName** of **ppsource**. > **Note:** The parameters required vary by stream target destination type. All stream targets must have an **entryName** and **profile** specified. See [Sample map file entries for Stream Target destinations (push publishing)](https://www.wowza.com/docs/sample-map-file-entries-for-stream-target-destinations-push-publishing) for the lists of additional required and optional parameters you can specify for each stream target destination type. ```bash curl -X POST \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/pushpublish/mapentries/ppsource \ -d '{ "serverName": "serverName", "sourceStreamName": "streamName", "entryName": "ppsource", "profile": "rtmp", "host": "localhost", "application": "testlive", "userName": "testUser", "password": "pass", "streamName": "streamName" }' ``` ## Update a stream target You can run the PUT request below to update a stream target for an **rtmp** profile. When updating stream targets, include all parameters you intend to preserve during the PUT request. Otherwise, those parameters will be removed from the stream target. ```bash curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries/{entryName} \ -d '{ "serverName": "serverName", "sourceStreamName": "streamName", "entryName": "entryName", "profile": "rtmp", "host": "localhost", "application": "appName", "userName": "testUser", "password": "pass", "streamName": "streamName" }' ``` ## Remove a stream target Delete a stream target: ```bash curl -X DELETE \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries/{entryName} ```