Document Management

Document Management API

The Document Management API allows you to manage documents and files in your TaskIP CRM system. You can upload, organize, share, and track documents with version control, access permissions, and collaboration features.

Endpoints Overview

MethodEndpointDescription
GET/api/public-v1/documentGet all documents
POST/api/public-v1/documentUpload a new document
GET/api/public-v1/document/{id}Get a specific document
PUT/api/public-v1/document/{id}Update document metadata
DELETE/api/public-v1/document/{id}Delete a document
GET/api/public-v1/document/{id}/downloadDownload document file

Get All Documents

Retrieve a list of all documents in your system.

GET /api/public-v1/document

Request Headers

X-Secret-Key: your-secret-key-here
Content-Type: application/json

Query Parameters

ParameterTypeRequiredDescription
pageintegerNoPage number for pagination (default: 1)
limitintegerNoNumber of documents per page (default: 50)
searchstringNoSearch term for document name or content
sortstringNoSort field (name, size, created_at, updated_at)
orderstringNoSort order (asc or desc)
folder_idintegerNoFilter by folder ID
file_typestringNoFilter by file type (pdf, doc, image, spreadsheet)
owner_idintegerNoFilter by document owner
shared_with_mebooleanNoShow only documents shared with current user
date_fromstringNoFilter documents from date (YYYY-MM-DD)
date_tostringNoFilter documents to date (YYYY-MM-DD)

Example Request

curl -X GET "https://public-api.taskip.net/api/public-v1/document?page=1&limit=20&folder_id=5&file_type=pdf" \
  -H "X-Secret-Key: your-secret-key-here" \
  -H "Content-Type: application/json"

JavaScript Example

const response = await fetch('https://public-api.taskip.net/api/public-v1/document?page=1&limit=20', {
  method: 'GET',
  headers: {
    'X-Secret-Key': 'your-secret-key-here',
    'Content-Type': 'application/json'
  }
});
 
const documents = await response.json();

Example Response

{
  "status": 200,
  "data": [
    {
      "id": 1,
      "uuid": "doc_abc123def456",
      "created_by": {
        "id": 3,
        "name": "Sarah Johnson",
        "image": {
          "id": 15,
          "original_url": "https://storage.googleapis.com/files/profile.jpg"
        },
        "type": "user",
        "email": "sarah@company.com",
        "contact_id": null
      },
      "folder": {
        "id": 5,
        "uuid": "folder_xyz789",
        "name": "Proposals"
      },
      "name": "Project Proposal - Acme Corp",
      "visibility": {
        "id": 1,
        "label": "Team"
      },
      "permissions": [
        {
          "id": 1,
          "document_id": 1,
          "user_id": 8,
          "access_type": 2,
          "user": {
            "name": "David Chen",
            "image": {
              "id": 20,
              "original_url": "https://storage.googleapis.com/files/david.jpg"
            },
            "type": "user",
            "email": "david@company.com",
            "contact_id": null
          }
        }
      ],
      "created_at": "Jan 15, 2024, 9:30 AM",
      "access": "Owner",
      "publish": null,
      "teams": []
    },
    {
      "id": 2,
      "uuid": "doc_ghi789jkl012",
      "created_by": {
        "id": 5,
        "name": "Mike Wilson",
        "image": {
          "id": 25,
          "original_url": "https://storage.googleapis.com/files/mike.jpg"
        },
        "type": "user",
        "email": "mike@company.com",
        "contact_id": null
      },
      "folder": {
        "id": 8,
        "uuid": "folder_def456",
        "name": "Templates"
      },
      "name": "Contract Template",
      "visibility": {
        "id": 2,
        "label": "Public"
      },
      "permissions": [],
      "created_at": "Jan 10, 2024, 11:15 AM",
      "access": "View",
      "publish": "https://workspace.taskip.net/document/contract-template-abc123",
      "teams": []
    }
  ]
}

Upload a New Document

Upload a new document to your system.

POST /api/public-v1/document

Request Headers

X-Secret-Key: your-secret-key-here
Content-Type: multipart/form-data

Request Body

FieldTypeRequiredDescription
namestringYesDocument name (max 191 characters)
visibilityintegerYesVisibility level (0=Private, 1=Team, 2=Public)
folder_idstringNoUUID of folder to place document in

Example Request

curl -X POST "https://public-api.taskip.net/api/public-v1/document" \
  -H "X-Secret-Key: your-secret-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Project Requirements - TechCorp",
    "visibility": 1,
    "folder_id": "folder_xyz789"
  }'

