Importing Data

Last Edit: Mar 03 2020

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

The steps for importing data into your app are as follows:

  1. Generate the import file for your data (full file reference below)
  2. Reach out to send us the import file

  3. The file will be validated according to the rules described in this doc
  4. If validation passes, a member of our team will approve and run the import
  5. Once the import is completed (usually a few minutes), you will get a confirmation email
Before uploading the import file make sure that every feed group in your import file is configured in your app.
Importing data on a live app may cause high response times for requests during the import process.

Import File

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:


[
	{
		"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

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

An import file can contain entries with any of these types.

Note that you can add custom fields to users, channels, members, messages, attachments and reactions. The limit is 5KB of custom field data per object.

User Type

The user type fields are shown below:


{
  "type": "user",
  "item": {
    "id": "aad24491-c286-4169-bbfc-9280de419cb6",
    "name": "Jesse",
    "profile_image": "http://getstream.com",
    "created_at": "2017-01-01T01:00:00Z",
    "description": "Taj Mahal guitar player at some point"
  }
}
                    

Channel Type

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


{
  "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

Channel members store the mapping between users and channels. The fields are shown below:


{
  "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

message creation time in RFC3339 format

last time the message was updated

message deletion time in RFC3339 format

reply messages are only shown inside the message thread unless show_in_channel is set to true, in that case the message is shown in the channel as well

Add as many custom fields as needed

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


{
  "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

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

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


{
  "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"
  }
}