Difference between revisions of "API:Reps:Stats:HTML:Update"

From docs
Jump to: navigation, search
Line 1: Line 1:
 +
== [[API]] » Update Rep Stats HTML ==
  
== [[API]] » Update Sales Rep Stats HTML ==
+
== Update Rep Stats HTML ==
  
'''URL:''' <nowiki>https://app.callproof.com/api/reps/stats/html/update/</nowiki>
+
=== Base URL ===
 +
https://app.callproof.com
  
'''Method:''' POST
+
=== Endpoint ===
 +
/api/reps/stats/html/update/
  
'''Required Fields:'''
+
=== Purpose ===
 +
Creates or updates custom HTML statistics content for a specific sales representative. Use this endpoint to store or refresh the HTML content displayed for a rep's statistics in CallProof or related integrations. If a record already exists for the rep, it is updated; otherwise, a new record is created.
  
* '''''api_key[key]''''' - API Key
+
=== HTTP Method ===
* '''''api_key[secret]''''' - API Key Secret
+
POST
* '''''rep[id]''''' - Sales Rep ID
 
* '''''rep[html]''''' - Sales Rep Stats HTML.  Include "#basic_stats#" (without quotes) to include basic stats.
 
  
'''Optional Fields:'''
+
=== Headers ===
  
* '''''None'''''
+
{| class="wikitable"
 +
! Header !! Required !! Description
 +
|-
 +
| Content-Type || Yes || Must be <code>application/json</code>.
 +
|}
  
'''Data Returned:'''
+
=== Security ===
  
* '''''results''''' - Array containing updated Sales Rep Stats HTML
+
* '''Yes''' – Requires a valid API key and secret with permission to update rep statistics HTML. Authentication credentials are provided in the request body.
* '''''errors''''' - Array of errors produced by the request
 
* '''''code''''' - HTTP request status
 
  
 +
=== Parameters ===
  
 +
==== Path Parameters ====
 +
None.
  
'''''rep[html]''''' can be styled to match existing #basic_stats# HTML:
+
==== Query Parameters ====
 +
None.
 +
 
 +
==== Request Body ====
 +
 
 +
{| class="wikitable"
 +
! Parameter !! Type !! Required !! Description
 +
|-
 +
| api_key || object || Yes || Authentication credentials.
 +
|-
 +
| api_key.key || string || Yes || Public API key assigned to your CallProof account.
 +
|-
 +
| api_key.secret || string || Yes || Private API secret associated with the API key.
 +
|-
 +
| rep || object || Yes || Sales representative information.
 +
|-
 +
| rep.id || integer || Yes || User ID of the sales representative whose HTML statistics should be created or updated.
 +
|-
 +
| rep.html || string || No || HTML content to store for the sales representative. Leading and trailing whitespace is removed. Maximum length is 4,096 characters.
 +
|}
 +
 
 +
=== cURL Example ===
 +
 
 +
<pre>
 +
curl -X POST "https://app.callproof.com/api/reps/stats/html/update/" \
 +
  -H "Content-Type: application/json" \
 +
  -d '{
 +
    "api_key": {
 +
      "key": "YOUR_API_KEY",
 +
      "secret": "YOUR_API_SECRET"
 +
    },
 +
    "rep": {
 +
      "id": 456,
 +
      "html": "<div>Calls today: 12</div>"
 +
    }
 +
  }'
 +
</pre>
 +
 
 +
=== Successful Response (200) ===
 +
 
 +
Returns the saved HTML statistics associated with the specified sales representative.
 +
 
 +
{| class="wikitable"
 +
! Field !! Type !! Description
 +
|-
 +
| results || object || Updated rep statistics record.
 +
|-
 +
| results.user_id || integer || User ID of the sales representative.
 +
|-
 +
| results.user || string || Sales representative's display name.
 +
|-
 +
| results.email || string || Sales representative's email address.
 +
|-
 +
| results.html || string or null || Stored HTML statistics content.
 +
|-
 +
| errors || array || Empty when the request succeeds.
 +
|-
 +
| code || integer || HTTP-style status code (<code>200</code>).
 +
|}
 +
 
 +
Example response:
 +
 
 +
<pre>
 +
{
 +
  "results": {
 +
    "user_id": 456,
 +
    "user": "Jane Smith",
 +
    "email": "rep@example.com",
 +
    "html": "<div>Calls today: 12</div>"
 +
  },
 +
  "errors": [],
 +
  "code": 200
 +
}
 +
</pre>
 +
 
 +
=== Error Responses ===
 +
 
 +
{| class="wikitable"
 +
! Status Code !! Meaning
 +
|-
 +
| 400 || Bad Request – The rep ID is missing, invalid, or does not belong to your company.
 +
|-
 +
| 401 || Unauthorized – The API key or secret is missing, invalid, inactive, associated with a disabled account, or does not have permission to update rep statistics.
 +
|-
 +
| 405 || Method Not Allowed – A method other than POST was used.
 +
|-
 +
| 500 || Internal Server Error – An unexpected server error occurred.
 +
|}
 +
 
 +
