Development Guide
Development Guide
Common Request Headers
| Field | Type | Required | Description |
|---|---|---|---|
| tenant_id | Int | Yes | Company id |
| timestamp | Long | Yes | Request timestamp: 1710936559123 |
| token | String | Yes | Encrypted 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 Page
Error Code Description
| Status Code | Exception Information | Description |
|---|---|---|
| 501 | appSecret error | appSecret does not exist |
| 502 | timestamp timeout | Request timestamp timeout |
| 503 | name is empty | Task name is empty |
| 504 | executor error | Executor parsing exception |
| 505 | executor is empty | Executor is empty |
| 506 | data is empty | Task data information is empty |
| 507 | data size big | Data size is too large |
| 508 | no exist userName | Executor information does not exist |
| 509 | customer group is null | Customer group information is empty |
| 510 | customer group key error | Customer group key information error |
| 511 | customer group value error | Customer group value information error |
| 512 | send type == 1 and startTime is not null | Immediate send with specified send time |
| 513 | start time is error | Send time parsing exception |
| 514 | content is null | Task send content is empty |
| 515 | file is null | Task file information does not exist |
| 516 | main userId is null | Main account information does not exist |
| 517 | database error | Database exception |
| 518 | timestamp is null | Timestamp is empty |
| 519 | timestamp is error | Timestamp parsing exception |
| 520 | send interval is null | Send interval time does not exist |
| 521 | task name repetition | Task name is duplicated |
| 522 | accessToken is error | accessToken information error |
| 523 | tenantId is null | Company id is empty |
| 524 | userName is null | Admin name is empty |
| 525 | token is null | token is empty |
| 526 | createTime is null | Create time is empty |
| 527 | group is error | Customer group chat type parsing exception |
| 528 | group is null | Customer group information does not exist |
| 529 | Non-professional Edition | Non-professional Edition |
| 530 | action username error | userName does not exist |
| 531 | userName is error | userName in data does not exist |
| 532 | customer whats id is null | friendWhatsId customer service number does not exist |
| 533 | extended field format error | Extended field format exception |
| 534 | whatsid list null | whatsid list is empty |
| 536 | groupLinkList is null | groupLinkList is empty |
| 537 | groupLink is not exist . Please reload it ! | groupLink not found. Please reload it! |
| 538 | parsing group link. Please try again later | groupLink 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)
}
