---
title: "Import messages"
method: POST
path: "/v1/{appId}/import/conversations/{conversationId}/messages"
tags: ["Messages"]
---

# Import messages

`POST /v1/{appId}/import/conversations/{conversationId}/messages`

## Request

- Base URL: `https://api.talkjs.com`
- URL: `https://api.talkjs.com/v1/{appId}/import/conversations/{conversationId}/messages`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
- TypeScript: <https://skmtc.dev/talkjs/apis/talkjs-api/docs/v1/:appId/import/conversations/:conversationId/messages/post.ts> (a function with typed inputs; its response is checked against the schema)

Imports one or more messages into a conversation. 

You can only import messages sent by conversation participants. You can't import messages sent by [guests](https://talkjs.com/docs/Reference/Concepts/Guests/) or [system messages](https://talkjs.com/docs/Reference/Concepts/System_Messages/).

Imported messages don't trigger notifications. Moreover, changes due to importing messages aren't synchronized back to active clients. If a user is currently reading a conversation that you're importing messages into, they need to reload before they see the imported messages.

### Import messages with attachments

To import messages with attachments into a conversation, do the following:
  
  1. Upload the file. You'll receive an `attachmentToken` in response.
  2. Specify the `attachmentToken` when importing the message.

The message is now imported with its attachment.

### Duplicates

Duplicate messages aren't removed. If you've sent or imported the same message twice, the message shows up twice, even if the messages have the same timestamp.

### Test and live mode

Import your data into the TalkJS test mode first to check if everything works as expected, before you import your data into live mode. 

If anything goes wrong while testing your import, you can use the **Reset all data** button on the **Settings** page of your [dashboard](https://talkjs.com/dashboard/) to irrevocably delete all messages, conversations, and users.

## Path parameters

- `appId` string, required
- `conversationId` string, required

## Request body

- object[]: An array of messages to import
  - `text` string, required: The body text of the message.
  - `sender` string, required: Unique identifier of the user who sent the message
  - `timestamp` integer, required: Timestamp when this message was posted, expressed as the number of milliseconds since the UNIX epoch (1970-1-1, 00:00:00 UTC).
  - `readBy` string[], required: An array of user ID of users who have read this message. **Note:** `readBy` is only used for conversations with at most 300 participants. For conversations with 301 or more participants, the `readBy` field will be empty.
  - `type` string, required: The type of message this concerns. Imported messages can only be of the type `"UserMessage"`.
  - `attachmentToken` string: Optional token to identify a file to attach to this message. To obtain an attachment token, first upload the file with the 'Upload a file' resource.
  - `custom` object, nullable, required: A custom object with key-value pairs that you want to associate with a message. Both keys and values must be strings. You can access a custom property in for example API responses, webhook events, and themes.

## Response `200`

Empty response

- object: Empty response

## Other responses

- `400`: Bad request
- `401`: Authorization information is missing or invalid.
- `404`: Resource not found
- `415`: Unsupported media type
- `429`: Too many requests
- `500`: Internal server error

---

[API](https://skmtc.dev/talkjs/apis/talkjs-api.md) - [All operations](https://skmtc.dev/talkjs/apis/talkjs-api/llms.txt) - [OpenAPI document](https://skmtc.dev/talkjs/apis/talkjs-api/revisions/9d4acc9cfa43?raw)
