API:Call:Create

From docs
Jump to: navigation, search

API » Create Call

Base URL

https://app.callproof.com

Endpoint

/api/call/create/

Purpose

Creates a new call record for the authenticated API user in your CallProof company. If a matching call already exists for the same user, phone number, call type, and start time, the existing record’s duration may be updated instead of creating a duplicate.

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 create calls. Credentials are sent in the request body.

Parameters

Path Parameters

None.

Query Parameters

None.

Request Body

Parameter Type Required Description
api_key object Yes Authentication credentials object.
api_key.key string Yes Public API key assigned to your CallProof account.
api_key.secret string Yes Private API secret paired with the API key.
call_data object Yes Call creation payload.
call_data.number string Yes Phone number for the call. Digits only after normalization. Must not be empty or all zeros.
call_data.start_datetime datetime string Yes Date and time the call started.
call_data.call_type string Yes Call type name (for example, outgoing or incoming). Must match a recognized call type.
call_data.duration integer No Call duration in seconds. Defaults to 0 if omitted or invalid.
call_data.local_id integer No Optional local/device identifier for the call. Defaults to 0 if omitted or invalid.

cURL Example

curl -X POST "https://app.callproof.com/api/call/create/" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": {
      "key": "YOUR_API_KEY",
      "secret": "YOUR_API_SECRET"
    },
    "call_data": {
      "number": "5551234567",
      "start_datetime": "2024-06-15 14:30:00",
      "call_type": "outgoing",
      "duration": 185,
      "local_id": 1
    }
  }'

Successful Response (200)

Indicates the call was created or an existing matching call was updated. The response returns the call details plus a new_call indicator.

Field Type Description
results object Saved call details.
results.id integer Unique identifier for the call.
results.created string Date and time the call started (YYYY-MM-DD HH:MM:SS).
results.contact_id integer Associated contact identifier, when available.
results.contact string Contact display name, when available.
results.contact_phone_id integer Associated contact phone identifier, when available.
results.contact_phone string Contact phone number used for the call, when available.
results.user_phone_id integer Identifier of the user phone used for the call, when available.
results.user_phone string User phone number used for the call, when available.
results.phone_number string Phone number recorded for the call.
results.rep object Sales representative associated with the call.
results.call_type string Call type name.
results.duration integer Call duration in seconds.
results.new_call integer 1 if a new call was created; 0 if an existing matching call was updated.
errors object Empty object when the request succeeds.
code integer HTTP-style status value; 200 on success.

Example response:

{
  "results": {
    "id": 5001,
    "created": "2024-06-15 14:30:00",
    "contact_id": 789,
    "contact": "John Doe",
    "contact_phone_id": 1001,
    "contact_phone": "5551234567",
    "user_phone_id": 22,
    "user_phone": "5559876543",
    "phone_number": "5551234567",
    "rep": {
      "id": 123,
      "email": "rep@example.com",
      "user_id": 456,
      "name": "Jane Smith",
      "title": "Account Executive",
      "updated": "2024-06-01 10:00:00"
    },
    "call_type": "outgoing",
    "duration": 185,
    "new_call": 1
  },
  "errors": {},
  "code": 200
}

Notes

  • number, start_datetime, and call_type are required.
  • Phone numbers are normalized to digits. An 11-digit number starting with 1 is treated as a U.S./Canada number and reduced to 10 digits.
  • A value of 0000000000 is treated as invalid.
  • For outgoing calls with a 7-digit number, the authenticated user’s area code may be prepended automatically.
  • If a call already exists for the same user, phone number, call type, and start time, a new record is not created. If the duration differs, the existing call’s duration is updated and new_call is set to 0.
  • Field-level validation failures typically return HTTP 200 with details in the errors object and an empty results value.
  • Invalid JSON in the request body returns HTTP 400.

Error Responses

Status Code Meaning
200 Validation issue – The phone number, start time, or call type is missing or invalid.
400 Bad Request – The JSON payload is invalid or required call data is missing.
401 Unauthorized – The API key and/or secret is missing, invalid, inactive, associated with a disabled account, or lacks permission to create calls.
405 Method Not Allowed – A method other than POST was used.
500 Internal Server Error – An unexpected server problem occurred. Not specified in Swagger.

400 response body example:

{
  "results": [],
  "errors": ["Invalid json data"],
  "code": 400
}

200 validation response example:

{
  "results": [],
  "errors": {
    "number": "Valid number required",
    "start_time": "Valid Start time required",
    "call_type": "Valid call type required"
  },
  "code": 200
}

401 response body example:

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

405 response body example:

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