Skip to content

Cannot create a Contact with email, external_id and role in a single API call #404

@rserry

Description

@rserry

ContactsClient::create() accepts a union of three mutually-exclusive request types:

public function create(
    CreateContactRequestWithEmail
    |CreateContactRequestWithExternalId
    |CreateContactRequestWithRole $request,
    ?array $options = null
): ContactsCreateResponse

Each type carries only one of the three identifiers. There is no request class that lets you create a contact with all three populated in the same POST /contacts body.

The REST endpoint itself accepts them together, so this is a property of the SDK's generated types, not the API.

The forced workaround I have to use is this two-step create-then-update:

  1. POST /contacts with email only via CreateContactRequestWithEmail
  2. PATCH /contacts/{id} with external_id + role + everything else

Solution: a request that merges the different bodies:

$request = new CreateContactRequest([
    'email'      => 'jane@example.com',
    'externalId' => 'app-user-1234',
    'role'       => 'user',
    'name'       => 'Jane',
]);
$client->contacts->create($request);

This was possible in the previous v4 sdk.
I use the latest sdk version.

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