'''400 response example:'''
  
 
<pre>
 
<pre>
<nowiki>
+
{
<table class="outer">
+
   "results": [],
<tr>
+
   "errors": [
   <td class="st">Appointments</td>
+
    "Invalid 'id' field"
   <td class="st r">0</td>
+
   ],
</tr>
+
   "code": 400
<tr>
+
}
  <td class="st">Calls</td>
 
   <td class="st r">0</td>
 
</tr>
 
<tr>
 
  <td class="st">Hours</td>
 
   <td class="st r">0</td>
 
</tr>
 
</table>
 
</nowiki>
 
 
</pre>
 
</pre>
 +
 +
'''401 response example:'''
 +
 +
<pre>
 +
{
 +
  "results": [],
 +
  "errors": [
 +
    "Invalid API Key"
 +
  ],
 +
  "code": 401
 +
}
 +
</pre>
 +
 +
'''405 response example:'''
 +
 +
<pre>
 +
{
 +
  "results": [],
 +
  "errors": [
 +
    "Method not allowed"
 +
  ],
 +
  "code": 405
 +
}
 +
</pre>
 +
 +
=== Notes ===
 +
 +
* If the sales representative already has stored HTML statistics, they are replaced with the new HTML provided.
 +
* If no statistics record exists for the sales representative, one is created automatically.
 +
* The <code>rep.id</code> must reference a valid sales representative belonging to the authenticated company.
 +
* The HTML content supports up to <code>4,096</code> characters.
 +
* Authentication is supplied in the JSON request body rather than HTTP headers.
 +
* This endpoint accepts only <code>POST</code> requests with a JSON payload.

Revision as of 07:46, 17 July 2026

API » Update Rep Stats HTML

Update Rep Stats HTML

Base URL

https://app.callproof.com

Endpoint

/api/reps/stats/html/update/

Purpose

Creates or updates custom HTML statistics content for a specific sales representative. Use this endpoint to store or refresh the HTML content displayed for a rep's statistics in CallProof or related integrations. If a record already exists for the rep, it is updated; otherwise, a new record is created.

HTTP Method

POST

Headers

Header Required Description
Content-Type Yes Must be application/json.

Security

  • Yes – Requires a valid API key and secret with permission to update rep statistics HTML. Authentication credentials are provided in the request body.

Parameters

Path Parameters

None.

Query Parameters

None.

Request Body

Parameter Type Required Description
api_key object Yes Authentication credentials.
api_key.key string Yes Public API key assigned to your CallProof account.
api_key.secret string Yes Private API secret associated with the API key.
rep object Yes Sales representative information.
rep.id integer Yes User ID of the sales representative whose HTML statistics should be created or updated.
rep.html string No HTML content to store for the sales representative. Leading and trailing whitespace is removed. Maximum length is 4,096 characters.

cURL Example

curl -X POST "https://app.callproof.com/api/reps/stats/html/update/" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": {
      "key": "YOUR_API_KEY",
      "secret": "YOUR_API_SECRET"
    },
    "rep": {
      "id": 456,
      "html": "<div>Calls today: 12</div>"
    }
  }'

Successful Response (200)

Returns the saved HTML statistics associated with the specified sales representative.

Field Type Description
results object Updated rep statistics record.
results.user_id integer User ID of the sales representative.
results.user string Sales representative's display name.
results.email string Sales representative's email address.
results.html string or null Stored HTML statistics content.
errors array Empty when the request succeeds.
code integer HTTP-style status code (200).

Example response:

{
  "results": {
    "user_id": 456,
    "user": "Jane Smith",
    "email": "rep@example.com",
    "html": "<div>Calls today: 12</div>"
  },
  "errors": [],
  "code": 200
}

Error Responses

Status Code Meaning
400 Bad Request – The rep ID is missing, invalid, or does not belong to your company.
401 Unauthorized – The API key or secret is missing, invalid, inactive, associated with a disabled account, or does not have permission to update rep statistics.
405 Method Not Allowed – A method other than POST was used.
500 Internal Server Error – An unexpected server error occurred.

400 response example:

{
  "results": [],
  "errors": [
    "Invalid 'id' field"
  ],
  "code": 400
}

401 response example:

{
  "results": [],
  "errors": [
    "Invalid API Key"
  ],
  "code": 401
}

405 response example:

{
  "results": [],
  "errors": [
    "Method not allowed"
  ],
  "code": 405
}

Notes

  • If the sales representative already has stored HTML statistics, they are replaced with the new HTML provided.
  • If no statistics record exists for the sales representative, one is created automatically.
  • The rep.id must reference a valid sales representative belonging to the authenticated company.
  • The HTML content supports up to 4,096 characters.
  • Authentication is supplied in the JSON request body rather than HTTP headers.
  • This endpoint accepts only POST requests with a JSON payload.