# Update an analytics connection

> Rename a connection or validate replacement custom credentials. Only team owners can update connections. Existing settings remain unchanged if validation fails.

```json
{
  "path": "/projects/{projectId}/analytics/connections/{connectionId}",
  "method": "patch",
  "schema": {
    "description": "Rename a connection or validate replacement custom credentials. Only team owners can update connections. Existing settings remain unchanged if validation fails.",
    "operationId": "updateAnalyticsConnection",
    "parameters": [
      {
        "description": "The owning Chunkify project ID.",
        "in": "path",
        "name": "projectId",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      {
        "description": "The saved analytics connection ID.",
        "in": "path",
        "name": "connectionId",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    ],
    "requestBody": {
      "content": {
        "application/json": {
          "example": {
            "name": "Production analytics"
          },
          "schema": {
            "$ref": "#/components/schemas/AnalyticsConnectionUpdateParams"
          }
        }
      },
      "description": "Analytics connection settings.",
      "required": true
    },
    "responses": {
      "200": {
        "content": {
          "application/json": {
            "example": {
              "data": {
                "created_at": "2026-10-29T12:00:00Z",
                "endpoint": "https://analytics.example.com",
                "id": "anc_example",
                "name": "Website analytics",
                "project_id": "proj_example",
                "status": "ready",
                "type": "custom",
                "updated_at": "2026-10-29T12:00:00Z"
              },
              "status": "success"
            },
            "schema": {
              "$ref": "#/components/schemas/AnalyticsConnectionResponse"
            }
          }
        },
        "description": "Success."
      },
      "400": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorValidation"
            }
          }
        },
        "description": "Validation error."
      },
      "401": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorAuthentication"
            }
          }
        },
        "description": "Authentication error."
      },
      "403": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorForbidden"
            }
          }
        },
        "description": "Forbidden error."
      },
      "404": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorNotFound"
            }
          }
        },
        "description": "NotFound error."
      },
      "409": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorConflict"
            }
          }
        },
        "description": "The name is already used, setup is incomplete, or deletion needs reconciliation."
      },
      "429": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorTooManyRequests"
            }
          }
        },
        "description": "TooManyRequests error."
      },
      "503": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ResponseErrorServiceUnavailable"
            }
          }
        },
        "description": "The analytics server is unavailable or returned an incompatible response."
      }
    },
    "security": [
      {
        "TeamAccessToken": []
      }
    ],
    "summary": "Update an analytics connection",
    "tags": [
      "Analytics Connections"
    ],
    "x-codeSamples": [
      {
        "lang": "typescript",
        "source": "import Chunkify from '@chunkify/chunkify';\n\nconst client = new Chunkify({\n  teamAccessToken: 'My Team Access Token',\n});\n\nconst result = await client.projects.analytics.connections.update(\n  'proj_example',\n  'anc_example',\n  {\n    name: 'Renamed analytics',\n  },\n);\n"
      },
      {
        "lang": "python",
        "source": "from chunkify import Chunkify\n\nclient = Chunkify(\n    team_access_token=\"My Team Access Token\",\n)\n\nresult = client.projects.analytics.connections.update(\n    \"proj_example\",\n    \"anc_example\",\n    name=\"Renamed analytics\",\n)\n"
      },
      {
        "lang": "php",
        "source": "\u003c?php\n\nuse Chunkify\\Client;\n\n$client = new Client(\n    teamAccessToken: 'My Team Access Token',\n);\n\n$result = $client-\u003eprojects-\u003eanalytics-\u003econnections-\u003eupdate(\n    'proj_example',\n    'anc_example',\n    name: 'Renamed analytics',\n);\n"
      },
      {
        "lang": "golang",
        "source": "package main\n\nimport (\n\t\"context\"\n\t\"github.com/chunkifydev/chunkify-go\"\n\t\"github.com/chunkifydev/chunkify-go/option\"\n)\n\nfunc main() {\n\tclient := chunkify.NewClient(\n\t\toption.WithTeamAccessToken(\"My Team Access Token\"),\n\t)\n\t_, err := client.Projects.Analytics.Connections.Update(\n\t\tcontext.TODO(),\n\t\t\"proj_example\",\n\t\t\"anc_example\",\n\t\tchunkify.ProjectAnalyticsConnectionUpdateParams{\n\t\t\tName: chunkify.String(\"Renamed analytics\"),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n"
      }
    ]
  }
}
```



