## Connection

Manage connections between sources and destinations.

A connection links a source to a destination and defines how webhooks are routed.
You can create connections with inline source and destination creation, or reference
existing resources.

[BETA] This feature is in beta. Please share bugs and feedback via:
https://github.com/hookdeck/hookdeck-cli/issues

**Usage:**

```bash
hookdeck gateway connection [command]

```

**Global options:**

| Flag | Type | Description |
| --- | --- | --- |
| `--color` | `string` | turn on/off color output (on, off, auto) |
| `--device-name` | `string` | device name |
| `--hookdeck-config` | `string` | path to CLI config file (default is $HOME/.config/hookdeck/config.toml) |
| `--insecure` | `bool` | Allow invalid TLS certificates |
| `--log-level` | `string` | log level (debug, info, warn, error) (default "info") |
| `-p, --profile` | `string` | profile name (default "default") |
|  |  |  |
|  |  |  |

```bash
hookdeck gateway connection create --name <name>  # Create a new connection
hookdeck gateway connection delete <connection-id>  # Delete a connection
hookdeck gateway connection disable <connection-id>  # Disable a connection
hookdeck gateway connection enable <connection-id>  # Enable a connection
hookdeck gateway connection get <connection-id-or-name>  # Get connection details
hookdeck gateway connection list  # List connections
hookdeck gateway connection pause <connection-id-or-name>  # Pause a connection temporarily
hookdeck gateway connection unpause <connection-id-or-name>  # Resume a paused connection
hookdeck gateway connection update <connection-id>  # Update a connection by ID
hookdeck gateway connection upsert <name>  # Create or update a connection by name

```

### hookdeck gateway connection list

List all connections or filter by source/destination.

**Usage:**

```bash
hookdeck gateway connection list [flags]

```

**Flags:**

| Flag | Type | Description |
| --- | --- | --- |
| `--destination-id` | `string` | Filter by destination ID |
| `--disabled` | `bool` | Include disabled connections |
| `--limit` | `int` | Limit number of results (default "100") |
| `--name` | `string` | Filter by connection name |
| `--output` | `string` | Output format (json) |
| `--source-id` | `string` | Filter by source ID |

```bash
# List all connections
hookdeck gateway connection list

# Filter by connection name
hookdeck gateway connection list --name my-connection

# Filter by source ID
hookdeck gateway connection list --source-id src_abc123

# Filter by destination ID
hookdeck gateway connection list --destination-id dst_def456

# Include disabled connections
hookdeck gateway connection list --disabled

# Limit results
hookdeck gateway connection list --limit 10

```

### hookdeck gateway connection get

Get detailed information about a specific connection.

You can specify either a connection ID or name.

**Usage:**

```bash
hookdeck gateway connection get <connection-id-or-name> [flags]

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `connection-id-or-name` | `string` | **Required.** Connection ID or name |

**Flags:**

| Flag | Type | Description |
| --- | --- | --- |
| `--include-destination-auth` | `bool` | Include destination authentication credentials in the response |
| `--include-source-auth` | `bool` | Include source authentication credentials in the response |
| `--output` | `string` | Output format (json) |

```bash
# Get connection by ID
hookdeck gateway connection get conn_abc123

# Get connection by name
hookdeck gateway connection get my-connection

```

### hookdeck gateway connection create

Create a connection between a source and destination.

You can either reference existing resources by ID or create them inline.

**Usage:**

```bash
hookdeck gateway connection create [flags]

