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

# Rename the account

> Rename the account that owns this API key. Single-field strict
allowlist — `accountName` is the only accepted field; any other key in
the body is rejected with 400.

Emits an `accountUpdated` EventBridge event with `actor: cli:{apiKeyPk}`
so downstream consumers can distinguish UI vs API-key mutations.

**Required scope:** `account:write`.




## OpenAPI

````yaml /api-reference/openapi.yaml patch /accounts/api/account
openapi: 3.1.0
info:
  title: Upstack Data API
  version: '1.0'
  description: >
    Programmatic access to your Upstack Data pixel — analytics queries, the

    measures/dimensions catalog, and dashboard view management.


    All requests authenticate with two headers:


    - `x-api-key`: your Upstack API key (mint one at **Settings → API Keys** in
    the dashboard).

    - `x-pixel-id`: the pixel id the request targets. One key is scoped to one
    pixel.
servers:
  - url: https://api.upstackdata.com
    description: Production
security:
  - apiKey: []
    pixelId: []
tags:
  - name: Analytics
    description: Query events, attribution, and cohort analyses.
  - name: Catalog
    description: List the measures available to your pixel.
  - name: Dashboards
    description: >-
      Manage dashboard views — create, update, copy, delete, and the high-level
      preset builder.
  - name: Account
    description: >-
      Read and update the account that owns this API key — display name, active
      owners and admins, and subscription summary.
  - name: Costs
    description: >-
      Read and update every cost surface — global product overrides, shipping
      method, per-variant handling fees and COGS history, and per-type cost
      lines (order / gateway / shipping profile / variable / fixed). Mutations
      trigger the same per-order COGS recalculation as web-UI changes.
  - name: Products
    description: Browse products + variants in the configured catalog.
  - name: Events
    description: Send server-side tracking events directly from your backend.
paths:
  /accounts/api/account:
    patch:
      tags:
        - Account
      summary: Rename the account
      description: |
        Rename the account that owns this API key. Single-field strict
        allowlist — `accountName` is the only accepted field; any other key in
        the body is rejected with 400.

        Emits an `accountUpdated` EventBridge event with `actor: cli:{apiKeyPk}`
        so downstream consumers can distinguish UI vs API-key mutations.

        **Required scope:** `account:write`.
      operationId: updateAccount
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RenameAccountRequest'
            examples:
              rename:
                summary: Rename to a new display name
                value:
                  accountName: Upstack Data
      responses:
        '200':
          description: The renamed account projection.
          content:
            application/json:
              schema:
                type: object
                required:
                  - account
                properties:
                  account:
                    $ref: '#/components/schemas/PublicAccountProjection'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    RenameAccountRequest:
      type: object
      required:
        - accountName
      description: >
        Strict allowlist — `accountName` is the only accepted field. Any other
        key

        in the body is rejected with 400. Control / zero-width / bidi characters

        are rejected; unicode letters, marks, digits, punctuation, and emoji are

        accepted. Trimmed; leading/trailing whitespace rejected.
      properties:
        accountName:
          type: string
          minLength: 1
          maxLength: 100
          example: Upstack Data
    PublicAccountProjection:
      type: object
      required:
        - accountName
        - createdAt
        - owners
        - admins
      description: >
        Slim public projection of an account — display name, creation date,

        active owners and admins, optional subscription summary.


        Internal fields are deliberately omitted: `id`, `ownerId`,
        `companyName`,

        `primaryEmail`, `settings.*`, `pixels`, `subscriptionId`, every Stripe
        ID,

        `planUsage`, `usageBillingRecords`, `last12Months*`, and similar

        implementation details.
      properties:
        accountName:
          type: string
          example: Upstack Data
        createdAt:
          type: string
          format: date-time
        owners:
          type: array
          description: Active members with the OWNER role.
          items:
            $ref: '#/components/schemas/PublicAccountUser'
        admins:
          type: array
          description: Active members with the ADMIN role.
          items:
            $ref: '#/components/schemas/PublicAccountUser'
        subscription:
          $ref: '#/components/schemas/PublicSubscription'
    PublicAccountUser:
      type: object
      required:
        - email
      description: Active member of the account — projected for public exposure.
      properties:
        email:
          type: string
          format: email
        firstName:
          type: string
        lastName:
          type: string
    PublicSubscription:
      type: object
      required:
        - plan
      properties:
        plan:
          $ref: '#/components/schemas/PublicSubscriptionPlan'
        status:
          type: string
          description: >-
            Subscription lifecycle state (active, paused, cancelled, expired,
            declined, etc.).
        trialEndsOn:
          type: string
          format: date-time
        currentPeriodEnd:
          type: string
          format: date-time
          description: ISO timestamp of the next billing date.
        cancelAtPeriodEnd:
          type: boolean
          description: >-
            True when the subscription is set to end at the current period
            boundary.
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Human-readable error message.
        errors:
          type: array
          description: Per-field validation errors (present on 400 responses).
          items:
            type: object
            properties:
              message:
                type: string
              key:
                type: string
              path:
                type: array
                items:
                  type: string
    PublicSubscriptionPlan:
      type: object
      required:
        - name
        - billingFrequency
        - displayPrice
        - currency
      properties:
        name:
          type: string
          example: Growth
          description: Plan display name (e.g. "Growth").
        billingFrequency:
          type: string
          enum:
            - monthly
            - yearly
        displayPrice:
          type: string
          example: $49/mo
          description: Original list price, formatted for display.
        discountedDisplayPrice:
          type: string
          example: $39/mo
          description: >
            Effective price after the active discount, formatted for display.


            Render rule: `discountedDisplayPrice ?? displayPrice`. v2
            (Stripe-native)

            plans may omit this even when a discount is present — consult
            `discount`

            for the deduction details in that case.
        currency:
          type: string
          example: USD
          description: ISO 4217 currency code.
        discount:
          $ref: '#/components/schemas/PublicSubscriptionDiscount'
    PublicSubscriptionDiscount:
      type: object
      required:
        - code
        - type
        - value
      description: Active discount summary. Omitted when no discount is applied.
      properties:
        code:
          type: string
          example: LAUNCH20
        type:
          type: string
          enum:
            - percentage
            - fixed_amount
        value:
          type: number
          description: >-
            Numeric value — 20 for 20% off, 10 for $10 off (interpret with
            `type`).
        appliesUntil:
          type: string
          format: date-time
          description: ISO timestamp when the discount expires. Absent = no end date.
        appliesForBillingIntervals:
          type: integer
          description: Discount valid for N billing intervals. Absent = ongoing.
  responses:
    BadRequest:
      description: Validation error. Includes an `errors` array with per-field detail.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: >-
        Missing or invalid `x-api-key` / `x-pixel-id`, or key is
        revoked/expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        API key does not carry the required scope for this endpoint, or body
        `pixelId` does not match the `x-pixel-id` header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The addressed resource does not exist (or belongs to a different pixel).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Your Upstack API key. Starts with `upstack_`.
    pixelId:
      type: apiKey
      in: header
      name: x-pixel-id
      description: The pixel id the request targets.

````