[[update-connector-last-sync-api]] === Update connector last sync stats API ++++ Update connector last sync stats ++++ preview::[] Updates the fields related to the last sync of a connector. This action is used for analytics and monitoring. To get started with Connector APIs, check out <>. [[update-connector-last-sync-api-request]] ==== {api-request-title} `PUT _connector//_last_sync` [[update-connector-last-sync-api-prereq]] ==== {api-prereq-title} * To sync data using self-managed connectors, you need to deploy the <>. on your own infrastructure. This service runs automatically on Elastic Cloud for Elastic managed connectors. * The `connector_id` parameter should reference an existing connector. [[update-connector-last-sync-api-path-params]] ==== {api-path-parms-title} ``:: (Required, string) [role="child_attributes"] [[update-connector-last-sync-api-request-body]] ==== {api-request-body-title} `last_access_control_sync_error`:: (Optional, string) The last error message related to access control sync, if any. `last_access_control_sync_scheduled_at`:: (Optional, datetime) The datetime indicating when the last access control sync was scheduled. `last_access_control_sync_status`:: (Optional, ConnectorSyncStatus) The status of the last access control sync. `last_deleted_document_count`:: (Optional, long) The number of documents deleted in the last sync process. `last_incremental_sync_scheduled_at`:: (Optional, datetime) The datetime when the last incremental sync was scheduled. `last_indexed_document_count`:: (Optional, long) The number of documents indexed in the last sync. `last_sync_error`:: (Optional, string) The last error message encountered during a sync process, if any. `last_sync_scheduled_at`:: (Optional, datetime) The datetime when the last sync was scheduled. `last_sync_status`:: (Optional, ConnectorSyncStatus) The status of the last sync. `last_synced`:: (Optional, datetime) The datetime of the last successful synchronization. The value of `ConnectorSyncStatus` is one of the following lowercase strings representing different sync states: * `canceling`: The sync process is in the process of being canceled. * `canceled`: The sync process has been canceled. * `completed`: The sync process completed successfully. * `error`: An error occurred during the sync process. * `in_progress`: The sync process is currently underway. * `pending`: The sync is pending and has not yet started. * `suspended`: The sync process has been temporarily suspended. [[update-connector-last-sync-api-response-codes]] ==== {api-response-codes-title} `200`:: Connector last sync stats were successfully updated. `400`:: The `connector_id` was not provided or the request payload was malformed. `404` (Missing resources):: No connector matching `connector_id` could be found. [[update-connector-last-sync-api-example]] ==== {api-examples-title} The following example updates the last sync stats for the connector with ID `my-connector`: //// [source, console] -------------------------------------------------- PUT _connector/my-connector { "index_name": "search-google-drive", "name": "My Connector", "service_type": "google_drive" } -------------------------------------------------- // TESTSETUP [source,console] -------------------------------------------------- DELETE _connector/my-connector -------------------------------------------------- // TEARDOWN //// [source,console] ---- PUT _connector/my-connector/_last_sync { "last_access_control_sync_error": "Houston, we have a problem!", "last_access_control_sync_scheduled_at": "2023-11-09T15:13:08.231Z", "last_access_control_sync_status": "pending", "last_deleted_document_count": 42, "last_incremental_sync_scheduled_at": "2023-11-09T15:13:08.231Z", "last_indexed_document_count": 42, "last_sync_error": "Houston, we have a problem!", "last_sync_scheduled_at": "2024-11-09T15:13:08.231Z", "last_sync_status": "completed", "last_synced": "2024-11-09T15:13:08.231Z" } ---- [source,console-result] ---- { "result": "updated" } ----