ממשקי API: הבדלים בין גרסאות בדף

מתוך MindCRM
קפיצה לניווט קפיצה לחיפוש
(יצירת קובץ ממשקי API)
 
 
(2 גרסאות ביניים של אותו משתמש אינן מוצגות)
שורה 1: שורה 1:


<span dir="ltr" class="mw-content-ltr" style="direction:ltr !important">
=CRM API Documentation=
=CRM API Documentation=
This documentation covers the core CRM endpoints: ''get_data.php'', ''set_data.php'', and ''set_status.php''.
This documentation covers the core CRM endpoints: ''get_data.php'', ''set_data.php'', and ''set_status.php''.
----
----
==1) <code>get_data.php - by phone</code>==
= Get Data API (get_data.php) =
;Purpose
 
Retrieve customer or repository data by DID and phone number.
'''Endpoint:''' <code>GET /api/get_data.php</code>
;Method
 
<code>GET</code>
This API endpoint retrieves customer data, call history information, and metadata based on specific search parameters.
;Authorization Required
 
Yes (<code>authkey</code>): Mindc_2023_get_data
----
===Parameters===
 
== Authentication ==
 
Every request must include the <code>authkey</code> parameter.
 
{| class="wikitable"
! Parameter !! Required !! Value / Notes
|-
| <code>authkey</code> || ✅ || <code>Mindc_2023_get_data</code>
|}
 
----
 
== Request Parameters ==
 
=== Required Parameters ===
 
{| class="wikitable"
! Parameter !! Type !! Required !! Description
|-
| <code>authkey</code> || string || ✅ || Authentication key. Must be <code>Mindc_2023_get_data</code>.
|-
| <code>out</code> || string || ✅ || Comma-separated list of fields to retrieve. Example: <code>out=first_name,last_name,last_status,last_call</code>
|}
 
=== Search Parameters ===
 
You must provide '''one''' of the following search combinations:
 
==== Combination A: By Repository Assign ID ====
 
{| class="wikitable"
! Parameter !! Type !! Required !! Description
|-
| <code>repository_assign_id</code> || string || ✅ (for A) || A single assignment ID, or a comma-separated list of assignment IDs.
|}
 
==== Combination B: By Phone Number & Context ====
 
{| class="wikitable"
{| class="wikitable"
!Parameter!!Required!!Description
! Parameter !! Type !! Required !! Description
|-
| <code>phone</code> || string || ✅ (for B) || The customer's phone number.
|-
| <code>did</code> || string || ✅* || DID number.
|-
| <code>project_id</code> || integer || ✅* || Project ID.
|-
| <code>worker_id</code> || integer || ✅* || Worker ID.
|-
|-
|<code>authkey</code>||||Authentication key: Mindc_2023_get_data
| <code>group_id</code> || integer || ❌ || Optional filter.
|-
|-
|<code>did</code>||||Incoming DID number
| <code>repository_id</code> || integer || ❌ || Optional filter.
|-
|-
|<code>phone</code>||||Customer phone number
| <code>site_id</code> || integer || ❌ || Optional filter.
|}
 
''✅* For Combination B, you must provide <code>phone</code> and at least one of: <code>did</code>, <code>project_id</code>, <code>worker_id</code>.'' 
''The optional filters (<code>group_id</code>, <code>repository_id</code>, <code>site_id</code>) may be used only with Combination B.''
 
----
 
== Output Fields (out parameter) ==
 
By default, <code>uid</code> is always returned.
 
You can request:
* Any dynamic customer field name (e.g., <code>first_name</code>, <code>last_name</code>, <code>email</code>)
* Plus any of the following predefined fields:
 
{| class="wikitable"
! Field !! Description
|-
|-
|<code>out</code>||✅||Comma-separated list of output fields
| <code>last_status</code> || Description of the most recent customer status.
|-
|-
|<code>project_id</code>||⚠️*||Project ID
| <code>last_call</code> || Timestamp of the most recent call.
|-
|-
|<code>worker_id</code>||⚠️*||Worker ID (used to resolve project)
| <code>last_notes</code> || Text of the most recent note.
|-
|-
|<code>group_id</code>||❌||Filter by group
| <code>repository_id</code> || ID of the repository.
|-
|-
|<code>repository_id</code>||❌||Filter by repository
| <code>repository_name</code> || Name of the repository.
|-
|-
|<code>site_id</code>||❌||Filter by site
| <code>repository_assign_id</code> || Assignment ID.
|}''⚠️ At least one of <code>project_id</code> or <code>worker_id</code> is required.''
|}
===Special <code>out</code> Fields===
 
