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

# Edit Connection

> Edit Connection edits a connection in the Connect AI Embed product.

Edit Connection returns a string containing the CData-hosted URL to redirect the user to.

A successful Edit Connection has the following flow:

<Steps>
  <Step>
    A successful Edit Connection request generates a URL to the CData-hosted **Edit Connection** page. The `redirectURL` in the request body maps to the **Return to** button on the **Edit Connection** page.
  </Step>

  <Step>
    The user clicks **Save & Test**. The internal API response includes connection details to the CData-hosted **Edit Connection** page.
  </Step>

  <Step>
    The user clicks **Return to**. The connection information is appended to the redirect URL as parameters.
    The parameters include the following:

    * `cdata_connection_id`–the connection unique Id.
    * `cdata_connection_name`–the connection name, such as `Salesforce1`.
    * `cdata_connection_status`–the connection status. Values include `success`, `error` (connection error), or `none` (no connection made).
  </Step>
</Steps>

Example 1: URL after successful **Save & Test**:

```
https://www.google.com/?cdata_connection_id=da77460c-7438-4288-be66-ea0059c160ae&cdata_connection_name=OData1&cdata_connection_status=success&zx=1773244250880&no_sw_cr=1
```

Example 2: URL if the user clicks **Return to** and does not **Save & Test**:

```
https://www.google.com/?cdata_connection_status=none&zx=1773252769892&no_sw_cr=1
```

Example 3: URL after save and unsuccessful test:

```
https://www.google.com/?cdata_connection_id=507b42e8-94b1-488e-a1d8-5a62d5d74a31&cdata_connection_name=Salesforce1&cdata_connection_status=error&zx=1773252951878&no_sw_cr=1
```


## OpenAPI

````yaml en/API/REST-API-Embedded.yaml POST /poweredby/connection/edit/{connectionId}
openapi: 3.1.0
info:
  title: CData Connect AI REST API Embedded
  version: v1
servers:
  - url: https://cloud.cdata.com/api
    description: Production base URL
security:
  - BearerAuth: []
paths:
  /poweredby/connection/edit/{connectionId}:
    post:
      tags:
        - Connection
      summary: Edit Connection
      description: >
        Edit Connection edits a connection in the Connect AI Embed product.
        Returns a string containing the URL to redirect the user to.
      operationId: editConnection
      parameters:
        - name: connectionId
          in: path
          required: true
          schema:
            type: string
          description: The connection Id created in Create Connection.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EditConnectionRequest'
            example:
              redirectURL: https://www.google.com
      responses:
        '200':
          description: >-
            A string containing the CData-hosted connection URL to redirect the
            user to.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RedirectURLResponse'
              example:
                redirectURL: >-
                  https://cloud.cdata.com/oem/user/connections/edit/eeef6211-5d6f-4347-b5bb-f99d574e75e5?driver=MailChimp&token=eyJhbGciOiJSUzI1NiIs...truncated...&redirectUrl=https%3A%2F%2Fwww.google.com
components:
  schemas:
    EditConnectionRequest:
      type: object
      required:
        - redirectURL
      properties:
        redirectURL:
          type: string
          description: >-
            The URL to redirect the customer once the customer has edited the
            connection through the Connect AI UI. This URL maps to the **Return
            to** button on the **Edit Connection** page in the Connect AI UI.
        name:
          type: string
          description: >-
            (Optional) If provided, the connection name. By default, this is a
            suggested default that the end user can change on the **Edit
            Connection** form. Set `editableName` to `false` to lock the field
            and enforce the supplied value server-side.
          nullable: true
        editableName:
          type: boolean
          description: >-
            (Optional) The default value is `true`. When `true`, any `name` you
            supply is shown as a suggested default value, and the end user can
            change it. When `false`, the **Connection Name** field is rendered
            read-only, and the server enforces the supplied `name` on submit.
            Has no effect when `name` is omitted.
          default: true
      additionalProperties: false
    RedirectURLResponse:
      type: object
      required:
        - redirectURL
      properties:
        redirectURL:
          type: string
          description: >-
            A string containing the CData-hosted connection URL to redirect the
            user to.
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT token authentication. Include the token in the Authorization header
        as `Bearer {token}`. See
        [Authentication](/en/API/Authentication-Embedded) for more information
        on creating a token.

````