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

From docs
Jump to: navigation, search
Line 1: Line 1:
 +
== [[API]] » Update Company Stats HTML ==
 +
 +
== Update Company Stats HTML ==
 +
 +
=== Base URL ===
 +
https://app.callproof.com
 +
 +
=== Endpoint ===
 +
/api/companies/stats/html/update/
 +
 +
=== Purpose ===
 +
Creates or updates custom HTML statistics content for your CallProof company. Use this endpoint to store or refresh company-wide statistics that are not associated with an individual sales representative. If company statistics already exist, they are updated; otherwise, a new record is created.
 +
 +
=== HTTP Method ===
 +
POST
 +
 +
=== Headers ===
 +
 +
{| class="wikitable"
 +
! Header !! Required !! Description
 +
|-
 +
| Content-Type || Yes || Must be <code>application/json</code>.
 +
|}
 +
 +
=== Security ===
 +
 +
* '''Yes''' – Requires a valid API key and secret with permission to update company statistics HTML. Authentication credentials are provided in the request body.
 +
 +
=== Parameters ===
 +
 +
==== Path Parameters ====
 +
None.
 +
 +
==== 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.
 +
|-
 +
| company || object || Yes || Company statistics information.
 +
|-
 +
| company.html || string || No || HTML content to store for the company statistics. Leading and trailing whitespace is removed. Maximum length is 4,096 characters.
 +
|}
  
== [[API]] &#187; Update Company Stats HTML ==
+
=== cURL Example ===
  
'''URL:''' <nowiki>https://app.callproof.com/api/companies/stats/html/update/</nowiki>
+
<pre>
 +
curl -X POST "https://app.callproof.com/api/companies/stats/html/update/" \
 +
  -H "Content-Type: application/json" \
 +
  -d '{
 +
    "api_key": {
 +
      "key": "YOUR_API_KEY",
 +
      "secret": "YOUR_API_SECRET"
 +
    },
 +
    "company": {
 +
      "html": "<div>Team calls today: 250</div>"
 +
    }
 +
  }'
 +
</pre>
  
'''Method:''' POST
+
=== Successful Response (200) ===
  
'''Required Fields:'''
+
Returns the saved company-level HTML statistics.
  
* '''''api_key[key]''''' - API Key
+
{| class="wikitable"
* '''''api_key[secret]''''' - API Key Secret
+
! Field !! Type !! Description
* '''''company[html]''''' - Sales Rep Stats HTML. Include "#basic_stats#" (without quotes) to include basic stats.
+
|-
 +
| results || object || Updated company statistics record.
 +
|-
 +
| results.user_id || null || Always <code>null</code> because company statistics are not associated with an individual user.
 +
|-
 +
| results.user || string || Empty string for company-level statistics.
 +
|-
 +
| results.email || string || Empty string for company-level statistics.
 +
|-
 +
| results.html || string or null || Stored company HTML statistics.
 +
|-
 +
| errors || array || Empty when the request succeeds.
 +
|-
 +
| code || integer || HTTP-style status code (<code>200</code>).
 +
|}
  
'''Optional Fields:'''
+
Example response:
  
* '''''None'''''
+
<pre>
 +
{
 +
  "results": {
 +
    "user_id": null,
 +
    "user": "",
 +
    "email": "",
 +
    "html": "<div>Team calls today: 250</div>"
 +
  },
 +
  "errors": [],
 +
  "code": 200
 +
}
 +
</pre>
  
'''Data Returned:'''
+
=== Error Responses ===
  
* '''''results''''' - Array containing updated Company Stats HTML
+
{| class="wikitable"
* '''''errors''''' - Array of errors produced by the request
+
! Status Code !! Meaning
* '''''code''''' - HTTP request status
+
|-
 +
| 401 || Unauthorized – The API key or secret is missing, invalid, inactive, associated with a disabled account, or does not have permission to update company statistics.
 +
|-
 +
| 405 || Method Not Allowed – A method other than POST was used.
 +
|-
 +
| 500 || Internal Server Error – An unexpected server error occurred.
 +
|}
  
 +
'''401 response example:'''
  
 +
<pre>
 +
{
 +
  "results": [],
 +
  "errors": [
 +
    "Invalid API Key"
 +
  ],
 +
  "code": 401
 +
}
 +
</pre>
  
'''''rep[html]''''' can be styled to match existing #basic_stats# HTML:
+
'''405 response example:'''
  
 
<pre>
 
<pre>
<nowiki>
+
{
<table class="outer">
+
   "results": [],
<tr>
+
   "errors": [
   <td class="st">Appointments</td>
+
    "Method not allowed"
   <td class="st r">0</td>
+
   ],
</tr>
+
   "code": 405
<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>
 +
 +
=== Notes ===
 +
 +
* This endpoint creates a new company statistics record if one does not already exist; otherwise, it updates the existing record.
 +
* Company statistics are stored independently of individual sales representatives, so the returned <code>user_id</code>, <code>user</code>, and <code>email</code> fields are empty.
 +
* The HTML content supports up to <code>4,096</code> characters.
 +
* If <code>company.html</code> is omitted or contains only whitespace, any existing HTML content may be cleared.
 +
* Authentication credentials are supplied in the JSON request body rather than HTTP headers.
 +
* This endpoint accepts only <code>POST</code> requests with a JSON payload.
 +
* This endpoint does not perform field-level validation on the HTML content; therefore, it does not return a <code>400 Bad Request</code> response for missing or invalid HTML.

Revision as of 08:09, 17 July 2026

API » Update Company Stats HTML

Update Company Stats HTML

Base URL

https://app.callproof.com

Endpoint

/api/companies/stats/html/update/

Purpose

Creates or updates custom HTML statistics content for your CallProof company. Use this endpoint to store or refresh company-wide statistics that are not associated with an individual sales representative. If company statistics already exist, they are 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 company 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.
company object Yes Company statistics information.
company.html string No HTML content to store for the company statistics. Leading and trailing whitespace is removed. Maximum length is 4,096 characters.

cURL Example

curl -X POST "https://app.callproof.com/api/companies/stats/html/update/" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": {
      "key": "YOUR_API_KEY",
      "secret": "YOUR_API_SECRET"
    },
    "company": {
      "html": "<div>Team calls today: 250</div>"
    }
  }'

Successful Response (200)

Returns the saved company-level HTML statistics.

Field Type Description
results object Updated company statistics record.
results.user_id null Always null because company statistics are not associated with an individual user.
results.user string Empty string for company-level statistics.
results.email string Empty string for company-level statistics.
results.html string or null Stored company HTML statistics.
errors array Empty when the request succeeds.
code integer HTTP-style status code (200).

Example response:

{
  "results": {
    "user_id": null,
    "user": "",
    "email": "",
    "html": "<div>Team calls today: 250</div>"
  },
  "errors": [],
  "code": 200
}

Error Responses

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

401 response example:

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

405 response example:

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

Notes

  • This endpoint creates a new company statistics record if one does not already exist; otherwise, it updates the existing record.
  • Company statistics are stored independently of individual sales representatives, so the returned user_id, user, and email fields are empty.
  • The HTML content supports up to 4,096 characters.
  • If company.html is omitted or contains only whitespace, any existing HTML content may be cleared.
  • Authentication credentials are supplied in the JSON request body rather than HTTP headers.
  • This endpoint accepts only POST requests with a JSON payload.
  • This endpoint does not perform field-level validation on the HTML content; therefore, it does not return a 400 Bad Request response for missing or invalid HTML.