PHP code example of mindtwo / laravel-clickup-api

1. Go to this page and download the library: Download mindtwo/laravel-clickup-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mindtwo / laravel-clickup-api example snippets


use Mindtwo\LaravelClickUpApi\Facades\ClickUpClient as ClickUp;

// Tasks
ClickUp::tasks()->create($listId, $taskDetails);
ClickUp::tasks()->index($listId, $filters);
ClickUp::tasks()->show($taskId);
ClickUp::tasks()->update($taskId, $updates);
ClickUp::tasks()->delete($taskId);

// Spaces
ClickUp::spaces()->index($teamId);
ClickUp::spaces()->create($teamId, $spaceDetails);

// Folders
ClickUp::folders()->index($spaceId);
ClickUp::folders()->create($spaceId, $folderDetails);

// Lists
ClickUp::lists()->index($folderId);
ClickUp::lists()->create($folderId, $listDetails);

// Custom Fields
ClickUp::customFields()->show($listId);
ClickUp::customFields()->set($taskId, $fieldId, $value);

// Attachments
ClickUp::attachments()->create($taskId, $fileData);

// Subtasks
ClickUp::subtasks()->create($taskId, $subtaskDetails);

// Milestones
ClickUp::milestones()->create($listId, $milestoneDetails);

// Task Dependencies
ClickUp::dependencies()->add($taskId, $dependsOn, $dependencyType);
ClickUp::dependencies()->remove($taskId, $dependsOn, $dependencyType);

// Task Links
ClickUp::links()->create($taskId, $linksTo);
ClickUp::links()->remove($taskId, $linksTo);

app(\Mindtwo\LaravelClickUpApi\Http\Endpoints\Task::class)->create($listId, $taskDetails);

use Mindtwo\LaravelClickUpApi\Facades\ClickUpClient as ClickUp;

   $taskDetails = [
       'name' => 'New Task', // Mandatory
       'description' => 'Task description', // Optional
       // Add other task details as needed
   ];

   $task = ClickUp::tasks()->create($listId, $taskDetails);
   

   $tasks = ClickUp::tasks()->index($listId, []);
   

   $task = ClickUp::tasks()->show($taskId);
   

   $updatedDetails = [
       'name' => 'Updated Task Name',
       // Other task details you want to update
   ];

   $updatedTask = ClickUp::tasks()->update($taskId, $updatedDetails);
   

   $response = ClickUp::tasks()->delete($taskId);
   



use Mindtwo\LaravelClickUpApi\Facades\ClickUpClient as ClickUp;

// Assuming $taskId holds the ID of the task you want to attach a file to
// and $data contains the file and other ther data fields as 

// Import the ClickUp facade at the top of your PHP file
use Mindtwo\LaravelClickUpApi\Facades\ClickUpClient as ClickUp;

// Assuming you have a list ID, you can retrieve its custom fields like so:
$listId = 'your_list_id_here'; // Replace with your actual list ID

// Fetch the custom fields for the specified list
$customFields = ClickUp::customFields()->show($listId);

// $customFields now contains the response from ClickUp API

use Mindtwo\LaravelClickUpApi\Http\Middleware\VerifyClickUpWebhookSignature;

return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'clickup.webhook' => VerifyClickUpWebhookSignature::class,
        ]);
    })
    // ...
    ->create();

protected $middlewareAliases = [
    // ... other middleware
    'clickup.webhook' => \Mindtwo\LaravelClickUpApi\Http\Middleware\VerifyClickUpWebhookSignature::class,
];

// In your routes/web.php or routes/api.php
Route::post('/webhooks/clickup', [WebhookController::class, 'handle'])
    ->middleware('clickup.webhook');

use Mindtwo\LaravelClickUpApi\Facades\ClickUpClient as ClickUp;

// Create a webhook - secret is automatically captured
$response = ClickUp::webhooks()->create($workspaceId, [
    'endpoint' => 'https://your-app.com/webhooks/clickup',
    'events' => ['taskCreated', 'taskUpdated'],
]);

// The webhook secret is stored in the database
$webhook = $response['webhook'];
// Secret is available at: $webhook['secret']

protected function schedule(Schedule $schedule): void
{
    // Check ClickUp webhook health every hour
    $schedule->job(\Mindtwo\LaravelClickUpApi\Jobs\CheckWebhookHealth::class)
        ->hourly()
        ->name('clickup-webhook-health-check')
        ->withoutOverlapping();
}
bash
php artisan vendor:publish --tag="clickup-api-config"
bash
php artisan vendor:publish --tag="clickup-api-migrations"
php artisan migrate
bash
php artisan clickup:webhook-recover {webhook_id}