You may request the following:
----
*<code>last_status</code>
 
*<code>last_call</code>
== Examples of Successful Requests ==
*<code>last_notes</code>
 
*<code>repository_id</code>
=== Example 1: Fetching data by repository_assign_id ===
*<code>repository_name</code>
 
*<code>repository_assign_id</code>
'''Request:'''
*Any customer field from the Forms module
===Example Requests===
<pre>
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&did=07333333333&phone=0500000000&project_id=10&out=first_name,last_status,repository_name
GET /api/get_data.php?authkey=Mindc_2023_get_data&out=first_name,last_status,last_call&repository_assign_id=102,103
</pre><pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&repository_assign_id=2190811&out=uid,repository_name,customer_name
</pre>
</pre>
===Success Response===
 
'''Response:'''
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
שורה 54: שורה 115:
   "message": [
   "message": [
     {
     {
       "uid": "123",
       "uid": 102,
       "name": "John Doe",
      "first_name": "John",
       "email": "john@mail.com",
      "last_status": "Interested",
       "last_status": "Interested"
       "last_call": "2023-10-15 14:30:00"
    },
    {
      "uid": 103,
       "first_name": "Jane",
       "last_status": "Callback",
      "last_call": "2023-10-16 09:15:00"
     }
     }
   ]
   ]
}
}
</syntaxhighlight>Or empty results:<syntaxhighlight lang="json">
</syntaxhighlight>
 
=== Example 2: Fetching data by phone and project_id ===
 
'''Request:'''
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&out=email,repository_name,last_notes&phone=5551234567&project_id=5
</pre>
 
'''Response:'''
<syntaxhighlight lang="json">
{
{
   "code": 0,
   "code": 0,
   "status": "success",
   "status": "success",
   "message": []
   "message": [
    {
      "uid": 104,
      "email": "customer@example.com",
      "repository_name": "Main Leads",
      "last_notes": "Customer asked to call back tomorrow."
    }
  ]
}
}
</syntaxhighlight>
</syntaxhighlight>
===Failure Response===
 
----
 
== Examples of Failed Requests ==
 
=== Error 1: Missing or Invalid Auth Key ===
 
'''Request:'''
<pre>
GET /api/get_data.php?authkey=wrong_key&out=last_status&phone=5551234567&project_id=5
</pre>
 
'''Response:'''
<syntaxhighlight lang="json">
{
  "code": 1,
  "status": "fail",
  "message": "Missing authkey or invalid value"
}
</syntaxhighlight>
 
=== Error 2: Missing out Parameter ===
 
'''Request:'''
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&phone=5551234567&project_id=5
</pre>
 
'''Response:'''
<syntaxhighlight lang="json">
{
  "code": 4,
  "status": "fail",
  "message": "Missing out parameter"
}
</syntaxhighlight>
 
=== Error 3: Missing Search Criteria (no repository_assign_id and no phone) ===
 
'''Request:'''
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&project_id=5
</pre>
 
