# Send migration records

Applies a batch of 1 to 100 records of one kind in dimmi's import format to the migration, as quiet history: nothing is sent and no event goes out. Each record is kept under its source_id, so sending it again updates what it became or skips it when unchanged, and a record naming one not sent yet waits for it. It needs the settings:write ability and the imports:manage permission. Returns a result per record, in the order sent, and the waiting records this batch let through.

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

## Authorization

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

## Path parameters

- `migration` (string, required): Migration: text.

## Body

- `kind` (string, required): Kind: one of teammate, team, tag, attribute_definition, company, contact, contact_note, ticket_type, help_center, collection, article, snippet, saved_reply, schedule, workflow, conversation, ticket. One of: `teammate`, `team`, `tag`, `attribute_definition`, `company`, `contact`, `contact_note`, `ticket_type`, `help_center`, `collection`, `article`, `snippet`, `saved_reply`, `schedule`, `workflow`, `conversation`, `ticket`.
- `records` (any[] | null, required): Records of the kind in the import format, version 1.

## Response 200 (OK)

- `data` (object, required)
  - `kind` (string, required): The kind of the records sent.
  - `object` (string, required): The kind of record this is, the same for every record of its kind, such as article.
  - `resolved` (object[] | null, required): Records sent before that waited for this batch and are now applied or failed.
    - `conflicts` (object[] | null, required): Fields a teammate changed in dimmi, which this 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.
    - `id` (string | null, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
    - `kind` (string, required): The record's kind.
    - `source_id` (string, required): The record's id in the other tool.
    - `status` (string, required): created, updated, unchanged (sent before as it is and skipped), deferred, failed or unsupported. One of: `created`, `updated`, `unchanged`, `deferred`, `failed`, `unsupported`.
    - `waiting_for` (object[] | null, required): The records a deferred record waits for. Empty otherwise.
      - `kind` (string, required): The kind of the record named, such as contact or teammate.
      - `source_id` (string, required): The record's id in the other tool.
    - `warnings` (object[] | null, required): Fields left out of the record, each with a code and why.
      - `code` (string, required): A stable code for the warning, such as not_supported_yet or file_unavailable.
      - `field` (string, required): The record field left out, such as custom_attributes.
      - `message` (string, required): What was left out and why, in words for a person.
  - `results` (object[] | null, required): A result per record, in the order sent.
    - `conflicts` (object[] | null, required): Fields a teammate changed in dimmi, which this 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.
    - `id` (string | null, required): The id of this record. Send it wherever an endpoint asks for this record; never use its name or title in its place.
    - `kind` (string, required): The record's kind.
    - `source_id` (string, required): The record's id in the other tool.
    - `status` (string, required): created, updated, unchanged (sent before as it is and skipped), deferred, failed or unsupported. One of: `created`, `updated`, `unchanged`, `deferred`, `failed`, `unsupported`.
    - `waiting_for` (object[] | null, required): The records a deferred record waits for. Empty otherwise.
      - `kind` (string, required): The kind of the record named, such as contact or teammate.
      - `source_id` (string, required): The record's id in the other tool.
    - `warnings` (object[] | null, required): Fields left out of the record, each with a code and why.
      - `code` (string, required): A stable code for the warning, such as not_supported_yet or file_unavailable.
      - `field` (string, required): The record field left out, such as custom_attributes.
      - `message` (string, required): What was left out and why, in words for a person.

## 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}/records' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "kind": "teammate",
  "records": [
    null
  ]
}'
```

## Example response

```json
{
  "data": {
    "kind": "<string>",
    "object": "<string>",
    "resolved": [
      {
        "conflicts": [
          {}
        ],
        "error": {
          "code": "<string>",
          "field": "<string>",
          "message": "<string>"
        },
        "id": "<string>",
        "kind": "<string>",
        "source_id": "<string>",
        "status": "created",
        "waiting_for": [
          {}
        ],
        "warnings": [
          {}
        ]
      }
    ],
    "results": [
      {
        "conflicts": [
          {}
        ],
        "error": {
          "code": "<string>",
          "field": "<string>",
          "message": "<string>"
        },
        "id": "<string>",
        "kind": "<string>",
        "source_id": "<string>",
        "status": "created",
        "waiting_for": [
          {}
        ],
        "warnings": [
          {}
        ]
      }
    ]
  }
}
```

---

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