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

# Update traits

> Merge-update the traits of one identified player. Keys that you do not send keep their values. null deletes a trait. The response has the merged traits. At most 50 traits and 8 KB of JSON in one call.



## OpenAPI

````yaml /api/openapi.json put /v0/projects/{projectId}/players/{playerKey}/traits
openapi: 3.1.0
info:
  title: Manalens API
  version: 0.1.0
  description: >-
    The public API of Manalens: event ingestion, Steam account links, player
    traits and the Query API. Success bodies are the resource, with no envelope.
    Errors use the `Error` format. See https://docs.manalens.dev/api/overview.
servers:
  - url: https://api.manalens.dev
    description: API
  - url: https://events.manalens.dev
    description: Event ingestion
security: []
tags:
  - name: Events
    description: Send website, game and server events
  - name: Accounts
    description: Link the Steam account of a player to the game install
  - name: Players
    description: Set and delete the traits of identified players
  - name: Query
    description: Read analytics reports with an API key
paths:
  /v0/projects/{projectId}/players/{playerKey}/traits:
    put:
      tags:
        - Players
      summary: Update traits
      description: >-
        Merge-update the traits of one identified player. Keys that you do not
        send keep their values. null deletes a trait. The response has the
        merged traits. At most 50 traits and 8 KB of JSON in one call.
      operationId: updatePlayerTraits
      parameters:
        - name: projectId
          in: path
          required: true
          description: The project ID
          schema:
            type: string
            format: uuid
        - name: playerKey
          in: path
          required: true
          description: >-
            The player key of an identified player: `user:` and the user ID that
            you send with identify (1 to 255 characters). URL-encode it, for
            example `user%3Aplayer-42`.
          schema:
            type: string
            minLength: 6
            maxLength: 260
            pattern: '^user:'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              propertyNames:
                type: string
                pattern: ^[A-Za-z][A-Za-z0-9_.-]{0,99}$
              additionalProperties:
                anyOf:
                  - type: string
                    maxLength: 1024
                  - type: number
                  - type: boolean
                  - type: 'null'
              description: >-
                1 to 50 traits, at most 8 KB as JSON. A value is a string (at
                most 1024 characters), a number, a boolean, or null to delete
                the trait. user_id is reserved.
      responses:
        '200':
          description: The player traits after the write
          content:
            application/json:
              schema:
                type: object
                properties:
                  player_key:
                    type: string
                    description: 'user: and the user ID'
                  user_id:
                    type: string
                  traits:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      anyOf:
                        - type: string
                          maxLength: 1024
                        - type: number
                        - type: boolean
                        - type: 'null'
                    description: >-
                      The user traits read before the write, with this update
                      merged in
                  set:
                    type: array
                    items:
                      type: string
                    description: The keys that this request set
                  deleted:
                    type: array
                    items:
                      type: string
                    description: The keys that this request deleted
                  updated_at:
                    type: string
                    description: The time of the write (ISO 8601)
                required:
                  - player_key
                  - user_id
                  - traits
                  - set
                  - deleted
                  - updated_at
        '400':
          description: >-
            `INVALID_TRAITS`: a key, a value, the player key or the user ID
            failed validation, or the traits of a player are over 50 keys or 8
            KB. Nothing is written.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            `UNAUTHORIZED`: the API key is missing, malformed, unknown or
            revoked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: >-
            `SUBSCRIPTION_REQUIRED`: the workspace has no active subscription or
            trial. `PLAN_UPGRADE_REQUIRED`: API keys need the Studio plan
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            `FORBIDDEN`: the key has no `profiles:write` scope, its creator is
            below editor, or the request came from a browser.
            `WORKSPACE_SUSPENDED`: the workspace is suspended.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            `NOT_FOUND`: the key belongs to another project, or the resource
            does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: >-
            `TOO_LARGE`: the body is larger than the limit (16 KB for one
            player, 200 KB for a batch)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            `TOO_MANY_REQUESTS`: the key or workspace budget is used up.
            `RATE_LIMITED`: the project sent too many server events and trait
            writes this minute.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            Retry-After:
              description: Seconds to wait before a retry
              schema:
                type: integer
            RateLimit-Limit:
              description: The limit of the window, when it is known
              schema:
                type: integer
            RateLimit-Policy:
              description: '`<limit>;w=<window seconds>`, when the limit is known'
              schema:
                type: string
            RateLimit-Remaining:
              description: Always 0 on a 429
              schema:
                type: integer
            RateLimit-Reset:
              description: Seconds until the window resets (the same as Retry-After)
              schema:
                type: integer
        '500':
          description: '`INTERNAL`: an unexpected error. The body has a `request_id`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKey: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: A stable, machine-readable code. Branch on it.
            message:
              type: string
              description: A human-readable text. The wording can change.
            request_id:
              description: 'INTERNAL only: quote it when you contact support'
              type: string
            issues:
              description: 'INVALID_EVENT only: up to five validation issues'
              type: array
              items:
                type: object
                properties:
                  path:
                    type: string
                    description: Where the problem is, such as `events.0.properties`
                  message:
                    type: string
                    description: What is wrong, such as `at most 50 keys`
                required:
                  - path
                  - message
            refused:
              description: >-
                INVALID_EVENT when no event of the batch is accepted: each
                refused event (the same list as `errors`, kept for SDKs that
                read it here)
              type: array
              items:
                type: object
                properties:
                  index:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                    description: The position of the event in the batch
                  message_id:
                    description: The message_id of the event, or null when it has none
                    type:
                      - string
                      - 'null'
                  code:
                    type: string
                    description: >-
                      The reason code, such as `INVALID_EVENT`,
                      `SESSION_ID_REQUIRED` or `FORBIDDEN`
                  message:
                    type: string
                    description: 'What is wrong, such as `properties: at most 50 keys`'
                required:
                  - index
                  - message_id
                  - code
                  - message
            results:
              description: 'INVALID_TRAITS of a batch trait update: the result of each item'
              type: array
              items:
                type: object
                properties:
                  index:
                    type: integer
                    minimum: -9007199254740991
                    maximum: 9007199254740991
                  user_id:
                    type: string
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - index
            feature:
              description: >-
                PLAN_UPGRADE_REQUIRED only: the plan feature that the request
                needs
              type: string
            billing_url:
              description: 'PLAN_UPGRADE_REQUIRED only: the billing page of the workspace'
              type: string
          required:
            - code
            - message
      required:
        - error
      description: >-
        The error format of every endpoint. See
        https://docs.manalens.dev/api/errors.
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      description: >-
        An API key (`mana_api_...`) with scopes. It reads reports and writes
        player traits.

````

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