'''Response:'''
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
   "code": 3,
   "code": 3,
   "status": "fail",
   "status": "fail",
   "message": "Missing phone"
   "message": "Missing phone_number parameter"
}
}
</syntaxhighlight>
</syntaxhighlight>
===Error Codes===
{| class="wikitable"
!Code!!Meaning
|-
|1||Missing or invalid authkey
|-
|2||Missing DID
|-
|3||Missing phone
|-
|4||Missing <code>out</code> parameter
|-
|5||Missing both project_id and worker_id
|-
|6||No matching repository assign
|-
|7||Database exception
|}
----


== 2) <code>get_data.php - by phone</code> ==
=== Error 4: Missing Context for Phone Search ===
;Purpose
 
Retrieve customer or repository data by repository_assign_id value
'''Request:'''
;Method
<code>GET</code>
;Authorization Required
Yes (<code>authkey</code>): Mindc_2023_get_data
===Parameters===
{| class="wikitable"
!Parameter!!Required!!Description
|-
|<code>authkey</code>||✅||Authentication key: Mindc_2023_get_data
|-
|<code>repository_id</code>||✅||Filter by repository
|-
|<code>out</code>||✅||Comma-separated list of output fields
|-
|<code>project_id</code>||⚠️*||Project ID
|-
|<code>worker_id</code>||⚠️*||Worker ID (used to resolve project)
|-
|<code>group_id</code>||❌||Filter by group
|-
|<code>site_id</code>||❌||Filter by site
|}
===Special <code>out</code> Fields===
You may request the following:
*<code>last_status</code>
*<code>last_call</code>
*<code>last_notes</code>
*<code>repository_id</code>
*<code>repository_name</code>
*<code>repository_assign_id</code>
*Any customer field from the Forms module
===Example Requests===
<pre>
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&repository_assign_id=2190811&out=uid,repository_name,customer_name
GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&phone=5551234567
</pre>
</pre>
===Success Response===
 
'''Response:'''
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
   "code": 0,
   "code": 5,
   "status": "success",
   "status": "fail",
   "message": [
   "message": "Missing project_id or worker_id or did input parameters"
    {
      "uid": "123",
      "name": "John Doe",
      "email": "john@mail.com",
      "last_status": "Interested"
    }
  ]
}
}
</syntaxhighlight>Or empty results:<syntaxhighlight lang="json">
</syntaxhighlight>
 
=== Error 5: No Matching Customer Data ===
 
'''Request:'''
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&phone=999999999&project_id=999
</pre>
 
'''Response:'''
<syntaxhighlight lang="json">
{
{
   "code": 0,
   "code": 6,
   "status": "success",
   "status": "fail",
   "message": []
   "message": "No matching customer found"
}
}
</syntaxhighlight>
</syntaxhighlight>
===Failure Response===
 
=== Error 6: Worker Not Found ===
 
'''Request:'''
<pre>
GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&phone=5551234567&worker_id=9999
</pre>
 
'''Response:'''
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
   "code": 3,
   "code": 8,
   "status": "fail",
   "status": "fail",
   "message": "Missing phone"
   "message": "Worker not found"
}
}
</syntaxhighlight>
</syntaxhighlight>
===Error Codes===
 
----
 
== Error Response Codes Reference ==
 
{| class="wikitable"
{| class="wikitable"
!Code!!Meaning
! Code !! Meaning
|-
|-
|1||Missing or invalid authkey
| <code>1</code> || Missing authkey or invalid value
|-
|-
|2||Missing DID
| <code>3</code> || Missing phone_number parameter
|-
|-
|3||Missing phone
| <code>4</code> || Missing out parameter
|-
|-
|4||Missing <code>out</code> parameter
| <code>5</code> || Missing project_id or worker_id or did input parameters
|-
|-
|5||Missing both project_id and worker_id
| <code>6</code> || No matching customer found
|-
|-
|6||No matching repository assign
| <code>7</code> || Database/SQL Exception
|-
|-
|7||Database exception
| <code>8</code> || Worker not found
|}
|}
==3) <code>set_data.php</code>==
 
