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

# Attach file to product

> Attach an existing store file by `file_id`, or create a new link on the fly by sending `name` + `link`. Blocked while the product is locked for review/approved.



## OpenAPI

````yaml /openapi.yaml post /v1/products/{id}/files
openapi: 3.1.0
info:
  title: Lojou API
  version: 1.0.0
  description: |
    Official reference for the Lojou `/v1` API — everything a developer needs
    to create products, process orders, manage plans, and receive webhooks
    from a Lojou store.
servers:
  - url: https://api.lojou.app
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Health
  - name: OAuth
  - name: User
  - name: Products
  - name: Plans
  - name: Orders
  - name: Customers
  - name: Files
  - name: Webhooks
  - name: Discounts
  - name: Affiliates
paths:
  /v1/products/{id}/files:
    post:
      tags:
        - Products
      summary: Attach file to product
      description: >-
        Attach an existing store file by `file_id`, or create a new link on the
        fly by sending `name` + `link`. Blocked while the product is locked for
        review/approved.
      operationId: postV1ProductFiles
      parameters:
        - $ref: '#/components/parameters/ProductIdParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddProductFileRequest'
      responses:
        '201':
          description: File attached
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                status: success
                message: File associated with product successfully.
                file:
                  id: 42
                  store_product_id: 272
                  name: Bônus - Planilha de controle.xlsx
                  link: https://cdn.lojou.app/lojou/stores/files/954/planilha.xlsx
                  size: 0
                  format: link
                  format_type: MB
                  created_at: '2026-08-31T16:10:00.000000Z'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          description: Forbidden — write scope missing, or product locked for changes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  Product files cannot be modified while product is pending
                  review or approved.
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          description: This file is already associated with the product
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: This file is already associated with the product.
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  parameters:
    ProductIdParam:
      name: id
      in: path
      required: true
      description: Product identifier (`id` or `product_pid`).
      schema:
        type: string
  schemas:
    AddProductFileRequest:
      type: object
      description: >-
        Send either `file_id` (reuse an existing store file) or `name` + `link`
        (create a new one on the fly).
      properties:
        file_id:
          type: integer
        name:
          type: string
        link:
          type: string
          format: uri
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: error
        message:
          type: string
      additionalProperties: true
    ValidationErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          properties:
            errors:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
  responses:
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Unauthorized user.
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Resource not found.
    ValidationError:
      description: Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
          example:
            status: error
            message: Validation failed.
            errors:
              amount:
                - The amount field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Send an API key or an OAuth access token in the `Authorization` header
        as a Bearer token. See [Authentication](/authentication) for details.

````