---
title: "Queue a priority analytics refresh"
description: "PubNio API analytics.refreshes.create: queue a priority analytics refresh. Request fields, examples in five clients, errors, and idempotency."
---

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

# Queue a priority analytics refresh

Queue a priority analytics refresh with [`POST /api/v1/analytics/refreshes`](https://pubnio.com/api/v1/docs#tag/analytics/POST/api/v1/analytics/refreshes). Requires an API key with the `read` scope or a signed-in workspace member.

## Request

Marks an existing published post cursor due now and returns 202. Repeating the request coalesces on the same refresh ID. No provider call happens in the request.

| Body field    | Type                       | Required |
| ------------- | -------------------------- | -------- |
| `workspaceId` | UUID                       | Yes      |
| `postId`      | UUID                       | No       |
| `targetId`    | UUID                       | No       |
| `metrics`     | array of one of 20 strings | No       |

## Response

- HTTP 202: `AnalyticsRefresh` with `id`, `workspaceId`, `subjectKind`, `subjectId`, `status`, `nextDueAt`, `lastSuccessAt`, `errorKind`, `createdAt`.
  - `status`: `queued`, `running`, `succeeded`, `failed`, `paused`, `deleted`, `inaccessible`

The [OpenAPI document](https://pubnio.com/api/v1/openapi) has each field's type.

## Examples

### TypeScript

```ts
const refresh = await workspace.analytics.refresh({ postId });
```

### Python

```python
refresh = workspace.analytics.create_refresh(post_id=post_id)
```

### cURL

```sh
curl -X POST "https://pubnio.com/api/v1/analytics/refreshes" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"workspaceId":"'"$WORKSPACE_ID"'","postId":"'"$POST_ID"'"}'
```

### CLI

```sh
pnio analytics refreshes create --workspace-id "$WORKSPACE_ID" --post-id "$POST_ID"
```

### MCP execute

```js
async () => {
  const postId = "<postId>";
  const response = await codemode.request({
    method: "POST",
    path: "/api/v1/analytics/refreshes",
    body: { workspaceId: codemode.workspaceId, postId: postId },
  });
  return response.data;
};
```

## Errors

It declares no problem of its own.

It declares the problems [every Analytics operation](https://pubnio.com/docs/reference/#analytics) and [most operations](https://pubnio.com/docs/reference/#shared-problems) declare.

## Idempotency

No key, so a retried `POST` is not deduplicated. Read the current state before you retry.

## Limits

- Field lengths and ranges are in the [OpenAPI document](https://pubnio.com/api/v1/openapi).

## Related

- [Analytics operations](https://pubnio.com/docs/reference/#analytics)

Source: https://pubnio.com/docs/reference/analytics-refreshes-create/index.mdx