JavaScript Example

const response = await fetch('https://public-api.taskip.net/api/public-v1/document', {
  method: 'POST',
  headers: {
    'X-Secret-Key': 'your-secret-key-here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Project Requirements - TechCorp',
    visibility: 1,
    folder_id: 'folder_xyz789'
  })
});
 
const result = await response.json();

Example Response

{
  "status": 200,
  "msg": "Document Created Successfully",
  "document": {
    "id": 126,
    "uuid": "doc_mno345pqr678",
    "created_by": {
      "id": 3,
      "name": "Current User",
      "image": {
        "id": 30,
        "original_url": "https://storage.googleapis.com/files/current-user.jpg"
      },
      "type": "user",
      "email": "current@company.com",
      "contact_id": null
    },
    "folder": {
      "id": 5,
      "uuid": "folder_xyz789",
      "name": "Proposals"
    },
    "name": "Project Requirements - TechCorp",
    "visibility": {
      "id": 1,
      "label": "Team"
    },
    "permissions": [],
    "created_at": "Jan 20, 2024, 10:30 AM",
    "access": "Owner",
    "publish": null,
    "teams": []
  }
}

Get a Specific Document

Retrieve details of a specific document by ID.

GET /api/public-v1/document/{id}

Path Parameters

ParameterTypeRequiredDescription
idintegerYesDocument ID

Example Request

curl -X GET "https://public-api.taskip.net/api/public-v1/document/126" \
  -H "X-Secret-Key: your-secret-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "success": true,
  "data": {
    "id": 126,
    "name": "Project Requirements - TechCorp",
    "original_filename": "project-requirements.pdf",
    "file_type": "pdf",
    "file_size": 1572864,
    "mime_type": "application/pdf",
    "folder_id": 5,
    "folder": {
      "id": 5,
      "name": "Proposals",
      "path": "/Documents/Proposals"
    },
    "owner_id": 3,
    "owner": {
      "id": 3,
      "name": "Sarah Johnson",
      "email": "sarah@company.com"
    },
    "description": "Detailed requirements document for TechCorp project",
    "tags": ["requirements", "project", "techcorp"],
    "version": "1.0",
    "is_public": false,
    "download_count": 8,
    "file_hash": "sha256:abc123def456...",
    "permissions": {
      "can_view": true,
      "can_edit": true,
      "can_delete": true,
      "can_share": true
    },
    "shared_with": [
      {
        "user_id": 8,
        "user_name": "David Chen",
        "permission": "edit",
        "shared_at": "2024-01-20T11:00:00Z"
      }
    ],
    "recent_activity": [
      {
        "action": "downloaded",
        "user": "Mike Wilson",
        "timestamp": "2024-01-21T09:15:00Z"
      },
      {
        "action": "shared",
        "user": "Sarah Johnson",
        "details": "Shared with David Chen",
        "timestamp": "2024-01-20T11:00:00Z"
      }
    ],
    "created_at": "2024-01-20T10:30:00Z",
    "updated_at": "2024-01-20T10:30:00Z"
  }
}

Update Document Metadata

Update an existing document's metadata (name, description, etc.).

PUT /api/public-v1/document/{id}

Path Parameters

ParameterTypeRequiredDescription
idintegerYesDocument ID to update

Request Body

FieldTypeRequiredDescription
namestringNoDocument name
descriptionstringNoDocument description
folder_idintegerNoMove to different folder
tagsarrayNoArray of tags
is_publicbooleanNoPublic access setting

Example Request

curl -X PUT "https://public-api.taskip.net/api/public-v1/document/126" \
  -H "X-Secret-Key: your-secret-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Project Requirements - TechCorp (Updated)",
    "description": "Updated requirements document with latest changes",
    "tags": ["requirements", "project", "techcorp", "updated"]
  }'

Example Response

{
  "success": true,
  "message": "Document updated successfully",
  "data": {
    "id": 126,
    "name": "Project Requirements - TechCorp (Updated)",
    "description": "Updated requirements document with latest changes",
    "tags": ["requirements", "project", "techcorp", "updated"],
    "created_at": "2024-01-20T10:30:00Z",
    "updated_at": "2024-01-21T14:15:00Z"
  }
}

Delete a Document

Delete a specific document from your system.

DELETE /api/public-v1/document/{id}

Path Parameters

ParameterTypeRequiredDescription
idintegerYesDocument ID to delete
⚠️

