Imports
The ChatKitty Platform API allows for batched imports of large amounts of data from other systems using import file upload endpoints. All import API methods accept a JSON array text file with each item in the JSON array matching the import item schema of the resource type being imported.
Importing users
POST /v1/imports/users
- cURL
- JavaScript
curl --location --request 'POST' \
'https://api.chatkitty.com/v1/imports/users' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ACCESS-TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@users_import_file.json;type=application/json
// npm install chatkitty-platform-sdk
const chatkitty = new ChatKitty({
clientId: 'CLIENT-ID',
clientSecret: 'CLIENT-SECRET'
})
const file = new File(
['[{name:"jane@chatkitty.com",displayName:"JaneDoe",isGuest:false,properties:{favoriteNumber:42}}]'],
"import.json",
{
type: "application/json"
})
await chatkitty.Imports.importUsers(file)
Item schema
display_name required | string Human readable name of this user. Shown to other users |
object (FileImport) External file properties | |
guest required | boolean True if this user was created by a guest user session |
idempotency_key | string Unique value generated by the client which ChatKitty uses to recognize subsequent retries of the same request. Optional but recommended |
name required | string The unique name used to identify this user across ChatKitty. Also known as username |
required | object Custom data associated with this user |
{- "name": "jane@chatkitty.com",
- "displayName": "Jane Doe",
- "isGuest": false,
- "properties": {
- "favoriteNumber": 42
}
}
Importing channels
POST /v1/imports/channels
- cURL
- JavaScript
curl --location --request 'POST' \
'https://api.chatkitty.com/v1/imports/channels' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ACCESS-TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@channels_import_file.json;type=application/json
// npm install chatkitty-platform-sdk
const chatkitty = new ChatKitty({
clientId: 'CLIENT-ID',
clientSecret: 'CLIENT-SECRET'
})
const file = new File(
['[{"idempotencyKey":"unique-external-id","type":"DIRECT","members":["jane@chatkitty.com","john@chatkitty.com"]}]'],
"import.json",
{
type: "application/json"
})
await chatkitty.Imports.importChannels(file)
Item schema
type required | string |
creator | string Username of the user who created this channel |
idempotency_key | string Unique value generated by the client which ChatKitty uses to recognize subsequent retries of the same request. Optional but recommended |
members required | Array of strings List of usernames of members of this channel |
object Custom data associated with this channel | |
name | string The unique name of this channel used to reference the channel. If absent defaults to a random UUID |
display_name | string Human readable name of this channel shown to users. If absent defaults to the channel name |
{- "idempotencyKey": "unique-external-id",
- "type": "PUBLIC",
- "name": "b0a0bd55-921a-4f72-8ee3-f26c6fda0bb7"
}
Importing channel members
POST /v1/imports/channels/{id}/members
- cURL
- JavaScript
curl --location --request 'POST' \
'https://api.chatkitty.com/v1/imports/channels/1/members' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ACCESS-TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@members_import_file.json;type=application/json
// npm install chatkitty-platform-sdk
const chatkitty = new ChatKitty({
clientId: 'CLIENT-ID',
clientSecret: 'CLIENT-SECRET'
})
const file = new File(
['[{"idempotencyKey":"unique-external-id","type":"DIRECT","members":["b2a6da08-88bf-4778-b993-7234e6d8a3ff","c6f75947-af48-4893-a78e-0e0b9bd68580"]}]'],
"import.json",
{
type: "application/json"
})
await chatkitty.Imports.importChannelMembers(1, [{
idempotencyKey: "123",
username: "string"
}])
Item schema
idempotency_key | string Unique value generated by the client which ChatKitty uses to recognize subsequent retries of the same request. Optional but recommended |
username required | string Username of the user to be added as a member |
{- "username": "jane@chatkitty.com"
}
Importing messages
POST /v1/imports/messages
- cURL
- JavaScript
curl --location --request 'POST' \
'https://api.chatkitty.com/v1/imports/messages' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ACCESS-TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@messages_import_file.json;type=application/json
// npm install chatkitty-platform-sdk
const chatkitty = new ChatKitty({
clientId: 'CLIENT-ID',
clientSecret: 'CLIENT-SECRET'
})
const file = new File(
['[{"type":"TEXT","body":"Hello, World!"}]'],
"import.json",
{
type: "application/json"
})
await chatkitty.Imports.importMessages(file)
Item schema
type required | string |
channel_id required | integer <int64> ID of the channel this message belongs to |
group_tag | string Tag identifying the message group this message belongs to |
idempotency_key | string Unique value generated by the client which ChatKitty uses to recognize subsequent retries of the same request. Optional but recommended |
object Map of custom data attached to this message | |
body required | string The text body of this message |
{- "type": "SYSTEM_TEXT",
- "body": "Hello, World!"
}