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

# Create or upsert Attributes

> A single payload returns a bare Attribute: `201` for a new key and `200` when the existing same-type key is updated. `{ "attributes": [...] }` performs up to 500 atomic database writes and returns `{ "data": [...] }`. Attribute webhook effects are dispatched after the database commit and are best-effort. Attribute type and relation kind are immutable for an existing key.

## Single and bulk behavior

* Send one Attribute object to create or upsert one key. A new key returns `201`; an existing compatible key returns `200` with the bare Attribute.
* Send `{ "attributes": [...] }` to upsert up to 500 Attributes atomically. The response is `200` with `{ "data": [...] }`.
* An existing Attribute's `type` cannot change. A Relation Attribute's relation kind cannot change either.
* Omitted `language`, `image_config`, and `number_config` values preserve existing metadata during an upsert.

Use a new key when you need a different type. Use `POST /attributes/{key}/rename` only when the identity stays the same and the key changes.


## OpenAPI

````yaml openapi.yaml POST /attributes
openapi: 3.1.0
info:
  title: Lasso API
  description: AI-powered product data extraction and enhancement API
  version: 1.0.0
  contact:
    name: Lasso Support
    url: https://lasso.ai
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://app.productlasso.com/api/v1
    description: Production
security:
  - BearerAuth: []
paths:
  /attributes:
    post:
      tags:
        - Attributes
      summary: Create or upsert Attributes
      description: >
        A single payload returns a bare Attribute: `201` for a new key and `200`
        when

        the existing same-type key is updated. `{ "attributes": [...] }`
        performs up

        to 500 atomic database writes and returns `{ "data": [...] }`. Attribute

        webhook effects are dispatched after the database commit and are
        best-effort.

        Attribute type and relation kind are immutable for an existing key.
      operationId: createOrBulkUpsertAttributes
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/AttributeInput'
                - $ref: '#/components/schemas/AttributeBulkInput'
            examples:
              legacyText:
                summary: >-
                  Existing compatible payload; language and image_config are
                  omitted
                value:
                  key: material
                  label: Material
                  type: text
              localizedText:
                value:
                  key: product_name_cs
                  label: Product name (Czech)
                  type: text
                  language: cs
              canonicalImage:
                value:
                  key: primary_image
                  label: Primary image
                  type: image
                  image_config:
                    format: webp
                    required_aspect_ratio: '1:1'
                    min_width: 1200
              bulk:
                value:
                  attributes:
                    - key: brand
                      label: Brand
                      type: text
                    - key: color
                      label: Color
                      type: enum
                      enum_values:
                        - black
                        - white
      responses:
        '200':
          description: Existing single Attribute updated, or bulk upsert completed
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/Attribute'
                  - $ref: '#/components/schemas/AttributeBulkResponse'
        '201':
          description: New single Attribute created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Attribute'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: Attribute key or unresolved image-policy conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                imageMigrationLocked:
                  value:
                    status_code: 409
                    error_type: conflict
                    message: >-
                      Resolve this Attribute image policy on the Attributes page
                      before changing it here.
                    request_id: 9de9ae63-7a89-40d0-a101-47e006ea8233
                    code: attribute_image_migration_locked
                    retryable: false
                    attribute_id: 11111111-1111-4111-8111-111111111111
                    attribute_key: primary_image
        '422':
          $ref: '#/components/responses/ValidationError'
        '503':
          description: >-
            Attribute rollout or migration inventory could not be read; no write
            occurred
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                rolloutReadFailed:
                  value:
                    status_code: 503
                    error_type: service_unavailable
                    message: Attribute feature state is temporarily unavailable.
                    request_id: 9de9ae63-7a89-40d0-a101-47e006ea8233
                    code: attribute_rollout_read_failed
                    retryable: true
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |
            curl --request POST \
              --url https://app.productlasso.com/api/v1/attributes \
              --header "Authorization: Bearer $LASSO_API_KEY" \
              --header "Content-Type: application/json" \
              --data '{
                "attributes": [
                  {"key": "brand", "label": "Brand", "type": "text"},
                  {"key": "color", "label": "Color", "type": "enum", "enum_values": ["black", "white"]}
                ]
              }'
        - lang: typescript
          label: TypeScript
          source: >
            const response = await
            fetch("https://app.productlasso.com/api/v1/attributes", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.LASSO_API_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                attributes: [
                  { key: "brand", label: "Brand", type: "text" },
                  { key: "color", label: "Color", type: "enum", enum_values: ["black", "white"] },
                ],
              }),
            });


            if (!response.ok) throw new Error(await response.text());

            const result = await response.json();
        - lang: python
          label: Python
          source: |
            import os
            import requests

            response = requests.post(
                "https://app.productlasso.com/api/v1/attributes",
                headers={"Authorization": f"Bearer {os.environ['LASSO_API_KEY']}"},
                json={
                    "attributes": [
                        {"key": "brand", "label": "Brand", "type": "text"},
                        {"key": "color", "label": "Color", "type": "enum", "enum_values": ["black", "white"]},
                    ]
                },
                timeout=30,
            )
            response.raise_for_status()
            result = response.json()