Warning: Deleting a document will permanently remove the file and all associated metadata, versions, and comments. This action cannot be undone.

Example Request

curl -X DELETE "https://public-api.taskip.net/api/public-v1/document/126" \
  -H "X-Secret-Key: your-secret-key-here"

Example Response

{
  "msg": "Document deleted successfully",
  "status": 200
}

Download Document File

Download the actual document file.

GET /api/public-v1/document/{id}/download

Path Parameters

ParameterTypeRequiredDescription
idintegerYesDocument ID to download

Query Parameters

ParameterTypeRequiredDescription
versionstringNoSpecific version to download (defaults to latest)

Example Request

curl -X GET "https://public-api.taskip.net/api/public-v1/document/125/download" \
  -H "X-Secret-Key: your-secret-key-here" \
  -O -J

JavaScript Example (with Blob)

const response = await fetch('https://public-api.taskip.net/api/public-v1/document/125/download', {
  method: 'GET',
  headers: {
    'X-Secret-Key': 'your-secret-key-here'
  }
});
 
if (response.ok) {
  const blob = await response.blob();
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = 'document.pdf';
  document.body.appendChild(a);
  a.click();
  window.URL.revokeObjectURL(url);
}

Response

The response will be a PDF file generated from the document content with appropriate headers:

Content-Type: application/pdf
Content-Disposition: attachment; filename="document-name.pdf"

The Laravel backend generates the PDF using:

return pdf()
    ->margins(top: 20, right: 20, bottom: 10, left: 20)
    ->format('a4')
    ->landscape(false)
    ->view('document::PDF.template', compact('content', 'title'))
    ->name($pdName);

Error Responses

Common Error Codes

Status CodeError TypeDescription
400Bad RequestInvalid request data or missing required fields
401UnauthorizedInvalid or missing X-Secret-Key
403ForbiddenInsufficient permissions to access document
404Not FoundDocument not found
409ConflictDocument name already exists in folder
413Payload Too LargeFile size exceeds limit
422Validation ErrorRequest data failed validation
429Too Many RequestsRate limit exceeded

Example Error Response

{
  "success": false,
  "error": "Validation Error",
  "message": "The given data was invalid",
  "errors": {
    "file": ["The file field is required."],
    "folder_id": ["The selected folder id is invalid."],
    "name": ["The name may not be greater than 255 characters."]
  },
  "status_code": 422
}

Response Schemas

Document Object

{
  "id": "integer",
  "name": "string",
  "original_filename": "string",
  "file_type": "string",
  "file_size": "integer",
  "mime_type": "string",
  "folder_id": "integer|null",
  "folder_name": "string|null",
  "owner_id": "integer",
  "owner_name": "string",
  "description": "string|null",
  "tags": "array",
  "version": "string",
  "is_public": "boolean",
  "download_count": "integer",
  "file_hash": "string",
  "shared_with": "array",
  "created_at": "string (ISO 8601)",
  "updated_at": "string (ISO 8601)"
}

Folder Object

{
  "id": "integer",
  "name": "string",
  "parent_id": "integer",
  "path": "string",
  "document_count": "integer",
  "subfolders": "array",
  "created_at": "string (ISO 8601)",
  "updated_at": "string (ISO 8601)"
}

Comment Object

{
  "id": "integer",
  "comment": "string",
  "author": "string",
  "author_id": "integer",
  "is_private": "boolean",
  "mentions": "array",
  "replies": "array",
  "created_at": "string (ISO 8601)"
}

Best Practices

Document Organization

  1. Folder structure: Create a logical folder hierarchy for better organization
  2. Naming conventions: Use consistent, descriptive file names
  3. Tagging strategy: Implement a standardized tagging system for easy discovery
  4. Version control: Use version notes to document changes between versions

Security & Access Control

  1. Permission management: Set appropriate permissions for document sharing
  2. Expiration dates: Use expiration dates for temporary document sharing
  3. Private comments: Use private comments for internal notes and feedback
  4. Access monitoring: Monitor document access and download activity

Storage Management

  1. File size limits: Keep file sizes reasonable for better performance
  2. Regular cleanup: Archive or delete outdated documents
  3. Storage monitoring: Monitor storage usage and plan for capacity
  4. Duplicate prevention: Check for duplicate files before uploading
💡

Tip: Use the search endpoint with content indexing to find documents based on their actual content, not just filenames. This is particularly useful for finding information within PDFs and Word documents.