> ## Documentation Index
> Fetch the complete documentation index at: https://docs.4mica.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Refresh tokens

> Exchange a refresh token for a new access token and refresh token.

`POST /auth/refresh`

No authentication. Core rotates the refresh token on every call: the one you send stops working, and the response carries its replacement. A refresh token lasts 30 days by default.

## Request body

**refresh\_token** `string` *required*

The refresh token from [`POST /auth/verify`](https://docs.4mica.io/api-reference/operator/verify-siwe) or from the previous refresh.

## Responses

**access\_token** `string` *required*

**refresh\_token** `string` *required*

The new refresh token. Store it in place of the old one.

**expires\_in** `number` *required*

Access token lifetime in seconds. 900 by default.

```bash cURL theme={null}
curl -X POST "https://base.sepolia.api.4mica.io/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{ "refresh_token": "refresh_3f9a..." }'
```

```javascript title="Fetch" theme={null}
const response = await fetch("https://base.sepolia.api.4mica.io/auth/refresh", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ refresh_token: refreshToken }),
});
console.log(await response.json());
```

```python Python theme={null}
import requests
url = "https://base.sepolia.api.4mica.io/auth/refresh"
print(requests.post(url, json={"refresh_token": refresh_token}).json())
```

```json 200 OK theme={null}
{
  "access_token": "eyJhbGciOi...",
  "refresh_token": "refresh_8c1d...",
  "expires_in": 900
}
```

```json 401 Unauthorized theme={null}
{ "error": "refresh token expired" }
```

## Status codes

| Code | Description |
| - | - |
| `200` | New tokens issued. |
| `401` | The refresh token is unknown (`invalid refresh token`), or it has expired, been used already, or been revoked (`refresh token expired`). Sign in again. |
| `500` | Core could not issue tokens. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.