<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# Refresh an access token

`POST https://marketplace-api.sequifi.com/v1/auth/refreshToken`

Module: Authentication · operationId: `refreshAccessToken` · Auth: none, no `Authorization` header (the credential goes in the body)
Web page: https://apidocs.sequifi.com/#/api/refresh-access-token

Exchanges a refresh token for a new access token and a new refresh token, so an integration can keep working past the access token's 60 days without an admin. Send the refresh token in the body; this call takes no `Authorization` header.

**Before you call:**

- You need the refresh token from the credentials an admin created under Admin > Tools > API Credentials, or from your last refresh.
- Refresh before the access token expires (60 days). The refresh token itself lasts 66 days; after that an admin has to create new credentials.

**What happens:**

- The refresh token is checked. If it is valid you get a new access token (60 days) and a new refresh token (66 days), counted from now. Refreshing on a schedule keeps an integration running indefinitely.
- The old pair stops working: the old access token within about five minutes, the old refresh token at once. Each refresh token works once.
- Store the new refresh token before you use the new access token. You need it for the next refresh.
- The credential keeps its name, and an admin still controls it: Pause or Delete in the web app stops refreshing too.

**Idempotency and retries:**

- If a refresh response is lost, retry with the same refresh token within 60 seconds and you get the same new pair. Two workers refreshing at once also get the same pair.
- After 60 seconds, a refresh token that was already used is treated as stolen: the credential is paused and the call returns `401`. An admin can resume it or create a new one. Keep one copy of the refresh token and refresh from one place.

**Formats:**

- Body: `{"refresh_token": "<token>"}`. Leading and trailing spaces are trimmed.
- Expiry times are `YYYY-MM-DD HH:MM:SS` in UTC.

**Errors:**

- `400 Invalid JSON body` or `400 Missing required field: refresh_token`.
- `401 Invalid or expired refresh token`: unknown, expired, paused or deleted credentials, or a company whose API access is off. The message is the same for all of them.
- `401` with a message saying the token was already used and the credential is paused: see retries above. An admin has to resume or replace the credential.
- Don't retry a `401` in a loop.

**Related:**

- The Authentication guide covers creating tokens and rotating them by hand.

## Request body

- `refresh_token` (string, **required**): The current refresh token. Each one works once. Example: `9f2c...e41a`.

Example

```json
{
  "refresh_token": "<your current refresh token>"
}
```

## Example request

```bash
curl -X POST "https://marketplace-api.sequifi.com/v1/auth/refreshToken" \
  -H "Content-Type: application/json" \
  -d '{"refresh_token":"<your current refresh token>"}'
```

## Responses

### 200: Refreshed. Use the new access token from now on and store the new refresh token for the next refresh.

- `status` (integer): Same as the HTTP status code. Example: `200`.
- `message` (string) Example: `Token refreshed successfully`.
- `data` (object)
  - `name` (string): The credential's name, as set when an admin created it.
  - `access_token` (string): Send as `Authorization: Bearer <access_token>`.
  - `access_token_expires_at` (string): When the access token stops working, `YYYY-MM-DD HH:MM:SS` UTC (60 days).
  - `refresh_token` (string): Use for the next refresh. Works once.
  - `refresh_token_expires_at` (string): Last moment to refresh, `YYYY-MM-DD HH:MM:SS` UTC (66 days).

```json
{
  "status": 200,
  "message": "Token refreshed successfully",
  "data": {
    "name": "CRM sync (production)",
    "access_token": "0f3a...:9c1d...:7be2...",
    "access_token_expires_at": "2026-12-07 18:00:00",
    "refresh_token": "9b41...c07e",
    "refresh_token_expires_at": "2026-12-13 18:00:00"
  }
}
```

### 400: The body is not JSON or has no `refresh_token`.

```json
{
  "status": 400,
  "message": "Missing required field: refresh_token",
  "data": {}
}
```

### 401: The refresh token can't be used, or it was already used and the credential is now paused.

Example (invalid): Unknown, expired, paused or deleted

```json
{
  "status": 401,
  "message": "Invalid or expired refresh token",
  "data": {}
}
```

### 500: Server error.

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```