```json #/components/schemas/AnalyticsConnectionUpdateParams
{
  "additionalProperties": false,
  "description": "Update a connection name, dashboard player default or custom credentials. Omitted fields stay unchanged. Changing the endpoint also requires a read_key. Connection type cannot change.",
  "properties": {
    "allowed_origins": {
      "description": "AllowedOrigins lists additional website origins permitted to ingest events for a hosted connection. Shared installation origins remain allowed. An empty list clears project-specific origins. Custom servers manage origins on their own infrastructure.",
      "items": {
        "maxLength": 2048,
        "type": "string"
      },
      "maxItems": 100,
      "type": "array",
      "x-go-omitzero": true
    },
    "default_for_dashboard": {
      "description": "DefaultForDashboard selects this ready connection for Chunkify dashboard players, public previews, the playground and newly generated snippets. Requires a public ingest key. Setting true replaces the previous default atomically. Setting false disables dashboard tracking if no default remains; another connection is not selected automatically. Existing external players keep their own configuration.",
      "type": "boolean"
    },
    "endpoint": {
      "description": "Endpoint specifies a replacement custom server base URL. Supply read_key together with it.",
      "maxLength": 2048,
      "type": "string"
    },
    "name": {
      "description": "Name identifies this connection in the dashboard.",
      "maxLength": 128,
      "minLength": 1,
      "type": "string"
    },
    "public_ingest_key": {
      "description": "PublicIngestKey optionally enables preview tracking for a custom connection. Supply the public ingestion key for the same analytics project as read_key. It is returned in connection reads and used in browser code. Omit for hosted connections. An empty string disables preview tracking. A replacement endpoint clears the saved public key unless a replacement is supplied.",
      "maxLength": 74,
      "pattern": "^(ck_public_[a-f0-9]{64})?$",
      "type": "string"
    },
    "read_key": {
      "description": "ReadKey replaces the custom connection credential after validation. Its value is never returned.",
      "maxLength": 4096,
      "minLength": 1,
      "type": "string",
      "writeOnly": true
    }
  },
  "type": "object",
  "x-reject-null-fields": [
    "name",
    "endpoint",
    "read_key",
    "public_ingest_key",
    "allowed_origins",
    "default_for_dashboard"
  ],
  "x-reject-unknown-fields": true
}
```



```json #/components/schemas/AnalyticsConnectionResponse
{
  "properties": {
    "data": {
      "$ref": "#/components/schemas/AnalyticsConnection"
    },
    "status": {
      "const": "success",
      "type": "string"
    }
  },
  "required": [
    "status",
    "data"
  ],
  "type": "object"
}
```



```json #/components/schemas/AnalyticsConnection
{
  "description": "A saved source for analytics reports. The dashboard player default is independent of the connection selected in reports. External players keep their own configuration. Only the public ingest key is included; read and management credentials stay private.",
  "properties": {
    "allowed_origins": {
      "description": "AllowedOrigins lists additional website origins permitted to ingest events for a hosted connection. Shared installation origins remain allowed. An empty list clears project-specific origins. Custom servers manage origins on their own infrastructure.",
      "items": {
        "maxLength": 2048,
        "type": "string"
      },
      "maxItems": 100,
      "type": "array",
      "x-go-omitzero": true
    },
    "created_at": {
      "description": "CreatedAt records when this connection was added.",
      "format": "date-time",
      "type": "string"
    },
    "default_for_dashboard": {
      "description": "DefaultForDashboard selects this connection for Chunkify dashboard players, public previews, the playground and newly generated snippets. It does not change existing external players. At most one connection per project is selected.",
      "type": "boolean"
    },
    "endpoint": {
      "description": "Endpoint specifies the analytics server base URL. It does not configure the player.",
      "format": "uri",
      "type": "string"
    },
    "id": {
      "description": "Id identifies this saved analytics connection.",
      "example": "anc_example",
      "type": "string"
    },
    "last_checked_at": {
      "description": "LastCheckedAt records the most recent successful connection check.",
      "format": "date-time",
      "type": "string"
    },
    "name": {
      "description": "Name identifies this connection in the dashboard.",
      "maxLength": 128,
      "minLength": 1,
      "type": "string"
    },
    "project_id": {
      "description": "ProjectId identifies the owning Chunkify project.",
      "example": "proj_example",
      "type": "string"
    },
    "public_ingest_key": {
      "description": "PublicIngestKey is the public browser ingestion key used by Chunkify previews and player examples. It cannot read or manage analytics. Hosted connections use their primary public key. Omitted when preview tracking is not configured.",
      "maxLength": 74,
      "pattern": "^(ck_public_[a-f0-9]{64})?$",
      "type": "string"
    },
    "retention_seconds": {
      "description": "RetentionSeconds is the last retention applied to a hosted project, in seconds. Omitted for custom connections.",
      "format": "int64",
      "minimum": 0,
      "type": "integer"
    },
    "status": {
      "description": "Status indicates whether the connection is ready to read or requires setup repair.",
      "enum": [
        "preparing",
        "ready",
        "failed"
      ],
      "type": "string"
    },
    "type": {
      "description": "Type specifies whether Chunkify manages the analytics project.",
      "enum": [
        "hosted",
        "custom"
      ],
      "type": "string"
    },
    "updated_at": {
      "description": "UpdatedAt records when this connection was last changed.",
      "format": "date-time",
      "type": "string"
    }
  },
  "required": [
    "id",
    "project_id",
    "name",
    "type",
    "endpoint",
    "status",
    "default_for_dashboard",
    "created_at",
    "updated_at"
  ],
  "type": "object"
}
```



