Import Users
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/data_import/users \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '{}'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/data_import/users"
payload = {}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/data_import/users', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appId}.api-{region}.cometchat.io/v3/data_import/users",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{appId}.api-{region}.cometchat.io/v3/data_import/users"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{appId}.api-{region}.cometchat.io/v3/data_import/users")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/data_import/users")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"data": {
"uid1": {
"success": true,
"data": {
"uid": "uid1",
"name": "uid1",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"metadata": {
"key": "value"
},
"status": "offline",
"role": "default",
"lastActiveAt": 1673421425,
"createdAt": 1673421419
}
}
}
}Users
Import Users
The CometChat user import API allows customers to import their users’ data into the CometChat systems.
POST
/
data_import
/
users
Import Users
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/data_import/users \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '{}'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/data_import/users"
payload = {}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/data_import/users', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appId}.api-{region}.cometchat.io/v3/data_import/users",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{appId}.api-{region}.cometchat.io/v3/data_import/users"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{appId}.api-{region}.cometchat.io/v3/data_import/users")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/data_import/users")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"data": {
"uid1": {
"success": true,
"data": {
"uid": "uid1",
"name": "uid1",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"metadata": {
"key": "value"
},
"status": "offline",
"role": "default",
"lastActiveAt": 1673421425,
"createdAt": 1673421419
}
}
}
}Constraints
| Item | Constraint | Notes |
|---|---|---|
| Entities per request | 50 | Transmit up to 50 entities within a single request for efficient processing |
| Requests per minute | 60 | Rate limit for data import endpoints; exceeding returns a rate limit error |
Authorizations
API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Body
application/json
Wrapper for the users.
Show child attributes
Show child attributes
Example:
{
"uid1": {
"uid": "uid1",
"name": "uid1",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": "1673421419",
"metadata": { "key": "value" },
"lastActiveAt": "1673421425"
}
}Response
200 - application/json
Import User(s)
Show child attributes
Show child attributes
Was this page helpful?
⌘I