# Temporal

> Connect Temporal Cloud or a self-hosted server so failed workflows open incidents, and Ace can pause schedules, roll workers back or reset workflows after approval.

Source: https://tryace.dev/docs/integrations/temporal

Failed and timed-out Temporal workflows open incidents in Ace, one per workflow type. On a self-hosted server, Ace can also pause a schedule, roll a worker deployment back, or reset failed workflows once the fix is live.

| | |
| --- | --- |
| Category | Jobs |
| Ace reads | On Temporal Cloud: namespace metrics and configuration, and the audit log with a Global Admin key. On a self-hosted server: failed workflows and their failures, task queue workers and backlog, worker deployments and schedules |
| Ace can change | On a self-hosted server only: pause or unpause a schedule, roll a worker deployment back, reset failed workflows, only after an admin allows actions |
| Opens incidents | Yes, for failed and timed-out workflows of workloads that route Temporal. On Temporal Cloud, also for throttled namespaces and task queues with no workers |
| Setup | Settings form. Temporal Cloud uses service account API keys, and a self-hosted server its HTTP API |

## What it reads
The **Deployment** field decides how Ace reads Temporal. Temporal Cloud serves workflows only over gRPC, so Ace reads its metrics and Ops API instead. A self-hosted server's HTTP API serves the workflows themselves, and Ace doesn't use gRPC.

Ace reads the namespaces in the **Namespaces** field, or every namespace when it's empty, while it investigates a workload that reads Temporal under **Observability** in the workload's settings, or routes its alerts.

**Temporal Cloud**

- The latest metrics minute: workflows failed, timed out and completed per minute, by workflow type and task queue.
- Each namespace's actions per second against its limit, throttled actions and resource-exhausted errors.
- Task queues whose tasks no worker polls, with their backlog and the oldest task's wait.
- Namespaces from the Ops API, with active region, replicas, retention, actions-per-second limit, state and last change, and the account's Nexus endpoints.
- Audit log entries in the incident window: each operation, when, by whom and whether it succeeded. This needs a key with the **Global Admin** role.

Temporal Cloud allows 180 metrics requests an hour per account, shared with every scraper you run. Ace reads metrics at most once every 5 minutes. Each investigation read and each Blueprint refresh uses one more.

**Self-hosted server**

- Workflows that failed, timed out or were terminated in the incident window, by namespace and workflow type.
- Up to five recent runs per type, with their failure.
- One run's status, task queue, build, timing, failure and pending activities with their attempts and last failure. Ace leaves out inputs, results and payloads.
- A task queue's pollers and backlog, for workflow and activity tasks.
- Worker deployments with their current and ramping build, and earlier versions.
- Schedules, paused or not, with their workflow type and recent and next runs.

A failure encoded by your payload codec shows only that the workflow failed.

On both, Ace reads the incident's workflow type after a fix, to confirm it works again. On Temporal Cloud it estimates this from the metric minutes it stored, which sample about one minute in five.

For the Blueprint, Ace reads namespaces and task queues with their workflow types. On Temporal Cloud it adds Nexus endpoints when it can read the Ops API. On a self-hosted server it adds schedules and worker deployments from up to 10 namespaces.