```

**Flags:**

| Flag | Type | Description |
| --- | --- | --- |
| `--description` | `string` | Connection description |
| `--destination-api-key` | `string` | API key for destination authentication |
| `--destination-api-key-header` | `string` | Key/header name for API key authentication |
| `--destination-api-key-to` | `string` | Where to send API key: 'header' or 'query' (default "header") |
| `--destination-auth-method` | `string` | Authentication method for HTTP destinations (hookdeck, bearer, basic, api_key, custom_signature, oauth2_client_credentials, oauth2_authorization_code, aws, gcp) |
| `--destination-aws-access-key-id` | `string` | AWS access key ID |
| `--destination-aws-region` | `string` | AWS region |
| `--destination-aws-secret-access-key` | `string` | AWS secret access key |
| `--destination-aws-service` | `string` | AWS service name |
| `--destination-basic-auth-pass` | `string` | Password for destination Basic authentication |
| `--destination-basic-auth-user` | `string` | Username for destination Basic authentication |
| `--destination-bearer-token` | `string` | Bearer token for destination authentication |
| `--destination-cli-path` | `string` | CLI path for CLI destinations (default: /) (default "/") |
| `--destination-custom-signature-key` | `string` | Key/header name for custom signature |
| `--destination-custom-signature-secret` | `string` | Signing secret for custom signature |
| `--destination-description` | `string` | Destination description |
| `--destination-gcp-scope` | `string` | GCP scope for service account authentication |
| `--destination-gcp-service-account-key` | `string` | GCP service account key JSON for destination authentication |
| `--destination-http-method` | `string` | HTTP method for HTTP destinations (GET, POST, PUT, PATCH, DELETE) |
| `--destination-id` | `string` | Use existing destination by ID |
| `--destination-name` | `string` | Destination name for inline creation |
| `--destination-oauth2-auth-server` | `string` | OAuth2 authorization server URL |
| `--destination-oauth2-auth-type` | `string` | OAuth2 Client Credentials authentication type: 'basic', 'bearer', or 'x-www-form-urlencoded' (default "basic") |
| `--destination-oauth2-client-id` | `string` | OAuth2 client ID |
| `--destination-oauth2-client-secret` | `string` | OAuth2 client secret |
| `--destination-oauth2-refresh-token` | `string` | OAuth2 refresh token (required for Authorization Code flow) |
| `--destination-oauth2-scopes` | `string` | OAuth2 scopes (comma-separated) |
| `--destination-path-forwarding-disabled` | `string` | Disable path forwarding for HTTP destinations (true/false) |
| `--destination-rate-limit` | `int` | Rate limit for destination (requests per period) (default "0") |
| `--destination-rate-limit-period` | `string` | Rate limit period (second, minute, hour, concurrent) |
| `--destination-type` | `string` | Destination type (CLI, HTTP, MOCK) |
| `--destination-url` | `string` | URL for HTTP destinations |
| `--name` | `string` | Connection name (required) |
| `--output` | `string` | Output format (json) |
| `--rule-deduplicate-exclude-fields` | `string` | Comma-separated list of fields to exclude for deduplication |
| `--rule-deduplicate-include-fields` | `string` | Comma-separated list of fields to include for deduplication |
| `--rule-deduplicate-window` | `int` | Time window in seconds for deduplication (default "0") |
| `--rule-delay` | `int` | Delay in milliseconds (default "0") |
| `--rule-filter-body` | `string` | Filter on request body using Hookdeck filter syntax (JSON) |
| `--rule-filter-headers` | `string` | Filter on request headers using Hookdeck filter syntax (JSON) |
| `--rule-filter-path` | `string` | Filter on request path using Hookdeck filter syntax (JSON) |
| `--rule-filter-query` | `string` | Filter on request query parameters using Hookdeck filter syntax (JSON) |
| `--rule-retry-count` | `int` | Number of retry attempts (default "0") |
| `--rule-retry-interval` | `int` | Interval between retries in milliseconds (default "0") |
| `--rule-retry-response-status-codes` | `string` | Comma-separated HTTP status codes to retry on |
| `--rule-retry-strategy` | `string` | Retry strategy (linear, exponential) |
| `--rule-transform-code` | `string` | Transformation code (if creating inline) |
| `--rule-transform-env` | `string` | JSON string representing environment variables for transformation |
| `--rule-transform-name` | `string` | Name or ID of the transformation to apply |
| `--rules` | `string` | JSON string representing the entire rules array |
| `--rules-file` | `string` | Path to a JSON file containing the rules array |
| `--source-allowed-http-methods` | `string` | Comma-separated list of allowed HTTP methods (GET, POST, PUT, PATCH, DELETE) |
| `--source-api-key` | `string` | API key for source authentication |
| `--source-basic-auth-pass` | `string` | Password for Basic authentication |
| `--source-basic-auth-user` | `string` | Username for Basic authentication |
| `--source-config` | `string` | JSON string for source authentication config |
| `--source-config-file` | `string` | Path to a JSON file for source authentication config |
| `--source-custom-response-body` | `string` | Custom response body (max 1000 chars) |
| `--source-custom-response-content-type` | `string` | Custom response content type (json, text, xml) |
| `--source-description` | `string` | Source description |
| `--source-hmac-algo` | `string` | HMAC algorithm (SHA256, etc.) |
| `--source-hmac-secret` | `string` | HMAC secret for signature verification |
| `--source-id` | `string` | Use existing source by ID |
| `--source-name` | `string` | Source name for inline creation |
| `--source-type` | `string` | Source type (WEBHOOK, STRIPE, etc.) |
| `--source-webhook-secret` | `string` | Webhook secret for source verification (e.g., Stripe) |

```bash
# Create with inline source and destination
hookdeck gateway connection create \
--name "test-webhooks-to-local" \
--source-type WEBHOOK --source-name "test-webhooks" \
--destination-type CLI --destination-name "local-dev"

