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

# Change a unit

> Changes what you send. A setting applies to changes from now on and changes nobody's balance: lowering a cap below what people hold leaves their balances, and stops further additions.



## OpenAPI

````yaml /api-reference/openapi.json patch /v1/units/{id}
openapi: 3.1.0
info:
  title: Lurk API
  version: 1.0.0
  description: Events in, rules decide, units change, receipts out.
servers:
  - url: https://api.getlurk.com
security: []
tags:
  - name: events
    description: Send what your users do. Lurk runs your live rules on each event.
    x-group: Events
    x-displayName: Events
  - name: units
    description: What people collect and hold, and their balances.
    x-group: Units
    x-displayName: Units
  - name: rules
    description: What Lurk does when an event comes in. A person takes a rule live.
    x-group: Rules
    x-displayName: Rules
  - name: activity
    description: A receipt for every change, with why it happened.
    x-group: Receipts
    x-displayName: Receipts
  - name: users
    description: The people your events are about.
    x-group: People
    x-displayName: People
  - name: webhook_endpoints
    description: Where Lurk sends signed notices of what changed.
    x-group: Webhooks
    x-displayName: Webhooks
  - name: known_values
    description: The properties of your own events whose values Lurk remembers.
    x-group: Known values
    x-displayName: Known values
  - name: feedback
    description: Tell the Lurk team about a bug, a gap or an idea.
    x-group: Feedback
    x-displayName: Feedback
  - name: annotations
    description: >-
      Short notes on a day of the project, such as a release or a campaign
      start.
    x-group: Annotations
    x-displayName: Annotations
  - name: trusted_issuers
    description: The sign-in providers a project trusts for its app's users.
    x-group: Trusted issuers
    x-displayName: Trusted issuers
  - name: client_events
    description: The events a signed-in device may send, and their caps.
    x-group: Client events
    x-displayName: Client events
  - name: issuer_identities
    description: Which person each sign-in subject is bound to.
    x-group: Issuer identities
    x-displayName: Issuer identities
  - name: proposals
    description: Changes an agent or Lurky asks for and a person approves or declines.
    x-group: Proposals
    x-displayName: Proposals
  - name: holds
    description: Changes a rule parked for a person to give or refuse.
    x-group: Holds
    x-displayName: Holds
  - name: audiences
    description: The groups of people that rules can read.
    x-group: Audiences
    x-displayName: Audiences
  - name: budgets
    description: What each live rule's budgets have given in the window they are in now.
    x-group: Budgets
    x-displayName: Budgets
  - name: templates
    description: Kits that add units and rules to a project in one go.
    x-group: Templates
    x-displayName: Templates
  - name: views
    description: Saved questions about a project, with their answers.
    x-group: Views
    x-displayName: Views
  - name: integrations
    description: Every way events reach Lurk or state leaves it, and the state of each.
    x-group: Integrations
    x-displayName: Integrations
  - name: projects
    description: Where units, rules and events live. An organization can have several.
    x-group: Projects
    x-displayName: Projects
  - name: clocks
    description: A test project's clock, which can be moved to try schedules and expiries.
    x-group: Clocks
    x-displayName: Clocks
