# Update the linked repository

> Change the branch, the root directory, or whether pushes deploy. Pass at least one field. rootDir: null clears the subdirectory.

`PATCH https://api.zavu.dev/v1/functions/{functionId}/git-link`

Change the branch, the root directory, or whether pushes deploy. Pass at least one field. `rootDir: null` clears the subdirectory.

## Parameters

- `functionId` (path, string, required): Zavu Function ID.

## Body

- `branch` (string)
- `rootDir` (string, nullable)
- `autoDeploy` (boolean)

## Responses

### 200

The link.

- `link` (object, required): A GitHub repository bound to a function. A push to `branch` deploys the function. A function holds at most one link.
  - `id` (string, required)
  - `functionId` (string, required)
  - `provider` (string, required) One of: `github`.
  - `owner` (string, required)
  - `repo` (string, required)
  - `branch` (string, required): Only pushes to this branch deploy.
  - `rootDir` (string, nullable): Subdirectory holding the project, for monorepos. Null when the project is at the repository root.
  - `autoDeploy` (boolean, required): When false the link is kept and pushes are ignored.
  - `connection` (string, required): How this link authenticates, decided by the server rather than by the caller. - `app`: the Zavu GitHub App is installed on the account. Pushes arrive on the app's webhook and private repositories work. Nothing to configure in the repository. - `manual`: no installation. The link carries its own secret and you add the webhook to the repository yourself. One of: `app`, `manual`.
  - `lastStatus` (string, nullable) One of: `deploying`, `deployed`, `failed`, `null`.
  - `lastCommitSha` (string, nullable)
  - `lastCommitMessage` (string, nullable)
  - `lastError` (string, nullable): Why the last deploy failed. Null otherwise.
  - `lastDeployAt` (string<date-time>, nullable)
  - `createdAt` (string<date-time>, required)
  - `updatedAt` (string<date-time>, required)
- `webhookUrl` (string<uri>, required): Endpoint that receives GitHub's push deliveries. Only needed on a `manual` link, where you add it to the repository yourself.
- `webhookSecret` (string): Shared secret for the repository's webhook. **Returned only when creating a `manual` link, and only there** — every later read strips it, and re-linking mints a new one. Absent entirely on an `app` link, which needs no secret of its own.

### 400

No fields to update, or invalid values.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 404

No repository is linked to this function.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X PATCH "https://api.zavu.dev/v1/functions/function_abc123/git-link" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "autoDeploy": false
}'
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.functions.gitLink.update("function_abc123", {
  autoDeploy: false,
});

console.log(result);
```
