[[set-connector-sync-job-error-api]]
=== Set connector sync job error API
++++
<titleabbrev>Set connector sync job error</titleabbrev>
++++

preview::[]

.New API reference
[sidebar]
--
For the most up-to-date API details, refer to {api-es}/group/endpoint-connector[Connector APIs].
--

Sets a connector sync job error.

To get started with Connector APIs, check out <<es-connectors-tutorial-api, our tutorial>>.


[[set-connector-sync-job-error-api-request]]
==== {api-request-title}
`PUT _connector/_sync_job/<connector_sync_job_id>/_error`

[[set-connector-sync-job-error-api-prereqs]]
==== {api-prereq-title}

* To sync data using self-managed connectors, you need to deploy the <<es-connectors-deploy-connector-service,Elastic connector service>>. on your own infrastructure. This service runs automatically on Elastic Cloud for Elastic managed connectors.
* The `connector_sync_job_id` parameter should reference an existing connector sync job.

[[set-connector-sync-job-error-api-desc]]
==== {api-description-title}

Sets the `error` field for the specified connector sync job and sets its `status` to `error`.

[[set-connector-sync-job-error-api-path-params]]
==== {api-path-parms-title}

`<connector_sync_job_id>`::
(Required, string)

[role="child_attributes"]
[[set-connector-sync-job-error-api-request-body]]
==== {api-request-body-title}

`error`::
(Required, string) The error to set the connector sync job `error` field to.

[[set-connector-sync-job-api-response-codes]]
==== {api-response-codes-title}

`200`::
Indicates that the connector sync job error was set successfully.

`404`::
No connector sync job matching `connector_sync_job_id` could be found.

[[set-connector-sync-job-error-api-example]]
==== {api-examples-title}

The following example sets the error `some-error` in the connector sync job `my-connector-sync-job`:

[source,console]
----
PUT _connector/_sync_job/my-connector-sync-job/_error
{
    "error": "some-error"
}
----
// TEST[skip:there's no way to clean up after creating a connector sync job, as we don't know the id ahead of time. Therefore, skip this test.]
