# Undo a migration

Undoes everything the migration created, in the background: conversations, contacts, articles and tickets go to the trash, tags, notes and replies are deleted. Records others now use are kept. Needs imports:rollback. Returns the migration with status rolling_back; poll it until rolled_back.

```http
POST https://trydimmi.com/api/v1/migrations/{migration}/rollbacks
```

## Authorization

Send an API token as `Authorization: Bearer <token>`.
The token needs: `settings:write`.

## Path parameters

- `migration` (string, required): The migration (mig_...) to undo, as starting or listing migrations returns it. Such as mig_01jc8q3x7m2n4p5r6s7t8v9w0y.

## Response 202 (Accepted)

- `data` (object, required)
  - `counts` (object[] | null, required): The migration's records per kind, by how they stand.
    - `applied` (integer, required): Records applied, created or matched to what the workspace had.
    - `conflicted` (integer, required): Records whose last sync left a teammate's change in place.
    - `created` (integer, required): Applied records the migration created, which an undo removes.
    - `deferred` (integer, required): Records waiting for others they name.
    - `failed` (integer, required): Records not applied because of an error.
    - `kind` (string, required): The record kind counted, such as conversation.
    - `unsupported` (integer, required): Records dimmi cannot apply yet.
  - `created_at` (string, required): When it was created, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.
  - `format_version` (integer, required): The import format version the migration reads, 1 today.
  - `id` (string, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
  - `last_record_at` (string | null, required): When the migration last received a record. Null before the first.
  - `name` (string | null, required): The migration's name, such as Intercom move. Null when none was given.
  - `object` (string, required): The kind of record this is, the same for every record of its kind, such as article.
  - `problems` (object[] | null, required): The latest 50 records that failed, are unsupported or carry conflicts, newest first.
    - `conflicts` (object[] | null, required): Fields a teammate changed in dimmi, which the last sync left as they are.
      - `dimmi` (any, required): The value it holds in dimmi now, which the sync kept.
      - `field` (string, required): The field a teammate changed in dimmi since the migration wrote it, such as status.
      - `source` (any, required): The value the other tool sent, which was not applied.
    - `error` (object, required)
      - `code` (string, required): A stable code for why the record failed, such as company_exists.
      - `field` (string): The record field at fault, such as external_id. Null when no single field is.
      - `message` (string, required): What went wrong, in words for a person.
    - `kind` (string, required): The record's kind.
    - `source_id` (string, required): The record's id in the other tool.
    - `status` (string, required): failed or unsupported; applied when only conflicts make it a problem. One of: `applied`, `deferred`, `failed`, `unsupported`.
    - `updated_at` (string, required): When it last changed, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.
  - `rollback` (object, required)
    - `error` (string | null, required): Why the undo stopped. Null unless it failed.
    - `finished_at` (string | null, required): When the undo finished or stopped. Null while it runs.
    - `removed` (integer, required): How many records the undo removed so far.
    - `requested_at` (string | null, required): When the undo was asked for.
  - `source` (string, required): The short name of the tool the history comes from, such as intercom.
  - `source_account` (string, required): The id of the account in that tool. Starting again for it resumes this migration.
  - `status` (string, required): active while it takes records, rolling_back while it is undone, rolled_back once undone, or rollback_failed when the undo stopped and can be asked again. One of: `active`, `rolling_back`, `rolled_back`, `rollback_failed`.
  - `updated_at` (string, required): When it last changed, as an RFC 3339 time, such as 2026-01-31T09:00:00Z.

## Response default (Error)

- `code` (string, required): Stable code for programs to tell errors apart, such as validation_failed or internal_error.
- `errors` (object): Each rejected field mapped to its messages. Only present when the input was invalid.
- `message` (string, required): What went wrong, in words safe to show a person.

## Example request

```bash
curl --request POST \
  --url 'https://trydimmi.com/api/v1/migrations/{migration}/rollbacks' \
  --header 'Authorization: Bearer <token>'
```

## Example response

```json
{
  "data": {
    "counts": [
      {
        "applied": 123,
        "conflicted": 123,
        "created": 123,
        "deferred": 123,
        "failed": 123,
        "kind": "<string>",
        "unsupported": 123
      }
    ],
    "created_at": "2026-11-01T09:30:00Z",
    "format_version": 123,
    "id": "<string>",
    "last_record_at": "2026-11-01T09:30:00Z",
    "name": "<string>",
    "object": "<string>",
    "problems": [
      {
        "conflicts": [
          {}
        ],
        "error": {
          "code": "<string>",
          "field": "<string>",
          "message": "<string>"
        },
        "kind": "<string>",
        "source_id": "<string>",
        "status": "applied",
        "updated_at": "2026-11-01T09:30:00Z"
      }
    ],
    "rollback": {
      "error": "<string>",
      "finished_at": "2026-11-01T09:30:00Z",
      "removed": 123,
      "requested_at": "2026-11-01T09:30:00Z"
    },
    "source": "<string>",
    "source_account": "<string>",
    "status": "active",
    "updated_at": "2026-11-01T09:30:00Z"
  }
}
```

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