=<code>set_data.php</code>=
;Purpose
;Purpose
Update customer fields and/or status.
Update customer fields and/or status.
שורה 277: שורה 371:
|}
|}
----
----
==4) <code>set_status.php</code>==
=<code>set_status.php</code>=
;Purpose
;Purpose
Set or clear customer status for a repository assign.
Set or clear customer status for a repository assign.
שורה 329: שורה 423:
|5||Failed to set status
|5||Failed to set status
|}
|}
</span>

גרסה אחרונה מ־14:22, 6 במרץ 2026

CRM API Documentation

This documentation covers the core CRM endpoints: get_data.php, set_data.php, and set_status.php.


Get Data API (get_data.php)

Endpoint: GET /api/get_data.php

This API endpoint retrieves customer data, call history information, and metadata based on specific search parameters.


Authentication

Every request must include the authkey parameter.

Parameter Required Value / Notes
authkey Mindc_2023_get_data

Request Parameters

Required Parameters

Parameter Type Required Description
authkey string Authentication key. Must be Mindc_2023_get_data.
out string Comma-separated list of fields to retrieve. Example: out=first_name,last_name,last_status,last_call

Search Parameters

You must provide one of the following search combinations:

Combination A: By Repository Assign ID

Parameter Type Required Description
repository_assign_id string ✅ (for A) A single assignment ID, or a comma-separated list of assignment IDs.

Combination B: By Phone Number & Context

Parameter Type Required Description
phone string ✅ (for B) The customer's phone number.
did string ✅* DID number.
project_id integer ✅* Project ID.
worker_id integer ✅* Worker ID.
group_id integer Optional filter.
repository_id integer Optional filter.
site_id integer Optional filter.

✅* For Combination B, you must provide phone and at least one of: did, project_id, worker_id. The optional filters (group_id, repository_id, site_id) may be used only with Combination B.


Output Fields (out parameter)

By default, uid is always returned.

You can request:

  • Any dynamic customer field name (e.g., first_name, last_name, email)
  • Plus any of the following predefined fields:
Field Description
last_status Description of the most recent customer status.
last_call Timestamp of the most recent call.
last_notes Text of the most recent note.
repository_id ID of the repository.
repository_name Name of the repository.
repository_assign_id Assignment ID.

Examples of Successful Requests

Example 1: Fetching data by repository_assign_id

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&out=first_name,last_status,last_call&repository_assign_id=102,103

Response:

{
  "code": 0,
  "status": "success",
  "message": [
    {
      "uid": 102,
      "first_name": "John",
      "last_status": "Interested",
      "last_call": "2023-10-15 14:30:00"
    },
    {
      "uid": 103,
      "first_name": "Jane",
      "last_status": "Callback",
      "last_call": "2023-10-16 09:15:00"
    }
  ]
}

Example 2: Fetching data by phone and project_id

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&out=email,repository_name,last_notes&phone=5551234567&project_id=5

Response:

{
  "code": 0,
  "status": "success",
  "message": [
    {
      "uid": 104,
      "email": "customer@example.com",
      "repository_name": "Main Leads",
      "last_notes": "Customer asked to call back tomorrow."
    }
  ]
}

Examples of Failed Requests

Error 1: Missing or Invalid Auth Key

Request:

GET /api/get_data.php?authkey=wrong_key&out=last_status&phone=5551234567&project_id=5

Response:

{
  "code": 1,
  "status": "fail",
  "message": "Missing authkey or invalid value"
}

Error 2: Missing out Parameter

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&phone=5551234567&project_id=5

Response:

{
  "code": 4,
  "status": "fail",
  "message": "Missing out parameter"
}

Error 3: Missing Search Criteria (no repository_assign_id and no phone)

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&project_id=5

Response:

{
  "code": 3,
  "status": "fail",
  "message": "Missing phone_number parameter"
}

Error 4: Missing Context for Phone Search

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&phone=5551234567

Response:

{
  "code": 5,
  "status": "fail",
  "message": "Missing project_id or worker_id or did input parameters"
}

