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

# Upsert Integration

> Create or update the (tenant, provider) row.

Flow:
  1. Pull existing row (if any) to know which secrets to preserve.
  2. Merge incoming config with existing secrets (keep-on-omit).
  3. Validate the merged config against the provider's Pydantic schema.
  4. Persist + audit (with redacted before/after — never log secrets).



## OpenAPI

````yaml https://api.vellaro.io/openapi.json put /api/v1/admin/integrations/{provider}
openapi: 3.1.0
info:
  title: Vellaro API
  description: Vellaro 2026 — E-commerce API
  version: 0.1.0
servers:
  - url: https://api.vellaro.io
    description: Produzione
security: []
tags: []
paths:
  /api/v1/admin/integrations/{provider}:
    put:
      tags:
        - admin:integrations
      summary: Upsert Integration
      description: |-
        Create or update the (tenant, provider) row.

        Flow:
          1. Pull existing row (if any) to know which secrets to preserve.
          2. Merge incoming config with existing secrets (keep-on-omit).
          3. Validate the merged config against the provider's Pydantic schema.
          4. Persist + audit (with redacted before/after — never log secrets).
      operationId: upsert_integration_api_v1_admin_integrations__provider__put
      parameters:
        - name: provider
          in: path
          required: true
          schema:
            type: string
            title: Provider
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IntegrationUpsert'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse_IntegrationOut_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    IntegrationUpsert:
      properties:
        config:
          additionalProperties: true
          type: object
          title: Config
        is_active:
          type: boolean
          title: Is Active
          default: true
      type: object
      title: IntegrationUpsert
      description: |-
        Body of PUT /admin/integrations/{provider}.

        `config` is validated against the provider schema. Secret fields
        can be:
          - omitted          → keep the existing value (no change)
          - empty string ""  → explicit removal
          - any other string → set/replace

        The "omit to keep" behaviour matters: the admin UI receives a
        redacted row (no plaintext) and the operator usually only edits
        one field at a time. Without the keep-on-omit rule, the next save
        would wipe the api key.
    ApiResponse_IntegrationOut_:
      properties:
        data:
          anyOf:
            - $ref: '#/components/schemas/IntegrationOut'
            - type: 'null'
        meta:
          anyOf:
            - $ref: '#/components/schemas/PaginationMeta'
            - type: 'null'
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
      type: object
      title: ApiResponse[IntegrationOut]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    IntegrationOut:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        tenant_id:
          type: string
          format: uuid
          title: Tenant Id
        provider:
          type: string
          title: Provider
        config:
          additionalProperties: true
          type: object
          title: Config
        is_active:
          type: boolean
          title: Is Active
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - tenant_id
        - provider
        - config
        - is_active
        - created_at
        - updated_at
      title: IntegrationOut
      description: Row as the operator sees it — secrets redacted.
    PaginationMeta:
      properties:
        page:
          type: integer
          title: Page
        page_size:
          type: integer
          title: Page Size
        total:
          type: integer
          title: Total
        total_pages:
          type: integer
          title: Total Pages
      type: object
      required:
        - page
        - page_size
        - total
        - total_pages
      title: PaginationMeta
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````