Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "email": "<string>",
// "role": "<string>",
// "first_name": "<string>",
// "last_name": "<string>"
// }
var json = new chilkat.JsonObject();
json.UpdateString("email","<string>");
json.UpdateString("role","<string>");
json.UpdateString("first_name","<string>");
json.UpdateString("last_name","<string>");
http.SetRequestHeader("Authorization","");
http.SetRequestHeader("Content-Type","application/json");
// resp: HttpResponse
var resp = http.PostJson3("https://api.squadcast.com/v3/users","application/json",json);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
var sbResponseBody = new chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);
var jResp = new chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;
console.log("Response Body:");
console.log(jResp.Emit());
var respStatusCode = resp.StatusCode;
console.log("Response Status Code = " + respStatusCode);
if (respStatusCode >= 400) {
console.log("Response Header:");
console.log(resp.Header);
console.log("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "id": "5e9c204dbde1298f6bcb5ef2",
// "first_name": "Manigandan",
// "last_name": "Dharmalingam",
// "email": "manigandan@squadcast.com",
// "contact": {
// "dial_code": "",
// "phone_number": ""
// },
// "secondary_emails": null,
// "email_verified": false,
// "time_zone": "",
// "title": "",
// "bio": "",
// "notification_rules": [
// {
// "type": "Email",
// "time": 0
// },
// {
// "type": "Push",
// "time": 0
// },
// {
// "type": "SMS",
// "time": 1
// },
// {
// "type": "Phone",
// "time": 2
// }
// ],
// "user_image": false
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var v_type;
var time;
var Id = jResp.StringOf("data.id");
var First_name = jResp.StringOf("data.first_name");
var Last_name = jResp.StringOf("data.last_name");
var v_Email = jResp.StringOf("data.email");
var Dial_code = jResp.StringOf("data.contact.dial_code");
var Phone_number = jResp.StringOf("data.contact.phone_number");
var Secondary_emails = jResp.StringOf("data.secondary_emails");
var Email_verified = jResp.BoolOf("data.email_verified");
var Time_zone = jResp.StringOf("data.time_zone");
var Title = jResp.StringOf("data.title");
var Bio = jResp.StringOf("data.bio");
var User_image = jResp.BoolOf("data.user_image");
var i = 0;
var count_i = jResp.SizeOfArray("data.notification_rules");
while (i < count_i) {
jResp.I = i;
v_type = jResp.StringOf("data.notification_rules[i].type");
time = jResp.IntOf("data.notification_rules[i].time");
i = i+1;
}
}
chilkatExample();
Curl Command
curl -X POST
-H "Authorization: "
-H "Content-Type: application/json"
-d '{
"email": "<string>",
"role": "<string>",
"first_name": "<string>",
"last_name": "<string>"
}'
https://api.squadcast.com/v3/users
Postman Collection Item JSON
{
"name": "Add User",
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Authorization",
"value": ""
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"<string>\",\n \"role\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
},
"description": "Add user to the organization with given role if not exists. Returns the user object in response. \nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `user-write` scope."
},
"response": [
{
"name": "Unprocessable Entity",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Unprocessable Entity (WebDAV) (RFC 4918)",
"code": 422,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": \"<integer>\",\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "Internal Server Error",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Internal Server Error",
"code": 500,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": \"<integer>\",\n \"error_message\": \"<string>\"\n }\n}"
},
{
"name": "Created",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"id\": \"5e9c204dbde1298f6bcb5ef2\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\",\n \"email\": \"manigandan@squadcast.com\",\n \"contact\": {\n \"dial_code\": \"\",\n \"phone_number\": \"\"\n },\n \"secondary_emails\": null,\n \"email_verified\": false,\n \"time_zone\": \"\",\n \"title\": \"\",\n \"bio\": \"\",\n \"notification_rules\": [\n {\n \"type\": \"Email\",\n \"time\": 0\n },\n {\n \"type\": \"Push\",\n \"time\": 0\n },\n {\n \"type\": \"SMS\",\n \"time\": 1\n },\n {\n \"type\": \"Phone\",\n \"time\": 2\n }\n ],\n \"user_image\": false\n }\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 400,\n \"error_message\": \"email required\"\n }\n}"
},
{
"name": "Conflict",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Conflict",
"code": 409,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 409,\n \"error_message\": \"cannot add same user manigandan2293@gmail.com again to the organization\"\n }\n}"
},
{
"name": "Unauthorized",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": 401,\n \"error_message\": \"invalid access token\"\n }\n}"
},
{
"name": "Forbidden",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"manigandan@squadcast.com\",\n \"role\": \"admin\",\n \"first_name\": \"Manigandan\",\n \"last_name\": \"Dharmalingam\"\n}"
},
"url": {
"raw": "{{baseUrl}}/users",
"host": [
"{{baseUrl}}"
],
"path": [
"users"
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"meta\": {\n \"status\": \"<integer>\",\n \"error_message\": \"<string>\"\n }\n}"
}
]
}