## What it can change
Ace can change Temporal only on a self-hosted server, after an admin turns on **Actions**. Temporal Cloud serves these writes only over gRPC, so Ace never proposes them there. See [Actions and approvals](https://tryace.dev/docs/concepts/actions-and-approvals).

| Action | What it does | Approval | Undo |
| --- | --- | --- | --- |
| Schedule pause | Pauses a schedule so it starts no new workflows, or unpauses it. Running workflows continue. | Approval only | Yes. Restores the previous state. |
| Worker deployment rollback | Makes an earlier build of a worker deployment current again, by default the one current before. New and auto-upgrading workflows run on it. | Approval, or Automatic | Yes, when a build was current before. Makes the replaced build current again. |
| Failed workflow reset | Resets one workflow type's failed and timed-out workflows from the incident window to their last workflow task, in stages, up to 200, each once. It waits for the fix to deploy. | Approval only | No |

Safeguards:

- Ace refuses a schedule pause or a rollback if someone changed the schedule or the deployment's current build since approval.
- A rollback writes with Temporal's conflict token. Ace refuses a drained build, and Temporal refuses a build no worker polls.
- A reset skips workflows retried or reset since the plan. Activities after the reset point run again, and later signals are reapplied.
- Ace rechecks the incident between stages.
- Unpausing a schedule Ace paused still runs after **Stop all actions**, because it brings back what the pause stopped.

Ace sends Temporal only these three writes. It refuses terminating, cancelling, signalling, starting or deleting workflows, batch jobs, namespace updates and admin APIs before they leave Ace, whatever the token allows.

Ace can't check a token's write permission before it writes, so Settings shows **Checked when it runs**. A Temporal Cloud connection has no **Actions** section.

## What opens an incident

Failures open incidents only on workloads that route this connection, and Ace polls only routed connections, every 2 minutes. Each incident is high severity.

| Temporal shows | What Ace does |
| --- | --- |
| Failed or timed-out workflows | Opens or joins an incident for that workflow type in its namespace. On a self-hosted server, terminated workflows count too. |
| Throttled actions or resource-exhausted errors in a namespace (Cloud) | Opens an incident for the namespace, and closes it when throttling stops. |
| A task queue with no worker polling and a backlog older than 2 minutes that keeps aging (Cloud) | Opens an incident for the queue, and closes it when workers poll again. |

On Temporal Cloud, Ace sees failures in one metrics minute every few minutes, so it counts a sample, not each run. A self-hosted poll reads each run, up to 200 per namespace and 20 namespaces.

When a metrics read fails, Ace waits before reading again. It waits at least 15 minutes after a `429`, or longer when Temporal asks, an hour after a refused key, and 15 minutes after a server error. When Temporal cuts a metrics answer short, Ace opens what it shows and closes nothing from it.

Changes join the change ledger. On a self-hosted server, a worker deployment's new current build is a deploy.

On Temporal Cloud, Ace reads namespace changes such as retention, limits and failover every 5 minutes. They come from the Ops API, or from the audit log with a **Global Admin** key.

## Before you start

- The **admin** role in Ace.
- For Temporal Cloud, an **Account Owner** or **Global Admin**, to create service accounts.
- For a self-hosted server, its frontend's HTTP API (port 7243 by default) over HTTPS, reachable from the internet. Worker deployments need Temporal 1.27 or later.

## Credentials and permissions

| Credential | Deployment | Permission | Why Ace needs it |
| --- | --- | --- | --- |
| **Metrics API key** | Temporal Cloud | A service account with the account role **Metrics Read-Only** | Failures, throttling and task queues from Temporal Cloud metrics. |
| **Inventory API key** | Temporal Cloud, optional | A second service account with the account role **Read-Only** | Namespaces, limits and Nexus endpoints for the Blueprint, and namespace changes for the timeline. |
| Same key, for the audit log | Temporal Cloud, optional | The account role **Global Admin** instead of **Read-Only** | Audit log entries for namespace and Nexus changes. |
| **Bearer token** | Self-hosted, only with an authorizer | Read on each namespace | Workflows, task queues, schedules and worker deployments. |
| Same token, for actions | Self-hosted | Write on each namespace | Pause schedules, roll worker deployments back and reset workflows. |

A Temporal Cloud connection sends only reads, whatever the key's role allows. Without an inventory key, Ace tries the metrics key on the Ops API.

Under Temporal's default authorizer, a token's `permissions` claim grants `<namespace>:read` or `<namespace>:write`. See [Temporal's security guide](https://docs.temporal.io/self-hosted-guide/security). Ace stores keys and tokens encrypted.

## Set up

### 1. Create a key or a token

**Temporal Cloud**

1. As an **Account Owner** or **Global Admin**, open [**Identities** > **Service Accounts**](https://cloud.temporal.io/identities?tab=service-accounts). Create a service account named Ace with the account role **Metrics Read-Only**.
2. In [**API Keys**](https://cloud.temporal.io/keys), create a key for that service account and copy it. Temporal shows it once.
3. Optional: create a second service account named Ace inventory with the account role **Read-Only**, then create a key for it the same way.

**Self-hosted server**

1. Expose the frontend's HTTP port (7243 by default) over HTTPS at an address reachable from the internet.
2. If the server has an authorizer, issue a token with read on each namespace Ace reads, or write for actions.

### 2. Connect Temporal

1. Open [**Settings** > **Integrations** > **Temporal**](https://app.tryace.dev/settings/integrations/temporal).
2. Choose **Deployment**: **Temporal Cloud** or **Self-hosted server**. The form shows that deployment's fields.
3. Fill in the form:

   | Field | Deployment | What to enter |
   | --- | --- | --- |
   | **Metrics API key** | Temporal Cloud | The **Metrics Read-Only** key. |
   | **Inventory API key** | Temporal Cloud | Optional. The **Read-Only** key. |
   | **HTTP API URL** | Self-hosted | The frontend's HTTP API, such as `temporal.example.com:7243`. |
   | **Bearer token** | Self-hosted | Only if the server has an authorizer. |
   | **Temporal UI URL** | Self-hosted | Optional, for links to workflows, such as `temporal-ui.example.com`. |
   | **Namespaces** | Both | Optional. Comma-separated, such as `payments.a1b2c` on Temporal Cloud. Leave empty to read every namespace, up to 20 on a self-hosted server. |

4. Select **Connect Temporal**. On Temporal Cloud, Ace checks that the metrics key reads metrics and the inventory key reads namespaces. On a self-hosted server, it checks that the HTTP API answers and every listed namespace exists.

With **Namespaces** empty on a self-hosted server, Ace saves the first 20 namespaces it can list. Temporal's default authorizer lists namespaces only for a token with `temporal-system:read`, so otherwise name them.

### 3. Route failures to a workload

In the workload's settings, open **Alerts** (`https://app.tryace.dev/workloads/<workload-id>/settings/alerts`), tick Temporal under **Sources** and turn on **Investigate alerts**. Polling starts within a few minutes.

### 4. Optional: allow actions

Only on a self-hosted server.

1. In the [**Actions** section](https://app.tryace.dev/settings/integrations/temporal#actions), turn the switch **On**.
2. To let worker deployment rollbacks run under an Automatic policy, choose a workload, enter its environment and select **Confirm workload**.

## Set up with an agent

Copy this prompt into a coding agent, or open it in one with the logos below it. The agent does the Temporal side in your terminal and asks you for each decision and each step in a browser. See [how agent setup works](https://tryace.dev/docs/integrations#set-up-with-an-agent).

Give your coding agent this prompt:

```text
Help me connect Temporal to Ace. Read https://tryace.dev/docs/integrations/temporal/agent.md and follow it step by step. Ask me whenever you need a decision or something only I can do.
```

## Confirm it's working

- The connection card shows **Synced**, and **Sync now** rechecks the credentials. A failed check names the problem, such as a missing role or a namespace the server doesn't have.
- If polling fails for 10 minutes, the page header shows **Needs attention**.
- On Temporal Cloud, a revoked or throttled metrics key doesn't fail the poll. Ace waits and tries again, so select **Sync now** to recheck the key.
- Incidents for failed workflows appear on the routed workload after the next failure.

## Disconnect

1. In Ace, open [**Settings** > **Integrations** > **Temporal**](https://app.tryace.dev/settings/integrations/temporal), select **Disconnect**, then **Disconnect Temporal**. To stop only actions, turn **Actions** off instead.
2. On Temporal Cloud, delete the Ace keys in [**API Keys**](https://cloud.temporal.io/keys) and the Ace service accounts in [**Identities** > **Service Accounts**](https://cloud.temporal.io/identities?tab=service-accounts).
3. On a self-hosted server, revoke the token in your authorizer.

## Next steps

- [Actions and approvals](https://tryace.dev/docs/concepts/actions-and-approvals)
- [Inngest](https://tryace.dev/docs/integrations/inngest)
- [Trigger.dev](https://tryace.dev/docs/integrations/trigger-dev)
- [All integrations](https://tryace.dev/docs/integrations)