# Create with existing resources
hookdeck gateway connection create \
--name "github-to-api" \
--source-id src_abc123 \
--destination-id dst_def456

# Create with source configuration options
hookdeck gateway connection create \
--name "api-webhooks" \
--source-type WEBHOOK --source-name "api-source" \
--source-allowed-http-methods "POST,PUT,PATCH" \
--source-custom-response-content-type "json" \
--source-custom-response-body '{"status":"received"}' \
--destination-type CLI --destination-name "local-dev"

```

### hookdeck gateway connection upsert

Create a new connection or update an existing one by name (idempotent).

This command is idempotent - it can be safely run multiple times with the same arguments.

When the connection doesn't exist:
- Creates a new connection with the provided properties
- Requires source and destination to be specified

When the connection exists:
- Updates the connection with the provided properties
- Only updates properties that are explicitly provided
- Preserves existing properties that aren't specified

Use `--dry-run` to preview changes without applying them.

**Usage:**

```bash
hookdeck gateway connection upsert <name> [flags]

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `name` | `string` | **Required.** Connection name (create or update by name) |

**Flags:**

| Flag | Type | Description |
| --- | --- | --- |
| `--description` | `string` | Connection description |
| `--destination-api-key` | `string` | API key for destination authentication |
| `--destination-api-key-header` | `string` | Key/header name for API key authentication |
| `--destination-api-key-to` | `string` | Where to send API key: 'header' or 'query' (default "header") |
| `--destination-auth-method` | `string` | Authentication method for HTTP destinations (hookdeck, bearer, basic, api_key, custom_signature, oauth2_client_credentials, oauth2_authorization_code, aws, gcp) |
| `--destination-aws-access-key-id` | `string` | AWS access key ID |
| `--destination-aws-region` | `string` | AWS region |
| `--destination-aws-secret-access-key` | `string` | AWS secret access key |
| `--destination-aws-service` | `string` | AWS service name |
| `--destination-basic-auth-pass` | `string` | Password for destination Basic authentication |
| `--destination-basic-auth-user` | `string` | Username for destination Basic authentication |
| `--destination-bearer-token` | `string` | Bearer token for destination authentication |
| `--destination-cli-path` | `string` | CLI path for CLI destinations (default: / for new connections) |
| `--destination-custom-signature-key` | `string` | Key/header name for custom signature |
| `--destination-custom-signature-secret` | `string` | Signing secret for custom signature |
| `--destination-description` | `string` | Destination description |
| `--destination-gcp-scope` | `string` | GCP scope for service account authentication |
| `--destination-gcp-service-account-key` | `string` | GCP service account key JSON for destination authentication |
| `--destination-http-method` | `string` | HTTP method for HTTP destinations (GET, POST, PUT, PATCH, DELETE) |
| `--destination-id` | `string` | Use existing destination by ID |
| `--destination-name` | `string` | Destination name for inline creation |
| `--destination-oauth2-auth-server` | `string` | OAuth2 authorization server URL |
| `--destination-oauth2-auth-type` | `string` | OAuth2 Client Credentials authentication type: 'basic', 'bearer', or 'x-www-form-urlencoded' (default "basic") |
| `--destination-oauth2-client-id` | `string` | OAuth2 client ID |
| `--destination-oauth2-client-secret` | `string` | OAuth2 client secret |
| `--destination-oauth2-refresh-token` | `string` | OAuth2 refresh token (required for Authorization Code flow) |
| `--destination-oauth2-scopes` | `string` | OAuth2 scopes (comma-separated) |
| `--destination-path-forwarding-disabled` | `string` | Disable path forwarding for HTTP destinations (true/false) |
| `--destination-rate-limit` | `int` | Rate limit for destination (requests per period) (default "0") |
| `--destination-rate-limit-period` | `string` | Rate limit period (second, minute, hour, concurrent) |
| `--destination-type` | `string` | Destination type (CLI, HTTP, MOCK) |
| `--destination-url` | `string` | URL for HTTP destinations |
| `--dry-run` | `bool` | Preview changes without applying them |
| `--output` | `string` | Output format (json) |
| `--rule-deduplicate-exclude-fields` | `string` | Comma-separated list of fields to exclude for deduplication |
| `--rule-deduplicate-include-fields` | `string` | Comma-separated list of fields to include for deduplication |
| `--rule-deduplicate-window` | `int` | Time window in seconds for deduplication (default "0") |
| `--rule-delay` | `int` | Delay in milliseconds (default "0") |
| `--rule-filter-body` | `string` | Filter on request body using Hookdeck filter syntax (JSON) |
| `--rule-filter-headers` | `string` | Filter on request headers using Hookdeck filter syntax (JSON) |
| `--rule-filter-path` | `string` | Filter on request path using Hookdeck filter syntax (JSON) |
| `--rule-filter-query` | `string` | Filter on request query parameters using Hookdeck filter syntax (JSON) |
| `--rule-retry-count` | `int` | Number of retry attempts (default "0") |
| `--rule-retry-interval` | `int` | Interval between retries in milliseconds (default "0") |
| `--rule-retry-response-status-codes` | `string` | Comma-separated HTTP status codes to retry on |
| `--rule-retry-strategy` | `string` | Retry strategy (linear, exponential) |
| `--rule-transform-code` | `string` | Transformation code (if creating inline) |
| `--rule-transform-env` | `string` | JSON string representing environment variables for transformation |
| `--rule-transform-name` | `string` | Name or ID of the transformation to apply |
| `--rules` | `string` | JSON string representing the entire rules array |
| `--rules-file` | `string` | Path to a JSON file containing the rules array |
| `--source-allowed-http-methods` | `string` | Comma-separated list of allowed HTTP methods (GET, POST, PUT, PATCH, DELETE) |
| `--source-api-key` | `string` | API key for source authentication |
| `--source-basic-auth-pass` | `string` | Password for Basic authentication |
| `--source-basic-auth-user` | `string` | Username for Basic authentication |
| `--source-config` | `string` | JSON string for source authentication config |
| `--source-config-file` | `string` | Path to a JSON file for source authentication config |
| `--source-custom-response-body` | `string` | Custom response body (max 1000 chars) |
| `--source-custom-response-content-type` | `string` | Custom response content type (json, text, xml) |
| `--source-description` | `string` | Source description |
| `--source-hmac-algo` | `string` | HMAC algorithm (SHA256, etc.) |
| `--source-hmac-secret` | `string` | HMAC secret for signature verification |
| `--source-id` | `string` | Use existing source by ID |
| `--source-name` | `string` | Source name for inline creation |
| `--source-type` | `string` | Source type (WEBHOOK, STRIPE, etc.) |
| `--source-webhook-secret` | `string` | Webhook secret for source verification (e.g., Stripe) |

