---
title: "Rotate a device refresh token and mint a short-lived access JWT"
---

> Documentation Index
> Fetch the complete documentation index at: https://tryshiba.dev/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Shiba public API › devices

`POST /devices/refresh`

## Request body

_Required._

- `refreshToken` (`refreshDeviceCredentials.refreshToken`; string, required)
  - minLength 24; maxLength 512

## Example request

```json
{
  "refreshToken": "stringstringstringstring"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/api/v1/devices/refresh' \
  --header 'Content-Type: application/json' \
  --data '
{
  "refreshToken": "stringstringstringstring"
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/devices/refresh';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({refreshToken: 'stringstringstringstring'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/api/v1/devices/refresh"

payload = { "refreshToken": "stringstringstringstring" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Success

#### Example

```json
{
  "ok": true,
  "device": {
    "deviceId": "string",
    "name": "string",
    "platform": "ios",
    "createdAt": 0,
    "lastSeenAt": 0,
    "revokedAt": 0
  },
  "refreshToken": "string",
  "accessToken": "string",
  "accessTokenExpiresAt": 0,
  "refreshTokenExpiresAt": 0
}
```

- `ok` (`refreshDeviceCredentials.response.200.ok`; boolean, required)
- `device` (`refreshDeviceCredentials.response.200.device`; object, required)
  - `deviceId` (`refreshDeviceCredentials.response.200.device.deviceId`; string, required)
  - `name` (`refreshDeviceCredentials.response.200.device.name`; string, required)
  - `platform` (`refreshDeviceCredentials.response.200.device.platform`; string, required)
    - one of `"ios"`, `"android"`, `"web"`, `"desktop"`, `"unknown"`
  - `createdAt` (`refreshDeviceCredentials.response.200.device.createdAt`; number, required)
  - `lastSeenAt` (`refreshDeviceCredentials.response.200.device.lastSeenAt`; number | null, required)
  - `revokedAt` (`refreshDeviceCredentials.response.200.device.revokedAt`; number | null, required)
- `refreshToken` (`refreshDeviceCredentials.response.200.refreshToken`; string, required)
- `accessToken` (`refreshDeviceCredentials.response.200.accessToken`; string, required)
- `accessTokenExpiresAt` (`refreshDeviceCredentials.response.200.accessTokenExpiresAt`; number, required)
- `refreshTokenExpiresAt` (`refreshDeviceCredentials.response.200.refreshTokenExpiresAt`; number, required)

### 401

Invalid, expired, rotated, or replayed token

#### Example

```json
{
  "ok": false,
  "error": "string",
  "detail": "string",
  "code": "string"
}
```

- `error` (`refreshDeviceCredentials.response.401.error`; string, required)
- `ok` (`refreshDeviceCredentials.response.401.ok`; boolean, optional)
- `detail` (`refreshDeviceCredentials.response.401.detail`; string, optional)
- `code` (`refreshDeviceCredentials.response.401.code`; string, optional)


Source: https://tryshiba.dev/reference/api/devices/refreshDeviceCredentials/index.md
