Development Guide
Development Guide
Common Header Parameters
| Field | Type | Required | Remarks |
|---|---|---|---|
| tenant_id | Int | Yes | Company ID |
| timestamp | Long | Yes | Request timestamp: 1710936559123 |
| token | String | Yes | Encrypted string |
Token Generation Rules
md5(tenant_id + timestamp + ApiKey), 32-bit lowercase.
For how to obtain tenant_id and ApiKey, please contact the administrator.
- The parameters participating in encryption must be placed in the request header.
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.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 API Information
The request limit is
50 times/1sper single API.API endpoint address
- Standard production environment: https://api.socialepoch.com
Other
Mobile number rules
📢 For interfaces involving friend
whatsapp, the number must include the country code, e.g.:86182217331411(86 is the country code,182217331411is the number).Customer admin account, agent account, and WhatsApp account
The customer admin account is the primary account under the customer company. Agent accounts are sub-accounts under the company. WhatsApp accounts are the WhatsApp accounts used for work.
Customer field information required by the API
📢 For the customer's basic information, customer tag information, and customer extended field information.

Error Code Explanation
| Status Code | Exception Info | 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 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 sending with specified time |
| 513 | start time is error | Sending time parsing exception |
| 514 | content is null | Task 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 | Sending interval does not exist |
| 521 | task name repetition | Task name already exists |
| 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 | Group chat type parsing exception |
| 528 | group is null | Group chat information does not exist |
| 529 | Non-professional Edition | Non-professional edition |
| 530 | action username error | userName does not exist |
| 531 | userName is error | userName does not exist in data |
| 532 | customer whats id is null | friendWhatsId (customer WhatsApp ID) 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 list is empty |
| 537 | groupLink is not exist. Please reload it ! | groupLink not found. Please re-import it! |
| 538 | parsing group link. Please try again later | Parsing groupLink. Please try again later |
Old Token Generation Rules
md5(tenantId + userName+ createTime + ApiKey), 32-bit lowercase.
userNameis the customer admin account. For how to obtaintenantIdandApiKey, please contact the administrator.
createTimeis the request time of the API (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://api.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)
}