paths:
  /v1/units/{id}:
    patch:
      tags:
        - units
      summary: Change a unit
      description: >-
        Changes what you send. A setting applies to changes from now on and
        changes nobody's balance: lowering a cap below what people hold leaves
        their balances, and stops further additions.
      operationId: units.update
      parameters:
        - schema:
            type: string
            description: A unit_… ID or the unit's key
          required: true
          description: A unit_… ID or the unit's key
          name: id
          in: path
        - schema:
            type: string
            description: W3C Trace Context; joins your trace to ours
          required: false
          description: W3C Trace Context; joins your trace to ours
          name: traceparent
          in: header
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: A retry with the same key and body returns the first response
          required: true
          description: A retry with the same key and body returns the first response
          name: Idempotency-Key
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 80
                  description: A new name, 1 to 80 characters
                singular:
                  type: string
                  minLength: 1
                  maxLength: 80
                  description: A new singular, 1 to 80 characters
                group:
                  $ref: '#/components/schemas/UnitGroup'
                shows_as:
                  $ref: '#/components/schemas/UnitShowsAs'
                color:
                  type:
                    - string
                    - 'null'
                  enum:
                    - blue
                    - green
                    - amber
                    - red
                    - purple
                    - pink
                    - teal
                    - gray
                    - null
                  description: A color, or null to clear it
                switches:
                  type: object
                  properties:
                    goes_up:
                      type: boolean
                      description: Rules can add to it
                    goes_down:
                      type: boolean
                      description: Rules can take from it. Off makes it earn-only
                    spendable:
                      type: boolean
                      description: >-
                        `units.spend` can take from it: a brand's server taking
                        value for a reward. On by default for a unit that goes
                        down; an earn-only unit is never spendable
                    usable:
                      type: boolean
                      description: >-
                        `units.use` can take one: a person redeeming the thing
                        itself, a coupon or a ticket, which fires the
                        `unit.used` webhook. Off by default; a unit that cannot
                        go down is never usable
                    sendable:
                      type: boolean
                      description: >-
                        `units.send` can move it from one person to another. Off
                        by default; a unit that cannot go down is never
                        sendable. Units cannot be bought, cashed out or given a
                        money value
                    send_cap_per_day:
                      type: integer
                      minimum: 1
                      maximum: 1000000
                      description: >-
                        The most one person may send of it in a day, in the
                        project's time zone. Always a number: a send is never
                        unlimited. 100 by default
                    resets:
                      type: boolean
                      description: >-
                        A rule's `reset` action can set it back to 0: a season's
                        XP, a monthly count. Works for a unit that only goes up.
                        Off by default
                    starts_at:
                      type: integer
                      minimum: 0
                      description: >-
                        What a person first heard of from now on begins with, as
                        a receipt written when they are first seen: a level
                        starts at 1. People Lurk has already heard of keep what
                        they hold. 0 for nothing. Not with a supply
                    held_by:
                      type:
                        - string
                        - 'null'
                      minLength: 1
                      maxLength: 100
                      description: >-
                        The key of an audience to follow: a person holds exactly
                        1 while they are in it and 0 when they are not, kept by
                        Lurk within minutes, as a pass or a role. Rules and
                        gives cannot change it by hand. Needs a cap of 1 (set
                        for you), and not an expiry, a supply or a start. Null
                        for an ordinary unit
                    cap:
                      type:
                        - integer
                        - 'null'
                      exclusiveMinimum: 0
                      description: >-
                        Never more than this per person; a change that would
                        pass it is refused whole. A badge is 1
                    min_balance:
                      type: integer
                      maximum: 0
                      description: >-
                        The lowest a balance may go. 0 normally; below 0 lets it
                        be overdrawn
                    visible:
                      type: boolean
                      description: >-
                        The brand's app shows it to people. A label: Lurk does
                        not act on it
                    supply:
                      type:
                        - integer
                        - 'null'
                      exclusiveMinimum: 0
                      description: >-
                        The most that can ever be given in all, across everyone:
                        40 in all. When it has run out a rule that would give it
                        is skipped (`supply_gone`). Counted from when it is set;
                        null for no limit
                    expires_after_days:
                      type:
                        - integer
                        - 'null'
                      minimum: 1
                      maximum: 3650
                      description: >-
                        What is given expires this many days later, and is taken
                        back; spending uses what expires first. Applies to what
                        is given from now on; null for never
                    expires_at:
                      type:
                        - string
                        - 'null'
                      format: date-time
                      description: >-
                        Everything of it ends at this moment: nothing is given
                        after it, and what is held then expires and is taken
                        back, whatever `expires_after_days` says. A ticket for
                        an event on a date. Must be in the future when set; null
                        for no end date
                  additionalProperties: false
                  description: Only the settings to change
              additionalProperties: false
      responses:
        '200':
          description: Change a unit
          headers:
            Request-Id:
              schema:
                type: string
                description: Quote this when you contact support
              required: true
              description: Quote this when you contact support
            traceparent:
              schema:
                type: string
                description: W3C Trace Context for this call, in the caller's trace
              required: true
              description: W3C Trace Context for this call, in the caller's trace
            RateLimit:
              schema:
                type: string
                description: The tightest limit now, e.g. `"ingest-key";r=5999;t=42`
              required: true
              description: The tightest limit now, e.g. `"ingest-key";r=5999;t=42`
            RateLimit-Policy:
              schema:
                type: string
                description: Its quota and window, e.g. `"ingest-key";q=6000;w=60`
              required: true
              description: Its quota and window, e.g. `"ingest-key";q=6000;w=60`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unit'
        '429':
          description: Too many requests. Wait `Retry-After` seconds.
          headers:
            Request-Id:
              schema:
                type: string
                description: Quote this when you contact support
              required: true
              description: Quote this when you contact support
            traceparent:
              schema:
                type: string
                description: W3C Trace Context for this call, in the caller's trace
              required: true
              description: W3C Trace Context for this call, in the caller's trace
            RateLimit:
              schema:
                type: string
                description: The tightest limit now, e.g. `"ingest-key";r=5999;t=42`
              required: true
              description: The tightest limit now, e.g. `"ingest-key";r=5999;t=42`
            RateLimit-Policy:
              schema:
                type: string
                description: Its quota and window, e.g. `"ingest-key";q=6000;w=60`
              required: true
              description: Its quota and window, e.g. `"ingest-key";q=6000;w=60`
            Retry-After:
              schema:
                type: string
                description: Seconds to wait
              required: true
              description: Seconds to wait
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    UnitGroup:
      type: string
      enum:
        - points
        - progress
        - badge
        - perk
      description: >-
        The tab the unit sits in: points, progress, badge or perk. A label for
        how people think of it; what it can do comes from its switches
    UnitShowsAs:
      type: string
      enum:
        - amount
        - thing
        - level
      description: >-
        How an app draws the unit. amount: a token and a number. thing: its own
        art, like a badge. level: a hexagon with the level in it
    Unit:
      type: object
      properties:
        id:
          type: string
          description: The unit_… ID
        key:
          type: string
          pattern: ^[a-z][a-z0-9_-]{0,63}$
          description: >-
            The unit's key: lowercase letters, numbers, - and _, starting with a
            letter, up to 64 characters. Rules and calls name the unit by it
        name:
          type: string
          description: 'The unit''s name, as people see it: Beans, XP'
        singular:
          type: string
          description: 'One of it: Bean, day, Free drink'
        group:
          $ref: '#/components/schemas/UnitGroup'
        shows_as:
          type: string
          enum:
            - amount
            - thing
            - level
          description: >-
            amount: a token and a number. thing: its own art, like a badge.
            level: a hexagon with the level in it
        color:
          type:
            - string
            - 'null'
          enum:
            - blue
            - green
            - amber
            - red
            - purple
            - pink
            - teal
            - gray
            - null
          description: >-
            The color apps draw it in (a level's hexagon, a chart's line). Null
            until one is chosen: the app picks its own
        switches:
          $ref: '#/components/schemas/UnitSwitches'
        stats:
          $ref: '#/components/schemas/UnitStats'
        created_at:
          type: string
          format: date-time
          description: 'When it was created: UTC, ISO 8601'
        updated_at:
          type: string
          format: date-time
          description: 'When it last changed: UTC, ISO 8601'
      required:
        - id
        - key
        - name
        - singular
        - group
        - shows_as
        - color
        - switches
        - stats
        - created_at
        - updated_at
      examples:
        - id: unit_01m1e34qm0ejgrs7g7pf9fb9m1
          key: points
          name: Points
          singular: Point
          group: points
          shows_as: amount
          color: amber
          switches:
            goes_up: true
            goes_down: true
            spendable: true
            usable: false
            sendable: true
            send_cap_per_day: 100
            resets: false
            starts_at: 0
            held_by: null
            cap: null
            min_balance: 0
            visible: true
            supply: null
            expires_after_days: null
            expires_at: null
          stats:
            held: 294
            holders: 3
            given_30d: 294
            spent_30d: 0
            issued: 0
          created_at: '2026-09-01T09:00:00.000Z'
          updated_at: '2026-10-15T08:00:00.000Z'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: integer
            code:
              type: string
              enum:
                - invalid_json
                - invalid_key
                - forbidden
                - approval_required
                - not_found
                - idempotency_conflict
                - conflict
                - unblock_clock_reversed
                - insufficient_balance
                - reference_used
                - validation_failed
                - rate_limited
                - internal
                - unavailable
            message:
              type: string
            param:
              type: string
            next_step:
              type: string
              description: >-
                What to do about this kind of error, in one sentence. Always
                sent by current servers
            request_id:
              type: string
            doc_url:
              type: string
              format: uri
          required:
            - status
            - code
            - message
            - request_id
            - doc_url
      required:
        - error
    UnitSwitches:
      type: object
      properties:
        goes_up:
          type: boolean
          description: Rules can add to it
        goes_down:
          type: boolean
          description: Rules can take from it. Off makes it earn-only
        spendable:
          type: boolean
          description: >-
            `units.spend` can take from it: a brand's server taking value for a
            reward. On by default for a unit that goes down; an earn-only unit
            is never spendable
        usable:
          type: boolean
          description: >-
            `units.use` can take one: a person redeeming the thing itself, a
            coupon or a ticket, which fires the `unit.used` webhook. Off by
            default; a unit that cannot go down is never usable
        sendable:
          type: boolean
          description: >-
            `units.send` can move it from one person to another. Off by default;
            a unit that cannot go down is never sendable. Units cannot be
            bought, cashed out or given a money value
        send_cap_per_day:
          type: integer
          minimum: 1
          maximum: 1000000
          description: >-
            The most one person may send of it in a day, in the project's time
            zone. Always a number: a send is never unlimited. 100 by default
        resets:
          type: boolean
          description: >-
            A rule's `reset` action can set it back to 0: a season's XP, a
            monthly count. Works for a unit that only goes up. Off by default
        starts_at:
          type: integer
          minimum: 0
          description: >-
            What a person first heard of from now on begins with, as a receipt
            written when they are first seen: a level starts at 1. People Lurk
            has already heard of keep what they hold. 0 for nothing. Not with a
            supply
        held_by:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 100
          description: >-
            The key of an audience to follow: a person holds exactly 1 while
            they are in it and 0 when they are not, kept by Lurk within minutes,
            as a pass or a role. Rules and gives cannot change it by hand. Needs
            a cap of 1 (set for you), and not an expiry, a supply or a start.
            Null for an ordinary unit
        cap:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
          description: >-
            Never more than this per person; a change that would pass it is
            refused whole. A badge is 1
        min_balance:
          type: integer
          maximum: 0
          description: >-
            The lowest a balance may go. 0 normally; below 0 lets it be
            overdrawn
        visible:
          type: boolean
          description: 'The brand''s app shows it to people. A label: Lurk does not act on it'
        supply:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
          description: >-
            The most that can ever be given in all, across everyone: 40 in all.
            When it has run out a rule that would give it is skipped
            (`supply_gone`). Counted from when it is set; null for no limit
        expires_after_days:
          type:
            - integer
            - 'null'
          minimum: 1
          maximum: 3650
          description: >-
            What is given expires this many days later, and is taken back;
            spending uses what expires first. Applies to what is given from now
            on; null for never
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Everything of it ends at this moment: nothing is given after it, and
            what is held then expires and is taken back, whatever
            `expires_after_days` says. A ticket for an event on a date. Must be
            in the future when set; null for no end date
      required:
        - goes_up
        - goes_down
        - spendable
        - usable
        - sendable
        - send_cap_per_day
        - resets
        - starts_at
        - held_by
        - cap
        - min_balance
        - visible
        - supply
        - expires_after_days
        - expires_at
      additionalProperties: false
      description: >-
        What the unit allows. Each setting is checked on every change to a
        balance
    UnitStats:
      type: object
      properties:
        held:
          type: integer
          description: The total across everyone right now
        holders:
          type: integer
          minimum: 0
          description: People with a balance above 0
        given_30d:
          type: integer
          minimum: 0
          description: Added in the last 30 days
        spent_30d:
          type: integer
          minimum: 0
          description: Taken in the last 30 days
        issued:
          type: integer
          minimum: 0
          description: >-
            Given so far against the supply, counted from when the supply was
            set; 0 without one
      required:
        - held
        - holders
        - given_30d
        - spent_30d
        - issued
      description: Totals across everyone, kept up to date by Lurk
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A project key (Developers → API keys). Keep it on your server, not in an
        app.

````

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