```json #/components/schemas/ResponseErrorForbidden
{
  "properties": {
    "error": {
      "description": "Error response details",
      "properties": {
        "code": {
          "const": 403,
          "description": "Code is the HTTP status code",
          "examples": [
            403
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "Unauthorized to perform this action"
          ],
          "type": "string"
        },
        "type": {
          "const": "ForbiddenError",
          "description": "Type indicates the error category",
          "enum": [
            "ForbiddenError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ]
}
```



```json #/components/schemas/ResponseErrorNotFound
{
  "description": "Error response",
  "properties": {
    "error": {
      "description": "Error response details",
      "properties": {
        "code": {
          "const": 404,
          "description": "Code is the HTTP status code",
          "examples": [
            404
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "Ressource not found"
          ],
          "type": "string"
        },
        "type": {
          "const": "NotFoundError",
          "description": "Type indicates the error category",
          "enum": [
            "NotFoundError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ],
  "type": "object"
}
```



```json #/components/schemas/ResponseErrorTooManyRequests
{
  "description": "Error response",
  "properties": {
    "error": {
      "description": "Error response details",
      "properties": {
        "code": {
          "const": 429,
          "description": "Code is the HTTP status code",
          "examples": [
            429
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "Rate limit exceeded"
          ],
          "type": "string"
        },
        "type": {
          "const": "TooManyRequestsError",
          "description": "Type indicates the error category",
          "enum": [
            "TooManyRequestsError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ],
  "type": "object"
}
```



```json #/components/schemas/ResponseErrorServiceUnavailable
{
  "properties": {
    "error": {
      "description": "Error response details",
      "properties": {
        "code": {
          "const": 503,
          "description": "Code is the HTTP status code",
          "examples": [
            503
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "The service is temporarily unavailable; retry the request"
          ],
          "type": "string"
        },
        "type": {
          "const": "ServiceUnavailableError",
          "description": "Type indicates the error category",
          "enum": [
            "ServiceUnavailableError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ]
}
```



```json #/components/schemas/ResponseErrorValidation
{
  "properties": {
    "error": {
      "properties": {
        "code": {
          "const": 400,
          "description": "Code is the HTTP status code",
          "examples": [
            400
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "Invalid request parameters"
          ],
          "type": "string"
        },
        "type": {
          "const": "ValidationError",
          "description": "Type indicates the error category",
          "enum": [
            "ValidationError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ]
}
```



```json #/components/schemas/ResponseErrorAuthentication
{
  "description": "Error response",
  "properties": {
    "error": {
      "description": "Error response details",
      "properties": {
        "code": {
          "const": 401,
          "description": "Code is the HTTP status code",
          "examples": [
            401
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "Authentication error: invalid token or subscription inactive"
          ],
          "type": "string"
        },
        "type": {
          "const": "AuthenticationError",
          "description": "Type indicates the error category",
          "enum": [
            "AuthenticationError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ],
  "type": "object"
}
```



```json #/components/schemas/ResponseErrorConflict
{
  "description": "Error response",
  "properties": {
    "error": {
      "description": "Error response details",
      "properties": {
        "code": {
          "const": 409,
          "description": "Code is the HTTP status code",
          "examples": [
            409
          ],
          "type": "integer"
        },
        "message": {
          "description": "Message is a human-readable error description",
          "examples": [
            "source_unavailable: the original video is no longer accessible"
          ],
          "type": "string"
        },
        "type": {
          "const": "ConflictError",
          "description": "Type indicates the error category",
          "enum": [
            "ConflictError"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "code",
        "message"
      ],
      "type": "object"
    },
    "status": {
      "const": "error",
      "description": "Status indicates the response status \"error\"",
      "type": "string"
    }
  },
  "required": [
    "status",
    "error"
  ],
  "type": "object"
}
```