```bash
# Create or update a connection with inline source and destination
hookdeck gateway connection upsert "my-connection" \
--source-name "stripe-prod" --source-type STRIPE \
--destination-name "my-api" --destination-type HTTP --destination-url https://api.example.com

# Update just the rate limit on an existing connection
hookdeck gateway connection upsert my-connection \
--destination-rate-limit 100 --destination-rate-limit-period minute

# Update source configuration options
hookdeck gateway connection upsert my-connection \
--source-allowed-http-methods "POST,PUT,DELETE" \
--source-custom-response-content-type "json" \
--source-custom-response-body '{"status":"received"}'

# Preview changes without applying them
hookdeck gateway connection upsert my-connection \
--destination-rate-limit 200 --destination-rate-limit-period hour \
--dry-run

```

#### Note: `connection upsert --dry-run` output

When you use `--dry-run`, the command prints a preview of the changes without applying them:

```bash
$ hookdeck gateway connection upsert my-connection \
  --destination-rate-limit 200 \
  --destination-rate-limit-period hour \
  --dry-run

```

Output:

```
=== DRY RUN MODE ===

Operation: UPDATE
Connection: my-connection (ID: web_xxx)

Changes to be applied:
  • Source: src_xxx → src_xxx (by ID)
  • Destination: my-api → my-api (inline creation)

Properties preserved (not specified in command):

=== DRY RUN COMPLETE ===
No changes were made. Remove --dry-run to apply these changes.

```

