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

# Merge Contact Data

> Shallow-merge fields into the stored data for a contact phone number

Use this endpoint when an external system needs to update only part of the
state stored against a caller's phone number. PATCH merges top-level fields
into the existing object without replacing unrelated fields.

Set a field to `null` to delete that field. If no data exists yet, the patch
starts with an empty object. A PATCH without `ttlSeconds` preserves the
existing expiration; provide a new value to replace it.

The data is scoped to your organization and the phone number. A previously
unknown number gets a contact automatically. US numbers can be formatted or
sent as digits. Non-US numbers must include the `+` country code. URL-encode
the `+` when it appears in the path.

```bash theme={null}
curl -X PATCH 'https://api.usesimple.ai/api/v1/contacts/14155550100/data' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "data": {
      "routingStatus": "completed",
      "five9ConversationId": null
    }
  }'
```

For example, if the stored object is
`{"five9ConversationId":"conv-48291","routingStatus":"queued"}`, the request
above leaves `{"routingStatus":"completed"}`.

The response contains the normalized phone number, the merged object, its
revision, and expiration metadata:

```json theme={null}
{
  "phoneNumber": "+14155550100",
  "data": {
    "routingStatus": "completed"
  },
  "revision": 2,
  "ttlSeconds": null,
  "expiresAt": null
}
```

The serialized `data` object may be at most 64 KiB. When supplied,
`ttlSeconds` must be an integer from 60 seconds through 90 days. Without an
explicit TTL, a record has no expiry by default or keeps its current expiry
when patching an existing record.

The endpoint returns `401` when authentication fails and `422` when the phone
number or request body is invalid.


## OpenAPI

````yaml PATCH /contacts/{phoneNumber}/data
openapi: 3.1.0
info:
  title: Public API v1
  description: >-
    Public API v1 requiring API keys.


    **Timestamps:** All datetime fields in API responses are returned in UTC
    using ISO 8601 format (e.g., `2024-01-15T14:30:00Z`). When filtering by date
    parameters, provide timestamps in ISO 8601 format.
  version: 0.1.0
servers:
  - url: https://api.prod.usesimple.ai/api/v1
    description: Production API Server
security: []
paths:
  /contacts/{phoneNumber}/data:
    patch:
      tags:
        - Contacts
      summary: Merge Contact Data
      description: >-
        Shallow-merge top-level fields into the JSON object stored for a phone
        number. Set a field to null to delete it.
      operationId: merge_contact_data_contacts__phoneNumber__data_patch
      parameters:
        - name: phoneNumber
          in: path
          required: true
          schema:
            type: string
          description: >-
            The caller's phone number. US numbers may be formatted or sent as
            digits; non-US numbers must include the + country code.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactDataRequest'
      responses:
        '200':
          description: Contact data merged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactDataResponse'
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
        '422':
          description: The phone number or request body is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    ContactDataRequest:
      type: object
      additionalProperties: false
      required:
        - data
      properties:
        data:
          type: object
          additionalProperties: true
          description: >-
            The JSON object to store. Its serialized UTF-8 size may not exceed
            64 KiB.
        ttlSeconds:
          type: integer
          minimum: 60
          maximum: 7776000
          description: >-
            Optional expiration in seconds. Omit for no expiry; allowed values
            range from 60 seconds through 90 days.
      title: Contact Data Request
    ContactDataResponse:
      type: object
      required:
        - phoneNumber
        - data
        - revision
        - ttlSeconds
        - expiresAt
      properties:
        phoneNumber:
          type: string
          description: The normalized phone number in E.164 format.
        data:
          type: object
          additionalProperties: true
          description: The stored JSON object.
        revision:
          type: integer
          minimum: 1
          description: The revision number of this value.
        ttlSeconds:
          anyOf:
            - type: integer
            - type: 'null'
          description: Remaining TTL in seconds, or null when the record has no expiry.
        expiresAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: Expiration timestamp in UTC, or null when the record has no expiry.
      title: Contact Data Response
    PublicApiError:
      type: object
      required:
        - status
        - success
        - error
        - errors
      properties:
        status:
          type: string
          const: error
        success:
          type: boolean
          const: false
        error:
          type: string
        errors:
          type: array
          items:
            type: string
      title: Public API Error
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization

````