components:
  schemas:
    AttributeInput:
      type: object
      additionalProperties: false
      required:
        - key
        - label
        - type
      properties:
        key:
          type: string
          pattern: ^[a-zA-Z0-9][a-zA-Z0-9_/]*$
        label:
          type: string
        type:
          $ref: '#/components/schemas/AttributeType'
        format_output_type:
          oneOf:
            - $ref: '#/components/schemas/FormatOutputType'
            - type: 'null'
          description: >-
            Only valid for format Attributes. Defaults to text when omitted or
            null.
        enum_values:
          type:
            - array
            - 'null'
          items:
            type: string
        tags_values:
          type:
            - array
            - 'null'
          items:
            type: string
        allow_custom_values:
          type: boolean
          default: true
        boolean_config:
          type:
            - object
            - 'null'
          additionalProperties: true
        number_config:
          oneOf:
            - $ref: '#/components/schemas/NumberConfig'
            - type: 'null'
          description: >-
            Only valid for number or Formula-number Attributes. Omit during an
            upsert to preserve existing metadata.
        relation_config:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Relation kind is immutable after creation.
        description:
          type:
            - string
            - 'null'
        validation:
          type:
            - object
            - 'null'
          additionalProperties: true
        language:
          type:
            - string
            - 'null'
          description: When omitted during an upsert, the existing language is preserved.
        image_config:
          $ref: '#/components/schemas/ImageConfig'
          description: >-
            When omitted during an upsert, existing canonical image requirements
            are preserved. Send an empty object to clear them.
        is_reviewed:
          type: boolean
    AttributeBulkInput:
      type: object
      required:
        - attributes
      properties:
        attributes:
          type: array
          minItems: 1
          maxItems: 500
          items:
            $ref: '#/components/schemas/AttributeInput'
    Attribute:
      type: object
      additionalProperties: false
      required:
        - id
        - key
        - label
        - type
        - format_output_type
        - enum_values
        - tags_values
        - allow_custom_values
        - boolean_config
        - number_config
        - relation_config
        - description
        - validation
        - language
        - image_config
        - status
        - archived_at
        - is_reviewed
        - source_id
        - external_id
        - source_synced_at
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        key:
          type: string
        label:
          type: string
        type:
          $ref: '#/components/schemas/AttributeType'
        format_output_type:
          oneOf:
            - $ref: '#/components/schemas/FormatOutputType'
            - type: 'null'
          type:
            - string
            - 'null'
          description: >-
            Declared output type for format Attributes; null for all other
            Attribute types.
        enum_values:
          type:
            - array
            - 'null'
          items:
            type: string
        tags_values:
          type:
            - array
            - 'null'
          items:
            type: string
        allow_custom_values:
          type: boolean
          description: Whether table editors may append missing enum or tag choices.
        boolean_config:
          type:
            - object
            - 'null'
          additionalProperties: true
        number_config:
          oneOf:
            - $ref: '#/components/schemas/NumberConfig'
            - type: 'null'
          type:
            - object
            - 'null'
          description: >-
            Present only as metadata; Attribute values returned by APIs remain
            raw numbers.
        relation_config:
          type:
            - object
            - 'null'
          additionalProperties: true
        description:
          type:
            - string
            - 'null'
        validation:
          type:
            - object
            - 'null'
          additionalProperties: true
        language:
          type:
            - string
            - 'null'
        image_config:
          oneOf:
            - $ref: '#/components/schemas/ImageConfig'
            - type: 'null'
          type:
            - object
            - 'null'
        status:
          type: string
          enum:
            - active
            - archived
          description: >-
            Derived from archive state. Archive and restore remain
            Dashboard-only.
        archived_at:
          type:
            - string
            - 'null'
          format: date-time
        is_reviewed:
          type: boolean
        source_id:
          type:
            - string
            - 'null'
          format: uuid
        external_id:
          type:
            - string
            - 'null'
        source_synced_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      examples:
        - id: 11111111-1111-4111-8111-111111111111
          key: product_name
          label: Product name
          type: text
          format_output_type: null
          enum_values: null
          tags_values: null
          allow_custom_values: true
          boolean_config: null
          number_config: null
          relation_config: null
          description: Public product title
          validation: null
          language: en
          image_config: null
          status: active
          archived_at: null
          is_reviewed: true
          source_id: null
          external_id: null
          source_synced_at: null
          created_at: '2026-07-01T00:00:00.000Z'
          updated_at: '2026-07-14T10:00:00.000Z'
    AttributeBulkResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Attribute'
    Error:
      type: object
      required:
        - status_code
        - error_type
        - message
        - request_id
      properties:
        status_code:
          type: integer
        error_type:
          type: string
          enum:
            - invalid_request
            - unauthenticated
            - forbidden
            - not_found
            - conflict
            - validation_error
            - rate_limited
            - service_unavailable
            - internal_error
        message:
          type: string
        request_id:
          type: string
        code:
          type: string
          description: >-
            Stable machine-readable detail code for validation, conflict, and
            retryable availability errors.
        retryable:
          type: boolean
          description: Whether the request can be retried without changing its payload.
        attribute_id:
          type: string
          format: uuid
          description: Stable Attribute identity when the error is scoped to one Attribute.
        attribute_key:
          type: string
          description: Attribute key when the error is scoped to one Attribute.
        details:
          type: object
          additionalProperties: true
        current_updated_at:
          type: string
          format: date-time
          description: >-
            Current resource revision supplied for client-directed refetch after
            a stale write.
    AttributeType:
      type: string
      enum:
        - text
        - number
        - url
        - email
        - date
        - boolean
        - richtext
        - format
        - enum
        - tags
        - image
        - images
        - file
        - files
        - json
        - relation
    FormatOutputType:
      type: string
      enum:
        - text
        - number
        - boolean
        - json
        - richtext
        - file
        - image
      description: >-
        The stored result type produced by a format Attribute. Format formulas
        execute only in Extraction; Catalog stores the resulting value.
    NumberConfig:
      type: object
      additionalProperties: false
      description: >-
        Presentation metadata for number and Formula-number Attributes. Stored
        and API values remain numeric.
      properties:
        unit:
          type: string
          minLength: 1
          maxLength: 64
          description: Literal, untranslated unit.
        unit_position:
          type: string
          enum:
            - before
            - after
          default: after
        format_style:
          type: string
          enum:
            - dot_plain
            - comma_plain
            - dot_with_comma_grouping
            - comma_with_dot_grouping
            - dot_with_space_grouping
            - comma_with_space_grouping
        file_export:
          type: string
          enum:
            - raw
            - formatted_text
          default: raw
          description: >-
            Applies to CSV/XLSX file exports, including files requested through
            export endpoints. JSON and non-file API or integration values remain
            raw.
    ImageConfig:
      type: object
      additionalProperties: false
      description: Canonical requirements shared by every usage of an image Attribute.
      properties:
        format:
          type: string
          enum:
            - original
            - webp
            - jpeg
            - png
        required_aspect_ratio:
          type: string
          enum:
            - original
            - '1:1'
            - '1:4'
            - '1:8'
            - '2:3'
            - '3:2'
            - '3:4'
            - '4:1'
            - '4:3'
            - '4:5'
            - '5:4'
            - '8:1'
            - '9:16'
            - '16:9'
            - '21:9'
        required_background_color:
          type: string
          enum:
            - white
            - black
          description: Omit to accept any background and preserve existing image behavior.
        max_size_mb:
          type: number
          minimum: 0
        min_width:
          type: number
          minimum: 0
        min_height:
          type: number
          minimum: 0
        max_width:
          type: number
          minimum: 0
        max_height:
          type: number
          minimum: 0
  responses:
    Unauthorized:
      description: Authentication error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ValidationError:
      description: Request validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````

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