# Sync with Anki

Ankinize speaks Anki's own sync protocol, so the Anki you already have works as is: you only change one setting, the address it syncs with.

## Before you start

- An Ankinize account with a verified email address.
- Your sync address, which is the address of this server, ending in a slash:

Sync address

```
https://ankinize.com/
```

You can copy it from *API Keys & Devices* in the dashboard. Keep the slash on the end: Anki adds `sync/` and `msync/` after it, and a server behind a reverse proxy on a sub-path needs it.

## Anki on your computer

1. Open the syncing settings
   
   Choose *Tools → Preferences → Syncing*.
2. Enter the address
   
   Paste your sync address into *Self-hosted sync server* and press OK. If Anki asks you to restart, restart it.
3. Log in and sync
   
   Press *Sync* in the main window. Log in with your Ankinize email and password. If you turned on two-factor, use an API key as the password instead; see [below](#two-factor).

## Your first sync

If your computer and the server hold different collections, Anki cannot merge them and asks which side to keep. This is a **full sync**:

| Choice | What happens |
| --- | --- |
| Upload to Ankinize | The server's copy is replaced by the one on this computer. Choose this for your first sync from your main computer. |
| Download from Ankinize | The copy on this computer is replaced by the server's. Choose this on a second device. |

> Check before you choose
> 
> Both choices overwrite one side completely. If you are not sure which side has your latest reviews, export the other one first.

After that, syncs only send what changed, and media files follow automatically.

## AnkiDroid

1. Open the setting
   
   Choose *Settings → Sync → Custom sync server*.
2. Enter the address
   
   AnkiDroid 2.16 and newer asks for one address: use your sync address. Older versions ask for two:
   
   Older AnkiDroid
   
   ```
   Sync URL        https://ankinize.com/sync/
   Media sync URL  https://ankinize.com/msync/
   ```
3. Log in
   
   Use the same email and password as on the computer, then sync.

## AnkiMobile (iPhone and iPad)

1. Open the setting
   
   Choose *Settings → Syncing → Custom sync server* and enter your sync address.
2. Log in and sync
   
   Log in on the sync screen and press Sync.

> Two things iOS is strict about
> 
> The server must use **HTTPS with TLS 1.2 or newer**; an older setup fails with error `-9836`. And if the server is on your home network, allow *Local Network* access for AnkiMobile in iOS Settings, or the connection is silently refused.

## If you use two-factor login

Anki has nowhere to type a second code. Create an API key with the `sync` scope under *API Keys & Devices* and use it as the **password** in Anki, with your email as the username. The key works only for syncing unless you also give it the REST scopes. See [Authentication](https://ankinize.com/docs/authentication).

## Seeing and removing devices

Each Anki that signs in appears under *Devices* in the dashboard, with its version and when it last synced. Sign a device out there and it has to log in again before it can sync.

## Troubleshooting

| What you see | What to do |
| --- | --- |
| “Invalid username or password” | Check that the email is verified. If two-factor is on, use a sync API key as the password. |
| A network or connection error | Open the sync address in a browser. It must load over HTTPS, and the address must end in a slash. |
| Error -9836 on iPhone | The server's TLS version is too old. Serve it with TLS 1.2 or newer. |
| Works on Wi‑Fi at home, not on iPhone | Allow Local Network access for AnkiMobile in iOS Settings. |
| Works on a phone only with two addresses | That AnkiDroid is older than 2.16: enter the sync and media addresses separately. |
| The API says “423 Locked” | A sync is running. Wait the number of seconds in Retry-After and try again. |
