# How to Upgrade

## Determine which version you're using

First determine which API version your application is using.

All requests made to the Peach API have an implicit or explicit version associated with them.

### API Keys

It's highly likely that your application is built using a Peach API Key. Each Peach API Key has an API Version associated with it. [Learn about API Keys](/developer-tools/api-keys).

Determine which API Key your application is using by finding it in your codebase or secrets manager.

You can then determine which API Version your key is using by either fetching from the `/api/keys` endpoint or referencing the `Peach-Version` response header.

### Check the `/api/keys` endpoint

1. Fetch the `http://api.peach.finance/api/keys` endpoint. See [API Key endpoints docs](/api-docs/api-public/api-keys/).
2. Match the last four alphanumerics of the `key` field to the last four of your API key.
3. Check the `apiVersion` field to see the API version for that key. e.g., `"2023-11-29"`


### Check the `Peach-Version` header

1. Fetch ANY peach endpoint with your API key.
2. Examine the response header named `Peach-Version:`. It should have a value like `"2023-11-29"`


An example command that will only display the `Peach-Version` header would be:


```bash
# Example—Be sure to set your API Key in place of the example `123ab...89def`.
> curl -H "X-API-KEY: 123ab...89def" -s -D - -o /dev/null  https://api.peach.finance/api/loans | grep -i 'peach-version'
```

...which would result in something like `peach-version: 2023-11-29`.

### Hardcoded API Version

It's also possible your application is hardcoding the API Version as well. Check if your application has set the request header `peach-version` to a value.

## Determine if your application uses API Versioned endpoints

Only certain endpoints in Peach are under API Versioning. Check to see if your application uses these endpoints.

Go to the [Breaking Changes](/developer-tools/breaking-changes) page to see the endpoints currently affected by breaking changes.

Check your application to see if you make requests to any of these endpoints. You should be able to tell by inspecting your code base.

If you're not making use of any of these endpoints then you shouldn't need to make changes to your application.

### Determine if they've changed since your last upgrade

If there's an endpoint you're using, then check if it's in a newer version than your current version.

You need to compare your current API version which you determined in the steps above to the API versions on the [Breaking Changes](/developer-tools/breaking-changes) page. If the breaking changes are all in your current version or earlier, then you shouldn't need to make changes to your application.

If the breaking changes are in versions newer than your current API Version, then you will need to change your application.

## Change your application

If your codebase makes use of endpoints affected by API Versioning, then you may need to change your application to match these changes.

The specific changes you need to make will be dependent on the nature of the breaking changes.

See the [Breaking Changes](/developer-tools/breaking-changes) page to see the changes. The upgrade procedure should be explained there. If you need additional help contact support@peachfinance.com.

## Test the changes in sandbox

You should first test your changes in your Sandbox environment.

Make the changes to your application which points at your sandbox environment (i.e., using the domain `sandboxapi.peach.finance`). Then upgrade the API key you're using in your Sandbox environment. See "Upgrading an API key's API version" in the [API Keys Doc](/developer-tools/api-keys) for details.

Confirm the endpoints work with the new changes by ensuring the application runs against those endpoints. Monitor your logs or other systems to confirm the system behaves as expected.

## Roll out the changes to prod

Once you've confirmed the changes to your application function in sandbox with the upgraded API Version, you should upgrade your production application codebase and the update associated API Key.

## Next steps

- **[Breaking Changes](/developer-tools/breaking-changes)** — The list of breaking changes you may need to account for.
- **[API Versioning](/developer-tools/api-versioning)** — Background on Peach's approach to versioning.