Difference between revisions of "API:Contact:Files:New"
Ashley DeBon (talk | contribs) |
Ashley DeBon (talk | contribs) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | == [[API]] » | + | == [[API]] » Add Contact File == |
| − | |||
| − | |||
=== Base URL === | === Base URL === | ||
| Line 7: | Line 5: | ||
=== Endpoint === | === Endpoint === | ||
| − | /api/contact/new/ | + | /api/contact/files/new/ |
=== Purpose === | === 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 === | === HTTP Method === | ||
| Line 23: | Line 21: | ||
=== Security === | === Security === | ||
| − | * '''Yes''' – Requires | + | * '''Yes''' – Requires valid API credentials with permission to create contact records. |
=== Parameters === | === Parameters === | ||
| Line 37: | Line 35: | ||
! Parameter !! Type !! Required !! Description | ! Parameter !! Type !! Required !! Description | ||
|- | |- | ||
| − | | api_key || object || Yes || Authentication credentials | + | | api_key || object || Yes || Authentication credentials. |
|- | |- | ||
| − | | api_key.key || string || Yes || Public API key assigned to | + | | 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. | | 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 Example === | ||
<pre> | <pre> | ||
| − | curl -X POST "https://app.callproof.com/api/contact/new/" \ | + | curl -X POST "https://app.callproof.com/api/contact/files/new/" \ |
-H "Content-Type: application/json" \ | -H "Content-Type: application/json" \ | ||
-d '{ | -d '{ | ||
| Line 111: | Line 61: | ||
"secret": "YOUR_API_SECRET" | "secret": "YOUR_API_SECRET" | ||
}, | }, | ||
| − | " | + | "files_data": { |
| − | " | + | "contact_id": 789, |
| − | " | + | "file": "JVBERi0xLjQKJc...", |
| − | + | "file_name": "proposal.pdf", | |
| − | + | "user_ids": [] | |
| − | " | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | " | ||
} | } | ||
}' | }' | ||
| Line 129: | Line 71: | ||
=== Successful Response (200) === | === Successful Response (200) === | ||
| − | Indicates the contact | + | Indicates that the file was uploaded and associated with the specified contact. The response contains the uploaded file and its sharing details. |
{| class="wikitable" | {| class="wikitable" | ||
! Field !! Type !! Description | ! Field !! Type !! Description | ||
|- | |- | ||
| − | | results || | + | | results || array || Uploaded file records. |
|- | |- | ||
| − | | results. | + | | results[].user_file_id || integer || Unique identifier of the uploaded file. |
|- | |- | ||
| − | | results. | + | | results[].name || string || Stored file name. |
|- | |- | ||
| − | | results. | + | | results[].rep || object or null || Profile of the user who uploaded the file. |
|- | |- | ||
| − | | results. | + | | results[].rep.id || integer || Uploader’s profile identifier. |
|- | |- | ||
| − | | results. | + | | results[].rep.email || string || Uploader’s email address. |
|- | |- | ||
| − | | results. | + | | results[].rep.user_id || integer || Uploader’s user identifier. |
|- | |- | ||
| − | | results. | + | | results[].rep.fullname || string || Uploader’s full name. |
|- | |- | ||
| − | | results.title || string || | + | | results[].rep.title || string || Uploader’s job title. |
|- | |- | ||
| − | | results. | + | | results[].rep.updated || string || Date and time the uploader’s profile was last updated. |
|- | |- | ||
| − | | results. | + | | results[].url || string || URL from which the file can be accessed. |
|- | |- | ||
| − | | results. | + | | results[].is_shared || string || <code>1</code> when shared with at least one user; otherwise <code>0</code>. |
|- | |- | ||
| − | | results. | + | | results[].reps || array || Profiles of users with whom the file is shared. |
|- | |- | ||
| − | | results. | + | | results[].updated || string || Date and time the file record was last updated (<code>YYYY-MM-DD HH:MM:SS</code>). |
|- | |- | ||
| − | | results. | + | | results[].created || string || Date and time the file record was created (<code>YYYY-MM-DD HH:MM:SS</code>). |
|- | |- | ||
| − | | | + | | errors || object || Empty object when the request succeeds. |
|- | |- | ||
| − | + | | code || integer || Response status value; <code>200</code> on success. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | | code || integer || | ||
|} | |} | ||
| + | |||
| + | Example response: | ||
| + | <pre> | ||
| + | { | ||
| + | "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 | ||
| + | } | ||
| + | </pre> | ||
=== Notes === | === Notes === | ||
| − | * <code> | + | * File contents must be Base64 encoded before being placed in <code>files_data.file</code>. |
| − | * | + | * The specified contact must belong to the authenticated company. |
| − | * The | + | * The authenticated user is recorded as the file uploader. |
| − | * | + | * <code>user_ids</code> 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 <code>user_ids</code> are skipped without producing an error. |
| − | * | + | * This endpoint accepts one file per request. |
| − | |||
| − | * | ||
=== Error Responses === | === Error Responses === | ||
| Line 218: | Line 151: | ||
! Status Code !! Meaning | ! 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, lack permission to create | + | | 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. | | 405 || Method Not Allowed – A method other than POST was used. | ||
|- | |- | ||
| − | | 500 || Internal Server Error – | + | | 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:''' |
<pre> | <pre> | ||
{ | { | ||
| − | "results": | + | "results": [], |
| − | "errors": [ | + | "errors": ["Invalid json data"], |
| − | + | "code": 400 | |
| − | |||
| − | |||
| − | "code": | ||
} | } | ||
</pre> | </pre> | ||
| − | ''' | + | '''200 field-validation response example:''' |
<pre> | <pre> | ||
{ | { | ||
"results": [], | "results": [], | ||
| − | "errors": ["Invalid | + | "errors": { |
| − | "code": | + | "contact_id": ["Invalid 'contact' field"], |
| + | "file": ["Invalid 'file' field"] | ||
| + | }, | ||
| + | "code": 200 | ||
} | } | ||
</pre> | </pre> | ||
| + | '''401 response example:''' | ||
<pre> | <pre> | ||
{ | { | ||
"results": [], | "results": [], | ||
| − | "errors": [" | + | "errors": ["Invalid API Key"], |
"code": 401 | "code": 401 | ||
} | } | ||
</pre> | </pre> | ||
| − | '''405 response | + | '''405 response example:''' |
<pre> | <pre> | ||
{ | { | ||
Latest revision as of 11:05, 17 July 2026
Contents
API » Add Contact File
Base URL
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_idsis 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_idsare 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
}