# Force a token refresh
URL: https://musicapi.com/docs/reference/refresh-integration-user-token.md

`POST https://api.musicapi.com/public/integrations/refreshAuthToken`

Section: Connect your users.
Product: MusicAPI Core and MusicAPI Managed Transfers.
Auth: Basic, Token, DevToken, DocsSession (any one of them). Use Basic with your Client ID and Client Secret from your server only.

Refreshes the music-service tokens of one connected user now. With Client Secret authentication the answer holds the new `authData`.

## Request body

`application/json`, required.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `integrationUserUUID` | uuid | yes |  |

## Response 200

OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `integrationUser` | IntegrationUserWithAuthData | yes |  |
| `integrationUser.uuid` | uuid | yes | The integrationUserUUID. Use it in every `/api/{integrationUserUUID}/...` call. |
| `integrationUser.integrationUserId` | string | yes | The user's id on the music service. |
| `integrationUser.name` | string \| null | yes |  |
| `integrationUser.email` | string \| null | yes |  |
| `integrationUser.imageUrl` | string \| null | yes |  |
| `integrationUser.country` | string \| null | yes | ISO 3166-1 alpha-2 country of the account, when the service tells us. |
| `integrationUser.authData` | object | no | The raw music-service credentials, without the refresh token. Only in answers to a Client Secret (Basic) or one-time-token call. |
| `integrationUser.authDataExpiresAt` | number \| null | no | When `authData` expires, in milliseconds since the epoch. |

```json
{
  "integrationUser": {
    "uuid": "3f0b8c1e-6a4d-4c7a-9a55-2f1e7d9b0c11",
    "integrationUserId": "mica.nowak",
    "name": "Mica Nowak",
    "email": "mica@example.com",
    "imageUrl": "https://images.example.com/mica.jpg",
    "country": "PL",
    "authData": {},
    "authDataExpiresAt": 0
  }
}
```

## Errors

- 401: The refresh failed. Send the user to sign in again.
- 404: Your account has no connected user with this uuid.

## Example

```bash
curl -X POST "https://api.musicapi.com/public/integrations/refreshAuthToken" \
  -u "$MUSICAPI_CLIENT_ID:$MUSICAPI_CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"integrationUserUUID":"5b0c6f0e-2c8a-4d0e-9a51-7e3f1c2d9b44"}'
```
