API:Contact:Files:New

From docs
Jump to: navigation, search

API » Add Contact File

Base URL

https://app.callproof.com

Endpoint

/api/contact/files/new/

Purpose

Uploads a file and associates it with a specific contact. The file can optionally be shared with selected users in the same CallProof company.

HTTP Method

POST

Headers

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

Security

  • Yes – Requires valid API credentials with permission to create contact records.

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 the CallProof account.
api_key.secret string Yes Private API secret paired with the API key.
files_data object Yes File upload details.
files_data.contact_id integer Yes Identifier of the contact to associate with the file. The contact must belong to the authenticated company.
files_data.file string Yes Base64-encoded file contents.
files_data.file_name string Yes Name under which the file will be stored.
files_data.user_ids array of integers No User identifiers with whom the file should be shared. Defaults to an empty list.

cURL Example

curl -X POST "https://app.callproof.com/api/contact/files/new/" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": {
      "key": "YOUR_API_KEY",
      "secret": "YOUR_API_SECRET"
    },
    "files_data": {
      "contact_id": 789,
      "file": "JVBERi0xLjQKJc...",
      "file_name": "proposal.pdf",
      "user_ids": []
    }
  }'

Successful Response (200)

Indicates that the file was uploaded and associated with the specified contact. The response contains the uploaded file and its sharing details.

Field Type Description
results array Uploaded file records.
results[].user_file_id integer Unique identifier of the uploaded file.
results[].name string Stored file name.
results[].rep object or null Profile of the user who uploaded the file.
results[].rep.id integer Uploader’s profile identifier.
results[].rep.email string Uploader’s email address.
results[].rep.user_id integer Uploader’s user identifier.
results[].rep.fullname string Uploader’s full name.
results[].rep.title string Uploader’s job title.
results[].rep.updated string Date and time the uploader’s profile was last updated.
results[].url string URL from which the file can be accessed.
results[].is_shared string 1 when shared with at least one user; otherwise 0.
results[].reps array Profiles of users with whom the file is shared.
results[].updated string Date and time the file record was last updated (YYYY-MM-DD HH:MM:SS).
results[].created string Date and time the file record was created (YYYY-MM-DD HH:MM:SS).
errors object Empty object when the request succeeds.
code integer Response status value; 200 on success.

Example response:

{
  "results": [
    {
      "user_file_id": 501,
      "name": "proposal.pdf",
      "rep": {
        "id": 123,
        "email": "rep@example.com",
        "user_id": 456,
        "fullname": "Jane Smith",
        "title": "Account Executive",
        "updated": "2024-06-01 10:00:00"
      },
      "url": "/user_files/ab/cd/ef/gh/abcdef...",
      "is_shared": "0",
      "reps": [],
      "updated": "2024-06-15 14:30:00",
      "created": "2024-06-15 14:30:00"
    }
  ],
  "errors": {},
  "code": 200
}

Notes

  • File contents must be Base64 encoded before being placed in files_data.file.
  • The specified contact must belong to the authenticated company.
  • The authenticated user is recorded as the file uploader.
  • user_ids is optional. If omitted, the file is not shared with other users.
  • Only users belonging to the authenticated company are added to the sharing list.
  • Invalid, unknown, or out-of-company values in user_ids are skipped without producing an error.
  • This endpoint accepts one file per request.

Error Responses

Status Code Meaning
400 Bad Request – The JSON payload is invalid or the required file details are missing or invalid.
401 Unauthorized – The API credentials are missing, invalid, inactive, associated with a disabled account, or lack permission to create contact records.
405 Method Not Allowed – A method other than POST was used.
500 Internal Server Error – The file could not be decoded or saved, or another unexpected problem occurred. Not specified in Swagger.

400 invalid JSON response example:

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

200 field-validation response example:

{
  "results": [],
  "errors": {
    "contact_id": ["Invalid 'contact' field"],
    "file": ["Invalid 'file' field"]
  },
  "code": 200
}

401 response example:

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

405 response example:

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