# Update sync

URL: https://docs.hanzo.ai/docs/openapi/sync/patch-sync-by-id

> Updates one sync's mutable policy — direction, trigger and actor — in place.

`PATCH /v1/sync/{id}`

> [Sync →](https://docs.hanzo.ai/docs/openapi/sync) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/sync/{id}`    |
| **Method**    | `PATCH`                                |
| **Operation** | `patch_sync_by_id`                     |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Updates one sync's mutable policy — direction, trigger and actor — in place.
The endpoints and the kind are immutable: re-pointing a sync is a delete and a
create, so a link can never silently start syncing somewhere else. A field the
request omits is left as it was. Changing the direction immediately reconciles the
derived outbound mirror, so turning push off stops the upstream being written to
rather than merely recording the intent.

## Request

14 fields, body `application/json` (required).

| Field              | In   | Type             | Required | Description                                                                                               |
| ------------------ | ---- | ---------------- | -------- | --------------------------------------------------------------------------------------------------------- |
| `id`               | path | string           | yes      | ID is the sync to update, from the path.                                                                  |
| `actor`            | body | string           | —        | Actor is the loop-guard identity the sync writes as.                                                      |
| `direction`        | body | string           | —        | Direction is both, pull, push or off.                                                                     |
| `id`               | body | string           | —        | ID is the sync to update, from the path.                                                                  |
| `kind`             | body | string           | —        | Kind names a different kind of sync, and is refused, for the same reason.                                 |
| `source`           | body | sync.endpointReq | —        |                                                                                                           |
| `source.connector` | body | string           | —        | Connector names the stored credential to reach this endpoint with.                                        |
| `source.locator`   | body | string           | —        | Locator addresses the resource.                                                                           |
| `source.provider`  | body | string           | —        | Provider is the platform: github or gitlab for a source; a target defaults to the native Hanzo Git plane. |
| `target`           | body | sync.endpointReq | —        |                                                                                                           |
| `target.connector` | body | string           | —        | Connector names the stored credential to reach this endpoint with.                                        |
| `target.locator`   | body | string           | —        | Locator addresses the resource.                                                                           |
| `target.provider`  | body | string           | —        | Provider is the platform: github or gitlab for a source; a target defaults to the native Hanzo Git plane. |
| `trigger`          | body | string           | —        | Trigger is webhook, poll or manual.                                                                       |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | sync.syncView   | ok      |
| `default` | problem-details | refused |

`200` body — 24 fields.

| Field               | In   | Type              | Always | Description                                                                                                                                                                                                                               |
| ------------------- | ---- | ----------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actor`             | body | string            | —      | Actor is the identity a reconcile writes AS.                                                                                                                                                                                              |
| `createdAt`         | body | string            | —      | CreatedAt is when the link was first declared, RFC3339 in UTC.                                                                                                                                                                            |
| `direction`         | body | string            | —      | Direction is which way work flows: "both", "pull" (target ← source), "push" (source → target), or "off" — which keeps the link declared and moves nothing.                                                                                |
| `id`                | body | string            | —      | ID is the link's handle, derived from its source and target — which is what makes re-declaring the same pair an update rather than a duplicate.                                                                                           |
| `kind`              | body | string            | —      | Kind is what is being synced.                                                                                                                                                                                                             |
| `native`            | body | sync.nativeView   | —      |                                                                                                                                                                                                                                           |
| `native.advancedAt` | body | string            | —      | AdvancedAt is when an import or a push last moved one of its refs, RFC3339 in UTC.                                                                                                                                                        |
| `native.branch`     | body | string            | —      | Branch is the forge's default branch, which an import sets to the upstream's once that branch has landed.                                                                                                                                 |
| `native.clone`      | body | string            | —      | Clone is the https address to clone it from.                                                                                                                                                                                              |
| `native.sizeBytes`  | body | integer (int64)   | —      | SizeBytes is the repository's size on the forge, in bytes.                                                                                                                                                                                |
| `native.ssh`        | body | string            | —      | SSH is the ssh address to clone it from, when the forge serves one.                                                                                                                                                                       |
| `native.status`     | body | string            | —      | Status is one of "synced" (the forge holds it and no ref is in conflict), "conflict" (an upstream ref diverged and the forge kept its own history), "pending" (the forge does not hold it yet) or "paused" (the link's direction is off). |
| `native.url`        | body | string            | —      | URL is the repository's page on the forge.                                                                                                                                                                                                |
| `scope`             | body | string            | —      | Scope is "repo" for a link to one repository, or "account" for a link to a whole GitHub account, which declares a repo link for every repository the account holds — the ones created later included.                                     |
| `source`            | body | sync.endpointView | —      |                                                                                                                                                                                                                                           |
| `source.connector`  | body | string            | —      | Connector names a connected account from the org's connector registry, when the endpoint reaches its provider through one.                                                                                                                |
| `source.locator`    | body | string            | —      | Locator addresses the thing INSIDE that provider, in the provider's own terms — an https clone URL for a hosted forge, a bare repository name for hanzo-git.                                                                              |
| `source.provider`   | body | string            | —      | Provider is the concrete integration: "github", "gitlab" or "hanzo-git".                                                                                                                                                                  |
| `target`            | body | sync.endpointView | —      |                                                                                                                                                                                                                                           |
| `target.connector`  | body | string            | —      | Connector names a connected account from the org's connector registry, when the endpoint reaches its provider through one.                                                                                                                |
| `target.locator`    | body | string            | —      | Locator addresses the thing INSIDE that provider, in the provider's own terms — an https clone URL for a hosted forge, a bare repository name for hanzo-git.                                                                              |
| `target.provider`   | body | string            | —      | Provider is the concrete integration: "github", "gitlab" or "hanzo-git".                                                                                                                                                                  |
| `trigger`           | body | string            | —      | Trigger is what starts a reconcile: "webhook" (the provider tells us), "poll" (we ask on a schedule), or "manual" (only an explicit call).                                                                                                |
| `updatedAt`         | body | string            | —      | UpdatedAt is bumped by every reconcile, so it reads as the LAST-SYNCED time rather than the last edit.                                                                                                                                    |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo sync update <id>
```

**SDK**

**.ts**

```ts
import { Configuration, SyncApi } from 'hanzoai';

const api = new SyncApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.patchSyncById({ id: 'id', actor: "<actor>", direction: "<direction>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import SyncApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = SyncApi(client).patch_sync_by_id(id='id', actor="<actor>", direction="<direction>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.SyncAPI.PatchSyncById(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, sync_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = sync_api::patch_sync_by_id(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.SyncApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new SyncApi(client).patchSyncById();
```

**HTTP**

```bash
curl -X PATCH https://api.hanzo.ai/v1/sync/<id> \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "actor": "<actor>",
       "direction": "<direction>"
     }'
```

**MCP**

MCP reaches **sync** through the `sync` tool, which names its 6 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_syncs"
         }
       }
     }'
```

---

[Sync API](https://docs.hanzo.ai/docs/openapi/sync) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
