When attempting to create a task using the tasks()->basicApi()->create() method in version 14.0 of the PHP SDK, the API consistently returns a 400 validation error indicating that the required property hs_timestamp was not set, even though it is correctly included in the properties array.
The same payload works perfectly when sent directly via HTTP client (e.g., Laravel's Http::post() or cURL), suggesting a serialization issue within the SDK when preparing the request for the Tasks endpoint.
Environment:
- SDK Version:
hubspot/api-client v14.0
- Endpoint:
POST /crm/v3/objects/tasks
Steps to Reproduce:
- Install
hubspot/api-client v14.0
- Attempt to create a task using the SDK:
use HubSpot\Factory;
use HubSpot\Client\Crm\Objects\Model\SimplePublicObjectInputForCreate;
$client = Factory::createWithAccessToken($accessToken);
$properties = [
'hs_task_subject' => 'Task Example',
'hs_task_body' => 'Body text.',
'hs_timestamp' => '1781773200000', // Unix timestamp in milliseconds as string
'hs_task_status' => 'NOT_STARTED',
'hs_task_priority' => 'MEDIUM',
];
$associations = [
[
'to' => ['id' => '9392020334929'],
'types' => [
[
'associationCategory' => 'HUBSPOT_DEFINED',
'associationTypeId' => 204,
],
],
],
];
$taskInput = new SimplePublicObjectInputForCreate([
'properties' => $properties,
'associations' => $associations,
]);
$response = $client->crm()->objects()->tasks()->basicApi()->create($taskInput);
Expected Behavior:
The task should be created successfully and return the task object with an ID.
Actual Behavior:
The API returns a 400 Bad Request error:
{
"status": "error",
"message": "Error creating TASK. Some required properties were not set.",
"correlationId": "019ed794-77c0-746d-8db3-33e8de915f6e",
"context": {
"properties": ["hs_timestamp"]
},
"category": "VALIDATION_ERROR"
}
Tested Formats for hs_timestamp:
We tested multiple formats for hs_timestamp as documented in the HubSpot API, all failed with the SDK but worked via direct HTTP:
- ✅ String of Unix milliseconds:
"1781773200000" (works via HTTP, fails via SDK)
- ✅ Integer Unix milliseconds:
1781773200000 (works via HTTP, fails via SDK)
- ✅ ISO 8601 with milliseconds:
"2026-06-18T09:00:00.000Z" (works via HTTP, fails via SDK)
- ✅ ISO 8601 basic:
"2026-06-18T09:00:00+00:00" (works via HTTP, fails via SDK)
Workaround:
Using Laravel's HTTP client (or any direct HTTP library) instead of the SDK works perfectly:
$payload = [
'properties' => [
'hs_task_subject' => 'Task Example',
'hs_task_body' => 'Body text.',
'hs_timestamp' => '1781773200000',
'hs_task_status' => 'NOT_STARTED',
'hs_task_priority' => 'MEDIUM',
],
'associations' => [
[
'to' => ['id' => '9392020334929'],
'types' => [
[
'associationCategory' => 'HUBSPOT_DEFINED',
'associationTypeId' => 204,
],
],
],
],
];
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json',
])->post('https://api.hubapi.com/crm/v3/objects/tasks', $payload);
// Returns 200 OK with task created successfully
Successful Response:
{
"id": "123123223232",
"properties": {
"hs_task_subject": "Task Example",
"hs_timestamp": "2026-06-18T09:00:00Z",
...
},
"createdAt": "2026-06-18T15:53:41.557Z",
...
}
Analysis:
The issue appears to be in how the SDK serializes the properties object when constructing the request body for the Tasks endpoint. The property is present in the PHP array but is not being correctly transmitted to the HubSpot API.
Other engagement types (notes, calls, emails, meetings) work correctly with the SDK using similar property structures, suggesting this is specific to the Tasks object type.
Additional Context:
- Other CRM object creation methods (contacts, notes, calls, emails, meetings) work correctly with the SDK
- The same HubSpot access token and portal work fine when using direct HTTP requests
- This issue blocks task automation workflows that rely on the SDK
Suggested Fix:
Investigate the serialization logic in SimplePublicObjectInputForCreate or the Tasks-specific API client to ensure properties are correctly encoded in the request body for the /crm/v3/objects/tasks endpoint.
When attempting to create a task using the
tasks()->basicApi()->create()method in version 14.0 of the PHP SDK, the API consistently returns a 400 validation error indicating that the required propertyhs_timestampwas not set, even though it is correctly included in the properties array.The same payload works perfectly when sent directly via HTTP client (e.g., Laravel's
Http::post()or cURL), suggesting a serialization issue within the SDK when preparing the request for the Tasks endpoint.Environment:
hubspot/api-clientv14.0POST /crm/v3/objects/tasksSteps to Reproduce:
hubspot/api-clientv14.0Expected Behavior:
The task should be created successfully and return the task object with an ID.
Actual Behavior:
The API returns a 400 Bad Request error:
{ "status": "error", "message": "Error creating TASK. Some required properties were not set.", "correlationId": "019ed794-77c0-746d-8db3-33e8de915f6e", "context": { "properties": ["hs_timestamp"] }, "category": "VALIDATION_ERROR" }Tested Formats for
hs_timestamp:We tested multiple formats for
hs_timestampas documented in the HubSpot API, all failed with the SDK but worked via direct HTTP:"1781773200000"(works via HTTP, fails via SDK)1781773200000(works via HTTP, fails via SDK)"2026-06-18T09:00:00.000Z"(works via HTTP, fails via SDK)"2026-06-18T09:00:00+00:00"(works via HTTP, fails via SDK)Workaround:
Using Laravel's HTTP client (or any direct HTTP library) instead of the SDK works perfectly:
Successful Response:
{ "id": "123123223232", "properties": { "hs_task_subject": "Task Example", "hs_timestamp": "2026-06-18T09:00:00Z", ... }, "createdAt": "2026-06-18T15:53:41.557Z", ... }Analysis:
The issue appears to be in how the SDK serializes the
propertiesobject when constructing the request body for the Tasks endpoint. The property is present in the PHP array but is not being correctly transmitted to the HubSpot API.Other engagement types (notes, calls, emails, meetings) work correctly with the SDK using similar property structures, suggesting this is specific to the Tasks object type.
Additional Context:
Suggested Fix:
Investigate the serialization logic in
SimplePublicObjectInputForCreateor the Tasks-specific API client to ensure properties are correctly encoded in the request body for the/crm/v3/objects/tasksendpoint.