# Authentication and limits

API keys, the Authorization header, the rate limit, timeouts and retries.

Source: https://clonelyapp.com/api/authentication/


## API keys

You create keys in Clonely under **Settings > API access**. A store can have up to 10 keys, each with a name of up to 60 characters, so you can give each tool or agent its own key.

Clonely shows a new key once. It looks like `clonely_3f9a1c2b7d4e_...`. The first part (`clonely_3f9a1c2b7d4e`) is the key's prefix, which the settings list shows next to the name, the date it was made and the date it was last used. Clonely stores only a hash of the key, so a lost key can't be shown again: revoke it and create a new one.

A revoked key stops working right away. Uninstalling Clonely deletes all of the store's keys.

## Sending the key

Send the key as a Bearer token on every request:

```bash
curl https://app.clonelyapp.com/api/v1/copies \
  -H "Authorization: Bearer clonely_3f9a1c2b7d4e_..."
```

A missing, malformed, unknown or revoked key gets `401` with the code `unauthorized`.

## Rate limit

Each key can make 60 requests a minute. Past that, requests get `429` with the code `rate_limited` and a `Retry-After` header with the number of seconds to wait.

## Timeouts

A single-product copy ([`POST /products/copy`](https://clonelyapp.com/api/products/#post-productscopy)) can take up to 30 seconds, because the answer waits for the copy. Give your HTTP client a timeout of at least 60 seconds for it. Every other endpoint answers quickly.

## Retries

Retry these, after the `Retry-After` seconds:

- `429 rate_limited`
- `503 shopify_unavailable`: the Shopify Admin API didn't answer after Clonely's own retries. Nothing was changed.

Don't blindly retry a start (`POST /copies` or `POST /products/copy`) that timed out on your side. Clonely may have received it and started the copy. Check [`GET /copies`](https://clonelyapp.com/api/copies/#get-copies) or [`GET /products`](https://clonelyapp.com/api/products/#get-products) first.

## Reconnecting

If Clonely has lost its access to the store, requests get `409` with the code `reconnect_required`. Open Clonely in the Shopify admin once and the API works again.

