> ## 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.

# Replace Contact Data

> Replace the stored data for a contact phone number

Use this endpoint to store the complete state that another system should find
the next time the caller contacts you. For example, Five9 can save a
conversation ID, routing status, or handoff details against the caller's phone
number.

The data is scoped to your organization and the phone number. If the number
does not belong to a contact yet, Simple creates a contact so the stored state
is visible in the dashboard.

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 PUT 'https://api.usesimple.ai/api/v1/contacts/%2B14155550100/data' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "data": {
      "five9ConversationId": "conv-48291",
      "routingStatus": "awaiting_follow_up",
      "preferredLanguage": "en"
    },
    "ttlSeconds": 86400
  }'
```

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

```json theme={null}
{
  "phoneNumber": "+14155550100",
  "data": {
    "five9ConversationId": "conv-48291",
    "routingStatus": "awaiting_follow_up",
    "preferredLanguage": "en"
  },
  "revision": 1,
  "ttlSeconds": 86400,
  "expiresAt": "2026-08-05T12:00:00.000Z"
}
```

Data does not expire unless you provide `ttlSeconds`. When supplied, it must
be an integer from 60 seconds through 90 days. The serialized `data` object
may be at most 64 KiB.

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


## OpenAPI

````yaml PUT /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:
    put:
      tags:
        - Contacts
      summary: Replace Contact Data
      description: >-
        Replace the complete JSON object stored for a phone number. The data is
        scoped to the authenticated organization, and an unknown phone number
        gets a contact automatically.
      operationId: replace_contact_data_contacts__phoneNumber__data_put
      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 replaced.
          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

````