Error 5: No Matching Customer Data

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&phone=999999999&project_id=999

Response:

{
  "code": 6,
  "status": "fail",
  "message": "No matching customer found"
}

Error 6: Worker Not Found

Request:

GET /api/get_data.php?authkey=Mindc_2023_get_data&out=last_status&phone=5551234567&worker_id=9999

Response:

{
  "code": 8,
  "status": "fail",
  "message": "Worker not found"
}

Error Response Codes Reference

Code Meaning
1 Missing authkey or invalid value
3 Missing phone_number parameter
4 Missing out parameter
5 Missing project_id or worker_id or did input parameters
6 No matching customer found
7 Database/SQL Exception
8 Worker not found

set_data.php

Purpose

Update customer fields and/or status.

Method

GET or POST

Authorization Required

Yes (authkey): Mindc_2023_set_data

Parameters

Parameter Required Description
authkey Authentication key: Mindc_2023_set_data
repository_assign_id ⚠️* Direct repository assign ID
project_id ⚠️* Project ID (used if repository_assign_id not provided)
worker_id ⚠️* Worker ID (used if repository_assign_id not provided)
phone ⚠️** Customer phone (required if not using repository_assign_id)
did ⚠️** DID number (required if not using repository_assign_id)
group_id Filter for lookup
repository_id Filter for lookup
site_id Filter for lookup
status_id Status ID to set
Any field name Any valid customer field (use display_name)

⚠️ Either repository_assign_id OR (project_id + worker_id + phone + did) is required.

⚠️ phone and did are required if not using repository_assign_id.

Example Requests

Update Customer Data (Using repository_assign_id)

POST /dev-6/api/set_data.php | authkey=Mindc_2023_set_data&repository_assign_id=555&first_name=Jane&email=jane@example.com
Content-Type: application/x-www-form-urlencoded

Update Status Only (Using Phone & Project Context)

GET /dev-6/api/set_data.php?authkey=Mindc_2023_set_data&did=123456&phone=972500000000&project_id=15&status_id=10

Update Data and Status Together (with worker_id)

POST /dev-6/api/set_data.php | authkey=Mindc_2023_set_data&repository_assign_id=555&city=New York&status_id=2&worker_id=99

Success Responses

Fields Updated
{
  "code": 0,
  "status": "success",
  "message": "email was updated to 'a@mail.com', name was updated to 'Anna'"
}
Only Status Updated
{
  "code": 0,
  "status": "success",
  "message": "Status set successfully"
}
Partial Success
{
  "code": 0,
  "status": "success",
  "message": "Fields updated",
  "errors": {
    "status": "Failed to set status"
  }
}

Error Codes

Code Meaning
1 Missing or invalid authkey
2 Missing repository assign ID
3 Invalid repository assign ID
4 Duplicate unique field
5 Update failed
6 No valid fields or repository not found
7 No fields provided in request

set_status.php

Purpose

Set or clear customer status for a repository assign.

Method

GET or POST

Authorization Required

Yes (authkey): Mindc_2023_set_status

Parameters

Parameter Required Description
authkey Authentication key: Mindc_2023_set_status
repository_assign_id Repository assign ID
status_id Status ID (or 0 = clear status)
worker_id Worker ID (for audit purposes)

Example Requests

Set Status for a Customer

GET /dev-6/api/set_status.php?authkey=Mindc_2023_set_status&repository_assign_id=555&status_id=10

Clear Status

POST /dev-6/api/set_status.php | authkey=Mindc_2023_set_status&repository_assign_id=555&status_id=0
Content-Type: application/x-www-form-urlencoded

Success Response

{
  "code": 0,
  "status": "success",
  "message": "Status set successfully"
}

Error Codes

Code Meaning
1 Missing or invalid authkey
2 Missing repository assign ID
3 Invalid repository assign ID
4 Missing status ID
5 Failed to set status