# Refresh an account now

> Page: https://docs.flung.dev/reference/api/post-v1-accounts-id-refresh. Index of every page: https://docs.flung.dev/llms.txt

Renews the access token now instead of waiting for the hourly renewal, and reports whether the platform still accepts the account.

`POST /v1/accounts/{id}/refresh`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Refresh an account now. |
| What does it need? | An API key or an OAuth access token. |
| What does it take? | `id` in the path. |
| What does it return? | Status 200 with a body of type [`RefreshResult`](https://docs.flung.dev/reference/api/schemas.md#refreshresult). |
| In the SDK? | `flung.accounts.refresh()` |
| As an MCP tool? | [`refresh_account`](https://docs.flung.dev/reference/mcp/refresh-account.md) |
| What can go wrong? | `401` Missing, unknown, revoked or expired API key; `404` No such account in this workspace; `422` The request failed validation; `429` Too many requests for this credential; wait for `retry-after` seconds. Every failure has the same [error shape](https://docs.flung.dev/reference/api/errors.md). |

## What it does

Renews the access token now instead of waiting for the hourly renewal, and reports whether the platform still accepts the account. Most callers never need this.

## Example

**curl**

```bash
curl -X POST 'https://api.flung.dev/v1/accounts/acct_aaaaaaaaaaaaaaaaaaaaaaaa/refresh' \
  --header "Authorization: Bearer $FLUNG_API_KEY"
```

**TypeScript**

```ts
import { Flung } from '@flung.dev/sdk'

const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })
const result = await flung.accounts.refresh({
  id: 'acct_aaaaaaaaaaaaaaaaaaaaaaaa',
})
```

**fetch**

```js
const response = await fetch('https://api.flung.dev/v1/accounts/acct_aaaaaaaaaaaaaaaaaaaaaaaa/refresh', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`,
  },
})
if (!response.ok) throw new Error((await response.json()).error.message)
const result = await response.json()
```

A successful answer looks like this:

```json
{
  "result": "refreshed",
  "account": {
    "id": "acct_aaaaaaaaaaaaaaaaaaaaaaaa",
    "platform": "x",
    "platformUserId": "string",
    "username": "string",
    "profileId": "string",
    "status": "active",
    "renewal": "automatic",
    "tokenExpiresAt": "2026-11-01T09:00:00.000Z",
    "reconnectBy": "2026-11-01T09:00:00.000Z",
    "defaultBoard": {
      "id": "string",
      "name": "string"
    },
    "inbox": {
      "enabled": true,
      "readAt": "2026-11-01T09:00:00.000Z",
      "error": "string"
    },
    "createdAt": "2026-11-01T09:00:00.000Z",
    "updatedAt": "2026-11-01T09:00:00.000Z"
  }
}
```

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | yes |  |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | What the refresh did, and the account after it. | [`RefreshResult`](https://docs.flung.dev/reference/api/schemas.md#refreshresult) |
| 401 | Missing, unknown, revoked or expired API key. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 404 | No such account in this workspace. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 422 | The request failed validation. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 429 | Too many requests for this credential; wait for `retry-after` seconds. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |

## Response body

A 200 answer has the type [`RefreshResult`](https://docs.flung.dev/reference/api/schemas.md#refreshresult).

| Field | Type | Required | Description |
|---|---|---|---|
| `result` | `"refreshed" \| "not_needed" \| "reconnect_required" \| "failed"` | yes | `refreshed`: a new token is stored. `not_needed`: this account has nothing to refresh. `reconnect_required`: the platform refused; the account is now `needs_reconnect`. `failed`: a temporary platform failure; try again later. |
| `account` | `Account` | yes |  |
| `account.id` | `string` | yes |  |
| `account.platform` | `Platform` | yes |  |
| `account.platformUserId` | `string` | yes |  |
| `account.username` | `string \| null` | yes |  |
| `account.profileId` | `string \| null` | yes |  |
| `account.status` | `"active" \| "needs_reconnect" \| "disconnected"` | yes | `needs_reconnect`: the platform refused the token; start a reconnect. |
| `account.renewal` | `"automatic" \| "manual" \| "not_needed"` | yes | `automatic`: Flung refreshes the token before it expires, until `reconnectBy` if set. `manual`: only a reconnect renews it, by `reconnectBy`. `not_needed`: the token does not expire. |
| `account.tokenExpiresAt` | `string \| null` | yes | When the current access token expires. Flung renews `automatic` ones about a day before. |
| `account.reconnectBy` | `string \| null` | yes | The last moment the account works without a reconnect; null when it renews indefinitely. Flung sends `account.reconnect_required_soon` a week before. |
| `account.defaultBoard` | `object \| null` | yes | Pinterest only: where pins go unless a post picks another board. |
| `account.defaultBoard.id` | `string` | yes |  |
| `account.defaultBoard.name` | `string \| null` | yes |  |
| `account.inbox` | `object` | yes | Reading comments and mentions into GET /v1/inbox. |
| `account.inbox.enabled` | `boolean \| null` | yes | Whether comments and mentions are read. null is the platform's default: on, except X, where reading costs money. |
| `account.inbox.readAt` | `string \| null` | yes |  |
| `account.inbox.error` | `string \| null` | yes | Why the last read failed, such as a missing permission. |
| `account.createdAt` | `string` | yes |  |
| `account.updatedAt` | `string` | yes |  |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.flung.dev/reference/api.md) | Every endpoint |
| [Schemas](https://docs.flung.dev/reference/api/schemas.md) | Every request and response type |
| [Errors](https://docs.flung.dev/reference/api/errors.md) | Every error code and what to do about it |
| [`refresh_account`](https://docs.flung.dev/reference/mcp/refresh-account.md) | The same operation as an MCP tool |
