Importing Data
Confused about "Importing Data"?
Let us know how we can improve our documentation:
If you've just started using Stream, you might want to import data from your infrastructure or provider. Instead of using the APIs and creating your import scripts, you can make use of our import feature.
The Process
Copied!Confused about "The Process"?
Let us know how we can improve our documentation:
The steps for importing data into your app are as follows:
- Generate the import file for your data (full file reference below)
Reach out to send us the import file
- The file will be validated according to the rules described in this doc
- If validation passes, a member of our team will approve and run the import
- Once the import is completed (usually a few minutes), you will get a confirmation email
Import File
Copied!Confused about "Import File"?
Let us know how we can improve our documentation:
The import file must be structured as a JSON array of objects. Each object is an item to add to your application (eg. a user, a message, etc.).
Here's an example of an import file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[
{
"type": "channel",
"item": {
"id": "6e693c74-262d-4d3d-8846-686364c571c8",
"type": "livestream",
"created_by": "aad24491-c286-4169-bbfc-9280de419cb6",
"name": "Rock'n Roll Circus"
}
},
{
"type": "message",
"item": {
"id": "977e691a-c091-4e3b-8f70-ba8944a3e500",
"channel_type": "livestream",
"channel_id": "6e693c74-262d-4d3d-8846-686364c571c8",
"user": "aad24491-c286-4169-bbfc-9280de419cb6",
"text": "Such a great song, check out my solo at 2:25",
"type": "regular",
"created_at": "2017-02-01T02:00:00Z",
"attachments": [
{
"type": "video",
"url": "https://www.youtube.com/watch?v=flgUbBtjl9c"
}
]
}
},
{
"type": "reaction",
"item": {
"message_id": "977e691a-c091-4e3b-8f70-ba8944a3e500",
"type": "love",
"user_id": "aad24491-c286-4169-bbfc-9280de419cb6",
"created_at": "2019-03-02T15:00:00Z"
}
}
]
Import Entries Format
Copied!Confused about "Import Entries Format"?
Let us know how we can improve our documentation:
Name | Type | Description |
---|---|---|
type | string | the type of data for this entry. Allowed values are: user, channel, message, reaction, member |
item | object | the data for this entry, see below for the format of each type |
Item Types
Copied!Confused about "Item Types"?
Let us know how we can improve our documentation:
An import file can contain entries with any of these types.
User Type
Copied!Confused about "User Type"?
Let us know how we can improve our documentation:
The user type
fields are shown below:
1
2
3
4
5
6
7
8
9
10
{
"type": "user",
"item": {
"id": "aad24491-c286-4169-bbfc-9280de419cb6",
"name": "Jesse",
"image": "http://getstream.com",
"created_at": "2017-01-01T01:00:00Z",
"description": "Taj Mahal guitar player at some point"
}
}
Channel Type
Copied!Confused about "Channel Type"?
Let us know how we can improve our documentation:
The channel type
fields are shown below:
name | type | description | default | optional |
---|---|---|---|---|
id | string | the unique id for the channel | ||
type | string | the type of the channel. ie livestream, messaging etc. | ||
created_by | string | the id of the user that created the message | ||
frozen | boolean | you can't add messages to a frozen channel | false | ✓ |
* | string/list/object | add as many custom fields as needed | ✓ |
1
2
3
4
5
6
7
8
9
{
"type": "channel",
"item": {
"id": "6e693c74-262d-4d3d-8846-686364c571c8",
"type": "livestream",
"created_by": "aad24491-c286-4169-bbfc-9280de419cb6",
"name": "Rock'n Roll Circus"
}
}
Member Type
Copied!Confused about "Member Type"?
Let us know how we can improve our documentation:
Channel members store the mapping between users and channels. The fields are shown below:
1
2
3
4
5
6
7
8
9
10
{
"type": "member",
"item": {
"channel_type": "livestream",
"channel_id": "6e693c74-262d-4d3d-8846-686364c571c8",
"user_id": "aad24491-c286-4169-bbfc-9280de419cb6",
"is_moderator": true,
"created_at": "2017-02-01T02:00:00Z"
}
}
Message Type
Copied!Confused about "Message Type"?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
id | string | the id of the message | A random UUIDv4 | ✓ |
channel_type | string | the type of channel for this message | ||
channel_id | string | the id of the channel for this message | ||
type | string | the type of the message, regular, deleted or system | regular | ✓ |
user | string | the id of the user that posted the message | ||
attachments | list of attachments | list of message attachments, see the attachment section below | [] | ✓ |
parent_id | string | the id of the parent message (if the message is a reply) | null | ✓ |
created_at | string | |||
updated_at | string | created_at | ✓ | |
deleted_at | string | null | ✓ | |
show_in_channel | bool | false | ✓ | |
* | string/list/object | ✓ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"type": "message",
"item": {
"id": "977e691a-c091-4e3b-8f70-ba8944a3e500",
"channel_type": "livestream",
"channel_id": "6e693c74-262d-4d3d-8846-686364c571c8",
"user":"aad24491-c286-4169-bbfc-9280de419cb6",
"text": "Such a great song, check out my solo at 2:25",
"type": "regular",
"created_at": "2017-02-01T02:00:00Z",
"attachments": [
{
"type": "video",
"url": "https://www.youtube.com/watch?v=flgUbBtjl9c"
}
]
}
}
Message Attachments
Copied!Confused about "Message Attachments"?
Let us know how we can improve our documentation:
The only required field of an attachment is "type". All other fields are optional, and you can add as many custom fields as you'd like. The attachments are a great way to extend Stream's functionality. If you want to have a custom product attachment, location attachment, checkout, etc., attachments are the way to go. The fields below are automatically picked up and shown by our component libraries.
Reaction Type
Copied!Confused about "Reaction Type"?
Let us know how we can improve our documentation:
The reaction type has the following fields:
name | type | description | default | optional |
---|---|---|---|---|
message_id | string | The id of the message | ||
type | string | The type of reaction (up to you to define the types, it's a string) | ||
user_id | string | The ID of the user | ||
created_at | string | The creation time in RFC3339 | ||
* | string/list/object | Add as many custom fields as needed | ✓ |
1
2
3
4
5
6
7
8
9
{
"type": "reaction",
"item": {
"message_id": "977e691a-c091-4e3b-8f70-ba8944a3e500",
"type": "love",
"user_id": "aad24491-c286-4169-bbfc-9280de419cb6",
"created_at": "2019-03-02T15:00:00Z"
}
}