This page explains how to configure a Pub/Sub topic that you can use
to receive job status updates from the Transcoder API.

## Configure job status updates

To receive job status updates, do the following:

1. If you don't have an existing Pub/Sub topic, create a topic.
   To learn how to create a Pub/Sub topic, see
   [Managing topics and subscriptions](https://docs.cloud.google.com/pubsub/docs/admin).

2. Make sure to configure the
   [`pubsubDestination`](https://docs.cloud.google.com/transcoder/docs/reference/rest/v1/JobConfig.md.txt#FIELDS.pubsub_destination)
   field in the job configuration.

   ```json
   {
     "config": {
       "pubsubDestination": {
         "topic": "projects/PROJECT_ID/topics/my-topic-id"
       }
     }
   }
   ```
3. [Create a job](https://docs.cloud.google.com/transcoder/docs/how-to/jobs.md.txt) to enable the
   [Google-managed Transcoder service account](https://docs.cloud.google.com/iam/docs/service-account-types.md.txt#google-managed).

4. Find the
   `service-PROJECT_NUMBER@gcp-sa-transcoder.iam.gserviceaccount.com`
   service account in the Google Cloud console, where
   <var translate="no">PROJECT_NUMBER</var> is the project number of the project you enabled
   the Transcoder API in and you plan to create the feed from.

   1. In the Google Cloud console, go to the **IAM** page.

      [Go to IAM](https://console.cloud.google.com/iam-admin/iam/project)
   2. Select the **Include Google-provided role grants** checkbox.

5. Make sure the service account has the `pubsub.topics.publish` permission
   enabled.

## Job status reporting

Job status is reported once the job fails or finishes successfully. No other
state changes are reported. Job status is reported using the `JobResult` message
format:

```json
Resource PubSubMessage
{
  job: {
    object (JobResult)
  }
}

JobResult
{
  name: string;
  state: string;
  error: {
    object (Status)
  }
}
```

For more information, refer to the following:

- [Job state](https://docs.cloud.google.com/transcoder/docs/reference/rest/v1/projects.locations.jobs.md.txt#processingstate)
- [Job status](https://docs.cloud.google.com/transcoder/docs/reference/rest/v1/projects.locations.jobs.md.txt#status)
- [Troubleshooting job errors](https://docs.cloud.google.com/transcoder/docs/troubleshooting.md.txt)