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

---
id: ca6e3cd6-bb67-451f-a7e1-7f851b1e0800
---

# Replace file

> Replace existing file data with new file data. Can be used to change image content without having to upload a new file and update all references.

export const ScopesList = ({scopes = [], description = "This API requires one of the following scopes:"}) => {
  if (!scopes || scopes.length === 0) {
    return null;
  }
  const sortedScopes = scopes.sort((a, b) => a.localeCompare(b));
  return <div>
      <div className="text-sm mb-2">{description}</div>
      <div>
        {sortedScopes.map((scope, index) => <div key={index}>
            <code>
              <span className="text-xs">{scope}</span>
            </code>
          </div>)}
      </div>
    </div>;
};

export const SupportedProducts = ({marketing, sales, service, cms, data, commerce, crm, marketingLevel, salesLevel, serviceLevel, cmsLevel, dataLevel, commerceLevel, crmLevel}) => {
  const translations = {
    description: "Requires one of the following products or higher.",
    productNames: {
      marketing: "Marketing Hub",
      sales: "Sales Hub",
      service: "Service Hub",
      cms: "Content Hub",
      data: "Data Hub",
      commerce: "Revenue Hub",
      crm: "Smart CRM"
    },
    tiers: {
      free: "Free",
      starter: "Starter",
      professional: "Professional",
      enterprise: "Enterprise"
    }
  };
  const translateTier = tier => {
    if (!tier) return '';
    const lowerTier = tier.toLowerCase();
    return translations.tiers[lowerTier] || tier;
  };
  const products = [{
    name: marketing ? translations.productNames.marketing : '',
    level: translateTier(marketingLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base_2023-24-25/developer/icons/MarketingHub.svg",
    alt: "Marketing Hub"
  }, {
    name: sales ? translations.productNames.sales : '',
    level: translateTier(salesLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base_2023-24-25/developer/icons/SalesHub.svg",
    alt: "Sales Hub"
  }, {
    name: service ? translations.productNames.service : '',
    level: translateTier(serviceLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base_2023-24-25/developer/icons/ServiceHub.svg",
    alt: "Service Hub"
  }, {
    name: cms ? translations.productNames.cms : '',
    level: translateTier(cmsLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base_2023-24-25/developer/icons/ContentHub.svg",
    alt: "Content Hub"
  }, {
    name: data ? translations.productNames.data : '',
    level: translateTier(dataLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base_2023-24-25/developer/icons/DataHub.svg",
    alt: "Data Hub"
  }, {
    name: commerce ? translations.productNames.commerce : '',
    level: translateTier(commerceLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base/subscription_key_icons/commerce_icon.svg",
    alt: "Revenue Hub"
  }, {
    name: crm ? translations.productNames.crm : '',
    level: translateTier(crmLevel),
    icon: "https://www.hubspot.com/hubfs/Knowledge_Base_2023-24-25/developer/icons/SmartCRM.svg",
    alt: "Smart CRM"
  }].filter(product => product.name && product.level);
  if (products.length === 0) return null;
  return <div>
      <div className="text-sm mb-2">{translations.description}</div>
      <div className={`grid ${products.length === 1 ? 'grid-cols-1' : 'grid-cols-2'} gap-1.5`}>
        {products.map((product, index) => <div key={index} style={{
    display: 'flex',
    alignItems: 'center'
  }}>
            <img src={product.icon} alt={product.alt} className="w-3.5 h-3.5 mr-1.5 mt-2.5 mb-2.5 flex-shrink-0 align-middle" />
            <span className="font-medium mr-1 text-sm">{product.name} -</span>
            <span className="text-sm">{product.level}</span>
          </div>)}
      </div>
    </div>;
};

<AccordionGroup>
  <Accordion title="Supported products" defaultOpen="true" icon="cubes">
    <SupportedProducts marketing={true} sales={true} service={true} cms={true} marketingLevel="FREE" salesLevel="FREE" serviceLevel="FREE" cmsLevel="FREE" />
  </Accordion>

  <Accordion title="Required Scopes" icon="key">
    <ScopesList
      scopes={[
  'files.ui_hidden.write',
  'files.write'
]}
    />
  </Accordion>
</AccordionGroup>


## OpenAPI

````yaml specs/legacy/v3/files-files-v3.json PUT /files/v3/files/{fileId}
openapi: 3.0.1
info:
  title: Files Files
  description: Upload and manage files.
  version: v3
  x-hubspot-product-tier-requirements:
    marketing: FREE
    sales: FREE
    service: FREE
    cms: FREE
    commerce: FREE
    crmHub: FREE
    dataHub: FREE
  x-hubspot-related-documentation:
    - name: Files Guide
      url: https://developers.hubspot.com/docs/guides/api/library/files
servers:
  - url: https://api.hubapi.com
security: []
tags:
  - name: Basic
  - name: Files
  - name: Folders
paths:
  /files/v3/files/{fileId}:
    put:
      tags:
        - Files
      summary: Replace file
      description: >-
        Replace existing file data with new file data. Can be used to change
        image content without having to upload a new file and update all
        references.
      operationId: put-/files/v3/files/{fileId}_replace
      parameters:
        - name: fileId
          in: path
          description: ID of the desired file.
          required: true
          style: simple
          explode: false
          schema:
            pattern: \d+
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                charsetHunch:
                  type: string
                  description: Character set of given file data.
                file:
                  type: string
                  description: >-
                    File data that will replace existing file in the file
                    manager.
                  format: binary
                options:
                  type: string
                  description: >-
                    JSON string representing FileReplaceOptions. Includes
                    options to set the access and expiresAt properties, which
                    will automatically update when the file is replaced.
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
        default:
          $ref: '#/components/responses/Error'
          description: ''
      security:
        - oauth2:
            - files.ui_hidden.write
components:
  schemas:
    File:
      required:
        - access
        - archived
        - createdAt
        - id
        - updatedAt
      type: object
      properties:
        access:
          type: string
          description: File access. Can be PUBLIC_INDEXABLE, PUBLIC_NOT_INDEXABLE, PRIVATE.
          enum:
            - HIDDEN_INDEXABLE
            - HIDDEN_NOT_INDEXABLE
            - HIDDEN_PRIVATE
            - HIDDEN_SENSITIVE
            - PRIVATE
            - PUBLIC_INDEXABLE
            - PUBLIC_NOT_INDEXABLE
            - SENSITIVE
        archived:
          type: boolean
          description: If the file is deleted.
        archivedAt:
          type: string
          description: Deletion time of the file object.
          format: date-time
        createdAt:
          type: string
          description: Creation time of the file object.
          format: date-time
        defaultHostingUrl:
          type: string
          description: >-
            Default hosting URL of the file. This will use one of HubSpot's
            provided URLs to serve the file.
        encoding:
          type: string
          description: Encoding of the file.
        expiresAt:
          type: integer
          format: int64
        extension:
          type: string
          description: 'Extension of the file. ex: .jpg, .png, .gif, .pdf, etc.'
        fileMd5:
          type: string
          description: The MD5 hash of the file.
        height:
          type: integer
          description: For image and video files, the height of the content.
          format: int32
        id:
          type: string
          description: File ID.
        isUsableInContent:
          type: boolean
          description: >-
            Previously "archied". Indicates if the file should be used when
            creating new content like web pages.
        name:
          type: string
          description: Name of the file.
        parentFolderId:
          type: string
          description: ID of the folder the file is in.
        path:
          type: string
          description: Path of the file in the file manager.
        size:
          type: integer
          description: Size of the file in bytes.
          format: int64
        sourceGroup:
          type: string
          enum:
            - CONTENT
            - CONVERSATIONS
            - FORMS
            - UI_EXTENSIONS
            - UNKNOWN
        type:
          type: string
          description: Type of the file. Can be IMG, DOCUMENT, AUDIO, MOVIE, or OTHER.
        updatedAt:
          type: string
          description: Timestamp of the latest update to the file.
          format: date-time
        url:
          type: string
          description: >-
            URL of the given file. This URL can change depending on the domain
            settings of the account. Will use the select file hosting domain.
        width:
          type: integer
          description: For image and video files, the width of the content.
          format: int32
      description: File
    Error:
      required:
        - category
        - correlationId
        - message
      type: object
      properties:
        category:
          type: string
          description: The error category
        context:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Context about the error condition
          example: >-
            {invalidPropertyName=[propertyValue], missingScopes=[scope1,
            scope2]}
        correlationId:
          type: string
          description: >-
            A unique identifier for the request. Include this value with any
            error reports or support tickets
          format: uuid
          example: aeb5f871-7f07-4993-9211-075dc63e7cbf
        errors:
          type: array
          description: further information about the error
          items:
            $ref: '#/components/schemas/ErrorDetail'
        links:
          type: object
          additionalProperties:
            type: string
          description: >-
            A map of link names to associated URIs containing documentation
            about the error or recommended remediation steps
        message:
          type: string
          description: >-
            A human readable message describing the error along with remediation
            steps where appropriate
          example: An error occurred
        subCategory:
          type: string
          description: >-
            A specific category that contains more specific detail about the
            error
      description: >-
        Represents an error response returned by the API when an operation
        fails. This component is used in various endpoints to provide detailed
        information about the error encountered.
      example:
        message: Invalid input (details will vary based on the error)
        correlationId: aeb5f871-7f07-4993-9211-075dc63e7cbf
        category: VALIDATION_ERROR
        links:
          knowledge-base: https://www.hubspot.com/products/service/knowledge-base
    ErrorDetail:
      required:
        - message
      type: object
      properties:
        code:
          type: string
          description: The status code associated with the error detail
        context:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Context about the error condition
          example: '{missingScopes=[scope1, scope2]}'
        in:
          type: string
          description: The name of the field or parameter in which the error was found.
        message:
          type: string
          description: >-
            A human readable message describing the error along with remediation
            steps where appropriate
        subCategory:
          type: string
          description: >-
            A specific category that contains more specific detail about the
            error
      description: >-
        Represents detailed information about an error that occurred in the API.
        This component is used to provide additional context and specifics about
        errors, typically as part of an error response.
  responses:
    Error:
      description: An error occurred.
      content:
        '*/*':
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://app.hubspot.com/oauth/authorize
          tokenUrl: https://api.hubapi.com/oauth/v1/token
          scopes:
            files.ui_hidden.read: ''
            files.ui_hidden.write: ''

````