---
title: "Backfill chats"
method: POST
path: "/api/profiles/{id}/backfill_chats"
tags: ["Profiles"]
---

# Backfill chats

`POST /api/profiles/{id}/backfill_chats`

## Request

- Base URL: `https://api.postproxy.dev`
- URL: `https://api.postproxy.dev/api/profiles/{id}/backfill_chats`
- Auth: HTTP bearer

Walks an Instagram or Facebook profile's conversations from the most recently active backwards, and each conversation's messages from the newest backwards, until both reach `from`, importing anything missing. Runs in the background - the response is the chat sync record, which you poll for progress. Backfilled messages do not fire message.received.

## Path parameters

- `id` string, required

## Query parameters

- `profile_group_id` string

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `from` string, required: ISO 8601 date/time, or a bare date meaning that date's start of day. Conversations last active before this are not opened; inside a conversation the run stops at the first message sent before this.

## Response `202`

Backfill accepted; returns the chat sync record to poll for progress

- ProfileChatSync: A chat sync run: the pull fired when the profile connects (or direct messages are enabled) or a backfill you start. Runs are kept for 30 days.
  - `id` string: Unique sync identifier.
  - `profile_id` string: Profile this run belongs to.
  - `placement_id` string, nullable: Always null for chat syncs.
  - `kind` 'chats': Always chats.
  - `trigger` 'connect' | 'backfill'
  - `status` 'pending' | 'running' | 'completed' | 'failed'
  - `started_at` string, nullable: ISO 8601 timestamp when the run began.
  - `completed_at` string, nullable: ISO 8601 timestamp when it finished or failed.
  - `chats_seen` integer: Conversations the platform returned across the run.
  - `messages_imported` integer: Messages that were new and got created. Messages you already have are skipped and not counted.
  - `backfill_from` string, nullable: The date floor requested. null for connect runs.
  - `oldest_updated_at` string, nullable: Last-activity time of the oldest conversation the run reached - how far back it has walked.
  - `error` string, nullable: Platform error message when status is failed.
  - `created_at` string: ISO 8601 timestamp.

## Other responses

- `400`: Missing required parameters.
- `401`: Invalid, missing, or insufficient API key permissions.
- `409`: Duplicate submission, or a request with the same Idempotency-Key is still in flight.
- `422`: Validation failed.

---

[API](https://skmtc.dev/postproxy/apis/postproxy-social-media-api.md) - [All operations](https://skmtc.dev/postproxy/apis/postproxy-social-media-api/llms.txt) - [OpenAPI document](https://skmtc.dev/postproxy/apis/postproxy-social-media-api/revisions/d54482ac4ce7?raw)