### hookdeck gateway connection delete

Delete a connection.

**Usage:**

```bash
hookdeck gateway connection delete <connection-id> [flags]

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `connection-id` | `string` | **Required.** Connection ID |

**Flags:**

| Flag | Type | Description |
| --- | --- | --- |
| `--force` | `bool` | Force delete without confirmation |

```bash
# Delete a connection (with confirmation)
hookdeck gateway connection delete conn_abc123

# Force delete without confirmation
hookdeck gateway connection delete conn_abc123 --force

```

### hookdeck gateway connection enable

Enable a disabled connection.

**Usage:**

```bash
hookdeck gateway connection enable <connection-id>

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `connection-id` | `string` | **Required.** Connection ID |

### hookdeck gateway connection disable

Disable an active connection. It will stop receiving new events until re-enabled.

**Usage:**

```bash
hookdeck gateway connection disable <connection-id>

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `connection-id` | `string` | **Required.** Connection ID |

### hookdeck gateway connection pause

Pause a connection temporarily.

The connection will queue incoming events until unpaused.

**Usage:**

```bash
hookdeck gateway connection pause <connection-id-or-name>

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `connection-id-or-name` | `string` | **Required.** Connection ID or name |

```bash
# Pause by connection ID
hookdeck gateway connection pause web_abc123

# Pause by connection name
hookdeck gateway connection pause my-connection

```

### hookdeck gateway connection unpause

Resume a paused connection.

The connection will start processing queued events.

**Usage:**

```bash
hookdeck gateway connection unpause <connection-id-or-name>

```

**Arguments:**

| Argument | Type | Description |
| --- | --- | --- |
| `connection-id-or-name` | `string` | **Required.** Connection ID or name |

```bash
# Unpause by connection ID
hookdeck gateway connection unpause web_abc123

# Unpause by connection name
hookdeck gateway connection unpause my-connection

```