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

# Upsert an identity

> Creates or updates an identity for a given type and external ID. Display fields merge — null values do not clear existing data.



## OpenAPI

````yaml /api-reference/openapi.json put /projects/{projectId}/identities/{typeName}/{externalId}
openapi: 3.1.0
info:
  title: Whistle SDK API
  description: >-
    HTTP API for the Whistle SDK. All endpoints are authenticated via an API key
    (`wh_…`) sent as a Bearer token. The API key is org-scoped — no organization
    slug or ID is needed in the URL.


    Base URL: `https://api.kansato.com/sdk/whistle/v1`


    Local development default: `http://localhost:3001/sdk/whistle/v1`
  version: 1.0.0
servers:
  - url: https://api.kansato.com/sdk/whistle/v1
    description: Production
  - url: http://localhost:3001/sdk/whistle/v1
    description: Local development (default PORT)
security:
  - apiKey: []
tags:
  - name: Reports
    description: Create, list, and manage moderation reports.
  - name: Identities
    description: Mirror user identities from your platform.
paths:
  /projects/{projectId}/identities/{typeName}/{externalId}:
    put:
      tags:
        - Identities
      summary: Upsert an identity
      description: >-
        Creates or updates an identity for a given type and external ID. Display
        fields merge — null values do not clear existing data.
      operationId: upsertIdentity
      parameters:
        - name: projectId
          in: path
          required: true
          description: Project UUID
          schema:
            type: string
        - name: typeName
          in: path
          required: true
          description: Identity type (e.g. `user`)
          schema:
            type: string
        - name: externalId
          in: path
          required: true
          description: External subject ID from your platform
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertIdentityBody'
      responses:
        '200':
          description: Identity upserted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpsertIdentityResponse'
        '400':
          description: Invalid external ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Project not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UpsertIdentityBody:
      type: object
      properties:
        display:
          type: object
          properties:
            name:
              type: string
              nullable: true
            username:
              type: string
              nullable: true
            avatarUrl:
              type: string
              nullable: true
        metadata:
          description: Arbitrary JSON metadata
    UpsertIdentityResponse:
      type: object
      required:
        - identity
      properties:
        identity:
          $ref: '#/components/schemas/IdentityRow'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
    IdentityRow:
      type: object
      required:
        - id
        - externalId
        - projectId
        - type
        - name
        - username
        - avatarUrl
        - metadata
        - reportCount
        - lastSeenAt
        - lastReportedAt
        - displayName
        - handleLabel
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
        externalId:
          type: string
        projectId:
          type: string
        type:
          type: string
        name:
          type: string
          nullable: true
        username:
          type: string
          nullable: true
        avatarUrl:
          type: string
          nullable: true
        metadata: {}
        reportCount:
          type: integer
        lastSeenAt:
          type: string
          format: date-time
          nullable: true
        lastReportedAt:
          type: string
          format: date-time
          nullable: true
        displayName:
          type: string
        handleLabel:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key with `wh_` prefix. Send as Bearer token: `Authorization: Bearer
        wh_xxxxxxxxxxxx`

````