> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ycloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a contact

> Updates a contact. If every supplied persisted contact field already has
the requested value, the contact is not updated and no
`contact.attributes_changed` event is emitted. Note mutations in the
same request are still applied.



## OpenAPI

````yaml /openapi/endpoints/ycloud-api-v2.yaml patch /contact/contacts/{id}
openapi: 3.0.0
info:
  description: >-
    The [YCloud](https://ycloud.com) API is organized around
    [REST](https://en.wikipedia.org/wiki/Representational_state_transfer). Our
    API is designed to have predictable, resource-oriented URLs, return
    [JSON](https://www.json.org) responses, and use standard HTTP response codes
    and verbs.
  version: v2
  title: YCloud API
  termsOfService: https://ycloud.com/terms-service
  contact:
    email: service@ycloud.com
servers:
  - url: https://api.ycloud.com/v2
    description: Base URL
security:
  - api_key: []
tags:
  - name: Balance
  - name: Contacts
  - name: Custom Events
  - name: Emails
  - name: SMS
  - name: Unsubscribers
  - name: Verify
  - name: Voices
  - name: Webhook Endpoints
  - name: WhatsApp Business Accounts
  - name: WhatsApp Inbound Messages
  - name: WhatsApp Media
  - name: WhatsApp Messages
  - name: WhatsApp Blocked Users
  - name: WhatsApp Groups
  - name: WhatsApp Calling
  - name: WhatsApp Phone Numbers
  - name: WhatsApp Templates
  - name: WhatsApp Flows
  - name: Meta Business Agent
  - name: WhatsApp Group Messages
externalDocs:
  description: Homepage
  url: https://ycloud.com
paths:
  /contact/contacts/{id}:
    patch:
      tags:
        - Contacts
      summary: Update a contact
      description: |-
        Updates a contact. If every supplied persisted contact field already has
        the requested value, the contact is not updated and no
        `contact.attributes_changed` event is emitted. Note mutations in the
        same request are still applied.
      operationId: contact-update
      parameters:
        - $ref: '#/components/parameters/id-in_path_for_contact'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactUpdateRequest'
      responses:
        '200':
          description: Successfully updated the contact.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contact'
        '400':
          description: The notes array, note ID, or note content is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            The contact or referenced contact note does not exist, or the note
            is not owned by the contact.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    id-in_path_for_contact:
      name: id
      in: path
      description: >-
        ID of the contact.

        Also support phone number([E.164](https://en.wikipedia.org/wiki/E.164)
        format, start with character '+'), example: +16315551111
      required: true
      schema:
        type: string
        example: 1693364594105000026/+16315551111
        maxLength: 255
  schemas:
    ContactUpdateRequest:
      type: object
      description: Contains the properties of the contact to be updated.
      properties:
        remarkName:
          type: string
          description: 'Contact''s remark name. Maximum length: 250 characters.'
          example: remark name
          maxLength: 250
        nickname:
          type: string
          deprecated: true
          description: >-
            Deprecated compatibility alias for `remarkName`.

            When `remarkName` is absent, this value is saved as the contact's
            remark name. It does not update the read-only WhatsApp nickname.

            Maximum length: 250 characters.
          example: remark name
          maxLength: 250
        phoneNumber:
          type: string
          description: >-
            Unique Phone number in [E.164](https://en.wikipedia.org/wiki/E.164)
            format.
          example: '+16315551111'
        countryCode:
          type: string
          description: >-
            Two-letter country abbreviation. See [ISO 3166-1 alpha-2 country
            code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
          example: US
        email:
          type: string
          description: |-
            The contact's email address.
            If present, the email address must be unique.
          example: support@example.com
          maxLength: 250
        tags:
          type: array
          description: 'Contact''s tags. Maximum items: 50.'
          maxItems: 50
          items:
            type: string
            description: 'Tag. Maximum length: 50 characters.'
            maxLength: 50
        customAttributes:
          type: array
          description: >-
            Contact's custom attributes.

            If present (i.e., not `null`), all previous attributes of this
            contact will be replaced.
          items:
            $ref: '#/components/schemas/ContactCustomAttribute'
        ownerEmail:
          type: string
          description: The email address of the contact's owner.
          example: support@example.com
          maxLength: 250
        notes:
          type: array
          description: >-
            Optional incremental note mutations. An empty array changes nothing.
            Items without `id` create notes;

            items with `id` update owned notes. Notes not listed remain
            unchanged. Delete notes with the dedicated endpoint.
          maxItems: 50
          items:
            $ref: '#/components/schemas/ContactNoteMutationInput'
    Contact:
      type: object
      description: Represents a contact.
      required:
        - id
      properties:
        id:
          type: string
          description: Unique ID for the object.
          example: 1693364594105000000
          maxLength: 255
        remarkName:
          type: string
          description: The business-managed remark name for the contact.
          example: Priority customer
          maxLength: 250
        nickname:
          type: string
          description: The read-only nickname obtained from WhatsApp.
          example: nickname
        metaUsername:
          type: string
          description: >-
            The read-only Meta username associated with the contact, without the
            leading `@`.
          example: alice_01
        countryCode:
          type: string
          description: >-
            Two-letter country abbreviation. See [ISO 3166-1 alpha-2 country
            code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
          example: US
        countryName:
          type: string
          description: Full country name.
        phoneNumber:
          type: string
          description: >-
            Unique Phone number in [E.164](https://en.wikipedia.org/wiki/E.164)
            format.
          example: '+16315551111'
        email:
          type: string
          description: |-
            The contact's email address.
            If present, the email address must be unique.
          example: support@example.com
        lastSeen:
          type: string
          format: date-time
          description: >-
            The time at which the contact last sent a message to your business,
            formatted in [RFC
            3339](https://datatracker.ietf.org/doc/html/rfc3339). e.g.,
            `2022-06-01T12:00:00.000Z`.
          example: '2022-06-01T12:00:00.000Z'
        lastMessageToPhoneNumber:
          type: string
          description: The business phone number that the contact last sent a message to.
          example: '+16315551111'
        tags:
          type: array
          description: Contact's tags.
          maxItems: 50
          items:
            type: string
            maxLength: 50
        createTime:
          type: string
          format: date-time
          description: >-
            The time at which the contact was created, formatted in [RFC
            3339](https://datatracker.ietf.org/doc/html/rfc3339). e.g.,
            `2022-06-01T12:00:00.000Z`.
          example: '2022-06-01T12:00:00.000Z'
        customAttributes:
          type: array
          description: Contact's custom attributes.
          items:
            $ref: '#/components/schemas/ContactCustomAttribute'
        ownerEmail:
          type: string
          description: The email address of the contact's owner.
          example: support@example.com
          maxLength: 250
        sourceType:
          $ref: '#/components/schemas/ContactSourceType'
          description: >-
            The source type of the contact. Indicates how the contact was
            created.
        sourceId:
          type: string
          description: >-
            Source identifier. A unique identifier related to the contact
            creation source.
          example: batch_import_123
          maxLength: 255
        sourceUrl:
          type: string
          description: Source URL. The source link address where the contact was created.
          example: https://example.com/signup
          maxLength: 500
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
          description: >-
            Contains the error code and human-readable message for the API
            error.
    ContactCustomAttribute:
      type: object
      properties:
        name:
          type: string
          description: Name of the attribute that you've previously defined.
        value:
          type: object
          description: >-
            Value of the attribute.

            Its data type depends on the format of the attribute you defined:

            For Text, the `value` is a string with a maximum length of 250.

            For Array, the `value` is an array of strings with a maximum length
            of 250.

            For Number, the `value` is a signed decimal number.

            For Boolean, the `value` is either `true` or `false`.

            For Time, the `value` is a Unix timestamp in milliseconds.

            For Long Text, the `value` is a string with a maximum length of
            5000.
    ContactNoteMutationInput:
      type: object
      description: >-
        An incremental note mutation for a contact update. When `id` is absent,
        a new note is created.

        When `id` is present, the owned note is updated. Notes omitted from the
        array remain unchanged.
      required:
        - content
      properties:
        id:
          type: string
          description: Existing note ID. Omit to create a new note.
          minLength: 24
          maxLength: 24
          pattern: ^[0-9a-fA-F]{24}$
          example: 6a3de646e18f344f743aaa4d
        content:
          type: string
          description: >-
            Note content. Leading and trailing whitespace is removed before
            validation and storage.
          minLength: 1
          maxLength: 500
          example: Customer now prefers afternoon follow-up.
    ContactSourceType:
      type: string
      description: >-
        Contact source type enumeration values. These are internal type
        identifiers, not the display names shown on the contact page.

        Each enumeration value corresponds to the following display names:

        - WHATSAPP: "Inbound message"

        - GROWTH_TOOL: "Link/QR Code"

        - MANUALLY_ADDED: "Manually added"

        - FILE_IMPORT: "File import"

        - SHOPIFY: "Shopify"

        - API: "API added"

        - AD: "AD"

        - POST: "Post"

        - CALLING: "Calling"

        - SMB: "Whatsapp Business App"

        - UNKNOWN: "Unknown"
      enum:
        - WHATSAPP
        - GROWTH_TOOL
        - MANUALLY_ADDED
        - FILE_IMPORT
        - SHOPIFY
        - API
        - AD
        - POST
        - CALLING
        - SMB
        - UNKNOWN
      example: API
    Error:
      type: object
      required:
        - status
        - code
      properties:
        status:
          type: integer
          format: int32
          pattern: '[45]\d{2}'
          description: >-
            HTTP status code, [RFC 7231, Section
            6](https://datatracker.ietf.org/doc/html/rfc7231#section-6). It
            conveys the HTTP status code used for the convenience of the
            consumer.
          example: 404
        code:
          type: string
          description: >-
            One of a server-defined error codes. Some `4xx` errors that could be
            handled programmatically include an error code that briefly explains
            the error reported.
          example: NOT_FOUND
        message:
          type: string
          description: >-
            A human-readable representation of the error. It is intended as an
            aid to developers and is not suitable for exposure to end users.
          example: The requested resource does not exist.
        target:
          type: string
          description: The target of the error.
          example: ''
        docUrl:
          type: string
          description: A URL to more information about the error.
          example: ''
        requestId:
          type: string
          description: >-
            Each API request has an associated request ID. It conveys the
            response header `YCloud-Request-ID` used for the convenience of the
            consumer.
          example: req_1KjtKI80IKoaJNa6n6p
        whatsappApiError:
          $ref: '#/components/schemas/WhatsappApiError'
          description: >-
            The original error object returned by WhatsApp. See [Handling
            Errors](https://developers.facebook.com/docs/graph-api/guides/error-handling),
            [Cloud API Error
            Codes](https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes).


            Note: This field is returned if we tried to request the WhatsApp
            Business API and got an error response.
        metaBusinessAgentApiError:
          $ref: '#/components/schemas/MetaBusinessAgentApiError'
          description: >-
            Sanitized upstream details returned when a Meta Business Agent
            request fails.
    WhatsappApiError:
      type: object
      description: >-
        The original error object returned by WhatsApp. See [Handling
        Errors](https://developers.facebook.com/docs/graph-api/guides/error-handling),
        [Cloud API Error
        Codes](https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes).
      required:
        - message
        - code
      properties:
        message:
          type: string
          description: A human-readable description of the error.
          example: HSM Template creation failed
        code:
          type: string
          description: An error code.
          example: 200002
        type:
          type: string
          description: Error type.
          example: OAuthException
        is_transient:
          type: boolean
          description: Whether the error is transient.
          example: false
        error_subcode:
          type: string
          description: Additional code about the error.
          example: 2388109
        error_user_msg:
          type: string
          description: >-
            The message to display to the user. The language of the message is
            based on the locale of the API request.
          example: This message template cannot be created.
        error_user_title:
          type: string
          description: >-
            The title of the dialog, if shown. The language of the message is
            based on the locale of the API request.
          example: Message Cannot Be Submitted
        fbtrace_id:
          type: string
          description: >-
            Internal support identifier. When reporting a bug related to a Graph
            API call, include the fbtrace_id to help us find log data for
            debugging.
          example: AVGjJ7ia2zJkrHG
        error_data:
          description: >-
            Additional data about the error. A string or map.

            - For template APIs, this field is a string describing the reason
            for the error.

            - For message APIs, this field is a map with property `details`
            describing the reason for the error.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
    MetaBusinessAgentApiError:
      type: object
      description: Sanitized details from a failed Meta Business Agent upstream request.
      properties:
        title:
          type: string
        detail:
          type: string
        type:
          type: string
        status:
          type: integer
          format: int32
        requestId:
          type: string
  securitySchemes:
    api_key:
      type: apiKey
      name: X-API-Key
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.