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

# Set or clear a member's attribute values

> Each entry is `{ key, value }` to set or `{ key, clear: true }` with no `value` to delete. A key may appear once per request, and `""` is a value, never a clear. Every value is checked against the key's definition and the batch is written in one transaction: one bad entry writes nothing. Provenance comes from the caller: an organization key stamps `partner_api`, an admin session `admin`, a member session `self`. A member session may write only its own user id, and only attributes your organization marked self-editable; an admin session only admin-editable ones. An organization key is not bound by either flag.



## OpenAPI

````yaml https://api.develop.fourdos.dev/openapi/partner.json put /v1/users/{userId}/attributes
openapi: 3.1.0
info:
  title: 4D OS Partner API
  version: 0.1.0
  description: >-
    REST API for 4D OS partners. Authenticate with your organization API key:
    `Authorization: Bearer <key>`.


    Requests and responses are JSON with `snake_case` field names. Errors share
    one envelope: `{ "error": { "code", "status", "message", "details"? } }`.


    Mutating endpoints that declare it accept an `Idempotency-Key` header so
    retries are safe.


    Bulk-migrating members? See the [Migrating to 4D
    guide](https://docs.fourdos.dev/walkthroughs/migrate-existing-members) for
    the canonical import schema, a worked example, and the `/v1/imports`
    sequence.
servers:
  - url: https://api.develop.fourdos.dev
security:
  - partnerApiKey: []
tags:
  - name: Users
    description: Create, read, and manage users and their org membership
  - name: Imports
    description: Bulk member import jobs (staging → validate → commit)
  - name: Consents
    description: Record, list and withdraw a member's consents and agreements
  - name: Rewards
    description: A member's reward catalog, claims and reward codes
  - name: XP
    description: >-
      A member's balance, earning headroom, expiry and boosts, and what each
      event pays
  - name: Tiers
    description: Read your organization's tier ladder
  - name: Webhooks
    description: Register webhook endpoints. Deliveries are not sent yet.
  - name: Events
    description: Refetch your organization's events from the last 30 days
  - name: API keys
    description: Issue, list, and revoke server-side organization API keys
  - name: Modules
    description: >-
      Publish private modules, install visible modules, and manage their
      credentials
  - name: Ingest
    description: Receive signed native events from an installed module
  - name: Engagement
    description: Browser event tracking (publishable keys) and tracking-key management
  - name: Revenue
    description: Report sales and refunds for the club's revenue dashboards
  - name: Ad delivery
    description: Fill a club site's ad slots, for anonymous or signed-in fans
  - name: Ad entries
    description: Fans entering a sponsor's draw, reported by the club's backend
paths:
  /v1/users/{userId}/attributes:
    put:
      tags:
        - Users
      summary: Set or clear a member's attribute values
      description: >-
        Each entry is `{ key, value }` to set or `{ key, clear: true }` with no
        `value` to delete. A key may appear once per request, and `""` is a
        value, never a clear. Every value is checked against the key's
        definition and the batch is written in one transaction: one bad entry
        writes nothing. Provenance comes from the caller: an organization key
        stamps `partner_api`, an admin session `admin`, a member session `self`.
        A member session may write only its own user id, and only attributes
        your organization marked self-editable; an admin session only
        admin-editable ones. An organization key is not bound by either flag.
      operationId: setMemberAttributeValues
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
        - name: Idempotency-Key
          in: header
          required: false
          description: >-
            Same key and body replays the original response; same key with a
            different body is `409 IDEMPOTENCY_CONFLICT`.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetAttributesBody'
      responses:
        '200':
          description: The values that were set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WrittenAttributeValues'
        '401':
          description: '`UNAUTHORIZED`: no valid credential'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            `ATTRIBUTE_NOT_EDITABLE`: a session caller wrote a key that is not
            editable for its role (`details.key`). `CONSENT_REQUIRED`: a session
            caller still owes an agreement (`details.scopes`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            `NOT_FOUND`: the user is not a member of your organization, or a
            member session named another user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            `IDEMPOTENCY_CONFLICT`: the `Idempotency-Key` was already used with
            a different body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            `VALIDATION_ERROR`: the body is not JSON or fails the schema.
            `ATTRIBUTE_UNKNOWN`: no such key. `ATTRIBUTE_DISABLED`: the
            definition is retired or not enabled for your organization.
            `ATTRIBUTE_INVALID_VALUE`: the value does not fit the definition, a
            `core.*` key was sent, a key repeats, or an entry has both or
            neither of `value` and `clear` (`details.key`, and `details.variant`
            for the malformed-entry cases)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - partnerApiKey: []
        - adminSession: []
        - memberSession: []
components:
  schemas:
    SetAttributesBody:
      type: object
      properties:
        values:
          minItems: 1
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                minLength: 1
              value: {}
              clear:
                type: boolean
            required:
              - key
      required:
        - values
    WrittenAttributeValues:
      type: object
      properties:
        values:
          type: array
          description: >-
            One entry per key that was set. Cleared keys are deleted and do not
            appear.
          items:
            type: object
            properties:
              key:
                type: string
              value:
                description: The value as stored.
              provenance:
                type: string
                enum:
                  - registration
                  - import
                  - partner_api
                  - admin
                  - self
            required:
              - key
              - value
              - provenance
      required:
        - values
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            status:
              type: integer
            message:
              type: string
            details:
              type: object
              additionalProperties: true
          required:
            - code
            - status
            - message
      required:
        - error
  securitySchemes:
    partnerApiKey:
      type: http
      scheme: bearer
      description: >-
        Organization API key (`org_...`) sent as `Authorization: Bearer <key>`.
        Keys are scoped to one organization; every request operates within that
        tenant.
    adminSession:
      type: http
      scheme: bearer
      description: >-
        Partner admin session token sent as `Authorization: Bearer <token>`.
        Obtained by signing in (console or the email OTP endpoints) and
        completing the second factor; see the Authentication page.
    memberSession:
      type: http
      scheme: bearer
      description: >-
        A signed-in member's session token sent as `Authorization: Bearer
        <token>`. Accepted only on the operations that list it, and each of
        those says which user ids a member may name. Your backend uses the
        organization API key instead.

````

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