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

# Create or update a record

> Creates a new record or updates an existing one based on a matching attribute



## OpenAPI

````yaml /api-reference/openapi.json put /v1/objects/{slug}
openapi: 3.0.0
info:
  description: >-
    REST API for accessing and managing your Nex data. Generate API keys from
    the Nex web UI and use them to authenticate requests.
  title: Nex Developer API
  contact: {}
  version: '1.0'
servers:
  - url: https://app.nex.ai/api/developers
security: []
paths:
  /v1/objects/{slug}:
    put:
      tags:
        - Records
      summary: Create or update a record
      description: >-
        Creates a new record or updates an existing one based on a matching
        attribute
      operationId: upsertRecord
      parameters:
        - description: Object slug (e.g., 'person', 'company')
          name: slug
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/developer.UpsertRecordRequest'
        description: Upsert record request with matching attribute and data
        required: true
      responses:
        '200':
          description: Created or updated record with all attributes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/developer.UpsertRecordResponse'
        '400':
          description: Bad request - Invalid data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '404':
          description: Object type not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    developer.UpsertRecordRequest:
      type: object
      required:
        - attributes
        - matching_attribute
      properties:
        attributes:
          type: object
          required:
            - name
          properties:
            name:
              description: >-
                Required when creating a new record, but optional when updating
                an existing record that already has a name. Can be a string
                (e.g., 'John Doe') or an object (e.g., {'first_name': 'John',
                'last_name': 'Doe'} for Person objects).
              oneOf:
                - type: string
                - type: object
                  additionalProperties: {}
          additionalProperties: {}
        matching_attribute:
          description: ID or slug of the attribute to match on
          type: string
      example:
        matching_attribute: email_addresses
        attributes:
          name:
            first_name: Jane
            last_name: Smith
          email_addresses:
            - jane@example.com
          job_title: CTO
          phone_number:
            country_code: 1
            number: '5559876543'
    developer.UpsertRecordResponse:
      type: object
      properties:
        attributes:
          type: object
          additionalProperties: {}
        created_at:
          type: string
        id:
          type: string
        object_id:
          type: string
        type:
          type: string
        updated_at:
          type: string
        workspace_id:
          type: string
      example:
        id: '32414268188027657'
        object_id: '32414268188027650'
        type: person
        workspace_id: '32414268188027645'
        created_at: '2024-01-21T12:00:00Z'
        updated_at: '2024-01-21T12:00:00Z'
        attributes:
          name:
            first_name: Jane
            last_name: Smith
          email_addresses:
            - jane@example.com
          job_title: CTO
          phone_number:
            country_code: 1
            number: '5559876543'
          location:
            city: San Francisco
            region: CA
            country: US
    httpx.APIError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: 'API key for authentication (format: "Bearer YOUR_API_KEY")'
      type: apiKey
      name: Authorization
      in: header

````