# Keep the API up to date

An API follows the branch it was analyzed from. With **Automatic**, every push starts an update. With **Manual**, nothing happens until you ask. An update compares the new code with the last analyzed commit and changes only the operations that were affected, so it is shorter than a full analysis.

## Before you begin

- The API's code comes from a repository. An API created from a ZIP has no branch to follow. See [Update an API created from a ZIP](#update-an-api-created-from-a-zip).

## Choose Automatic or Manual

To change how the API updates:

1. In the portal, go to [**APIs**](https://auth.faustine.ai/go?to=%2Fintegrations%2Fapis) and select your API.
2. Select the **Settings** tab, then **Keep up to date**.
3. Select **Automatic** or **Manual**.
4. Select **Save changes**.

| Mode | On a push to the connected branch |
| --- | --- |
| **Automatic** | Faustine re-analyzes what changed and publishes a new version if the API changed. A push that does not touch the API path is skipped and uses no tokens. |
| **Manual** | Nothing. You run **Check for updates** or **Re-analyze** when you want. |

Automatic is the recommended mode, because the operations agents see then match the code that is deployed from that branch. Choose Manual when you want to review each change before it is published.

The **Overview** tab has the same setting as the **Auto-update** switch on the card that shows the repository. The switch applies when you change it.

For an API made of several services, a push to the branch of any of its repositories updates the services of that repository. The update goes into the draft, and you publish it.

## Check for updates

To update the API on demand:

1. Open the **Actions** menu in the API's header.
2. Select **Check for updates**.

The portal opens the **Activity** tab with the run selected. If the branch has no change that affects the API, the run ends with **No impact** and uses no tokens. Otherwise it updates the affected operations and publishes a version.

**Check for updates** is the same process that a push starts in Automatic mode. To discard what the last analysis understood and read all the code again, use **Re-analyze**. See [The analysis](https://docs.faustine.ai/apis/analysis/).

## Update an API created from a ZIP

An uploaded archive has no branch, so **Auto-update** is off and cannot be turned on. To update the API, upload the new code:

1. Open the **Actions** menu and select **Upload a new version**.
2. Choose the new archive.

Faustine replaces the stored archive and runs an update over the difference between the two.

If the code was not kept after the analysis, the menu shows **Upload the code again** instead. After the upload, the portal offers to re-analyze the API.

## Next steps

- [Versions and updates](https://docs.faustine.ai/apis/versions/): what a published version changes for the gateways that serve the API.
- [The analysis](https://docs.faustine.ai/apis/analysis/): what a full re-analysis keeps and what it replaces.
- [Generate and run API tests](https://docs.faustine.ai/apis/tests/): check the API after an update.
