# Upsert a customer

Creates or updates (upserts) a customer with a specified ID.

If the customer already has an identifier within your system,
and you want to create a customer with a specified ID &mdash; use this operation to prevent duplicate customers.
For more information, see Prevent duplicate customers.

Endpoint: PUT /customers/{id}
Version: latest
Security: SecretApiKey, JWT

## Path parameters:

  - `id` (string, required)
    ID of the resource.

## Request fields (application/json):

  - `websiteId` (string)
    ID of the website.
A website is where an organization obtains a customer.
For more information, see [Obtain an organization ID and website ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
    Example: "web_0YV7DE4Z26DQSA1AC92FBJ7SEG"

  - `paymentToken` (string)
    Write-only payment token.
If supplied, the token is converted into a payment instrument and set as the defaultPaymentInstrument value.
If both are supplied, the value of this property overrides the defaultPaymentInstrument value.
The token expires after first use.

  - `defaultPaymentInstrument` (object,null)

  - `preferredPayoutInstrumentId` (string,null)
    ID of the customer's preferred payment instrument for payouts.
    Example: "inst_0YVB8KPKNXCBR9EDX7JHSED75N"

  - `customFields` (object)
    Use custom fields to extend a resource scheme to include custom data that is not provided as a common field.
For more information, see [Custom fields](https://www.rebilly.com/catalog/all/custom-fields).

  - `primaryAddress` (any)
    Customer's primary address.

  - `locale` (string,null)
    Language locale identifier in [RFC 5646](https://tools.ietf.org/html/rfc5646) format.
    Example: "fr-FR"

  - `taxNumbers` (array,null)
    Tax numbers of the customer.

  - `taxNumbers.type` (string, required)
    Type of the tax number.
    Enum: "eu-vat", "other"

  - `taxNumbers.value` (string, required)
    Value of the tax number.
    Example: "GB980780684"

  - `taxNumbers.isDefault` (boolean)
    Determines if the tax number is selected as default to display on invoices.
    Example: true

  - `leadSource` (object)
    Lead source information.

  - `leadSource.medium` (string,null)
    Category of the lead source traffic.
For example, the medium could be organic search, Google ads, Display ads, and so on.

  - `leadSource.source` (string,null)
    Domain, platform, or channel from which the lead source originates.

  - `leadSource.campaign` (string,null)
    Campaign name of the lead source.

  - `leadSource.term` (string,null)
    Term associated with a lead source.

  - `leadSource.content` (string,null)
    Content contained in the lead source content.
For example, content could be graphics, video, and so on.

  - `leadSource.affiliate` (string,null)
    Individual or entity that is affiliated with the lead source.

  - `leadSource.subAffiliate` (string,null)
    Individual or entity that is associated with a lead source affiliate.
In other products, this field may also be referred to as sub ID or click ID in some.

  - `leadSource.salesAgent` (string,null)
    Name of the sales agent associated with the lead source.

  - `leadSource.clickId` (string,null)
    ID of the lead source click.
This value is passed in the ad click URL for tracking and campaign attribution.

  - `leadSource.path` (string,null)
    URL from which the lead source originates.

  - `leadSource.referrer` (string,null)
    Lead source [referrer URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer).
    Example: "https://www.rebilly.com"

  - `personId` (string,null)
    ID of the associated person.
    Example: "prs_0YV7DDSDD1C8DA64KHH2W33CPF"

  - `notificationEmails` (array)
    Additional email addresses for notification delivery.

## Response 401 fields (application/json):

  - `status` (integer)
    HTTP status code.

  - `type` (string)
    Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
It should provide human-readable documentation for the problem type.
When this member is not present, its value is assumed to be "about:blank".

  - `title` (string)
    Short, human-readable summary of the problem type.
Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.

  - `detail` (string)
    Human-readable explanation that is specific to this occurrence of the problem.

  - `instance` (string)
    URI reference that identifies the specific occurrence of the problem.
It may or may not yield further information if dereferenced.

## Response 403 fields (application/json):

  - `status` (integer)
    HTTP status code.

  - `type` (string)
    Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
It should provide human-readable documentation for the problem type.
When this member is not present, its value is assumed to be "about:blank".

  - `title` (string)
    Short, human-readable summary of the problem type.
Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.

  - `detail` (string)
    Human-readable explanation that is specific to this occurrence of the problem.

  - `instance` (string)
    URI reference that identifies the specific occurrence of the problem.
It may or may not yield further information if dereferenced.

## Response 409 fields (application/json):

  - `status` (integer)
    HTTP status code.

  - `type` (string)
    Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
It should provide human-readable documentation for the problem type.
When this member is not present, its value is assumed to be "about:blank".

  - `title` (string)
    Short, human-readable summary of the problem type.
Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.

  - `detail` (string)
    Human-readable explanation that is specific to this occurrence of the problem.

  - `instance` (string)
    URI reference that identifies the specific occurrence of the problem.
It may or may not yield further information if dereferenced.

## Response 422 fields (application/json):

  - `status` (integer)
    HTTP status code.

  - `type` (string)
    Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
It should provide human-readable documentation for the problem type.
When this member is not present, its value is assumed to be "about:blank".

  - `title` (string)
    Short, human-readable summary of the problem type.
Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.

  - `detail` (string)
    Human-readable explanation that is specific to this occurrence of the problem.

  - `instance` (string)
    URI reference that identifies the specific occurrence of the problem.
It may or may not yield further information if dereferenced.

  - `invalidFields` (array)
    Invalid field details.

  - `invalidFields.field` (string)
    Name of the field.
Dot notation is used for nested object field names.

  - `invalidFields.message` (string)
    Message field.

## Response 429 fields (application/json):

  - `type` (string)
    Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
It should provide human-readable documentation for the problem type.
When this member is not present, its value is assumed to be "about:blank".
    Example: "about:blank"

  - `title` (string)
    Short, human-readable summary of the problem type.
Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
    Example: "Rate Limit Exceeded"

  - `status` (integer)
    HTTP status code.

  - `detail` (string)
    Human-readable explanation that is specific to this occurrence of the problem.
    Example: "A request cannot be executed because the user has sent too many requests within a certain period of time"

  - `instance` (string)
    URI reference that identifies the specific occurrence of the problem.
It may or may not yield further information if dereferenced.


