> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Connection

> Updates an existing connection in a project. All connection fields can be updated, including changing the connection name (if the new name does not conflict with existing connections).

## Endpoint

```
PUT /apiops/projects/{projectName}/connections/{connectionName}/
```

## Authentication

Requires a Personal API Access Token.

### Header

```
Authorization: Bearer YOUR_TOKEN
```

## Request

### Headers

| Header        | Value            | Required |
| ------------- | ---------------- | -------- |
| Authorization | Bearer {token}   | Yes      |
| Content-Type  | application/json | Yes      |

### Path Parameters

| Parameter      | Type   | Required | Description                  |
| -------------- | ------ | -------- | ---------------------------- |
| projectName    | string | Yes      | Project name                 |
| connectionName | string | Yes      | Connection name (must exist) |

### Request Body

#### Full JSON Body Example (Email Connection)

```json theme={null}
{
  "type": "email",
  "name": "my-email-connection",
  "description": "Updated email connection description",
  "deployToWorker": true,
  "enabled": true,
  "host": "smtp.gmail.com",
  "port": 587,
  "enableStartTls": true,
  "auth": true,
  "username": "updated-user@example.com",
  "password": "new-app-password",
  "defaultEncoding": "UTF-8",
  "from": "noreply@example.com",
  "additionalProperties": []
}
```

#### Request Body Fields

The request body structure is identical to [Create Connection](/api-reference/connections/crud/create-connection). See that documentation for complete field descriptions.

**Important:** The `connectionName` path parameter identifies the existing connection to update. To rename a connection, provide the new name in the `name` field of the request body while keeping the old name in the path parameter. If `name` is omitted from the body, the existing name (from the path parameter) is preserved.

##### Common Fields

| Field          | Type    | Required | Default                | Description                                                                                                                                                                                              |
| -------------- | ------- | -------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type           | string  | Yes      | -                      | Connection type discriminator field. Must match the existing connection type. Used to identify the connection type in API requests/responses.                                                            |
| name           | string  | No       | (path parameter value) | New connection name. If omitted or empty, the existing name from the path parameter is used. If provided with a different value, the connection is renamed (must not conflict with existing connections) |
| description    | string  | No       | -                      | Connection description                                                                                                                                                                                   |
| deployToWorker | boolean | No       | true                   | Whether to deploy to worker                                                                                                                                                                              |
| enabled        | boolean | No       | true                   | Whether connection is enabled                                                                                                                                                                            |

**Note:** Connection-specific fields vary by connection type. See individual connection type documentation for details.

## Response

### Success Response (200 OK)

```json theme={null}
{
  "success": true,
  "deploymentResult": {
    "success": true
  }
}
```

#### Response Fields

| Field                    | Type    | Description                                |
| ------------------------ | ------- | ------------------------------------------ |
| success                  | boolean | Indicates if the request was successful    |
| deploymentResult         | object  | Deployment result (if deployToWorker=true) |
| deploymentResult.success | boolean | Deployment success                         |

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "Connection (name: my-email-connection) was not found!"
}
```

#### Common Causes

* Connection name does not exist
* Connection name in path does not match name in body (unless renaming)
* New connection name conflicts with existing connection
* Invalid connection type (cannot change connection type)
* Missing required fields for connection type
* Invalid field values

### Error Response (401 Unauthorized)

```json theme={null}
{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}
```

### Error Response (404 Not Found)

```json theme={null}
{
  "error": "not_found",
  "error_description": "Project 'MyProject' not found"
}
```

## cURL Example

### Example 1: Update Connection Configuration

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-email-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "email",
    "name": "my-email-connection",
    "description": "Updated email connection",
    "deployToWorker": true,
    "enabled": true,
    "host": "smtp.gmail.com",
    "port": 587,
    "enableStartTls": true,
    "auth": true,
    "username": "updated-user@example.com",
    "password": "new-app-password",
    "defaultEncoding": "UTF-8",
    "from": "noreply@example.com"
  }'
```

### Example 2: Rename Connection

Rename a connection by providing a new name in the body (path parameter keeps old name).

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/old-connection-name/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "email",
    "name": "new-connection-name",
    "description": "Renamed connection",
    "deployToWorker": true,
    "enabled": true,
    "host": "smtp.gmail.com",
    "port": 587,
    "auth": true,
    "username": "user@example.com",
    "password": "password"
  }'
```

**Note:** The new name must not conflict with existing connections.

### Example 3: Update and Disable

Update connection configuration and disable it.

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/connections/my-db-connection/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "database",
    "name": "my-db-connection",
    "description": "Updated database connection - disabled",
    "deployToWorker": true,
    "enabled": false,
    "host": "localhost",
    "port": 5432,
    "databaseName": "mydb",
    "username": "dbuser",
    "password": "dbpassword"
  }'
```

## Permissions

* User must have **`CONNECTIONS` + `MANAGE`** permission in the project

## Notes and Warnings

* **Name Change**: To rename a connection, provide the new name in the `name` field of the request body. The path parameter always identifies the existing connection. If the new name conflicts with another connection, the update will fail
* **Type Cannot Change**: Connection type (`type`) cannot be changed. Use Delete and Create to change type.
* **Name Conflicts**: If renaming, ensure the new name doesn't conflict with existing connections
* **Secret Fields**: Secret fields can be updated. Ensure you have the correct values.
* **Deployment**: If `deployToWorker: true`, connection is automatically redeployed to workers
* **References**: References to certificates or keystores can be updated by providing new names

## Related Documentation

* [Get Connection](/api-reference/connections/crud/get-connection) - Get connection details
* [Create Connection](/api-reference/connections/crud/create-connection) - Create a new connection
* [Delete Connection](/api-reference/connections/crud/delete-connection) - Delete a connection
* [Email Connection](/api-reference/connections/connections/connection-email) - Email connection details
