Skip to content

Task creation fails with validation error on hs_timestamp property in v14.0 #620

Description

@cristof-g

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:

  1. Install hubspot/api-client v14.0
  2. 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:

  1. String of Unix milliseconds: "1781773200000" (works via HTTP, fails via SDK)
  2. Integer Unix milliseconds: 1781773200000 (works via HTTP, fails via SDK)
  3. ISO 8601 with milliseconds: "2026-06-18T09:00:00.000Z" (works via HTTP, fails via SDK)
  4. 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.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions