To avoid incurring charges to your Google Cloud account for the resources used
on this page, follow these steps.

## Delete the live config

Delete the live config. The Video Stitcher API archives the livestream event in
Ad Manager.

### REST


Before using any of the request data,
make the following replacements:

- `PROJECT_NUMBER`: your Google Cloud project number; this is located in the **Project number** field on the [IAM Settings](https://console.cloud.google.com/iam-admin/settings) page
- `LOCATION`: the location of the live config; use one of the [supported regions](https://docs.cloud.google.com/video-stitcher/docs/locations.md.txt) Show locations
  - `us-central1`
  - `us-east1`
  - `us-west1`
  - `asia-east1`
  - `asia-south1`
  - `asia-southeast1`
  - `europe-west1`
  - `southamerica-east1`
- `LIVE_CONFIG_ID`: the user-defined identifier for the live config

To send your request, expand one of these options:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Execute the following command:

```
curl -X DELETE \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method DELETE `
    -Headers $headers `
    -Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID" | Select-Object -Expand Content
```

You should receive a JSON response similar to the following:

```
{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
    "verb": "delete",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}
```
This command creates a [long-running operation (LRO)](https://docs.cloud.google.com/video-stitcher/docs/how-to/manage-long-running-operations.md.txt) that you can query to track progress.

### C#


Before trying this sample, follow the C# setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API C# API
reference documentation](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Video.Stitcher.V1/latest).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```c#

using Google.Cloud.Video.Stitcher.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public class DeleteLiveConfigSample
{
    public async Task DeleteLiveConfigAsync(
        string projectId, string location, string liveConfigId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        DeleteLiveConfigRequest request = new DeleteLiveConfigRequest
        {
            LiveConfigName = LiveConfigName.FromProjectLocationLiveConfig(projectId, location, liveConfigId)
        };

        // Make the request.
        Operation<Empty, OperationMetadata> response = await client.DeleteLiveConfigAsync(request);

        // Poll until the returned long-running operation is complete.
        await response.PollUntilCompletedAsync();
    }
}
```

### Go


Before trying this sample, follow the Go setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API Go API
reference documentation](https://pkg.go.dev/cloud.google.com/go/video/stitcher).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```go
import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// deleteLiveConfig deletes a previously-created live config.
func deleteLiveConfig(w io.Writer, projectID, liveConfigID string) error {
	// projectID := "my-project-id"
	// liveConfigID := "my-live-config-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.DeleteLiveConfigRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/liveConfigs/%s", projectID, location, liveConfigID),
	}
	// Deletes the live config.
	op, err := client.DeleteLiveConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("client.DeleteLiveConfig: %w", err)
	}
	err = op.Wait(ctx)
	if err != nil {
		return err
	}

	fmt.Fprintf(w, "Deleted live config")
	return nil
}
```

### Java


Before trying this sample, follow the Java setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API Java API
reference documentation](https://docs.cloud.google.com/java/docs/reference/google-cloud-video-stitcher/latest/overview).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```java

import com.google.cloud.video.stitcher.v1.DeleteLiveConfigRequest;
import com.google.cloud.video.stitcher.v1.LiveConfigName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteLiveConfig {

  private static final int TIMEOUT_IN_MINUTES = 2;

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String liveConfigId = "my-live-config-id";

    deleteLiveConfig(projectId, location, liveConfigId);
  }

  // Deletes a live config.
  public static void deleteLiveConfig(String projectId, String location, String liveConfigId)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      DeleteLiveConfigRequest deleteLiveConfigRequest =
          DeleteLiveConfigRequest.newBuilder()
              .setName(LiveConfigName.of(projectId, location, liveConfigId).toString())
              .build();

      videoStitcherServiceClient
          .deleteLiveConfigAsync(deleteLiveConfigRequest)
          .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
      System.out.println("Deleted live config");
    }
  }
}
```

### Node.js


Before trying this sample, follow the Node.js setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API Node.js API
reference documentation](https://cloud.google.com/nodejs/docs/reference/video-stitcher/latest).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```javascript
/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// liveConfigId = 'my-live-config-id';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function deleteLiveConfig() {
  // Construct request
  const request = {
    name: stitcherClient.liveConfigPath(projectId, location, liveConfigId),
  };
  const [operation] = await stitcherClient.deleteLiveConfig(request);
  await operation.promise();
  console.log('Deleted live config');
}

deleteLiveConfig().catch(err => {
  console.error(err.message);
  process.exitCode = 1;
});
```

### PHP


Before trying this sample, follow the PHP setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API PHP API
reference documentation](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/latest/videostitcher/readme).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```php
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\DeleteLiveConfigRequest;

/**
 * Deletes a live config.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the live config
 * @param string $liveConfigId         The ID of the live config
 */
function delete_live_config(
    string $callingProjectId,
    string $location,
    string $liveConfigId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->liveConfigName($callingProjectId, $location, $liveConfigId);
    $request = (new DeleteLiveConfigRequest())
        ->setName($formattedName);
    $operationResponse = $stitcherClient->deleteLiveConfig($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        // Print status
        printf('Deleted live config %s' . PHP_EOL, $liveConfigId);
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}
```

### Python


Before trying this sample, follow the Python setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API Python API
reference documentation](https://docs.cloud.google.com/python/docs/reference/videostitcher/latest).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python

import argparse

from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)
from google.protobuf import empty_pb2 as empty


def delete_live_config(
    project_id: str, location: str, live_config_id: str
) -> empty.Empty:
    """Deletes a live config.
    Args:
        project_id: The GCP project ID.
        location: The location of the live config.
        live_config_id: The user-defined live config ID."""

    client = VideoStitcherServiceClient()

    name = f"projects/{project_id}/locations/{location}/liveConfigs/{live_config_id}"
    operation = client.delete_live_config(name=name)
    response = operation.result()
    print("Deleted live config")
    return response

```

### Ruby


Before trying this sample, follow the Ruby setup instructions in the
[Video Stitcher API quickstart using
client libraries](https://docs.cloud.google.com/video-stitcher/docs/reference/libraries).


For more information, see the
[Video Stitcher API Ruby API
reference documentation](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-video-stitcher/latest).


To authenticate to Video Stitcher API, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```ruby
require "google/cloud/video/stitcher"

##
# Delete a live config
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param live_config_id [String] Your live config name (e.g. `my-live-config`)
#
def delete_live_config project_id:, location:, live_config_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the live config.
  name = client.live_config_path project: project_id, location: location,
                                 live_config: live_config_id

  # Delete the live config.
  operation = client.delete_live_config name: name

  # The returned object is of type Gapic::Operation. You can use this
  # object to check the status of an operation, cancel it, or wait
  # for results. Here is how to block until completion:
  operation.wait_until_done!

  # Print a success message.
  puts "Deleted live config"
end
```

<br />

## Delete the CDN key

If CDN keys were registered,
[delete the CDN keys](https://docs.cloud.google.com/video-stitcher/docs/how-to/managing-cdn-keys.md.txt#delete_cdn_key).
You need to do this for each CDN key you registered.

## Clean up resources from the Ad Manager account

If you are completely done, you may contact your Google representative to help
clean up the resources created on your Ad Manager account.

## Clean up resources from the livestream

If you created the livestream, make sure to clean up the livestream resources.
See the **Clean up** section in the
[Live Stream API quickstart](https://docs.cloud.google.com/livestream/docs/quickstarts/quickstart-hls.md.txt).