Skip to main content

Development Guide

About 3 min

Development Guide

Common Request Headers

FieldTypeRequiredDescription
tenant_idIntYesCompany id
timestampLongYesRequest timestamp: 1710936559123
tokenStringYesEncrypted string

Token Generation Rule

    md5(tenant_id + timestamp + ApiKey), 32-bit lowercase.

    Please contact the administrator to obtain tenant_id and ApiKey.

  • Parameters used for encryption must be placed in the request headers of the interface
	package main

	import (
		"bytes"
		"crypto/md5"
		"encoding/hex"
		"encoding/json"
		"fmt"
		"io/ioutil"
		"net/http"
		"strconv"
		"time"
	)

	func MD5(str string) string {
		data := []byte(str)
		has := md5.Sum(data)
		return hex.EncodeToString(has[:])
	}

	func generateCommonHeaders(tenantID, apiKey, userID string) http.Header {
		timestamp := strconv.FormatInt(time.Now().UnixNano()/int64(time.Millisecond), 10)
		tokenInput := tenantID + timestamp + apiKey
		token := MD5(tokenInput)
		headers := make(http.Header)
		headers.Set("Content-Type", "application/json")
		headers.Set("tenant_id", tenantID)
		headers.Set("timestamp", timestamp)
		headers.Set("token", token)
		return headers
	}

	func main() {
		url := "https://api.socialscrm.com/wscrm-bus-api/customer/query"
		method := "POST"

		tenantID := "1"
		userID := "WhatsApp"
		apiKey := "QOEAcPj6Tb8XRhwFvYih"
		headers := generateCommonHeaders(tenantID, apiKey, userID)
		requestBodyData := []map[string]string{
			{
				"whatsApp":   "15266667779",
			},
		}

		jsonBody, err := json.Marshal(requestBodyData)
		if err != nil {
			fmt.Printf("Error marshalling request body: %v\n", err)
			return
		}

		req, err := http.NewRequest(method, url, bytes.NewBuffer(jsonBody))
		if err != nil {
			fmt.Printf("Error creating request: %v\n", err)
			return
		}

		req.Header = headers

		client := &http.Client{}
		resp, err := client.Do(req)
		if err != nil {
			fmt.Printf("Error sending request: %v\n", err)
			return
		}
		defer resp.Body.Close()

		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			fmt.Printf("Error reading response body: %v\n", err)
			return
		}
	}

Basic Interface Information

  • Interface request limit: 50 requests per second per interface.

  • Interface Address

    • Standard production environment: https://api.socialepoch.com

    • Indonesia production environment: http://id.wascrm.socialepoch.com

      📢 ApiKey, tenantId, and account information are not shared between production environment and Indonesia environment.

  • Others

    • Phone number rules

      📢 For interfaces involving friend WhatsApp, numbers must include country code, e.g.: 86182217331411 (86 is the country code, 182217331411 is the number).

    • Customer admin account, agent account, customer service number

      Customer admin account is the main account under the company, agent account is a sub-account under the company, customer service number is the WhatsApp account used for work.

  • Related customer field information for interfaces

    📢 For customer basic information, customer tag information, and customer extended field information, please check the management backend. Management Backend - Extended Fields & Tag Configuration Pageopen in new window

Error Code Description

Status CodeException InformationDescription
501appSecret errorappSecret does not exist
502timestamp timeoutRequest timestamp timeout
503name is emptyTask name is empty
504executor errorExecutor parsing exception
505executor is emptyExecutor is empty
506data is emptyTask data information is empty
507data size bigData size is too large
508no exist userNameExecutor information does not exist
509customer group is nullCustomer group information is empty
510customer group key errorCustomer group key information error
511customer group value errorCustomer group value information error
512send type == 1 and startTime is not nullImmediate send with specified send time
513start time is errorSend time parsing exception
514content is nullTask send content is empty
515file is nullTask file information does not exist
516main userId is nullMain account information does not exist
517database errorDatabase exception
518timestamp is nullTimestamp is empty
519timestamp is errorTimestamp parsing exception
520send interval is nullSend interval time does not exist
521task name repetitionTask name is duplicated
522accessToken is erroraccessToken information error
523tenantId is nullCompany id is empty
524userName is nullAdmin name is empty
525token is nulltoken is empty
526createTime is nullCreate time is empty
527group is errorCustomer group chat type parsing exception
528group is nullCustomer group information does not exist
529Non-professional EditionNon-professional Edition
530action username erroruserName does not exist
531userName is erroruserName in data does not exist
532customer whats id is nullfriendWhatsId customer service number does not exist
533extended field format errorExtended field format exception
534whatsid list nullwhatsid list is empty
536groupLinkList is nullgroupLinkList is empty
537groupLink is not exist . Please reload it !groupLink not found. Please reload it!
538parsing group link. Please try again latergroupLink is being parsed, please try again later

Old Token Generation Rule

md5(tenantId + userName+ createTime + ApiKey), 32-bit lowercase.

userName is the customer admin account, **Please contact the administrator to obtain tenantId and ApiKey.

createTime is the request time of the interface (format: yyyy-mm-dd HH:mm:ss)

package main

import (
	"bytes"
	"crypto/md5"
	"fmt"
	"io/ioutil"
	"net/http"
)

func MD5(str string) string {
	data := []byte(str)
	has := md5.Sum(data)
	md5str := fmt.Sprintf("%x", has)
	return md5str
}

func main() {

	url := "https://www.socialscrm.com/wscrm-bus-api/customer/api/import"
	method := "PUT"
	tenantId := "1"
	userName := "WhatsApp"
	apiKey := "QOEAcPj6Tb8XRhwFvYih"
	createTime := "2023-06-01 12:12:12"

	genToken := MD5(tenantId + userName + createTime + apiKey)

	data := "[{\"whatsApp\":\"15266667779\",\"friendName\":\"lee\",\"sex\":\"male\",\"birthday\":\"2020/03/08\",\"address\":\"beijing\",\"email\":\"223@gmail.com\",\"profession\":\"good day\",\"income\":\"100$\",\"desc\":\"\",\"tabName\":\"GoodMan\",\"stage\":\"New Customer\",\"source\":\"System\",\"languageTag\":\"Auto\",\"welcome\":\"hello\"}]"
	token := genToken

	post := "{\"tenantId\":\"" + tenantId +
		"\",\"userName\":\"" + userName +
		"\",\"data\":" + data +
		",\"token\":\"" + token +
		"\",\"createTime\":\"" + createTime +
		"\"}"

  fmt.Printf("\n\n%s\n\n", post)

	var jsonStr = []byte(post)
	req, err := http.NewRequest(method, url, bytes.NewBuffer(jsonStr))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)

	// Response Body: {"code":-1,"message":"Admin Cannot import data","data":""}
	fmt.Printf("%s", body)
}

Last update:
Contributors: kubrick,zhangzhuangzhuang